OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
setting.hpp
Go to the documentation of this file.
1 #ifndef CSM_PREFS_SETTING_H
2 #define CSM_PREFS_SETTING_H
3 
4 #include <string>
5 #include <utility>
6 
7 #include <QObject>
8 
9 class QWidget;
10 class QColor;
11 class QMutex;
12 
13 namespace Settings
14 {
15  class Manager;
16 }
17 
18 namespace CSMPrefs
19 {
20  class Category;
21 
22  class Setting : public QObject
23  {
24  Q_OBJECT
25 
28  QMutex *mMutex;
29  std::string mKey;
30  std::string mLabel;
31 
32  protected:
33 
35 
36  QMutex *getMutex();
37 
38  public:
39 
40  Setting (Category *parent, Settings::Manager *values, QMutex *mutex, const std::string& key, const std::string& label);
41 
42  virtual ~Setting();
43 
48  virtual std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent);
49 
50  const Category *getParent() const;
51 
52  const std::string& getKey() const;
53 
54  const std::string& getLabel() const;
55 
56  int toInt() const;
57 
58  double toDouble() const;
59 
60  std::string toString() const;
61 
62  bool isTrue() const;
63 
64  QColor toColor() const;
65  };
66 
67  // note: fullKeys have the format categoryKey/settingKey
68  bool operator== (const Setting& setting, const std::string& fullKey);
69  bool operator== (const std::string& fullKey, const Setting& setting);
70  bool operator!= (const Setting& setting, const std::string& fullKey);
71  bool operator!= (const std::string& fullKey, const Setting& setting);
72 }
73 
74 #endif
Settings::Manager & getValues()
Definition: setting.cpp:10
const Category * getParent() const
Definition: setting.cpp:33
std::string mKey
Definition: setting.hpp:29
double toDouble() const
Definition: setting.cpp:54
Definition: category.hpp:12
const std::string & getLabel() const
Definition: setting.cpp:43
std::string toString() const
Definition: setting.cpp:60
virtual std::pair< QWidget *, QWidget * > makeWidgets(QWidget *parent)
Definition: setting.cpp:28
QMutex * getMutex()
Definition: setting.cpp:15
QMutex * mMutex
Definition: setting.hpp:28
bool operator==(const Setting &setting, const std::string &fullKey)
Definition: setting.cpp:78
const std::string & getKey() const
Definition: setting.cpp:38
QColor toColor() const
Definition: setting.cpp:72
Category * mParent
Definition: setting.hpp:26
Definition: setting.hpp:22
Setting(Category *parent, Settings::Manager *values, QMutex *mutex, const std::string &key, const std::string &label)
Definition: setting.cpp:20
std::string mLabel
Definition: setting.hpp:30
Settings management (can change during runtime)
Definition: settings.hpp:17
bool isTrue() const
Definition: setting.cpp:66
virtual ~Setting()
Definition: setting.cpp:26
bool operator!=(const Setting &setting, const std::string &fullKey)
Definition: setting.cpp:89
int toInt() const
Definition: setting.cpp:48
Settings::Manager * mValues
Definition: setting.hpp:27