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;
59 * @brief Main Window Class
61 class MainWindow : public QMainWindow
69 * @param parent Parent
71 MainWindow(QWidget *parent = 0);
79 /*******************************************************************************
80 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
81 ******************************************************************************/
84 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
86 void keyPressEvent(QKeyEvent* event);
88 /*******************************************************************************
89 * MEMBER FUNCTIONS AND SLOTS
90 ******************************************************************************/
93 * @brief Clears cookie jar
96 void clearCookieJar();
103 void loggedIn(bool logged);
106 * @brief Gets the login state (logged in/logged out)
108 * @return bool Login state
113 * @brief Reads automatic location update settings.
115 void readAutomaticLocationUpdateSettings();
118 // * @brief Enable / disable auto centering button.
120 // * @param enabled true if shoud be enabled, false otherwise
122 // void setAutoCenteringButtonEnabled(bool enabled);
125 * @brief Enable / disable GPS button.
127 * Does set visibilities for manual location cursor and auto centering menu button.
129 * @param enabled true if enabled, false otherwise
131 void setGPSButtonEnabled(bool enabled);
134 * @brief Enable / disable direction indicator button.
136 * @param enabled true if shoud be enabled, false otherwise
138 void setIndicatorButtonEnabled(bool enabled);
141 * @brief Set scene for MapView
143 * @param scene Scene to be set
145 void setMapViewScene(QGraphicsScene *scene);
148 * Shows dialog with enable automatic location update question.
150 * @param text text to show in dialog
152 void showEnableAutomaticUpdateLocationDialog(const QString &text);
155 * @brief Gets the username from member variable for saving purposes
157 * @return QString Username
159 const QString username();
164 * @brief Build direction indicator button and connect slots
166 void buildIndicatorButton();
169 * @brief Builds information box with message.
171 * @param message Information message
172 * @param modal Modal = true, non-modal false
174 void buildInformationBox(const QString &message, bool modal=false);
177 * @brief Slot for failed login
183 * @brief Slot to intercept signal when login with cookies is requested
186 void loginUsingCookies();
189 * @brief Public slot, which open settings dialog
191 void openSettingsDialog();
194 * @brief Set own location crosshair visibility
198 void setOwnLocationCrosshairVisibility(bool visible);
201 * @brief Sets username to member variable for login dialog
203 * @param username Username to be set
205 void setUsername(const QString &username);
208 * @brief Method to show panels
214 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
218 void startLoginProcess();
221 * @brief Toggle progress indicator.
223 * @param state true if progress indicator should be shown, false otherwise
225 void toggleProgressIndicator(bool state);
228 * @brief Shows / hides Situare related UI items
231 void updateItemVisibility();
235 * @brief Build fullscreen toggle button and connect slots
237 void buildFullScreenButton();
240 * @brief Build friend list panel and connect slots
242 void buildFriendListPanel();
245 * @brief Build manual location setting cross hair and connect slots
247 void buildManualLocationCrosshair();
250 * @brief Build map and connect slots
255 * @brief Build map scale and connect slots
257 void buildMapScale();
260 * @brief Build OSM license and connect slots
262 void buildOsmLicense();
265 * @brief Build user info panel and connect slots
267 void buildUserInfoPanel();
270 * @brief Build webview and connect slots
276 * @brief Build zoom button panel and connect slots
278 void buildZoomButtonPanel();
281 * @brief Private method to create the Menu items
286 * @brief Grab or release HW increase and decrease buttons.
288 * @param grab Use true for grabbing and false for releasing the keys
290 void grabZoomKeys(bool grab);
293 * @brief Queues dialog/information box
295 * @param dialog Dialog to be added into queue
297 void queueDialog(QDialog *dialog);
300 * @brief Shows queued error information box
303 void showErrorInformationBox();
306 * @brief Shows queued information box
308 * @fn showInformationBox
310 void showInformationBox();
314 * @brief Slot for automatic update dialog finished.
316 * @result result code
318 void automaticUpdateDialogFinished(int result);
321 * @brief Slot to intercept signal when dialog/information note is processed
323 * @param status Status of the dialog
325 void dialogFinished(int status);
328 * @brief Slot for drawing the fullscreen toggle button
330 * @param size Size of the screen
332 void drawFullScreenButton(const QSize &size);
335 * @brief Slot for drawing the map distance scale
337 * @param size Size of the screen
339 void drawMapScale(const QSize &size);
342 * @brief Slot for drawing the Open Street Map license text
344 * @param size Size of the screen
346 void drawOsmLicense(const QSize &size);
349 * @brief Slot for drawing the own location crosshair
351 * @param size Size of the screen
353 void drawOwnLocationCrosshair(const QSize &size);
356 * @brief Slot to intercept signal when error dialog/information note is processed
358 * @param status Status of the dialog
360 void errorDialogFinished(int status);
363 * @brief Slot for gps timeout.
365 * Called when request timeout occurs.
370 * @brief Slot to load cookies from settings
376 * @brief Slot to intercept signal when webview has finished loading webpage
378 * @param done Status of the loading
380 void loadDone(bool done);
383 * @brief Slot to save cookies to settings
389 * @brief Slot for settings dialog accepted.
391 void settingsDialogAccepted();
394 * @brief Set correnct view port size to datamembers
396 * @param size Size of the screen
398 void setViewPortSize(const QSize &size);
401 * @brief Start location search (open search dialog)
403 void startLocationSearch();
406 * @brief Toggle between fullscreen and normal window mode
408 void toggleFullScreen();
411 * @brief Slot to intercept signal from webview's networkaccessmanager
413 * @param reply Network reply (contains errors)
415 void webViewRequestFinished(QNetworkReply* reply);
418 /*******************************************************************************
420 ******************************************************************************/
423 * @brief Automatic centering setting changed by user
425 * @param enabled True if automatic centering is enabled, otherwise false
427 void autoCenteringTriggered(bool enabled);
430 * @brief Signal that indicates when user has cancelled login process
433 void cancelLoginProcess();
436 * @brief View should be centered to new location
438 * @param coordinate Scene coordinates of the new center point
440 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
443 * @brief Signal for enabling automatic location update.
445 * @param enabled true if enabled, false otherwise
446 * @param updateIntervalMsecs update interval in milliseconds
448 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
451 * @brief Signals error
453 * @param context error context
454 * @param error error code
456 void error(const int context, const int error);
459 * @brief Signal for requesting username from settings
462 void fetchUsernameFromSettings();
465 * @brief Signal for finding user.
467 * @param coordinates user geo coordinates
469 void findUser(const GeoCoordinate &coordinates);
472 * @brief Signals when friend's profile image is ready
476 void friendImageReady(User *user);
479 * @brief GPS setting changed
481 * @param enabled True if GPS is enabled, otherwise false
483 void gpsTriggered(bool enabled);
486 * @brief Signal for finding friend.
488 * @param coordinates friend's geo coordinates
490 void findFriend(const GeoCoordinate &coordinates);
493 * @brief Signal for friend location ready.
497 void friendsLocationsReady(QList<User *> &friendsList);
500 * @brief Emited when location request is parsed and is ready for further processing
502 * @param result List of Location items
504 void locationDataParsed(QList<Location> &result);
507 * @brief Signal is emitted when location item is clicked.
509 * @param userIDs list of friends user IDs in the group
511 void locationItemClicked(const QList<QString> &userIDs);
514 * @brief Signals when Login/Logout action is pressed
517 void loginActionPressed();
520 * @brief MapView has been resized
522 * @param size view size
524 void mapViewResized(const QSize &size);
527 * @brief Forwarding signal from MapView to MapEngine
531 void mapViewScrolled(const SceneCoordinate &coordinate);
534 * @brief Forwarding signal from MapEngine to MapView
536 void maxZoomLevelReached();
539 * @brief Forwarding signal from MapEngine to MapView
541 void minZoomLevelReached();
544 * @brief Forwarding signal from MapEngine to MapScale
546 void newMapResolution(qreal scale);
549 * @brief Signal for refreshing user data.
552 void refreshUserData();
555 * @brief Signal for requesting reverseGeo from SituareEngine
558 void requestReverseGeo();
561 * @brief Signals, when address data is ready
563 * @param address Street address
565 void reverseGeoReady(const QString &address);
568 * @brief Signal to save username to settings
570 * @param username Username
572 void saveUsername(const QString &username);
575 * @brief Signal for location search
577 * @param location QString location
579 void searchForLocation(QString location);
582 * @brief Signal for requestLocationUpdate from SituareEngine
584 * @param status Status message
585 * @param publish Publish on Facebook
587 void statusUpdate(const QString &status, const bool &publish);
590 * @brief Signals when webview's urlChanged signal is emitted
594 void updateCredentials(const QUrl &url);
597 * @brief Signals when updateLocationDialog's data must be cleared
600 void clearUpdateLocationDialogData();
603 * @brief MapView has finished zooming
605 void viewZoomFinished();
608 * @brief Signal for use location ready.
610 * @param user User object
612 void userLocationReady(User *user);
615 * @brief Map zoom in request
620 * @brief Forwarding signal from MapEngine to MapView
622 void zoomLevelChanged(int zoomLevel);
625 * @brief Map zoom out request
629 /*******************************************************************************
631 ******************************************************************************/
633 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
634 bool m_errorShown; ///< Indicates if error dialog/note is shown
635 bool m_loggedIn; ///< Indicates login state
636 bool m_refresh; ///< Indicates when webpage is refreshed
638 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
640 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
641 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
642 QAction *m_loginAct; ///< Action to Login/Logout
643 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
644 QAction *m_searchLocationAct; /// @todo this is temporary, remove when not needed!
646 QLabel *m_osmLicense; ///< Label for Open Street Map license
647 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
649 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
650 QList<QDialog *> m_queue; ///< QList type dialog queue
652 QMenu *m_viewMenu; ///< Object that hold the view menu items
654 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
656 QSize m_viewPortSize; ///< Size of the viewport
658 QString m_email; ///< Placeholder for email
659 QString m_password; ///< Placeholder for password
661 QWebView *m_webView; ///< Shows facebook login page
663 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
664 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
665 IndicatorButton *m_indicatorButton; ///< Instance of direction indicator button
666 MapScale *m_mapScale; ///< Instance of the map scale
667 MapView *m_mapView; ///< Instance of the map view
668 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
669 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
670 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
671 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
672 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
675 #endif // MAINWINDOW_H