2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Henri Lampela - henri.lampela@ixonos.com
6 Kaj Wallin - kaj.wallin@ixonos.com
7 Sami Rämö - sami.ramo@ixonos.com
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.
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.
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,
27 #include <QtGui/QMainWindow>
30 #include "network/networkcookiejar.h"
31 #include "panelsidebar.h"
37 class FacebookAuthentication;
38 class FriendListPanel;
44 class ZoomButtonPanel;
47 * @brief Main Window Class
49 class MainWindow : public QMainWindow
57 * @param parent Parent
59 MainWindow(QWidget *parent = 0);
67 /*******************************************************************************
68 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
69 ******************************************************************************/
72 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
74 void keyPressEvent(QKeyEvent* event);
76 /*******************************************************************************
77 * MEMBER FUNCTIONS AND SLOTS
78 ******************************************************************************/
81 * @brief Clears cookie jar
84 void clearCookieJar();
91 void loggedIn(bool logged);
94 * @brief Enable / disable auto centering button.
96 * @param enabled true if shoud be enabled, false otherwise
98 void setAutoCenteringButtonEnabled(bool enabled);
101 * @brief Enable / disable GPS button.
103 * Does set visibilities for manual location cursor and auto centering menu button.
105 * @param enabled true if enabled, false otherwise
107 void setGPSButtonEnabled(bool enabled);
110 * @brief Set scene for MapView
112 * @param scene Scene to be set
114 void setMapViewScene(QGraphicsScene *scene);
117 * @brief Show Maemo information box with message.
119 * @param message Information message
120 * @param modal Modal = true, non-modal false
122 void showMaemoInformationBox(const QString &message, bool modal=false);
125 * @brief Gets the username from member variable for saving purposes
127 * @return QString Username
129 const QString username();
134 * @brief Slot to intercept signal when login has failed (loginFailure signal)
140 * @brief Slot to intercept signal when login with cookies is requested
143 void loginUsingCookies();
146 * @brief Public slot, which open settings dialog
148 void openSettingsDialog();
151 * @brief Sets username to member variable for login dialog
153 * @param username Username to be set
155 void setUsername(const QString &username);
158 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
161 * @param url Login page url
163 void startLoginProcess(const QUrl &url);
166 * @brief Toggle progress indicator.
168 * @param state true if progress indicator should be shown, false otherwise
170 void toggleProgressIndicator(bool state);
173 * @brief Shows / hides Situare related UI items
177 void updateItemVisibility(bool show);
181 * @brief Build friend list panel and connect slots
183 void buildFriendListPanel();
186 * @brief Build manual location setting cross hair and connect slots
188 void buildManualLocationCrosshair();
191 * @brief Build map and connect slots
196 * @brief Build OSM license and connect slots
198 void buildOsmLicense();
201 * @brief Build user info panel and connect slots
203 void buildUserInfoPanel();
206 * @brief Build webview and connect slots
212 * @brief Build zoom button panel and connect slots
214 void buildZoomButtonPanel();
217 * @brief Private method to create the Menu items
222 * @brief Grab or release HW increase and decrease buttons.
224 * @param grab Use true for grabbing and false for releasing the keys
226 void grabZoomKeys(bool grab);
229 * @brief Set own location crosshair visibility
233 void setOwnLocationCrosshairVisibility(bool visible);
237 * @brief Slot for drawing the Open Street Map license text
239 * @param size Size of the screen
241 void drawOsmLicense(const QSize &size);
244 * @brief Slot for drawing the own location crosshair
246 * @param width Width of the viewport
247 * @param height Height of the viewport
249 void drawOwnLocationCrosshair(int width, int height);
252 * @brief Slot for gps error.
254 * @param message error message
256 void gpsError(const QString &message);
259 * @brief Slot for gps timeout.
261 * Called when request timeout occurs.
266 * @brief Slot to load cookies from settings
272 * @brief Slot to intercept signal when webview has finished loading webpage
274 * @param done Status of the loading
276 void loadDone(bool done);
279 * @brief Slot to save cookies to settings
285 * @brief Set correnct view port size to datamembers
287 * @param width Width of the viewport
288 * @param height Height of the viewport
290 void setViewPortSize(const int width, const int height);
292 /*******************************************************************************
294 ******************************************************************************/
297 * @brief Automatic centering setting changed by user
299 * @param enabled True if automatic centering is enabled, otherwise false
301 void autoCenteringTriggered(bool enabled);
304 * @brief Signal that indicates when user has cancelled login process
307 void cancelLoginProcess();
310 * @brief View should be centered to new location
312 * @param sceneCoordinate Scene coordinates of the new center point
314 void centerToSceneCoordinates(QPoint sceneCoordinate);
317 * @brief Signal for requesting username from settings
320 void fetchUsernameFromSettings();
323 * @brief Signal for finding user.
325 * @param coordinates user geo coordinates
327 void findUser(const QPointF &coordinates);
330 * @brief GPS setting changed
332 * @param enabled True if GPS is enabled, otherwise false
334 void gpsTriggered(bool enabled);
337 * @brief Signal for finding friend.
339 * @param coordinates friend's geo coordinates
341 void findFriend(const QPointF &coordinates);
344 * @brief Signal for friend location ready.
348 void friendsLocationsReady(QList<User *> &friendsList);
351 * @brief Signal is emitted when location item is clicked.
353 * @param userIDs list of friends user IDs in the group
355 void locationItemClicked(const QList<QString> &userIDs);
358 * @brief Signals when Login/Logout action is pressed
361 void loginActionPressed();
364 * @brief MapView has been resized
366 * @param size view size
368 void mapViewResized(const QSize &size);
371 * @brief Forwarding signal from MapView to MapEngine
373 * @param sceneCoordinate
375 void mapViewScrolled(QPoint sceneCoordinate);
378 * @brief Forwarding signal from MapEngine to MapView
380 void maxZoomLevelReached();
383 * @brief Forwarding signal from MapEngine to MapView
385 void minZoomLevelReached();
388 * @brief Signal for refreshing user data.
391 void refreshUserData();
394 * @brief Signal for requesting reverseGeo from SituareEngine
397 void requestReverseGeo();
400 * @brief Signals, when address data is ready
402 * @param address Street address
404 void reverseGeoReady(const QString &address);
407 * @brief Signal for requestLocationUpdate from SituareEngine
409 * @param status Status message
410 * @param publish Publish on Facebook
412 void statusUpdate(const QString &status, const bool &publish);
415 * @brief Signals when webview's urlChanged signal is emitted
419 void updateCredentials(const QUrl &url);
422 * @brief MapView has finished zooming
424 void viewZoomFinished();
427 * @brief Signal for use location ready.
429 * @param user User object
431 void userLocationReady(User *user);
434 * @brief Map zoom in request
439 * @brief Forwarding signal from MapEngine to MapView
441 void zoomLevelChanged(int zoomLevel);
444 * @brief Map zoom out request
448 /*******************************************************************************
450 ******************************************************************************/
453 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
454 bool m_loggedIn; ///< Indicates login state
455 bool m_refresh; ///< Indicates when webpage is refreshed
457 int m_viewPortHeight; ///< Height of view port
458 int m_viewPortWidth; ///< Width of view port
460 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
461 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
462 QAction *m_loginAct; ///< Action to Login/Logout
463 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
465 QLabel *m_osmLicense; ///< Label for Open Street Map license
466 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
468 QMenu *m_viewMenu; ///< Object that hold the view menu items
470 QString m_email; ///< Placeholder for email
471 QString m_password; ///< Placeholder for password
473 QWebView *m_webView; ///< Shows facebook login page
475 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
476 MapView *m_mapView; ///< Instance of the map view
477 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
478 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
479 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
480 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
481 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
484 #endif // MAINWINDOW_H