Updated some changes to userinfo
[situare] / src / ui / mainwindow.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5       Henri Lampela - henri.lampela@ixonos.com
6       Kaj Wallin - kaj.wallin@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
24 #ifndef MAINWINDOW_H
25 #define MAINWINDOW_H
26
27 #include <QtGui/QMainWindow>
28 #include <QWidget>
29 #include <QtWebKit>
30 #include <QDebug>
31 #include <QObject>
32 #include <QNetworkAccessManager>
33 #include "facebookservice/facebookauthentication.h"
34 #include "situareservice/situareservice.h"
35 #include "mapviewscreen.h"
36 #include "updatelocation/updatelocationdialog.h"
37 #include "ui/logindialog.h"
38
39 class QLabel;
40
41 /**
42 * @brief Main Window Class
43 *
44 * @class MainWindow mainwindow.h "src/ui/mainwindow.h"
45 */
46 class MainWindow : public QMainWindow
47 {
48     Q_OBJECT
49
50 public:
51     /**
52     * @brief Constructor
53     *
54     * @param parent Parent
55     */
56     MainWindow(QWidget *parent = 0);
57
58     /**
59     * @brief Destructor
60     *
61     */
62     ~MainWindow();
63
64 /*******************************************************************************
65  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
66  ******************************************************************************/
67 private:
68     /**
69       * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
70       */
71     void keyPressEvent(QKeyEvent* event);
72
73 /*******************************************************************************
74  * MEMBER FUNCTIONS AND SLOTS
75  ******************************************************************************/
76 public:
77     /**
78     * @brief Set auto centering button enabled.
79     *
80     * @param enabled true if enabled, false otherwise
81     */
82     void setAutoCenteringButton(bool enabled);
83
84     /**
85     * @brief Notify for auto centering enabling.
86     *
87     * @param enabled true if enabled, false otherwise
88     */
89     void autoCenteringEnabled(bool enabled);
90
91     /**
92     * @brief Set GPS button enabled.
93     *
94     * @param enabled true if enabled, false otherwise
95     */
96     void setGPSButton(bool enabled);
97
98 public slots:
99     /**
100     * @brief Slot for auto centering enabling.
101     *
102     * @param checked true if button state is checked, false otherwise
103     */
104     void autoCenteringToggled(bool checked);
105
106         /**
107     * @brief Slot for gps enabling.
108     *
109     * @param checked true if button state is checked, false otherwise
110     */
111     void gpsToggled(bool checked);
112
113     /**
114     * @brief Slot to intercept signal when user has pressed connect button from loginDialog
115     *
116     * @param email E-mail
117     * @param password Password
118     */
119     void loginDialogDone(const QString &email, const QString &password);
120
121     /**
122     * @brief Slot to intercept signal when login has failed (loginFailure signal)
123     *
124     */
125     void loginFailed();
126
127         /**
128     * @brief Slot for map location change.
129     */
130     void mapLocationChanged();
131
132     /**
133     * @brief Public slot, which open settings dialog
134     */
135     void openSettingsDialog();
136
137     /**
138     * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
139     *        doesn't exist yet
140     *
141     * @param url Login page url
142     */
143     void startLoginProcess(const QUrl &url);
144
145     /**
146     * @brief Toggle progress indicator.
147     *
148     * @param state true if progress indicator should be shown, false otherwise
149     */
150     void toggleProgressIndicator(bool state);
151
152 private:
153     /**
154     * @brief Private method to create the Menu items
155     */
156     void createMenus();
157
158     /**
159       * @brief Grab or release HW increase and decrease buttons.
160       *
161       * @param grab Use true for grabbing and false for releasing the keys
162       */
163     void grabZoomKeys(bool grab);
164
165     /**
166     * @brief Show Maemo information box with message.
167     *
168     * @brief message information message
169     */
170     void showMaemoInformationBox(const QString &message);
171
172 private slots:
173     /**
174     * @brief Slot for gps timeout.
175     *
176     * Called when request timeout occurs.
177     */
178     void gpsTimeout();
179
180     /**
181     * @brief Slot for gps error.
182     *
183     * @param message error message
184     */
185     void gpsError(const QString &message);
186
187     /**
188     * @brief Slot to intercept signal when webview has finished loading webpage
189     *
190     * @param done Status of the loading
191     */
192     void loadDone(bool done);
193
194 /*******************************************************************************
195  * SIGNALS
196  ******************************************************************************/
197 signals:
198     /**
199     * @brief Signal that indicates when user has cancelled login process
200     *
201     */
202     void cancelLoginProcess();
203
204     /**
205     * @brief Signal for map auto centering
206     *
207     * @param enabled true if map should auto center to gps location
208     */
209     void autoCentering(bool enabled);
210
211     /**
212     * @brief Signal for gps enabling.
213     *
214     * @param enabled true if gps should be enabled
215     */
216     void enableGPS(bool enabled);
217
218         /**
219     * @brief Signal for auto centering enabling.
220     *
221     * @param enabled if auto centering should be enabled
222     */
223     void enableAutoCentering(bool enabled);
224
225     /**
226     * @brief Signal for friend location ready.
227     *
228     * @param friendsList
229     */
230     void friendsLocationsReady(QList<User *> &friendsList);
231
232     /**
233     * @brief Signal for gps position.
234     *
235     * @param position longitude and latitude values
236     * @param accuracy coordinate accuracy in metres
237     */
238     void positionReceived(QPointF position, qreal accuracy);
239
240     /**
241     * @brief Signal for refreshing user data.
242     *
243     */
244     void refreshUserData();
245
246     /**
247     * @brief Signal for requesting reverseGeo from SituareEngine
248     *
249     */
250     void requestReverseGeo();
251
252     /**
253     * @brief Signals, when address data is ready
254     *
255     * @param address Street address
256     */
257     void reverseGeoReady(const QString &address);
258
259     /**
260     * @brief Signal for requestLocationUpdate from SituareEngine
261     *
262     * @param status Status message
263     * @param publish Publish on Facebook
264     */
265     void statusUpdate(const QString &status, const bool &publish);
266
267     /**
268     * @brief Signals when webview's urlChanged signal is emitted
269     *
270     * @param url New url
271     */
272     void updateCredentials(const QUrl &url);
273
274     /**
275     * @brief Signal for use location ready.
276     *
277     * @param user User object
278     */
279     void userLocationReady(User *user);
280
281     /**
282       * @brief Signal for HW increase button
283       */
284     void zoomInKeyPressed();
285
286     /**
287       * @brief Signal for HW decrease button
288       */
289     void zoomOutKeyPressed();
290
291 /*******************************************************************************
292  * DATA MEMBERS
293  ******************************************************************************/
294 private:
295
296     QAction *m_autoCenteringAct;    ///< Action to auto center map using gps position
297     QString m_email; ///< Placeholder for email
298     QAction *m_gpsToggleAct;    ///< Action to trigger gps toggle
299     UpdateLocationDialog *m_locationDialog; ///< Message dialog
300     LoginDialog *m_loginDialog; ///< Login dialog
301     QUrl m_loginUrl; ///< Placeholder for login page url
302     MapViewScreen *m_mapViewScreen; ///< Instance of the map view
303     QString m_password; ///< Placeholder for password
304     bool m_refresh; ///< Indicates when webpage is refreshed
305     QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
306     QMenu *m_viewMenu; ///< Object that hold the view menu items
307     QWebView *m_webView; ///< Shows facebook login page
308 };
309
310 #endif // MAINWINDOW_H