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 Jussi Laitinen - jussi.laitinen@ixonos.com
8 Sami Rämö - sami.ramo@ixonos.com
9 Ville Tiensuu - ville.tiensuu@ixonos.com
10 Katri Kaikkonen - katri.kaikkonen@ixonos.com
12 Situare is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License
14 version 2 as published by the Free Software Foundation.
16 Situare is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with Situare; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
30 #include <QtGui/QMainWindow>
34 #include "network/networkcookiejar.h"
43 class FacebookAuthentication;
44 class FriendListPanel;
45 class FullScreenButton;
47 class IndicatorButtonPanel;
49 class LocationSearchPanel;
55 class SceneCoordinate;
61 class ZoomButtonPanel;
64 * @brief Main Window Class
66 class MainWindow : public QMainWindow
74 * @param parent Parent
76 MainWindow(QWidget *parent = 0);
83 /*******************************************************************************
84 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
85 ******************************************************************************/
88 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
90 void keyPressEvent(QKeyEvent* event);
92 /*******************************************************************************
93 * MEMBER FUNCTIONS AND SLOTS
94 ******************************************************************************/
97 * @brief Clears cookie jar
100 void clearCookieJar();
107 void loggedIn(bool logged);
110 * @brief Gets the login state (logged in/logged out)
112 * @return bool Login state
117 * @brief Reads automatic location update settings.
119 void readAutomaticLocationUpdateSettings();
122 * @brief Enable / disable GPS button.
124 * Does set visibilities for manual location cursor and auto centering menu button.
126 * @param enabled true if enabled, false otherwise
128 void setGPSButtonEnabled(bool enabled);
131 * @brief Enable / disable direction indicator button.
133 * @param enabled true if shoud be enabled, false otherwise
135 void setIndicatorButtonEnabled(bool enabled);
138 * @brief Set scene for MapView
140 * @param scene Scene to be set
142 void setMapViewScene(QGraphicsScene *scene);
145 * Shows dialog with enable automatic location update question.
147 * @param text text to show in dialog
149 void showEnableAutomaticUpdateLocationDialog(const QString &text);
152 * @brief Gets the username from member variable for saving purposes
154 * @return QString Username
156 const QString username();
160 * @brief Builds information box with message.
162 * @param message Information message
163 * @param modal Modal = true, non-modal false
165 void buildInformationBox(const QString &message, bool modal=false);
168 * @brief Slot for failed login
173 * @brief Slot to intercept signal when login with cookies is requested
175 void loginUsingCookies();
178 * @brief Public slot, which open settings dialog
180 void openSettingsDialog();
183 * @brief Set own location crosshair visibility
187 void setCrosshairVisibility(bool visible);
190 * @brief Sets username to member variable for login dialog
192 * @param username Username to be set
194 void setUsername(const QString &username);
197 * @brief Shows contact dialog.
199 * Shows contact dialog with contact's information.
200 * @param guid globally unique ID of a contact
202 void showContactDialog(const QString &guid);
205 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
208 void startLoginProcess();
211 * @brief Toggle progress indicator.
213 * @param state true if progress indicator should be shown, false otherwise
215 void toggleProgressIndicator(bool state);
218 * @brief Shows / hides Situare related UI items
221 void updateItemVisibility();
225 * @brief Build manual location setting cross hair and connect slots
227 void buildCrosshair();
230 * @brief Build friend list panel and connect slots
232 void buildFriendListPanel();
235 * @brief Build fullscreen toggle button and connect slots
237 void buildFullScreenButton();
240 * @brief Build direction indicator button panel and connect signals
242 void buildIndicatorButtonPanel();
246 * @brief Build location search panel and connect signals
248 void buildLocationSearchPanel();
251 * @brief Build map and connect slots
256 * @brief Build map scale and connect slots
258 void buildMapScale();
261 * @brief Build OSM license and connect slots
263 void buildOsmLicense();
266 * @brief Build application panels
271 * @brief Build routing panel and connect slots
273 void buildRoutingPanel();
276 * @brief Build user info panel and connect slots
278 void buildUserInfoPanel();
281 * @brief Build webview and connect slots
286 * @brief Build zoom button panel and connect slots
288 void buildZoomButtonPanel();
291 * @brief Private method to create the Menu items
296 * @brief Grab or release HW increase and decrease buttons.
298 * @param grab Use true for grabbing and false for releasing the keys
300 void grabZoomKeys(bool grab);
303 * @brief Queues dialog/information box
305 * @param dialog Dialog to be added into queue
307 void queueDialog(QDialog *dialog);
310 * @brief Shows queued error information box
313 void showErrorInformationBox();
316 * @brief Shows queued information box
318 * @fn showInformationBox
320 void showInformationBox();
324 * @brief Slot for automatic update dialog finished.
326 * @result result code
328 void automaticUpdateDialogFinished(int result);
331 * @brief Slot to intercept signal when dialog/information note is processed
333 * @param status Status of the dialog
335 void dialogFinished(int status);
338 * @brief Slot for drawing the fullscreen toggle button
340 * @param size Size of the screen
342 void drawFullScreenButton(const QSize &size);
345 * @brief Slot for drawing the map distance scale
347 * @param size Size of the screen
349 void drawMapScale(const QSize &size);
352 * @brief Slot for drawing the Open Street Map license text
354 * @param size Size of the screen
356 void drawOsmLicense(const QSize &size);
359 * @brief Slot to intercept signal when error dialog/information note is processed
361 * @param status Status of the dialog
363 void errorDialogFinished(int status);
366 * @brief Slot for gps timeout.
368 * Called when request timeout occurs.
373 * @brief Slot to load cookies from settings
378 * @brief Slot to intercept signal when webview has finished loading webpage
380 * @param done Status of the loading
382 void loadDone(bool done);
385 * @brief Called when map center point horizontal shifting is changed
387 * @param shifting New shifting value
389 void mapCenterHorizontalShiftingChanged(int shifting);
392 * @brief Move the crosshair
394 void moveCrosshair();
397 * @brief Slot to save cookies to settings
402 * @brief Slot for settings dialog accepted.
404 void settingsDialogAccepted();
407 * @brief Ignore SSL error from the reply
409 void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
412 * @brief Start location search (open search dialog)
414 void startLocationSearch();
417 * @brief Toggle between fullscreen and normal window mode
419 void toggleFullScreen();
422 * @brief Slot to intercept signal from webview's networkaccessmanager
424 * @param reply Network reply (contains errors)
426 void webViewRequestFinished(QNetworkReply* reply);
428 /*******************************************************************************
430 ******************************************************************************/
433 * @brief Automatic centering setting changed by user
435 * @param enabled True if automatic centering is enabled, otherwise false
437 void autoCenteringTriggered(bool enabled);
440 * @brief Signal that indicates when user has cancelled login process
443 void cancelLoginProcess();
446 * @brief Signal for centering to coordinates.
448 * @param coordinates geo coordinates to center to.
450 void centerToCoordinates(const GeoCoordinate &coordinates);
453 * @brief View should be centered to new location
455 * @param coordinate Scene coordinates of the new center point
457 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
460 * @brief Emitted when route is cleared
465 * @brief Signal when direction and distance from current map center point to current GPS
466 * location is changed
468 * @param direction Direction in degrees
469 * @param distance Distance in meters
470 * @param draw Should the indicator triangle be drawn or not
472 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
475 * @brief Signal for enabling automatic location update.
477 * @param enabled true if enabled, false otherwise
478 * @param updateIntervalMsecs update interval in milliseconds
480 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
483 * @brief Signals error
485 * @param context error context
486 * @param error error code
488 void error(const int context, const int error);
491 * @brief Signal for requesting username from settings
494 void fetchUsernameFromSettings();
497 * @brief Signals when friend's profile image is ready
501 void friendImageReady(User *user);
504 * @brief GPS setting changed
506 * @param enabled True if GPS is enabled, otherwise false
508 void gpsTriggered(bool enabled);
511 * @brief Signal for friend location ready.
515 void friendsLocationsReady(QList<User *> &friendsList);
518 * @brief Emited when location request is parsed and is ready for further processing
520 * @param result List of Location items
522 void locationDataParsed(const QList<Location> &result);
525 * @brief Signal is emitted when location item is clicked on map.
527 * @param userIDs list of friends user IDs in the group
529 void locationItemClicked(const QList<QString> &userIDs);
532 * @brief Signal is emitted when location item is clicked in list.
534 * @param swBound south-west bound in GeoCoorinate
535 * @param neBound north-east bound in GeoCoordinate
537 void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
540 * @brief Signals when Login/Logout action is pressed
543 void loginActionPressed();
546 * @brief MapView has been resized
548 * @param size view size
550 void mapViewResized(const QSize &size);
553 * @brief Forwarding signal from MapView to MapEngine
555 * @param coordinate New center point coordinate
557 void mapViewScrolled(const SceneCoordinate &coordinate);
560 * @brief Forwarding signal from MapEngine to MapView
562 void maxZoomLevelReached();
565 * @brief Forwarding signal from MapEngine to MapView
567 void minZoomLevelReached();
570 * @brief Forwarding signal from MapEngine to MapScale
572 void newMapResolution(qreal scale);
575 * @brief Signal for refreshing user data.
578 void refreshUserData();
581 * @brief Requests contact dialog.
583 * @param facebookId contact's facebookId
585 void requestContactDialog(const QString &facebookId);
588 * @brief Signal for requesting reverseGeo from SituareEngine
591 void requestReverseGeo();
594 * @brief Signals, when address data is ready
596 * @param address Street address
598 void reverseGeoReady(const QString &address);
601 * @brief Emited when route is parsed and is ready for further processing
603 * @param route Route item containing parsed route details
605 void routeParsed(Route &route);
608 * @brief Signal for routing to geo coordinates.
610 * @param coordinates destination geo coordinates
612 void routeTo(const GeoCoordinate &coordinates);
615 * @brief Request routing to current cursor position
617 void routeToCursor();
620 * @brief Signal to save username to settings
622 * @param username Username
624 void saveUsername(const QString &username);
627 * @brief Signal for location search
629 * @param location QString location
631 void searchForLocation(QString location);
634 * @brief Signal is emitted when search history item is clicked.
636 * @param searchString search string used
638 void searchHistoryItemClicked(const QString &searchString);
641 * @brief Signal for requestLocationUpdate from SituareEngine
643 * @param status Status message
644 * @param publish Publish on Facebook
646 void statusUpdate(const QString &status, const bool &publish);
649 * @brief Signals when webview's urlChanged signal is emitted
653 void updateCredentials(const QUrl &url);
656 * @brief Signals when updateLocationDialog's data must be cleared
659 void clearUpdateLocationDialogData();
662 * @brief Dragging mode triggered.
664 void draggingModeTriggered();
667 * @brief MapView has finished zooming
669 void viewZoomFinished();
672 * @brief Signal for use location ready.
674 * @param user User object
676 void userLocationReady(User *user);
679 * @brief Map zoom in request
684 * @brief Forwarding signal from MapEngine to MapView
686 void zoomLevelChanged(int zoomLevel);
689 * @brief Map zoom out request
693 /*******************************************************************************
695 ******************************************************************************/
697 bool m_errorShown; ///< Indicates if error dialog/note is shown
698 bool m_loggedIn; ///< Indicates login state
699 bool m_refresh; ///< Indicates when webpage is refreshed
701 int m_mapCenterHorizontalShifting; ///< Amount of map center point horizontal shifting
702 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
704 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
705 QAction *m_loginAct; ///< Action to Login/Logout
706 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
708 QLabel *m_crosshair; ///< Label for center point crosshair
709 QLabel *m_osmLicense; ///< Label for Open Street Map license
711 QList<int> m_situareTabsIndexes; ///< List of Situare tab indexes
712 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
713 QList<QDialog *> m_queue; ///< QList type dialog queue
715 QMenu *m_viewMenu; ///< Object that hold the view menu items
717 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
719 QString m_email; ///< Placeholder for email
720 QString m_password; ///< Placeholder for password
722 QWebView *m_webView; ///< Shows facebook login page
724 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
725 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
726 IndicatorButtonPanel *m_indicatorButtonPanel; ///< Instance of direction indicator button
727 LocationSearchPanel *m_locationSearchPanel; ///< Location search panel
728 MapScale *m_mapScale; ///< Instance of the map scale
729 MapView *m_mapView; ///< Instance of the map view
730 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
731 RoutingPanel *m_routingPanel; ///< Instance of routing panel
732 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
733 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
734 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
737 #endif // MAINWINDOW_H