#ifndef USERSETTINGS_HPP #define USERSETTINGS_HPP #include #include #include #include #include #include "support.hpp" #ifndef Q_MOC_RUN #include #endif namespace Files { typedef std::vector PathContainer; struct ConfigurationManager;} class QFile; namespace CSMSettings { struct UserSettings: public QObject { Q_OBJECT SectionMap mSectionSettings; static UserSettings *mUserSettingsInstance; QStringList mPaths; Files::ConfigurationManager mCfgMgr; QString mReadOnlyMessage; QString mReadWriteMessage; public: /// Singleton implementation static UserSettings& instance(); UserSettings(); ~UserSettings(); UserSettings (UserSettings const &); //not implemented void operator= (UserSettings const &); //not implemented /// Writes settings to the last loaded settings file bool writeSettings(QMap §ions); /// Called from editor to trigger signal to update the specified setting. /// If no setting name is specified, all settings found in the specified section are updated. void updateSettings (const QString §ionName, const QString &settingName = ""); /// Retrieves the settings file at all three levels (global, local and user). /// TODO: Multi-valued settings are not fully implemented. Setting values /// loaded in later files will always overwrite previously loaded values. void loadSettings (const QString &fileName); /// Returns the entire map of settings across all sections const SectionMap &getSettings () const; /// Retrieves the value as a QString of the specified setting in the specified section QString getSetting(const QString §ion, const QString &setting) const; private: /// Opens a QTextStream from the provided path as read-only or read-write. QTextStream *openFileStream (const QString &filePath, bool isReadOnly = false) const; /// Parses a setting file specified in filePath from the provided text stream. void loadFromFile (const QString &filePath = ""); signals: void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue); }; } #endif // USERSETTINGS_HPP