Torc  0.1
torcsetting.h
Go to the documentation of this file.
1 #ifndef TORCSETTING_H
2 #define TORCSETTING_H
3 
4 // Qt
5 #include <QSet>
6 #include <QReadWriteLock>
7 #include <QObject>
8 #include <QVariant>
9 #include <QStringList>
10 
11 // Torc
12 #include "torchttpservice.h"
13 #include "torcreferencecounted.h"
14 
15 class TorcSetting : public QObject, public TorcHTTPService, public TorcReferenceCounter
16 {
17  public:
18  enum Type
19  {
25  };
26 
27  enum Role
28  {
29  None = (0 << 0),
30  Persistent = (1 << 0),
31  Public = (1 << 1)
32  };
33 
34  Q_ENUM(Type)
35  Q_DECLARE_FLAGS(Roles, Role)
36 
37  public:
38  TorcSetting(TorcSetting *Parent, const QString &DBName, const QString &UIName,
39  Type SettingType, Roles SettingRoles, const QVariant &Default);
40 
41  public:
42  Q_OBJECT
43  Q_CLASSINFO("Version", "1.0.0")
44  Q_CLASSINFO("Secure", "")
45  Q_CLASSINFO("GetChildList", "type=settings,methods=AUTH")
46  Q_PROPERTY (QVariant value READ GetValue NOTIFY ValueChanged )
47  Q_PROPERTY (QString uiName READ GetUiName CONSTANT )
48  Q_PROPERTY (QString helpText READ GetHelpText CONSTANT )
49  Q_PROPERTY (QVariant defaultValue READ GetDefaultValue CONSTANT )
50  Q_PROPERTY (bool isActive READ GetIsActive NOTIFY ActiveChanged )
51  Q_PROPERTY (QString settingType READ GetSettingType CONSTANT )
52  Q_PROPERTY (QVariantMap selections READ GetSelections CONSTANT )
53 
54  public:
55  void Remove (void);
56  void SetActiveThreshold (int Threshold);
57  void SetHelpText (const QString &HelpText);
58  void SetRange (int Begin, int End, int Step);
59  void SetSelections (QVariantMap &Selections);
60 
61  public slots:
62  void SubscriberDeleted (QObject *Subscriber);
63  QVariantMap GetChildList (void);
64  bool SetValue (const QVariant &Value);
65  bool GetIsActive (void);
66  void SetActive (bool Value);
67  QVariant GetValue (void);
68  QString GetUiName (void);
69  QString GetHelpText (void);
70  QVariant GetDefaultValue (void);
71  QString GetSettingType (void);
72  QVariantMap GetSelections (void);
73 
74  // Integer
75  int GetBegin (void);
76  int GetEnd (void);
77  int GetStep (void);
78 
79  signals:
80  void ValueChanged (int Value);
81  void ValueChanged (bool Value);
82  void ValueChanged (QString &Value);
83  void ValueChanged (QStringList &Value);
84  void ActiveChanged (bool Active);
85  void Removed (void);
86 
87  protected:
88  virtual ~TorcSetting() = default;
89  QString GetChildList (QVariantMap &Children);
90  TorcSetting* FindChild (const QString &Child, bool Recursive = false);
91  QSet<TorcSetting*> GetChildren (void);
92  void AddChild (TorcSetting *Child);
93  void RemoveChild (TorcSetting *Child);
94 
95  private:
96  Q_DISABLE_COPY(TorcSetting)
97 
98  private:
99  TorcSetting *m_parent;
100  Type type;
101  QString settingType;
102  Roles roles;
103  QString m_dbName;
104  QString uiName;
105  QString helpText;
106  QVariant value;
107  QVariant defaultValue;
108  QVariantMap selections;
109 
110  // Integer
111  int m_begin;
112  int m_end;
113  int m_step;
114 
115  bool isActive;
116  int m_active;
117  int m_activeThreshold;
118  QList<TorcSetting*> m_children;
119 };
120 
121 Q_DECLARE_OPERATORS_FOR_FLAGS(TorcSetting::Roles)
122 
124 {
125  Q_OBJECT
126  public:
127  TorcSettingGroup(TorcSetting *Parent, const QString &UIName);
128 };
129 
130 Q_DECLARE_METATYPE(TorcSetting*)
131 
132 #endif // TORCSETTING_H
QVariant GetDefaultValue(void)
QVariantMap GetSelections(void)
QString GetSettingType(void)
void SetHelpText(const QString &HelpText)
void Removed(void)
QVariantMap selections
Definition: torcsetting.h:52
QVariant GetValue(void)
High level group of related settings.
Definition: torcsetting.h:123
QString GetHelpText(void)
int GetEnd(void)
QString settingType
Definition: torcsetting.h:51
A reference counting implementation.
void SubscriberDeleted(QObject *Subscriber)
A wrapper around a database setting.
Definition: torcsetting.h:15
QString uiName
Definition: torcsetting.h:47
void RemoveChild(TorcSetting *Child)
TorcSetting * FindChild(const QString &Child, bool Recursive=false)
void Remove(void)
QSet< TorcSetting * > GetChildren(void)
QString GetUiName(void)
bool isActive
Definition: torcsetting.h:50
void AddChild(TorcSetting *Child)
int GetStep(void)
QVariant value
Definition: torcsetting.h:46
bool SetValue(const QVariant &Value)
int GetBegin(void)
void ActiveChanged(bool Active)
QVariant defaultValue
Definition: torcsetting.h:49
void SetActiveThreshold(int Threshold)
void SetRange(int Begin, int End, int Step)
void SetSelections(QVariantMap &Selections)
void ValueChanged(int Value)
bool GetIsActive(void)
QVariantMap GetChildList(void)
QString helpText
Definition: torcsetting.h:48
void SetActive(bool Value)