diff options
Diffstat (limited to 'logic/settings/SettingsObject.h')
-rw-r--r-- | logic/settings/SettingsObject.h | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/logic/settings/SettingsObject.h b/logic/settings/SettingsObject.h index 99782a01..6272d24c 100644 --- a/logic/settings/SettingsObject.h +++ b/logic/settings/SettingsObject.h @@ -22,6 +22,9 @@ #include <memory> class Setting; +class SettingsObject; + +typedef std::shared_ptr<SettingsObject> SettingsObjectPtr; /*! * \brief The SettingsObject handles communicating settings between the application and a @@ -39,6 +42,22 @@ class SettingsObject : public QObject { Q_OBJECT public: + class Lock + { + public: + Lock(SettingsObjectPtr locked) + :m_locked(locked) + { + m_locked->suspendSave(); + } + ~Lock() + { + m_locked->resumeSave(); + } + private: + SettingsObjectPtr m_locked; + }; +public: explicit SettingsObject(QObject *parent = 0); virtual ~SettingsObject(); /*! @@ -127,6 +146,8 @@ public: */ virtual bool reload(); + virtual void suspendSave() = 0; + virtual void resumeSave() = 0; signals: /*! * \brief Signal emitted when one of this SettingsObject object's settings changes. @@ -184,6 +205,7 @@ protected: private: QMap<QString, std::shared_ptr<Setting>> m_settings; +protected: + bool m_suspendSave = false; + bool m_doSave = false; }; - -typedef std::shared_ptr<SettingsObject> SettingsObjectPtr; |