]> sigrok.org Git - pulseview.git/commitdiff
Let SignalBase store/restore its internal data
authorSoeren Apel <redacted>
Mon, 29 Aug 2016 16:08:11 +0000 (18:08 +0200)
committerSoeren Apel <redacted>
Mon, 29 Aug 2016 16:08:11 +0000 (18:08 +0200)
pv/data/signalbase.cpp
pv/data/signalbase.hpp
pv/session.cpp

index d2dd75ab60f684b65a02611a24c6b4b6283baedb..beefa5168a32befb421de14f36e7ef69a08a33c7 100644 (file)
@@ -152,5 +152,20 @@ void SignalBase::set_decoder_stack(std::shared_ptr<pv::data::DecoderStack>
 }
 #endif
 
+void SignalBase::save_settings(QSettings &settings) const
+{
+       settings.setValue("name", name());
+       settings.setValue("enabled", enabled());
+       settings.setValue("colour", colour());
+}
+
+void SignalBase::restore_settings(QSettings &settings)
+{
+       set_name(settings.value("name").toString());
+       set_enabled(settings.value("enabled").toBool());
+       set_colour(settings.value("colour").value<QColor>());
+}
+
+
 } // namespace data
 } // namespace pv
index 2b3f2f1cb5a35368c5fefae6cd03e2902c531bbd..54d9ee0adc2d337a87e9b3195a5223099e46e4c6 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <QColor>
 #include <QObject>
+#include <QSettings>
 #include <QString>
 
 #include <libsigrokcxx/libsigrokcxx.hpp>
@@ -134,6 +135,10 @@ public:
                decoder_stack);
 #endif
 
+       void save_settings(QSettings &settings) const;
+
+       void restore_settings(QSettings &settings);
+
 Q_SIGNALS:
        void enabled_changed(const bool &value);
 
index 34ed26b8fada81a4468868e94447610f78754a03..8bb1cb0d5741161217ea8608607efe3eb589f955 100644 (file)
@@ -202,9 +202,7 @@ void Session::save_settings(QSettings &settings) const
 #endif
                        {
                                settings.beginGroup(base->internal_name());
-                               settings.setValue("name", base->name());
-                               settings.setValue("enabled", base->enabled());
-                               settings.setValue("colour", base->colour());
+                               base->save_settings(settings);
                                settings.endGroup();
                        }
                }
@@ -247,9 +245,7 @@ void Session::restore_settings(QSettings &settings)
                // Restore channels
                for (shared_ptr<data::SignalBase> base : signalbases_) {
                        settings.beginGroup(base->internal_name());
-                       base->set_name(settings.value("name").toString());
-                       base->set_enabled(settings.value("enabled").toBool());
-                       base->set_colour(settings.value("colour").value<QColor>());
+                       base->restore_settings(settings);
                        settings.endGroup();
                }