X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;ds=inline;f=pv%2Fdata%2Fdecode%2Frow.cpp;h=341c61dfd1fea3547bc3dab46fd1d965970e425b;hb=63e9fa9d569cfa2f098054b49317b6030a425f17;hp=1266b8436e1e09934b92418b62e5a6ebc42e7728;hpb=870ea3dbf35b182e120c5d84ab89bf9cb7691232;p=pulseview.git
diff --git a/pv/data/decode/row.cpp b/pv/data/decode/row.cpp
index 1266b843..341c61df 100644
--- a/pv/data/decode/row.cpp
+++ b/pv/data/decode/row.cpp
@@ -17,6 +17,7 @@
* along with this program; if not, see .
*/
+#include "decoder.hpp"
#include "row.hpp"
#include
@@ -26,44 +27,107 @@ namespace data {
namespace decode {
Row::Row() :
+ index_(0),
decoder_(nullptr),
- row_(nullptr)
+ srd_row_(nullptr),
+ visible_(true)
{
}
-Row::Row(const srd_decoder *decoder, const srd_decoder_annotation_row *row) :
+Row::Row(uint32_t index, Decoder* decoder, const srd_decoder_annotation_row* srd_row) :
+ index_(index),
decoder_(decoder),
- row_(row)
+ srd_row_(srd_row),
+ visible_(true)
{
}
-const srd_decoder* Row::decoder() const
+const Decoder* Row::decoder() const
{
return decoder_;
}
-const srd_decoder_annotation_row* Row::row() const
+const srd_decoder_annotation_row* Row::get_srd_row() const
{
- return row_;
+ return srd_row_;
}
const QString Row::title() const
{
- if (decoder_ && decoder_->name && row_ && row_->desc)
+ if (decoder_ && decoder_->name() && srd_row_ && srd_row_->desc)
return QString("%1: %2")
- .arg(QString::fromUtf8(decoder_->name),
- QString::fromUtf8(row_->desc));
- if (decoder_ && decoder_->name)
- return QString::fromUtf8(decoder_->name);
- if (row_ && row_->desc)
- return QString::fromUtf8(row_->desc);
+ .arg(QString::fromUtf8(decoder_->name()),
+ QString::fromUtf8(srd_row_->desc));
+ if (decoder_ && decoder_->name())
+ return QString::fromUtf8(decoder_->name());
+ if (srd_row_ && srd_row_->desc)
+ return QString::fromUtf8(srd_row_->desc);
+
return QString();
}
-bool Row::operator<(const Row &other) const
+const QString Row::description() const
+{
+ if (srd_row_ && srd_row_->desc)
+ return QString::fromUtf8(srd_row_->desc);
+ return QString();
+}
+
+vector Row::ann_classes() const
+{
+ assert(decoder_);
+
+ vector result;
+
+ if (!srd_row_) {
+ if (index_ == 0) {
+ // When operating as the fallback row, all annotation classes belong to it
+ return decoder_->ann_classes();
+ }
+ return result;
+ }
+
+ for (GSList *l = srd_row_->ann_classes; l; l = l->next) {
+ size_t class_id = (size_t)l->data;
+ result.push_back(decoder_->get_ann_class_by_id(class_id));
+ }
+
+ return result;
+}
+
+uint32_t Row::index() const
+{
+ return index_;
+}
+
+bool Row::visible() const
+{
+ return visible_;
+}
+
+void Row::set_visible(bool visible)
+{
+ visible_ = visible;
+}
+
+bool Row::has_hidden_classes() const
+{
+ for (const AnnotationClass* c : ann_classes())
+ if (!c->visible)
+ return true;
+
+ return false;
+}
+
+bool Row::operator<(const Row& other) const
{
return (decoder_ < other.decoder_) ||
- (decoder_ == other.decoder_ && row_ < other.row_);
+ (decoder_ == other.decoder_ && srd_row_ < other.srd_row_);
+}
+
+bool Row::operator==(const Row& other) const
+{
+ return ((decoder_ == other.decoder()) && (srd_row_ == other.srd_row_));
}
} // namespace decode