Added functional test for automatic location update confirmation dialog.
[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 Sets automatic location update settings from settings dialog.
70     */
71     void setAutomaticLocationUpdateSettings(bool enabled);
72
73     /**
74     * @brief Enables Situare related settings from settings dialog.
75     *
76     */
77     void enableSituareSettings(bool enabled);
78
79     /**
80     * @brief Emits automatic location update settings.
81     */
82     void emitAutomaticLocationUpdateSettings();
83
84 private slots:
85     /**
86     * @brief Saves settings to file.
87     */
88     void saveValues();
89
90     /**
91     * @brief Rejects changes made to settings.
92     */
93     void rejectValues();
94
95     /**
96     * @brief Toggles automatic location update state.
97     *
98     * Enables and disabled automatic location update interval time edit.
99     *
100     * @param value true if settings are enabled, false otherwise
101     */
102     void toggleAutomaticLocationUpdate(bool enabled);
103
104  private:
105     void populateUpdateIntervalList(QStandardItemModel *model);
106
107     /**
108     * @brief Read settings.
109     */
110     void readSettings();
111
112     /**
113     * @brief Sets time.
114     *
115     * @param time time to set
116     */
117     void setTime(const QTime &time);
118
119     /**
120     * @brief Returns current update interval time.
121     *
122     * @return current time
123     */
124     QTime time();
125
126 signals:
127     /**
128     * @brief Signal for enabling automatic location update.
129     *
130     * @param enabled true if enabled, false otherwise
131     * @param updateIntervalMsecs update interval in milliseconds
132     */
133     void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
134
135 /*******************************************************************************
136  * DATA MEMBERS
137  ******************************************************************************/
138 private:
139     QCheckBox *m_automaticLocationUpdate;           ///< Pointer to CheckBox
140     bool m_automaticLocationUpdateOldValue;         ///< Automatic location update state
141     QTime m_automaticLocationUpdateIntervalOldValue;///< Automatic location update interval value
142
143 #ifdef Q_WS_MAEMO_5
144     QMaemo5ValueButton *m_automaticLocationUpdateIntervalButton;    ///< Maemo 5 value button
145     QMaemo5ListPickSelector *m_timePick;                            ///< Maemo 5 time pick selector
146 #else
147     QTimeEdit *m_automaticLocationUpdateInterval;   ///< Pointer to QTimeEdit
148 #endif
149 };
150
151 #endif // SETTINGSDIALOG_H