]> sigrok.org Git - pulseview.git/blobdiff - pv/views/tabular_decoder/model.cpp
TabularDecView: Remove unnecessary stuff
[pulseview.git] / pv / views / tabular_decoder / model.cpp
index b0632f7ad35b5d3d2be9e6084cd930baa9a2a7d0..c8692efb17d7125003b8989a2311b3b275a00b3d 100644 (file)
@@ -25,6 +25,7 @@
 #include "view.hpp"
 
 #include "pv/util.hpp"
+#include "pv/globalsettings.hpp"
 
 using std::make_shared;
 
@@ -48,9 +49,6 @@ AnnotationCollectionModel::AnnotationCollectionModel(QObject* parent) :
        end_index_(0),
        hide_hidden_(false)
 {
-       GlobalSettings::add_change_handler(this);
-       theme_is_dark_ = GlobalSettings::current_theme_is_dark();
-
        // TBD Maybe use empty columns as indentation levels to indicate stacked decoders
        header_data_.emplace_back(tr("Sample"));     // Column #0
        header_data_.emplace_back(tr("Time"));       // Column #1
@@ -101,7 +99,7 @@ QVariant AnnotationCollectionModel::data(const QModelIndex& index, int role) con
 
                // Only use custom cell background color if column index reached the hierarchy level
                if (index.column() >= level) {
-                       if (theme_is_dark_)
+                       if (GlobalSettings::current_theme_is_dark())
                                return QBrush(ann->dark_color());
                        else
                                return QBrush(ann->bright_color());
@@ -189,9 +187,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
@@ -324,14 +328,22 @@ void AnnotationCollectionModel::update_annotations_without_hidden()
        all_annotations_without_hidden_.resize(count);
 }
 
-void AnnotationCollectionModel::on_setting_changed(const QString &key, const QVariant &value)
+void AnnotationCollectionModel::on_annotation_visibility_changed()
 {
-       (void)key;
-       (void)value;
+       if (!hide_hidden_)
+               return;
+
+       update_annotations_without_hidden();
+
+       // Re-apply the requested sample range
+       set_sample_range(start_sample_, end_sample_);
 
-       // We don't really care about the actual setting, we just update the
-       // flag that indicates whether we are using a bright or dark color theme
-       theme_is_dark_ = GlobalSettings::current_theme_is_dark();
+       if (dataset_)
+               dataChanged(index(0, 0), index(dataset_->size(), 0));
+       else
+               dataChanged(QModelIndex(), QModelIndex());
+
+       layoutChanged();
 }
 
 } // namespace tabular_decoder