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
8 Katri Kaikkonen - katri.kaikkonen@ixonos.com
10 Situare is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 version 2 as published by the Free Software Foundation.
14 Situare is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Situare; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
28 #include <QtGui/QMainWindow>
31 #include "network/networkcookiejar.h"
32 #include "panelsidebar.h"
41 class FacebookAuthentication;
42 class FullScreenButton;
43 class FriendListPanel;
44 class IndicatorButton;
50 class SceneCoordinate;
54 class ZoomButtonPanel;
58 * @brief Main Window Class
60 class MainWindow : public QMainWindow
68 * @param parent Parent
70 MainWindow(QWidget *parent = 0);
78 /*******************************************************************************
79 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
80 ******************************************************************************/
83 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
85 void keyPressEvent(QKeyEvent* event);
87 /*******************************************************************************
88 * MEMBER FUNCTIONS AND SLOTS
89 ******************************************************************************/
92 * @brief Clears cookie jar
95 void clearCookieJar();
102 void loggedIn(bool logged);
105 * @brief Gets the login state (logged in/logged out)
107 * @return bool Login state
112 * @brief Reads automatic location update settings.
114 void readAutomaticLocationUpdateSettings();
117 // * @brief Enable / disable auto centering button.
119 // * @param enabled true if shoud be enabled, false otherwise
121 // void setAutoCenteringButtonEnabled(bool enabled);
124 * @brief Enable / disable GPS button.
126 * Does set visibilities for manual location cursor and auto centering menu button.
128 * @param enabled true if enabled, false otherwise
130 void setGPSButtonEnabled(bool enabled);
133 * @brief Enable / disable direction indicator button.
135 * @param enabled true if shoud be enabled, false otherwise
137 void setIndicatorButtonEnabled(bool enabled);
140 * @brief Set scene for MapView
142 * @param scene Scene to be set
144 void setMapViewScene(QGraphicsScene *scene);
147 * Shows dialog with enable automatic location update question.
149 * @param text text to show in dialog
151 void showEnableAutomaticUpdateLocationDialog(const QString &text);
154 * @brief Gets the username from member variable for saving purposes
156 * @return QString Username
158 const QString username();
163 * @brief Build direction indicator button and connect slots
165 void buildIndicatorButton();
168 * @brief Builds information box with message.
170 * @param message Information message
171 * @param modal Modal = true, non-modal false
173 void buildInformationBox(const QString &message, bool modal=false);
176 * @brief Slot for failed login
181 * @brief Slot to intercept signal when login with cookies is requested
183 void loginUsingCookies();
186 * @brief Public slot, which open settings dialog
188 void openSettingsDialog();
191 * @brief Set own location crosshair visibility
195 void setOwnLocationCrosshairVisibility(bool visible);
198 * @brief Sets username to member variable for login dialog
200 * @param username Username to be set
202 void setUsername(const QString &username);
205 * @brief Method to show panels
210 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
214 void startLoginProcess();
217 * @brief Toggle progress indicator.
219 * @param state true if progress indicator should be shown, false otherwise
221 void toggleProgressIndicator(bool state);
224 * @brief Shows / hides Situare related UI items
227 void updateItemVisibility();
231 * @brief Build fullscreen toggle button and connect slots
233 void buildFullScreenButton();
236 * @brief Build friend list panel and connect slots
238 void buildFriendListPanel();
241 * @brief Build manual location setting cross hair and connect slots
243 void buildManualLocationCrosshair();
246 * @brief Build map and connect slots
251 * @brief Build map scale and connect slots
253 void buildMapScale();
256 * @brief Build OSM license and connect slots
258 void buildOsmLicense();
261 * @brief Build user info panel and connect slots
263 void buildUserInfoPanel();
266 * @brief Build webview and connect slots
271 * @brief Build zoom button panel and connect slots
273 void buildZoomButtonPanel();
276 * @brief Private method to create the Menu items
281 * @brief Grab or release HW increase and decrease buttons.
283 * @param grab Use true for grabbing and false for releasing the keys
285 void grabZoomKeys(bool grab);
288 * @brief Queues dialog/information box
290 * @param dialog Dialog to be added into queue
292 void queueDialog(QDialog *dialog);
295 * @brief Shows queued error information box
298 void showErrorInformationBox();
301 * @brief Shows queued information box
303 * @fn showInformationBox
305 void showInformationBox();
309 * @brief Slot for automatic update dialog finished.
311 * @result result code
313 void automaticUpdateDialogFinished(int result);
316 * @brief Slot to intercept signal when dialog/information note is processed
318 * @param status Status of the dialog
320 void dialogFinished(int status);
323 * @brief Slot for drawing the fullscreen toggle button
325 * @param size Size of the screen
327 void drawFullScreenButton(const QSize &size);
330 * @brief Slot for drawing the map distance scale
332 * @param size Size of the screen
334 void drawMapScale(const QSize &size);
337 * @brief Slot for drawing the Open Street Map license text
339 * @param size Size of the screen
341 void drawOsmLicense(const QSize &size);
344 * @brief Slot for drawing the own location crosshair
346 * @param size Size of the screen
348 void drawOwnLocationCrosshair(const QSize &size);
351 * @brief Slot to intercept signal when error dialog/information note is processed
353 * @param status Status of the dialog
355 void errorDialogFinished(int status);
358 * @brief Slot for gps timeout.
360 * Called when request timeout occurs.
365 * @brief Slot to load cookies from settings
370 * @brief Slot to intercept signal when webview has finished loading webpage
372 * @param done Status of the loading
374 void loadDone(bool done);
377 * @brief Slot to save cookies to settings
382 * @brief Slot for settings dialog accepted.
384 void settingsDialogAccepted();
387 * @brief Set correnct view port size to datamembers
389 * @param size Size of the screen
391 void setViewPortSize(const QSize &size);
394 * @brief Start location search (open search dialog)
396 void startLocationSearch();
399 * @brief Toggle between fullscreen and normal window mode
401 void toggleFullScreen();
404 * @brief Slot to intercept signal from webview's networkaccessmanager
406 * @param reply Network reply (contains errors)
408 void webViewRequestFinished(QNetworkReply* reply);
410 /*******************************************************************************
412 ******************************************************************************/
415 * @brief Automatic centering setting changed by user
417 * @param enabled True if automatic centering is enabled, otherwise false
419 void autoCenteringTriggered(bool enabled);
422 * @brief Signal that indicates when user has cancelled login process
425 void cancelLoginProcess();
428 * @brief View should be centered to new location
430 * @param coordinate Scene coordinates of the new center point
432 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
435 * @brief Signal when direction and distance from current map center point to current GPS
436 * location is changed
438 * @param direction Direction in degrees
439 * @param distance Distance in kilometers
440 * @param draw Should the indicator triangle be drawn or not
442 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
445 * @brief Signal for enabling automatic location update.
447 * @param enabled true if enabled, false otherwise
448 * @param updateIntervalMsecs update interval in milliseconds
450 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
453 * @brief Signals error
455 * @param context error context
456 * @param error error code
458 void error(const int context, const int error);
461 * @brief Signal for requesting username from settings
464 void fetchUsernameFromSettings();
467 * @brief Signal for finding user.
469 * @param coordinates user geo coordinates
471 void findUser(const GeoCoordinate &coordinates);
474 * @brief Signals when friend's profile image is ready
478 void friendImageReady(User *user);
481 * @brief GPS setting changed
483 * @param enabled True if GPS is enabled, otherwise false
485 void gpsTriggered(bool enabled);
488 * @brief Signal for finding friend.
490 * @param coordinates friend's geo coordinates
492 void findFriend(const GeoCoordinate &coordinates);
495 * @brief Signal for friend location ready.
499 void friendsLocationsReady(QList<User *> &friendsList);
502 * @brief Signal is emitted when location item is clicked.
504 * @param userIDs list of friends user IDs in the group
506 void locationItemClicked(const QList<QString> &userIDs);
509 * @brief Signals when Login/Logout action is pressed
512 void loginActionPressed();
515 * @brief MapView has been resized
517 * @param size view size
519 void mapViewResized(const QSize &size);
522 * @brief Forwarding signal from MapView to MapEngine
526 void mapViewScrolled(const SceneCoordinate &coordinate);
529 * @brief Forwarding signal from MapEngine to MapView
531 void maxZoomLevelReached();
534 * @brief Forwarding signal from MapEngine to MapView
536 void minZoomLevelReached();
539 * @brief Forwarding signal from MapEngine to MapScale
541 void newMapResolution(qreal scale);
544 * @brief Signal for refreshing user data.
547 void refreshUserData();
550 * @brief Signal for requesting reverseGeo from SituareEngine
553 void requestReverseGeo();
556 * @brief Signals, when address data is ready
558 * @param address Street address
560 void reverseGeoReady(const QString &address);
563 * @brief Signal to save username to settings
565 * @param username Username
567 void saveUsername(const QString &username);
570 * @brief Signal for location search
572 * @param location QString location
574 void searchForLocation(QString location);
577 * @brief Signal for requestLocationUpdate from SituareEngine
579 * @param status Status message
580 * @param publish Publish on Facebook
582 void statusUpdate(const QString &status, const bool &publish);
585 * @brief Signals when webview's urlChanged signal is emitted
589 void updateCredentials(const QUrl &url);
592 * @brief Signals when updateLocationDialog's data must be cleared
595 void clearUpdateLocationDialogData();
598 * @brief MapView has finished zooming
600 void viewZoomFinished();
603 * @brief Signal for use location ready.
605 * @param user User object
607 void userLocationReady(User *user);
610 * @brief Map zoom in request
615 * @brief Forwarding signal from MapEngine to MapView
617 void zoomLevelChanged(int zoomLevel);
620 * @brief Map zoom out request
624 /*******************************************************************************
626 ******************************************************************************/
628 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
629 bool m_errorShown; ///< Indicates if error dialog/note is shown
630 bool m_loggedIn; ///< Indicates login state
631 bool m_refresh; ///< Indicates when webpage is refreshed
633 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
635 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
636 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
637 QAction *m_loginAct; ///< Action to Login/Logout
638 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
639 QAction *m_searchLocationAct; /// @todo this is temporary, remove when not needed!
641 QLabel *m_osmLicense; ///< Label for Open Street Map license
642 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
644 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
645 QList<QDialog *> m_queue; ///< QList type dialog queue
647 QMenu *m_viewMenu; ///< Object that hold the view menu items
649 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
651 QSize m_viewPortSize; ///< Size of the viewport
653 QString m_email; ///< Placeholder for email
654 QString m_password; ///< Placeholder for password
656 QWebView *m_webView; ///< Shows facebook login page
658 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
659 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
660 IndicatorButton *m_indicatorButton; ///< Instance of direction indicator button
661 MapScale *m_mapScale; ///< Instance of the map scale
662 MapView *m_mapView; ///< Instance of the map view
663 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
664 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
665 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
666 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
667 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
670 #endif // MAINWINDOW_H