libqutim  0.3.1.0
datasettingsobject.h
Go to the documentation of this file.
1 #ifndef QUTIM_SDK_0_3_DATASETTINGSOBJECT_H
2 #define QUTIM_SDK_0_3_DATASETTINGSOBJECT_H
3 
4 #include "menucontroller.h"
5 #include "settingslayer.h"
6 #include "dataforms.h"
7 
8 namespace qutim_sdk_0_3 {
9 
10 class DataSettingsItemPrivate;
11 class DataSettingsGenerator;
12 class DataSettingsObjectPrivate;
13 
14 class LIBQUTIM_EXPORT DataSettingsObject : public QObject
15 {
16  Q_OBJECT
17  Q_DECLARE_PRIVATE(DataSettingsObject)
18  Q_PROPERTY(qutim_sdk_0_3::DataItem item READ item NOTIFY itemChanged)
19  Q_PROPERTY(QObject *controller READ controller WRITE setController NOTIFY controllerChanged)
20 public:
21  DataSettingsObject(QObject *parent = 0);
23 
24  qutim_sdk_0_3::DataItem item() const;
25  void setController(QObject *controller);
26  QObject *controller() const;
27 
28 public slots:
29  void load();
30  void save(const qutim_sdk_0_3::DataItem &item);
31  void cancel();
32 
33 protected:
34  virtual void loadImpl() = 0;
35  virtual void saveImpl(const qutim_sdk_0_3::DataItem &item) = 0;
36  virtual void cancelImpl();
37  virtual void setControllerImpl(QObject *controller);
38  void setItem(const qutim_sdk_0_3::DataItem &item);
39 
40 signals:
41  void itemChanged(const qutim_sdk_0_3::DataItem &item);
42  void controllerChanged(QObject *controller);
43 
44 private:
45  QScopedPointer<DataSettingsObjectPrivate> d_ptr;
46 };
47 
49 {
50  Q_DECLARE_PRIVATE(DataSettingsItem)
51 public:
52  DataSettingsItem(Settings::Type type, const QIcon &icon, const LocalizedString &text);
54  virtual ~DataSettingsItem();
55 
56 protected:
57  virtual DataSettingsObject *createObject() = 0;
58  virtual const ObjectGenerator *generator() const;
59  friend class DataSettingsGenerator;
60 };
61 
62 template<typename T>
64 {
65 public:
66  GeneralDataSettingsItem(Settings::Type type, const QIcon &icon, const LocalizedString &text)
67  : DataSettingsItem(type, icon, text) {}
69  : DataSettingsItem(type, text) {}
71 protected:
73  {
74  return new T();
75  }
76 };
77 
78 } // namespace qutim_sdk_0_3
79 
80 #endif // QUTIM_SDK_0_3_DATASETTINGSOBJECT_H

Generated by Doxygen