OpenMW
apps/opencs/model/settings/usersettings.hpp
Go to the documentation of this file.
00001 #ifndef USERSETTINGS_HPP
00002 #define USERSETTINGS_HPP
00003 
00004 #include <QTextStream>
00005 #include <QStringList>
00006 #include <QString>
00007 #include <QMap>
00008 
00009 #include <boost/filesystem/path.hpp>
00010 
00011 #include "support.hpp"
00012 
00013 #ifndef Q_MOC_RUN
00014 #include <components/files/configurationmanager.hpp>
00015 #endif
00016 
00017 namespace Files { typedef std::vector<boost::filesystem::path> PathContainer;
00018                   struct ConfigurationManager;}
00019 
00020 class QFile;
00021 
00022 namespace CSMSettings {
00023 
00024     struct UserSettings: public QObject
00025     {
00026 
00027         Q_OBJECT
00028 
00029         SectionMap mSectionSettings;
00030         SectionMap mEditorSettingDefaults;
00031 
00032         static UserSettings *mUserSettingsInstance;
00033         QString mUserFilePath;
00034         Files::ConfigurationManager mCfgMgr;
00035         QString mReadOnlyMessage;
00036         QString mReadWriteMessage;
00037 
00038     public:
00039 
00041         static UserSettings& instance();
00042 
00043         UserSettings();
00044         ~UserSettings();
00045 
00046         UserSettings (UserSettings const &);        //not implemented
00047         void operator= (UserSettings const &);      //not implemented
00048 
00050         bool writeSettings(QMap<QString, SettingList *> &sections);
00051 
00054         void updateSettings (const QString &sectionName, const QString &settingName = "");
00055 
00057 
00060         void loadSettings (const QString &fileName);
00061 
00063         const SectionMap &getSectionMap () const;
00064 
00065         const SettingMap *getSettings (const QString &sectionName) const;
00066 
00068         QString getSetting(const QString &section, const QString &setting) const;
00069 
00070     private:
00071 
00072 
00074         QTextStream *openFileStream (const QString &filePath, bool isReadOnly = false) const;
00075 
00077         bool loadFromFile (const QString &filePath = "");
00078 
00080         void mergeMap (const SectionMap &);
00081 
00082         void displayFileErrorMessage(const QString &message, bool isReadOnly);
00083 
00084         void buildEditorSettingDefaults();
00085 
00086         SettingMap *getValidSettings (const QString &sectionName) const;
00087 
00088     signals:
00089 
00090         void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue);
00091 
00092     };
00093 }
00094 #endif // USERSETTINGS_HPP