Updraft  1.0
Open source glider flight visualisation tool.
settingsmanager.h
Go to the documentation of this file.
00001 #ifndef UPDRAFT_SRC_CORE_SETTINGSMANAGER_H_
00002 #define UPDRAFT_SRC_CORE_SETTINGSMANAGER_H_
00003 
00004 #include <QtGui>
00005 #include "ui/settingsdialog.h"
00006 #include "variantfunctions.h"
00007 #include "../settingsgrouptype.h"
00008 
00009 namespace Updraft {
00010 
00011 class SettingInterface;
00012 
00013 namespace Core {
00014 
00015 class BasicSetting;
00016 class SettingsModel;
00017 class SettingsItem;
00018 
00021 class SettingsManager: public QObject {
00022   Q_OBJECT
00023 
00024  public:
00029   SettingsManager();
00030   ~SettingsManager();
00031 
00035   void finishInit();
00036 
00053   SettingInterface* addSetting(
00054     const QString& settingId,
00055     const QString& description,
00056     QVariant defaultValue,
00057     SettingsGroupType type = GROUP_VISIBLE);
00058 
00067   void addGroup(
00068     const QString& groupId,
00069     const QString& description,
00070     SettingsGroupType type = GROUP_VISIBLE,
00071     const QString& icon = ":/core/icons/configure.png");
00072 
00074   QDir getSettingsDir();
00075 
00076   friend class BasicSetting;
00077 
00078  public slots:
00080   void execDialog();
00081 
00083   void resetToDefaults();
00084 
00085  private slots:
00088   void itemValueChanged(SettingsItem* item);
00089 
00090  private:
00096   QModelIndex getGroup(const QString& groupId);
00097 
00102   QModelIndex getSetting(const QString& settingId, QModelIndex groupIndex);
00103 
00113   QModelIndex addGroupInternal(
00114     const QString& groupId,
00115     const QString& description,
00116     const QString& icon);
00117 
00123   void registerSetting(SettingsItem* item, BasicSetting* setting);
00124 
00131   void unregisterSetting(SettingsItem* item, BasicSetting* setting);
00132 
00135   QString getSettingsFilename();
00136 
00141   QString checkSettingsXml(const QString &dir1, const QString &dir2);
00142 
00148   QString createSettingsXml(const QString &dir1, const QString &dir2);
00149 
00151   QString settingsFile;
00152 
00154   QAction* settingsAction;
00155 
00157   SettingsDialog* dialog;
00158 
00160   SettingsModel* model;
00161 
00163   QRegExp idRegExp;
00164 
00167   QMultiHash<SettingsItem*, BasicSetting*> settings;
00168 };
00169 
00170 }  // End namespace Core
00171 }  // End namespace Updraft
00172 
00173 #endif  // UPDRAFT_SRC_CORE_SETTINGSMANAGER_H_
00174 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines