#ifndef CSMSETTINGS_SETTINGMANAGER_HPP #define CSMSETTINGS_SETTINGMANAGER_HPP #include #include #include #include #include "support.hpp" #include "setting.hpp" namespace CSMSettings { typedef QMap DefinitionMap; typedef QMap DefinitionPageMap; typedef QMap > SettingPageMap; class SettingManager : public QObject { Q_OBJECT QString mReadOnlyMessage; QString mReadWriteMessage; QList mSettings; public: explicit SettingManager(QObject *parent = 0); ///retrieve a setting object from a given page and setting name Setting *findSetting (const QString &pageName, const QString &settingName); ///retrieve all settings for a specified page QList findSettings (const QString &pageName); ///retrieve all settings named in the attached list. ///Setting names are specified in "PageName.SettingName" format. QList findSettings (const QStringList &list); ///Retreive a map of the settings, keyed by page name SettingPageMap settingPageMap() const; protected: ///add a new setting to the model and return it Setting *createSetting (CSMSettings::SettingType typ, const QString &page, const QString &name, const QStringList &values = QStringList()); ///add definitions to the settings specified in the page map void addDefinitions (DefinitionPageMap &pageMap); ///read setting definitions from file DefinitionPageMap readFilestream(QTextStream *stream); ///write setting definitions to file bool writeFilestream (QTextStream *stream, const QMap &settingMap); ///merge PageMaps of settings when loading from multiple files void mergeSettings (DefinitionPageMap &destMap, DefinitionPageMap &srcMap); QTextStream *openFilestream (const QString &filePath, bool isReadOnly) const; void destroyStream(QTextStream *stream) const; void displayFileErrorMessage(const QString &message, bool isReadOnly) const; QList settings() const { return mSettings; } void dumpModel(); signals: void userSettingUpdated (const QString &, const QStringList &); public slots: void updateUserSetting (const QString &, const QStringList &); }; } #endif // CSMSETTINGS_SETTINGMANAGER_HPP