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 "networkcookiejar.h"
31 #include "panelsidebar.h"
37 class FacebookAuthentication;
38 class FriendListPanel;
45 class ZoomButtonPanel;
48 * @brief Main Window Class
50 class MainWindow : public QMainWindow
58 * @param parent Parent
60 MainWindow(QWidget *parent = 0);
68 /*******************************************************************************
69 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
70 ******************************************************************************/
73 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
75 void keyPressEvent(QKeyEvent* event);
77 /*******************************************************************************
78 * MEMBER FUNCTIONS AND SLOTS
79 ******************************************************************************/
86 void loggedIn(bool logged);
89 * @brief Enable / disable auto centering button.
91 * @param enabled true if shoud be enabled, false otherwise
93 void setAutoCenteringButtonEnabled(bool enabled);
96 * @brief Enable / disable GPS button.
98 * Does set visibilities for manual location cursor and auto centering menu button.
100 * @param enabled true if enabled, false otherwise
102 void setGPSButtonEnabled(bool enabled);
105 * @brief Set scene for MapView
107 * @param scene Scene to be set
109 void setMapViewScene(QGraphicsScene *scene);
112 * @brief Show Maemo information box with message.
114 * @brief message information message
116 void showMaemoInformationBox(const QString &message);
119 * @brief Gets the username from member variable for saving purposes
121 * @return QString Username
123 const QString username();
127 * @brief Slot to intercept signal when user has pressed connect button from loginDialog
129 * @param email E-mail
130 * @param password Password
132 void loginDialogDone(const QString &email, const QString &password);
135 * @brief Slot to intercept signal when login has failed (loginFailure signal)
141 * @brief Slot to intercept signal when login with cookies is requested
144 void loginUsingCookies();
147 * @brief Public slot, which open settings dialog
149 void openSettingsDialog();
152 * @brief Sets username to member variable for login dialog
154 * @param username Username to be set
156 void setUsername(const QString &username);
163 void showPanels(bool show);
166 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
169 * @param url Login page url
171 void startLoginProcess(const QUrl &url);
174 * @brief Toggle progress indicator.
176 * @param state true if progress indicator should be shown, false otherwise
178 void toggleProgressIndicator(bool state);
182 * @brief Build friend list panel and connect slots
184 void buildFriendListPanel();
187 * @brief Build login dialog and connect slots
190 void buildLoginDialog();
193 * @brief Build manual location setting cross hair and connect slots
195 void buildManualLocationCrosshair();
198 * @brief Build map and connect slots
203 * @brief Build OSM license and connect slots
205 void buildOsmLicense();
208 * @brief Build user info panel and connect slots
210 void buildUserInfoPanel();
213 * @brief Build webview and connect slots
219 * @brief Build zoom button panel and connect slots
221 void buildZoomButtonPanel();
224 * @brief Clears cookie jar
227 void clearCookieJar();
230 * @brief connect/disconnect webview signals
232 * @param connectSignals true = connect, false = disconnect
234 void connectWebViewSignals(bool connectSignals);
237 * @brief Private method to create the Menu items
242 * @brief Grab or release HW increase and decrease buttons.
244 * @param grab Use true for grabbing and false for releasing the keys
246 void grabZoomKeys(bool grab);
249 * @brief Set own location crosshair visibility
253 void setOwnLocationCrosshairVisibility(bool visible);
257 * @brief Slot for drawing the Open Street Map license text
259 * @param size Size of the screen
261 void drawOsmLicense(const QSize &size);
264 * @brief Slot for drawing the own location crosshair
266 * @param width Width of the viewport
267 * @param height Height of the viewport
269 void drawOwnLocationCrosshair(int width, int height);
272 * @brief Slot for gps error.
274 * @param message error message
276 void gpsError(const QString &message);
279 * @brief Slot for gps timeout.
281 * Called when request timeout occurs.
286 * @brief Slot to load cookies from settings
292 * @brief Slot to intercept signal when webview has finished loading webpage
294 * @param done Status of the loading
296 void loadDone(bool done);
299 * @brief Slot to save cookies to settings
305 * @brief Set correnct view port size to datamembers
307 * @param width Width of the viewport
308 * @param height Height of the viewport
310 void setViewPortSize(const int width, const int height);
312 /*******************************************************************************
314 ******************************************************************************/
317 * @brief Automatic centering setting changed by user
319 * @param enabled True if automatic centering is enabled, otherwise false
321 void autoCenteringTriggered(bool enabled);
324 * @brief Signal that indicates when user has cancelled login process
327 void cancelLoginProcess();
330 * @brief View should be centered to new location
332 * @param sceneCoordinate Scene coordinates of the new center point
334 void centerToSceneCoordinates(QPoint sceneCoordinate);
337 * @brief Signal for requesting username from settings
340 void fetchUsernameFromSettings();
343 * @brief Signal for finding user.
345 * @param coordinates user geo coordinates
347 void findUser(const QPointF &coordinates);
350 * @brief GPS setting changed
352 * @param enabled True if GPS is enabled, otherwise false
354 void gpsTriggered(bool enabled);
357 * @brief Signal for finding friend.
359 * @param coordinates friend's geo coordinates
361 void findFriend(const QPointF &coordinates);
364 * @brief Signal for friend location ready.
368 void friendsLocationsReady(QList<User *> &friendsList);
371 * @brief Signal is emitted when location item is clicked.
373 * @param userIDs list of friends user IDs in the group
375 void locationItemClicked(const QList<QString> &userIDs);
378 * @brief Signals when Login/Logout action is pressed
381 void loginActionPressed();
384 * @brief MapView has been resized
386 * @param size view size
388 void mapViewResized(const QSize &size);
391 * @brief Forwarding signal from MapView to MapEngine
393 * @param sceneCoordinate
395 void mapViewScrolled(QPoint sceneCoordinate);
398 * @brief Forwarding signal from MapEngine to MapView
400 void maxZoomLevelReached();
403 * @brief Forwarding signal from MapEngine to MapView
405 void minZoomLevelReached();
408 * @brief Signal for refreshing user data.
411 void refreshUserData();
414 * @brief Signal for requesting reverseGeo from SituareEngine
417 void requestReverseGeo();
420 * @brief Signals, when address data is ready
422 * @param address Street address
424 void reverseGeoReady(const QString &address);
427 * @brief Signal for requestLocationUpdate from SituareEngine
429 * @param status Status message
430 * @param publish Publish on Facebook
432 void statusUpdate(const QString &status, const bool &publish);
435 * @brief Signals when webview's urlChanged signal is emitted
439 void updateCredentials(const QUrl &url);
442 * @brief MapView has finished zooming
444 void viewZoomFinished();
447 * @brief Signal for use location ready.
449 * @param user User object
451 void userLocationReady(User *user);
454 * @brief Map zoom in request
459 * @brief Forwarding signal from MapEngine to MapView
461 void zoomLevelChanged(int zoomLevel);
464 * @brief Map zoom out request
468 /*******************************************************************************
470 ******************************************************************************/
473 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
474 bool m_loggedIn; ///< Indicates login state
475 bool m_refresh; ///< Indicates when webpage is refreshed
477 int m_viewPortHeight; ///< Height of view port
478 int m_viewPortWidth; ///< Width of view port
480 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
481 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
482 QAction *m_loginAct; ///< Action to Login/Logout
483 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
485 QLabel *m_osmLicense; ///< Label for Open Street Map license
486 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
488 QMenu *m_viewMenu; ///< Object that hold the view menu items
490 QString m_email; ///< Placeholder for email
491 QString m_password; ///< Placeholder for password
493 QWebView *m_webView; ///< Shows facebook login page
495 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
496 LoginDialog *m_loginDialog; ///< Login dialog
497 MapView *m_mapView; ///< Instance of the map view
498 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
499 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
500 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
501 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
502 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
505 #endif // MAINWINDOW_H