Added minor 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       Sami Rämö - sami.ramo@ixonos.com
8
9    Situare is free software; you can redistribute it and/or
10    modify it under the terms of the GNU General Public License
11    version 2 as published by the Free Software Foundation.
12
13    Situare is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with Situare; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
21    USA.
22 */
23
24 #ifndef MAINWINDOW_H
25 #define MAINWINDOW_H
26
27 #include <QtGui/QMainWindow>
28 #include <QUrl>
29
30 #include "panelsidebar.h"
31
32 class QGraphicsScene;
33 class QLabel;
34 class QWebView;
35
36 class FacebookAuthentication;
37 class FriendListPanel;
38 class LoginDialog;
39 class MapScene;
40 class MapView;
41 class SituareService;
42 class User;
43 class UserInfoPanel;
44 class ZoomButtonPanel;
45
46 /**
47 * @brief Main Window Class
48 */
49 class MainWindow : public QMainWindow
50 {
51     Q_OBJECT
52
53 public:
54     /**
55     * @brief Constructor
56     *
57     * @param parent Parent
58     */
59     MainWindow(QWidget *parent = 0);
60
61     /**
62     * @brief Destructor
63     *
64     */
65     ~MainWindow();
66
67 /*******************************************************************************
68  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
69  ******************************************************************************/
70 private:
71     /**
72       * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
73       */
74     void keyPressEvent(QKeyEvent* event);
75
76 /*******************************************************************************
77  * MEMBER FUNCTIONS AND SLOTS
78  ******************************************************************************/
79 public:    
80     /**
81     * @brief
82     *
83     * @param logged
84     */
85     void loggedIn(bool logged);
86
87     /**
88     * @brief Enable / disable auto centering button.
89     *
90     * @param enabled true if shoud be enabled, false otherwise
91     */
92     void setAutoCenteringButtonEnabled(bool enabled);
93
94     /**
95     * @brief Enable / disable GPS button.
96     *
97     * Does set visibilities for manual location cursor and auto centering menu button.
98     *
99     * @param enabled true if enabled, false otherwise
100     */
101     void setGPSButtonEnabled(bool enabled);
102
103     /**
104       * @brief Set scene for MapView
105       *
106       * @param scene Scene to be set
107       */
108     void setMapViewScene(QGraphicsScene *scene);
109
110     /**
111     * @brief Show Maemo information box with message.
112     *
113     * @brief message information message
114     */
115     void showMaemoInformationBox(const QString &message);
116
117     /**
118     * @brief Gets the username from member variable for saving purposes
119     *
120     * @return QString Username
121     */
122     const QString username();
123
124 public slots:
125     /**
126     * @brief Slot to intercept signal when user has pressed connect button from loginDialog
127     *
128     * @param email E-mail
129     * @param password Password
130     */
131     void loginDialogDone(const QString &email, const QString &password);
132
133     /**
134     * @brief Slot to intercept signal when login has failed (loginFailure signal)
135     *
136     */
137     void loginFailed();
138
139     /**
140     * @brief Public slot, which open settings dialog
141     */
142     void openSettingsDialog();
143
144     /**
145     * @brief Sets username to member variable for login dialog
146     *
147     * @param username Username to be set
148     */
149     void setUsername(const QString &username);
150
151     /**
152     * @brief
153     *
154     * @param show
155     */
156     void showPanels(bool show);
157
158     /**
159     * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
160     *        doesn't exist yet
161     *
162     * @param url Login page url
163     */
164     void startLoginProcess(const QUrl &url);
165
166     /**
167     * @brief Toggle progress indicator.
168     *
169     * @param state true if progress indicator should be shown, false otherwise
170     */
171     void toggleProgressIndicator(bool state);
172
173 private:
174     /**
175       * @brief Build friend list panel and connect slots
176       */
177     void buildFriendListPanel();
178
179     /**
180       * @brief Build manual location setting cross hair and connect slots
181       */
182     void buildManualLocationCrosshair();
183
184     /**
185       * @brief Build map and connect slots
186       */
187     void buildMap();
188
189     /**
190       * @brief Build OSM license and connect slots
191       */
192     void buildOsmLicense();
193
194     /**
195       * @brief Build user info panel and connect slots
196       */
197     void buildUserInfoPanel();
198
199     /**
200       * @brief Build zoom button panel and connect slots
201       */
202     void buildZoomButtonPanel();
203
204     /**
205     * @brief Private method to create the Menu items
206     */
207     void createMenus();
208
209     /**
210       * @brief Grab or release HW increase and decrease buttons.
211       *
212       * @param grab Use true for grabbing and false for releasing the keys
213       */
214     void grabZoomKeys(bool grab);
215
216     /**
217       * @brief Set own location crosshair visibility
218       *
219       * @param visible
220       */
221     void setOwnLocationCrosshairVisibility(bool visible);
222
223 private slots:
224     /**
225     * @brief Slot for drawing the Open Street Map license text
226     *
227     * @param size Size of the screen
228     */
229     void drawOsmLicense(const QSize &size);
230
231     /**
232     * @brief Slot for drawing the own location crosshair
233     *
234     * @param width Width of the viewport
235     * @param height Height of the viewport
236     */
237     void drawOwnLocationCrosshair(int width, int height);
238
239     /**
240     * @brief Slot for gps error.
241     *
242     * @param message error message
243     */
244     void gpsError(const QString &message);
245
246     /**
247     * @brief Slot for gps timeout.
248     *
249     * Called when request timeout occurs.
250     */
251     void gpsTimeout();
252
253     /**
254     * @brief Slot to intercept signal when webview has finished loading webpage
255     *
256     * @param done Status of the loading
257     */
258     void loadDone(bool done);
259
260     /**
261     * @brief Set correnct view port size to datamembers
262     *
263     * @param width Width of the viewport
264     * @param height Height of the viewport
265     */
266     void setViewPortSize(const int width, const int height);
267
268 /*******************************************************************************
269  * SIGNALS
270  ******************************************************************************/
271 signals:
272     /**
273     * @brief Automatic centering setting changed by user
274     *
275     * @param enabled True if automatic centering is enabled, otherwise false
276     */
277     void autoCenteringTriggered(bool enabled);
278
279     /**
280     * @brief Signal that indicates when user has cancelled login process
281     *
282     */
283     void cancelLoginProcess();
284
285     /**
286     * @brief View should be centered to new location
287     *
288     * @param sceneCoordinate Scene coordinates of the new center point
289     */
290     void centerToSceneCoordinates(QPoint sceneCoordinate);
291
292     /**
293     * @brief Signal for requesting username from settings
294     *
295     */
296     void fetchUsernameFromSettings();
297
298     /**
299     * @brief Signal for finding user.
300     *
301     * @param coordinates user geo coordinates
302     */
303     void findUser(const QPointF &coordinates);
304
305     /**
306     * @brief GPS setting changed
307     *
308     * @param enabled True if GPS is enabled, otherwise false
309     */
310     void gpsTriggered(bool enabled);
311
312     /**
313     * @brief Signal for finding friend.
314     *
315     * @param coordinates friend's geo coordinates
316     */
317     void findFriend(const QPointF &coordinates);
318
319     /**
320     * @brief Signal for friend location ready.
321     *
322     * @param friendsList
323     */
324     void friendsLocationsReady(QList<User *> &friendsList);
325
326     /**
327     * @brief Signal is emitted when location item is clicked.
328     *
329     * @param userIDs list of friends user IDs in the group
330     */
331     void locationItemClicked(const QList<QString> &userIDs);
332
333     /**
334     * @brief Signals when Login/Logout action is pressed
335     *
336     */
337     void loginActionPressed();
338
339     /**
340     * @brief MapView has been resized
341     *
342     * @param size view size
343     */
344     void mapViewResized(const QSize &size);
345
346     /**
347       * @brief Forwarding signal from MapView to MapEngine
348       *
349       * @param sceneCoordinate
350       */
351     void mapViewScrolled(QPoint sceneCoordinate);
352
353     /**
354       * @brief Forwarding signal from MapEngine to MapView
355       */
356     void maxZoomLevelReached();
357
358     /**
359       * @brief Forwarding signal from MapEngine to MapView
360       */
361     void minZoomLevelReached();
362
363     /**
364     * @brief Signal for refreshing user data.
365     *
366     */
367     void refreshUserData();
368
369     /**
370     * @brief Signal for requesting reverseGeo from SituareEngine
371     *
372     */
373     void requestReverseGeo();
374
375     /**
376     * @brief Signals, when address data is ready
377     *
378     * @param address Street address
379     */
380     void reverseGeoReady(const QString &address);
381
382     /**
383     * @brief Signal for requestLocationUpdate from SituareEngine
384     *
385     * @param status Status message
386     * @param publish Publish on Facebook
387     */
388     void statusUpdate(const QString &status, const bool &publish);
389
390     /**
391     * @brief Signals when webview's urlChanged signal is emitted
392     *
393     * @param url New url
394     */
395     void updateCredentials(const QUrl &url);
396
397     /**
398     * @brief MapView has finished zooming
399     */
400     void viewZoomFinished();
401
402     /**
403     * @brief Signal for use location ready.
404     *
405     * @param user User object
406     */
407     void userLocationReady(User *user);
408
409     /**
410     * @brief Map zoom in request
411     */
412     void zoomIn();
413
414     /**
415       * @brief Forwarding signal from MapEngine to MapView
416       */
417     void zoomLevelChanged(int zoomLevel);
418
419     /**
420     * @brief Map zoom out request
421     */
422     void zoomOut();
423
424 /*******************************************************************************
425  * DATA MEMBERS
426  ******************************************************************************/
427 private:
428
429     bool m_drawOwnLocationCrosshair;        ///< Flag for making ownLocationCrosshair visible or not
430     bool m_loggedIn;                        ///< Indicates login state
431     bool m_refresh;                         ///< Indicates when webpage is refreshed
432
433     int m_viewPortHeight;                   ///< Height of view port
434     int m_viewPortWidth;                    ///< Width of view port
435
436     QAction *m_autoCenteringAct;            ///< Action to auto center map using gps position
437     QAction *m_gpsToggleAct;                ///< Action to trigger gps toggle
438     QAction *m_loginAct;                    ///< Action to Login/Logout
439     QAction *m_toSettingsAct;               ///< Action to trigger switch to settings dialog
440
441     QLabel *m_osmLicense;                   ///< Label for Open Street Map license
442     QLabel *m_ownLocationCrosshair;         ///< Label that show ownLocationCrosshair
443
444     QMenu *m_viewMenu;                      ///< Object that hold the view menu items
445
446     QString m_email;                        ///< Placeholder for email
447     QString m_password;                     ///< Placeholder for password
448
449     QUrl m_loginUrl;                        ///< Placeholder for login page url
450
451     QWebView *m_webView;                    ///< Shows facebook login page
452
453     FriendListPanel *m_friendsListPanel;    ///< Instance of friends list panel
454     LoginDialog *m_loginDialog;             ///< Login dialog
455     MapView *m_mapView;                     ///< Instance of the map view
456     PanelSideBar *m_userPanelSidebar;       ///< User panel side bar
457     PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
458     UserInfoPanel *m_userPanel;             ///< Instance of the user information panel
459     ZoomButtonPanel *m_zoomButtonPanel;     ///< Instance of zoom button panel
460 };
461
462 #endif // MAINWINDOW_H