]> sigrok.org Git - pulseview.git/blobdiff - pv/views/tabular_decoder/model.cpp
Introduce DecodeSignal::annotation_visibility_changed and use it
[pulseview.git] / pv / views / tabular_decoder / model.cpp
index b0632f7ad35b5d3d2be9e6084cd930baa9a2a7d0..6037cf3e8171745caa67191999b6a967914edd8b 100644 (file)
@@ -189,9 +189,15 @@ void AnnotationCollectionModel::set_signal_and_segment(data::DecodeSignal* signa
                return;
        }
 
+       disconnect(this, SLOT(on_annotation_visibility_changed()));
+
        all_annotations_ = signal->get_all_annotations_by_segment(current_segment);
        signal_ = signal;
 
+       for (const shared_ptr<Decoder>& dec : signal_->decoder_stack())
+               connect(dec.get(), SIGNAL(annotation_visibility_changed()),
+                       this, SLOT(on_annotation_visibility_changed()));
+
        if (hide_hidden_)
                update_annotations_without_hidden();
        else
@@ -334,6 +340,24 @@ void AnnotationCollectionModel::on_setting_changed(const QString &key, const QVa
        theme_is_dark_ = GlobalSettings::current_theme_is_dark();
 }
 
+void AnnotationCollectionModel::on_annotation_visibility_changed()
+{
+       if (!hide_hidden_)
+               return;
+
+       update_annotations_without_hidden();
+
+       // Re-apply the requested sample range
+       set_sample_range(start_sample_, end_sample_);
+
+       if (dataset_)
+               dataChanged(index(0, 0), index(dataset_->size(), 0));
+       else
+               dataChanged(QModelIndex(), QModelIndex());
+
+       layoutChanged();
+}
+
 } // namespace tabular_decoder
 } // namespace views
 } // namespace pv