00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SETTINGSMODEL_H
00026 #define SETTINGSMODEL_H
00027
00028
00029 #include "MvcCore/abstractmodel.h"
00030
00031 #include <QPointer>
00032 #include <QSettings>
00033
00034 #include "settingsmodelevents.h"
00035
00036 class SettingsController;
00037
00038
00039 class SettingsModel : public QObject, public AbstractModel {
00040
00041 Q_OBJECT
00042
00043 public:
00044 SettingsModel( const QString& organization,
00045 const QString& application = QString(),
00046 QObject* parent = 0 );
00047 SettingsModel( QSettings::Scope scope,
00048 const QString& organization,
00049 const QString& application = QString(),
00050 QObject* parent = 0 );
00051 SettingsModel( QSettings::Format format,
00052 QSettings::Scope scope,
00053 const QString& organization,
00054 const QString& application = QString(),
00055 QObject* parent = 0 );
00056 SettingsModel( const QString& fileName,
00057 QSettings::Format format,
00058 QObject* parent = 0 );
00059 SettingsModel( QObject* parent = 0 );
00060
00061 SettingsController* settingsController() const;
00062
00063 const QSettings* constSettings() const;
00064 QVariant value( const QString& key,
00065 const QVariant& defaultValue = QVariant() ) const;
00066
00068 inline static MvcModuleId_t classModuleId() { return MvcSettings::id(); }
00070 virtual MvcModuleId_t moduleId() const { return classModuleId(); }
00071
00072
00073 protected:
00074 inline virtual void customEvent( QEvent* e ) {
00075 MEvent* me = dynamic_cast<MEvent*>(e);
00076 if ( me != 0 ) dispatchEvent(me);
00077 }
00078 virtual void dispatchEvent( MEvent* );
00079
00080 virtual void changeControllerEvent( MChangeControllerEvent* );
00081
00082 virtual void settingsChangeValueEvent( MSettingsChangeValueEvent* );
00083 virtual void settingsRemoveKeyEvent( MSettingsRemoveKeyEvent* );
00084 virtual void settingsRemoveAllEvent( MSettingsEvent* );
00085 virtual void settingsSyncAllEvent( MSettingsEvent* );
00086
00087 QSettings* settings() const;
00088
00089
00090 private:
00091
00092 QSettings* m_settings;
00093
00094
00095 QPointer<SettingsController> c_settingsController;
00096 };
00097
00098
00099 #endif // ! SETTINGSMODEL_H