]> sigrok.org Git - pulseview.git/blobdiff - pv/data/decodesignal.cpp
Continue reworking the channel/signal handling
[pulseview.git] / pv / data / decodesignal.cpp
index eb6488e7570a4bfeb85e7fbfd1c695da56e6110d..28157794208c6fbf4a7b65be20b76773bb21b189 100644 (file)
@@ -86,6 +86,9 @@ void DecodeSignal::stack_decoder(const srd_decoder *decoder, bool restart_decode
        const shared_ptr<Decoder> dec = make_shared<Decoder>(decoder, stack_.size());
        stack_.push_back(dec);
 
+       connect(dec.get(), SIGNAL(annotation_visibility_changed()),
+               this, SLOT(on_annotation_visibility_changed()));
+
        // Include the newly created decode channels in the channel lists
        update_channel_list();
 
@@ -105,11 +108,12 @@ void DecodeSignal::remove_decoder(int index)
        assert(index < (int)stack_.size());
 
        // Find the decoder in the stack
-       auto iter = stack_.begin();
-       for (int i = 0; i < index; i++, iter++)
-               assert(iter != stack_.end());
+       auto iter = stack_.begin() + index;
+       assert(iter != stack_.end());
+
+       shared_ptr<Decoder> dec = *iter;
 
-       decoder_removed(iter->get());
+       decoder_removed(dec.get());
 
        // Delete the element
        stack_.erase(iter);
@@ -358,7 +362,7 @@ void DecodeSignal::set_initial_pin_state(const uint16_t channel_id, const int in
        begin_decode();
 }
 
-double DecodeSignal::samplerate() const
+double DecodeSignal::get_samplerate() const
 {
        double result = 0;
 
@@ -698,7 +702,7 @@ void DecodeSignal::save_settings(QSettings &settings) const
                i = 0;
                for (const AnnotationClass* ann_class : decoder->ann_classes()) {
                        settings.beginGroup("ann_class" + QString::number(i));
-                       settings.setValue("visible", ann_class->visible);
+                       settings.setValue("visible", ann_class->visible());
                        settings.endGroup();
                        i++;
                }
@@ -752,6 +756,9 @@ void DecodeSignal::restore_settings(QSettings &settings)
                        if (QString::fromUtf8(dec->id) == id) {
                                shared_ptr<Decoder> decoder = make_shared<Decoder>(dec, stack_.size());
 
+                               connect(decoder.get(), SIGNAL(annotation_visibility_changed()),
+                                       this, SLOT(on_annotation_visibility_changed()));
+
                                stack_.push_back(decoder);
                                decoder->set_visible(settings.value("visible", true).toBool());
 
@@ -782,7 +789,7 @@ void DecodeSignal::restore_settings(QSettings &settings)
                                i = 0;
                                for (AnnotationClass* ann_class : decoder->ann_classes()) {
                                        settings.beginGroup("ann_class" + QString::number(i));
-                                       ann_class->visible = settings.value("visible", true).toBool();
+                                       ann_class->set_visible(settings.value("visible", true).toBool());
                                        settings.endGroup();
                                        i++;
                                }
@@ -1591,5 +1598,10 @@ void DecodeSignal::on_data_received()
                logic_mux_cond_.notify_one();
 }
 
+void DecodeSignal::on_annotation_visibility_changed()
+{
+       annotation_visibility_changed();
+}
+
 } // namespace data
 } // namespace pv