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