Check for device state on update.
[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_ShowLight = 0,
13         C_ShowRank,
14         C_ShowTime,
15         C_ShowHint,
16         C_UpdateOnWiFi,
17         C_UpdateOnGSM,
18         C_UpdateWhenLocked,
19     };
20
21 private:
22     QString _regionID;          // region ID which will be displayed
23     QMap<QString, QString> _cities;
24     QMap<check_t, bool> _checks;
25     int _updateIntervalIndex;
26
27     void makeDefault ();
28
29     void loadCities (QSettings *settings);
30     void saveCities (QSettings *settings);
31
32     int intervalIndex2Minutes (int index) const;
33     int minutes2IntervalIndex (int minutes) const;
34
35 public:
36     Settings ();
37
38     void load ();
39     void save ();
40
41     QString regionID () const
42     { return _regionID; };
43
44     void setRegionID (const QString &id)
45     { _regionID = id; };
46
47     QMap<QString, QString> cities () const
48     { return _cities; };
49
50     bool check (check_t entry) const
51     { return _checks[entry]; };
52
53     void setCheck (check_t entry, bool val)
54     { _checks[entry] = val; };
55
56     QStringList updateIntervals () const;
57
58     int getUpdateIntervalIndex () const
59     { return _updateIntervalIndex; };
60
61     void setUpdateIntervalIndex (int index)
62     { _updateIntervalIndex = index; };
63
64     int updateInterval () const
65     { return intervalIndex2Minutes (_updateIntervalIndex); };
66 };
67
68
69 #endif // __SETTINGS_H__