+ visible_ = visible;
+
+ visibility_changed();
+}
+
+
+Decoder::Decoder(const srd_decoder *const dec, uint8_t stack_level) :
+ srd_decoder_(dec),
+ stack_level_(stack_level),
+ visible_(true),
+ decoder_inst_(nullptr)
+{
+ // Query the annotation output classes
+ uint32_t i = 0;
+ for (GSList *l = dec->annotations; l; l = l->next) {
+ char **ann_class = (char**)l->data;
+ char *name = ann_class[0];
+ char *desc = ann_class[1];
+ ann_classes_.emplace_back(i++, name, desc, nullptr);
+
+ connect(&(ann_classes_.back()), SIGNAL(visibility_changed()),
+ this, SLOT(on_class_visibility_changed()));
+ }
+
+ // Query the binary output classes
+ i = 0;
+ for (GSList *l = dec->binary; l; l = l->next) {
+ char **bin_class = (char**)l->data;
+ char *name = bin_class[0];
+ char *desc = bin_class[1];
+ bin_classes_.push_back({i++, name, desc});
+ }
+
+ // Query the annotation rows and reference them by the classes that use them
+ uint32_t row_count = 0;
+ for (const GSList *rl = srd_decoder_->annotation_rows; rl; rl = rl->next)
+ row_count++;
+
+ i = 0;
+ for (const GSList *rl = srd_decoder_->annotation_rows; rl; rl = rl->next) {
+ const srd_decoder_annotation_row *const srd_row = (srd_decoder_annotation_row *)rl->data;
+ assert(srd_row);
+ rows_.emplace_back(i++, this, srd_row);
+
+ // FIXME PV can crash from .at() if a PD's ann classes are defined incorrectly
+ for (const GSList *cl = srd_row->ann_classes; cl; cl = cl->next)
+ ann_classes_.at((size_t)cl->data).row = &(rows_.back());
+
+ connect(&(rows_.back()), SIGNAL(visibility_changed()),
+ this, SLOT(on_row_visibility_changed()));
+ }
+
+ if (rows_.empty()) {
+ // Make sure there is a row for PDs without row declarations
+ rows_.emplace_back(0, this);
+
+ for (AnnotationClass& c : ann_classes_)
+ c.row = &(rows_.back());
+ }