Reorganization of settings dialog to eliminate code duplication.
[yandex-traffic] / settingsDialog.hpp
1 #ifndef __SETTINGSDIALOG_H__
2 #define __SETTINGSDIALOG_H__
3
4 #include <QtGui>
5
6 #ifdef Q_WS_MAEMO_5
7 #include <QtMaemo5>
8 #else
9 #include "QtMaemo5Adapters.hpp"
10 #endif
11
12 #include "settings.hpp"
13
14
15 class SettingsDialog : public QDialog
16 {
17     Q_OBJECT
18
19 private:
20     QMaemo5ValueButton *_displayButton;
21     QMaemo5ValueButton *_updateButton;
22     QMaemo5ValueButton *_alertsButton;
23
24     Settings *_settings;
25
26 protected slots:
27     void displayClicked ();
28     void updateClicked ();
29
30 public:
31     SettingsDialog (Settings *settings);
32 };
33
34
35 class BaseSettingsDialog : public QDialog
36 {
37     Q_OBJECT
38 private:
39     Settings *_settings;
40     QVBoxLayout *_layout;
41     QPushButton *_saveButton;
42
43 protected slots:
44     void saveClicked ();
45
46 protected:
47     Settings* settings () const
48     { return _settings; };
49
50     QVBoxLayout* layout () const
51     { return _layout; };
52
53     virtual void saveSettings () = 0;
54
55 public:
56     BaseSettingsDialog (Settings *settings);
57 };
58
59
60 class DisplaySettingsDialog : public BaseSettingsDialog
61 {
62     Q_OBJECT
63
64 private:
65     QListWidget *_cities;
66     QCheckBox *_showLight, *_showRank, *_showTime, *_showHint;
67
68     void initCities (QBoxLayout *layout);
69     void initChecks (QBoxLayout *layout);
70
71 protected:
72     virtual void saveSettings ();
73
74 public:
75     DisplaySettingsDialog (Settings *settings);
76 };
77
78
79 class UpdateSettingsDialog : public BaseSettingsDialog
80 {
81     Q_OBJECT
82
83 private:
84     QMaemo5ValueButton *_intervalButton;
85     QCheckBox *_wifiUpdate, *_gsmUpdate;
86
87 protected:
88     virtual void saveSettings ();
89
90 public:
91     UpdateSettingsDialog (Settings *settings);
92 };
93
94
95 #endif // __SETTINGSDIALOG_H__