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 FacebookLoginBrowser;
45 class FriendListPanel;
46 class FullScreenButton;
48 class IndicatorButtonPanel;
50 class LocationSearchPanel;
56 class SceneCoordinate;
62 class ZoomButtonPanel;
65 * @brief Main Window Class
67 class MainWindow : public QMainWindow
75 * @param parent Parent
77 MainWindow(QWidget *parent = 0);
84 /*******************************************************************************
85 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
86 ******************************************************************************/
89 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
91 void keyPressEvent(QKeyEvent* event);
93 /*******************************************************************************
94 * MEMBER FUNCTIONS AND SLOTS
95 ******************************************************************************/
98 * @brief Clears cookie jar
101 void clearCookieJar();
108 void loggedIn(bool logged);
111 * @brief Gets the login state (logged in/logged out)
113 * @return bool Login state
118 * @brief Reads automatic location update settings.
120 void readAutomaticLocationUpdateSettings();
123 * @brief Enable / disable GPS button.
125 * Does set visibilities for manual location cursor and auto centering menu button.
127 * @param enabled true if enabled, false otherwise
129 void setGPSButtonEnabled(bool enabled);
132 * @brief Enable / disable direction indicator button.
134 * @param enabled true if shoud be enabled, false otherwise
136 void setIndicatorButtonEnabled(bool enabled);
139 * @brief Set scene for MapView
141 * @param scene Scene to be set
143 void setMapViewScene(QGraphicsScene *scene);
146 * Shows dialog with enable automatic location update question.
148 * @param text text to show in dialog
150 void showEnableAutomaticUpdateLocationDialog(const QString &text);
153 * @brief Gets the username from member variable for saving purposes
155 * @return QString Username
157 const QString username();
160 void buildFacebookLoginBrowser();
162 void destroyFacebookLoginBrowser();
165 * @brief Builds information box with message.
167 * @param message Information message
168 * @param modal Modal = true, non-modal false
170 void buildInformationBox(const QString &message, bool modal=false);
173 * @brief Slot for failed login
178 * @brief Slot to intercept signal when login with cookies is requested
180 void loginUsingCookies();
183 * @brief Public slot, which open settings dialog
185 void openSettingsDialog();
188 * @brief Set own location crosshair visibility
192 void setCrosshairVisibility(bool visible);
195 * @brief Shows contact dialog.
197 * Shows contact dialog with contact's information.
198 * @param guid globally unique ID of a contact
200 void showContactDialog(const QString &guid);
203 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
206 void startLoginProcess();
209 * @brief Toggle progress indicator.
211 * @param state true if progress indicator should be shown, false otherwise
213 void toggleProgressIndicator(bool state);
216 * @brief Shows / hides Situare related UI items
219 void updateItemVisibility();
223 * @brief Build manual location setting cross hair and connect slots
225 void buildCrosshair();
228 * @brief Build friend list panel and connect slots
230 void buildFriendListPanel();
233 * @brief Build fullscreen toggle button and connect slots
235 void buildFullScreenButton();
238 * @brief Build direction indicator button panel and connect signals
240 void buildIndicatorButtonPanel();
244 * @brief Build location search panel and connect signals
246 void buildLocationSearchPanel();
249 * @brief Build map and connect slots
254 * @brief Build map scale and connect slots
256 void buildMapScale();
259 * @brief Build OSM license and connect slots
261 void buildOsmLicense();
264 * @brief Build application panels
269 * @brief Build routing panel and connect slots
271 void buildRoutingPanel();
274 * @brief Build user info panel and connect slots
276 void buildUserInfoPanel();
279 * @brief Build webview and connect slots
284 * @brief Build zoom button panel and connect slots
286 void buildZoomButtonPanel();
289 * @brief Private method to create the Menu items
294 * @brief Grab or release HW increase and decrease buttons.
296 * @param grab Use true for grabbing and false for releasing the keys
298 void grabZoomKeys(bool grab);
301 * @brief Queues dialog/information box
303 * @param dialog Dialog to be added into queue
305 void queueDialog(QDialog *dialog);
308 * @brief Shows queued error information box
311 void showErrorInformationBox();
314 * @brief Shows queued information box
316 * @fn showInformationBox
318 void showInformationBox();
322 * @brief Slot for automatic update dialog finished.
324 * @result result code
326 void automaticUpdateDialogFinished(int result);
329 * @brief Slot to intercept signal when dialog/information note is processed
331 * @param status Status of the dialog
333 void dialogFinished(int status);
336 * @brief Slot for drawing the fullscreen toggle button
338 * @param size Size of the screen
340 void drawFullScreenButton(const QSize &size);
343 * @brief Slot for drawing the map distance scale
345 * @param size Size of the screen
347 void drawMapScale(const QSize &size);
350 * @brief Slot for drawing the Open Street Map license text
352 * @param size Size of the screen
354 void drawOsmLicense(const QSize &size);
357 * @brief Slot to intercept signal when error dialog/information note is processed
359 * @param status Status of the dialog
361 void errorDialogFinished(int status);
364 * @brief Slot for gps timeout.
366 * Called when request timeout occurs.
371 * @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 Called when map center point horizontal shifting is changed
385 * @param shifting New shifting value
387 void mapCenterHorizontalShiftingChanged(int shifting);
390 * @brief Move the crosshair
392 void moveCrosshair();
395 * @brief Slot to save cookies to settings
400 * @brief Slot for settings dialog accepted.
402 void settingsDialogAccepted();
405 * @brief Ignore SSL error from the reply
407 void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
410 * @brief Start location search (open search dialog)
412 void startLocationSearch();
415 * @brief Toggle between fullscreen and normal window mode
417 void toggleFullScreen();
420 * @brief Slot to intercept signal from webview's networkaccessmanager
422 * @param reply Network reply (contains errors)
424 void webViewRequestFinished(QNetworkReply* reply);
426 /*******************************************************************************
428 ******************************************************************************/
431 * @brief Automatic centering setting changed by user
433 * @param enabled True if automatic centering is enabled, otherwise false
435 void autoCenteringTriggered(bool enabled);
438 * @brief Signal that indicates when user has cancelled login process
441 void cancelLoginProcess();
444 * @brief Signal for centering to coordinates.
446 * @param coordinates geo coordinates to center to.
448 void centerToCoordinates(const GeoCoordinate &coordinates);
451 * @brief View should be centered to new location
453 * @param coordinate Scene coordinates of the new center point
455 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
458 * @brief Emitted when route is cleared
463 * @brief Signal when direction and distance from current map center point to current GPS
464 * location is changed
466 * @param direction Direction in degrees
467 * @param distance Distance in meters
468 * @param draw Should the indicator triangle be drawn or not
470 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
473 * @brief Signal for enabling automatic location update.
475 * @param enabled true if enabled, false otherwise
476 * @param updateIntervalMsecs update interval in milliseconds
478 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
481 * @brief Signals error
483 * @param context error context
484 * @param error error code
486 void error(const int context, const int error);
489 * @brief Signal for requesting username from settings
492 void fetchUsernameFromSettings();
495 * @brief Signals when friend's profile image is ready
499 void friendImageReady(User *user);
502 * @brief GPS setting changed
504 * @param enabled True if GPS is enabled, otherwise false
506 void gpsTriggered(bool enabled);
509 * @brief Signal for friend location ready.
513 void friendsLocationsReady(QList<User *> &friendsList);
516 * @brief Emited when location request is parsed and is ready for further processing
518 * @param result List of Location items
520 void locationDataParsed(const QList<Location> &result);
523 * @brief Signal is emitted when location item is clicked on map.
525 * @param userIDs list of friends user IDs in the group
527 void locationItemClicked(const QList<QString> &userIDs);
530 * @brief Signal is emitted when location item is clicked in list.
532 * @param swBound south-west bound in GeoCoorinate
533 * @param neBound north-east bound in GeoCoordinate
535 void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
538 * @brief Signals when Login/Logout action is pressed
541 void loginActionPressed();
543 void loginBrowserCreated(FacebookLoginBrowser *);
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 for location search
622 * @param location QString location
624 void searchForLocation(QString location);
627 * @brief Signal is emitted when search history item is clicked.
629 * @param searchString search string used
631 void searchHistoryItemClicked(const QString &searchString);
634 * @brief Signal for requestLocationUpdate from SituareEngine
636 * @param status Status message
637 * @param publish Publish on Facebook
639 void statusUpdate(const QString &status, const bool &publish);
642 * @brief Signals when webview's urlChanged signal is emitted
646 void updateCredentials(const QUrl &url);
649 * @brief Signals when updateLocationDialog's data must be cleared
652 void clearUpdateLocationDialogData();
655 * @brief Dragging mode triggered.
657 void draggingModeTriggered();
660 * @brief MapView has finished zooming
662 void viewZoomFinished();
665 * @brief Signal for use location ready.
667 * @param user User object
669 void userLocationReady(User *user);
672 * @brief Map zoom in request
677 * @brief Forwarding signal from MapEngine to MapView
679 void zoomLevelChanged(int zoomLevel);
682 * @brief Map zoom out request
686 /*******************************************************************************
688 ******************************************************************************/
690 bool m_errorShown; ///< Indicates if error dialog/note is shown
691 bool m_loggedIn; ///< Indicates login state
692 bool m_refresh; ///< Indicates when webpage is refreshed
694 int m_mapCenterHorizontalShifting; ///< Amount of map center point horizontal shifting
695 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
697 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
698 QAction *m_loginAct; ///< Action to Login/Logout
699 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
701 QLabel *m_crosshair; ///< Label for center point crosshair
702 QLabel *m_osmLicense; ///< Label for Open Street Map license
704 QList<int> m_situareTabsIndexes; ///< List of Situare tab indexes
705 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
706 QList<QDialog *> m_queue; ///< QList type dialog queue
708 QMenu *m_viewMenu; ///< Object that hold the view menu items
710 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
712 QString m_email; ///< Placeholder for email
713 QString m_password; ///< Placeholder for password
715 QWebView *m_webView; ///< Shows facebook login page
717 FacebookLoginBrowser *m_facebookLoginBrowser;
718 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
719 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
720 IndicatorButtonPanel *m_indicatorButtonPanel; ///< Instance of direction indicator button
721 LocationSearchPanel *m_locationSearchPanel; ///< Location search panel
722 MapScale *m_mapScale; ///< Instance of the map scale
723 MapView *m_mapView; ///< Instance of the map view
724 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
725 RoutingPanel *m_routingPanel; ///< Instance of routing panel
726 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
727 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
728 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
731 #endif // MAINWINDOW_H