From: Soeren Apel Date: Mon, 29 Aug 2016 16:08:11 +0000 (+0200) Subject: Let SignalBase store/restore its internal data X-Git-Tag: pulseview-0.4.0~258 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6de38b17e7a9182b6557104dd3a902bb7784db95;p=pulseview.git Let SignalBase store/restore its internal data --- diff --git a/pv/data/signalbase.cpp b/pv/data/signalbase.cpp index d2dd75ab..beefa516 100644 --- a/pv/data/signalbase.cpp +++ b/pv/data/signalbase.cpp @@ -152,5 +152,20 @@ void SignalBase::set_decoder_stack(std::shared_ptr } #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()); +} + + } // namespace data } // namespace pv diff --git a/pv/data/signalbase.hpp b/pv/data/signalbase.hpp index 2b3f2f1c..54d9ee0a 100644 --- a/pv/data/signalbase.hpp +++ b/pv/data/signalbase.hpp @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -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); diff --git a/pv/session.cpp b/pv/session.cpp index 34ed26b8..8bb1cb0d 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -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 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()); + base->restore_settings(settings); settings.endGroup(); }