backup...
[situare] / src / ui / settingsdialog.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5       Katri Kaikkonen - katri.kaikkonen@ixonos.com
6       Jussi Laitinen - jussi.laitinen@ixonos.com
7
8    Situare is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License
10    version 2 as published by the Free Software Foundation.
11
12    Situare is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with Situare; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20    USA.
21 */
22
23 #ifndef SETTINGSDIALOG_H
24 #define SETTINGSDIALOG_H
25
26 #include <QDialog>
27 #include <QTime>
28 #include <QStandardItemModel>
29
30 class QCheckBox;
31
32 #ifdef Q_WS_MAEMO_5
33 #include <QMaemo5ValueButton>
34 #include <QMaemo5ListPickSelector>
35 #else
36 #include <QTimeEdit>
37 #endif
38
39
40 /**
41 * @brief Settings Dialog.
42 *
43 * @class SettingsDialog settingsdialog.h "ui/settingsdialog.h"
44 */
45 class SettingsDialog : public QDialog
46  {
47     Q_OBJECT
48
49 public:
50     /**
51     * @brief Default constructor
52     *
53     * @param parent Parent
54     */
55     SettingsDialog(QWidget *parent = 0);
56
57     /**
58     * @brief Destructor.
59     *
60     * Saves automatic update interval in settings.
61     */
62     ~SettingsDialog();
63
64 /*******************************************************************************
65 * MEMBER FUNCTIONS AND SLOTS
66 ******************************************************************************/
67  public:
68     /**
69     * @brief Enables Situare related settings from settings dialog.
70     *
71     */
72     void enableSituareSettings(bool enabled);
73
74
75 private slots:
76     /**
77     * @brief Saves settings to file.
78     */
79     void saveValues();
80
81     /**
82     * @brief Rejects changes made to settings.
83     */
84     void rejectValues();
85
86     /**
87     * @brief Toggles automatic location update state.
88     *
89     * Enables and disabled automatic location update interval time edit.
90     *
91     * @param value true if settings are enabled, false otherwise
92     */
93     void toggleAutomaticLocationUpdate(bool enabled);
94
95  private:
96     void populateUpdateIntervalList(QStandardItemModel *model);
97
98     /**
99     * @brief Read settings.
100     */
101     void readSettings();
102
103     /**
104     * @brief Sets time.
105     *
106     * @param time time to set
107     */
108     void setTime(const QTime &time);
109
110     /**
111     * @brief Returns current update interval time.
112     *
113     * @return current time
114     */
115     QTime time();
116
117 signals:
118     /**
119     * @brief Signal for enabling automatic location update.
120     *
121     * @param enabled true if enabled, false otherwise
122     * @param updateIntervalMsecs update interval in milliseconds
123     */
124     void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
125
126 /*******************************************************************************
127  * DATA MEMBERS
128  ******************************************************************************/
129 private:
130     QCheckBox *m_automaticLocationUpdate; ///< Pointer to CheckBox
131     bool m_automaticLocationUpdateOldValue;         ///< Automatic location update state
132     QTime m_automaticLocationUpdateIntervalOldValue;///< Automatic location update interval value
133
134 #ifdef Q_WS_MAEMO_5
135     QMaemo5ValueButton *m_automaticLocationUpdateIntervalButton;
136     QMaemo5ListPickSelector *m_timePick;
137 #else
138     QTimeEdit *m_automaticLocationUpdateInterval;   ///< Pointer to QTimeEdit
139 #endif
140 };
141
142 #endif // SETTINGSDIALOG_H