Reorganization of settings dialog to eliminate code duplication.
[yandex-traffic] / settings.hpp
1 #ifndef __SETTINGS_H__
2 #define __SETTINGS_H__
3
4 #include <QtCore>
5
6
7 class Settings : public QObject
8 {
9     Q_OBJECT
10 public:
11     enum check_t {
12         C_Light = 0,
13         C_Rank,
14         C_Time,
15         C_Hint,
16     };
17
18 private:
19     QString _regionID;          // region ID which will be displayed
20     QMap<QString, QString> _cities;
21     QMap<check_t, bool> _checks;
22
23     void makeDefault ();
24
25     void loadCities (QSettings *settings);
26     void saveCities (QSettings *settings);
27
28 public:
29     Settings ();
30
31     void load ();
32     void save ();
33
34     QString regionID () const
35     { return _regionID; };
36
37     void setRegionID (const QString &id)
38     { _regionID = id; };
39
40     QMap<QString, QString> cities () const
41     { return _cities; };
42
43     bool check (check_t entry) const
44     { return _checks[entry]; };
45
46     void setCheck (check_t entry, bool val)
47     { _checks[entry] = val; }
48 };
49
50
51 #endif // __SETTINGS_H__