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();
133 * @brief Slot to intercept signal when login has failed (loginFailure signal)
139 * @brief Slot to intercept signal when login with cookies is requested
142 void loginUsingCookies();
145 * @brief Public slot, which open settings dialog
147 void openSettingsDialog();
150 * @brief Sets username to member variable for login dialog
152 * @param username Username to be set
154 void setUsername(const QString &username);
157 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
160 * @param url Login page url
162 void startLoginProcess(const QUrl &url);
165 * @brief Toggle progress indicator.
167 * @param state true if progress indicator should be shown, false otherwise
169 void toggleProgressIndicator(bool state);
172 * @brief Shows / hides Situare related UI items
176 void updateItemVisibility(bool show);
180 * @brief Build friend list panel and connect slots
182 void buildFriendListPanel();
185 * @brief Build manual location setting cross hair and connect slots
187 void buildManualLocationCrosshair();
190 * @brief Build map and connect slots
195 * @brief Build OSM license and connect slots
197 void buildOsmLicense();
200 * @brief Build user info panel and connect slots
202 void buildUserInfoPanel();
205 * @brief Build webview and connect slots
211 * @brief Build zoom button panel and connect slots
213 void buildZoomButtonPanel();
216 * @brief Private method to create the Menu items
221 * @brief Grab or release HW increase and decrease buttons.
223 * @param grab Use true for grabbing and false for releasing the keys
225 void grabZoomKeys(bool grab);
228 * @brief Set own location crosshair visibility
232 void setOwnLocationCrosshairVisibility(bool visible);
236 * @brief Slot for drawing the Open Street Map license text
238 * @param size Size of the screen
240 void drawOsmLicense(const QSize &size);
243 * @brief Slot for drawing the own location crosshair
245 * @param width Width of the viewport
246 * @param height Height of the viewport
248 void drawOwnLocationCrosshair(int width, int height);
251 * @brief Slot for gps error.
253 * @param message error message
255 void gpsError(const QString &message);
258 * @brief Slot for gps timeout.
260 * Called when request timeout occurs.
265 * @brief Slot to load cookies from settings
271 * @brief Slot to intercept signal when webview has finished loading webpage
273 * @param done Status of the loading
275 void loadDone(bool done);
278 * @brief Slot to save cookies to settings
284 * @brief Set correnct view port size to datamembers
286 * @param width Width of the viewport
287 * @param height Height of the viewport
289 void setViewPortSize(const int width, const int height);
291 /*******************************************************************************
293 ******************************************************************************/
296 * @brief Automatic centering setting changed by user
298 * @param enabled True if automatic centering is enabled, otherwise false
300 void autoCenteringTriggered(bool enabled);
303 * @brief Signal that indicates when user has cancelled login process
306 void cancelLoginProcess();
309 * @brief View should be centered to new location
311 * @param sceneCoordinate Scene coordinates of the new center point
313 void centerToSceneCoordinates(QPoint sceneCoordinate);
316 * @brief Signal for requesting username from settings
319 void fetchUsernameFromSettings();
322 * @brief Signal for finding user.
324 * @param coordinates user geo coordinates
326 void findUser(const QPointF &coordinates);
329 * @brief GPS setting changed
331 * @param enabled True if GPS is enabled, otherwise false
333 void gpsTriggered(bool enabled);
336 * @brief Signal for finding friend.
338 * @param coordinates friend's geo coordinates
340 void findFriend(const QPointF &coordinates);
343 * @brief Signal for friend location ready.
347 void friendsLocationsReady(QList<User *> &friendsList);
350 * @brief Signal is emitted when location item is clicked.
352 * @param userIDs list of friends user IDs in the group
354 void locationItemClicked(const QList<QString> &userIDs);
357 * @brief Signals when Login/Logout action is pressed
360 void loginActionPressed();
363 * @brief MapView has been resized
365 * @param size view size
367 void mapViewResized(const QSize &size);
370 * @brief Forwarding signal from MapView to MapEngine
372 * @param sceneCoordinate
374 void mapViewScrolled(QPoint sceneCoordinate);
377 * @brief Forwarding signal from MapEngine to MapView
379 void maxZoomLevelReached();
382 * @brief Forwarding signal from MapEngine to MapView
384 void minZoomLevelReached();
387 * @brief Signal for refreshing user data.
390 void refreshUserData();
393 * @brief Signal for requesting reverseGeo from SituareEngine
396 void requestReverseGeo();
399 * @brief Signals, when address data is ready
401 * @param address Street address
403 void reverseGeoReady(const QString &address);
406 * @brief Signal for requestLocationUpdate from SituareEngine
408 * @param status Status message
409 * @param publish Publish on Facebook
411 void statusUpdate(const QString &status, const bool &publish);
414 * @brief Signals when webview's urlChanged signal is emitted
418 void updateCredentials(const QUrl &url);
421 * @brief MapView has finished zooming
423 void viewZoomFinished();
426 * @brief Signal for use location ready.
428 * @param user User object
430 void userLocationReady(User *user);
433 * @brief Map zoom in request
438 * @brief Forwarding signal from MapEngine to MapView
440 void zoomLevelChanged(int zoomLevel);
443 * @brief Map zoom out request
447 /*******************************************************************************
449 ******************************************************************************/
451 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
452 bool m_loggedIn; ///< Indicates login state
453 bool m_refresh; ///< Indicates when webpage is refreshed
455 int m_viewPortHeight; ///< Height of view port
456 int m_viewPortWidth; ///< Width of view port
458 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
459 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
460 QAction *m_loginAct; ///< Action to Login/Logout
461 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
463 QLabel *m_osmLicense; ///< Label for Open Street Map license
464 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
466 QMenu *m_viewMenu; ///< Object that hold the view menu items
468 QString m_email; ///< Placeholder for email
469 QString m_password; ///< Placeholder for password
471 QWebView *m_webView; ///< Shows facebook login page
473 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
474 MapView *m_mapView; ///< Instance of the map view
475 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
476 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
477 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
478 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
479 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
482 #endif // MAINWINDOW_H