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>
33 #include "network/networkcookiejar.h"
42 class FacebookAuthentication;
43 class FacebookLoginBrowser;
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 ******************************************************************************/
96 FacebookLoginBrowser* buildFacebookLoginBrowser();
99 * @brief Clears cookie jar
102 void clearCookieJar();
104 void destroyFacebookLoginBrowser();
111 void loggedIn(bool logged);
114 * @brief Gets the login state (logged in/logged out)
116 * @return bool Login state
121 * @brief Reads automatic location update settings.
123 void readAutomaticLocationUpdateSettings();
126 * @brief Enable / disable GPS button.
128 * Does set visibilities for manual location cursor and auto centering menu button.
130 * @param enabled true if enabled, false otherwise
132 void setGPSButtonEnabled(bool enabled);
135 * @brief Enable / disable direction indicator button.
137 * @param enabled true if shoud be enabled, false otherwise
139 void setIndicatorButtonEnabled(bool enabled);
142 * @brief Set scene for MapView
144 * @param scene Scene to be set
146 void setMapViewScene(QGraphicsScene *scene);
149 * Shows dialog with enable automatic location update question.
151 * @param text text to show in dialog
153 void showEnableAutomaticUpdateLocationDialog(const QString &text);
156 * @brief Gets the username from member variable for saving purposes
158 * @return QString Username
160 const QString username();
164 * @brief Builds information box with message.
166 * @param message Information message
167 * @param modal Modal = true, non-modal false
169 void buildInformationBox(const QString &message, bool modal=false);
172 * @brief Slot for failed login
177 * @brief Slot to intercept signal when login with cookies is requested
179 void loginUsingCookies();
182 * @brief Public slot, which open settings dialog
184 void openSettingsDialog();
187 * @brief Set own location crosshair visibility
191 void setCrosshairVisibility(bool visible);
194 * @brief Shows contact dialog.
196 * Shows contact dialog with contact's information.
197 * @param guid globally unique ID of a contact
199 void showContactDialog(const QString &guid);
202 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
205 void startLoginProcess();
208 * @brief Toggle progress indicator.
210 * @param state true if progress indicator should be shown, false otherwise
212 void toggleProgressIndicator(bool state);
215 * @brief Shows / hides Situare related UI items
218 void updateItemVisibility();
222 * @brief Build manual location setting cross hair and connect slots
224 void buildCrosshair();
227 * @brief Build friend list panel and connect slots
229 void buildFriendListPanel();
232 * @brief Build fullscreen toggle button and connect slots
234 void buildFullScreenButton();
237 * @brief Build direction indicator button panel and connect signals
239 void buildIndicatorButtonPanel();
243 * @brief Build location search panel and connect signals
245 void buildLocationSearchPanel();
248 * @brief Build map and connect slots
253 * @brief Build map scale and connect slots
255 void buildMapScale();
258 * @brief Build OSM license and connect slots
260 void buildOsmLicense();
263 * @brief Build application panels
268 * @brief Build routing panel and connect slots
270 void buildRoutingPanel();
273 * @brief Build user info panel and connect slots
275 void buildUserInfoPanel();
278 * @brief Build webview and connect slots
283 * @brief Build zoom button panel and connect slots
285 void buildZoomButtonPanel();
288 * @brief Private method to create the Menu items
293 * @brief Grab or release HW increase and decrease buttons.
295 * @param grab Use true for grabbing and false for releasing the keys
297 void grabZoomKeys(bool grab);
300 * @brief Queues dialog/information box
302 * @param dialog Dialog to be added into queue
304 void queueDialog(QDialog *dialog);
307 * @brief Shows queued error information box
310 void showErrorInformationBox();
313 * @brief Shows queued information box
315 * @fn showInformationBox
317 void showInformationBox();
321 * @brief Slot for automatic update dialog finished.
323 * @result result code
325 void automaticUpdateDialogFinished(int result);
328 * @brief Slot to intercept signal when dialog/information note is processed
330 * @param status Status of the dialog
332 void dialogFinished(int status);
335 * @brief Slot for drawing the fullscreen toggle button
337 * @param size Size of the screen
339 void drawFullScreenButton(const QSize &size);
342 * @brief Slot for drawing the map distance scale
344 * @param size Size of the screen
346 void drawMapScale(const QSize &size);
349 * @brief Slot for drawing the Open Street Map license text
351 * @param size Size of the screen
353 void drawOsmLicense(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
375 * @brief Slot to intercept signal when webview has finished loading webpage
377 * @param done Status of the loading
379 void loadDone(bool done);
382 * @brief Called when map center point horizontal shifting is changed
384 * @param shifting New shifting value
386 void mapCenterHorizontalShiftingChanged(int shifting);
389 * @brief Move the crosshair
391 void moveCrosshair();
394 * @brief Slot to save cookies to settings
399 * @brief Slot for settings dialog accepted.
401 void settingsDialogAccepted();
404 * @brief Start location search (open search dialog)
406 void startLocationSearch();
409 * @brief Toggle between fullscreen and normal window mode
411 void toggleFullScreen();
414 * @brief Slot to intercept signal from webview's networkaccessmanager
416 * @param reply Network reply (contains errors)
418 void webViewRequestFinished(QNetworkReply* reply);
420 /*******************************************************************************
422 ******************************************************************************/
425 * @brief Automatic centering setting changed by user
427 * @param enabled True if automatic centering is enabled, otherwise false
429 void autoCenteringTriggered(bool enabled);
432 * @brief Signal that indicates when user has cancelled login process
435 void cancelLoginProcess();
438 * @brief Signal for centering to coordinates.
440 * @param coordinates geo coordinates to center to.
442 void centerToCoordinates(const GeoCoordinate &coordinates);
445 * @brief View should be centered to new location
447 * @param coordinate Scene coordinates of the new center point
449 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
452 * @brief Emitted when route is cleared
457 * @brief Signal when direction and distance from current map center point to current GPS
458 * location is changed
460 * @param direction Direction in degrees
461 * @param distance Distance in meters
462 * @param draw Should the indicator triangle be drawn or not
464 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
467 * @brief Signal for enabling automatic location update.
469 * @param enabled true if enabled, false otherwise
470 * @param updateIntervalMsecs update interval in milliseconds
472 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
475 * @brief Signals error
477 * @param context error context
478 * @param error error code
480 void error(const int context, const int error);
483 * @brief Signal for requesting username from settings
486 void fetchUsernameFromSettings();
489 * @brief Signals when friend's profile image is ready
493 void friendImageReady(User *user);
496 * @brief GPS setting changed
498 * @param enabled True if GPS is enabled, otherwise false
500 void gpsTriggered(bool enabled);
503 * @brief Signal for friend location ready.
507 void friendsLocationsReady(QList<User *> &friendsList);
510 * @brief Emited when location request is parsed and is ready for further processing
512 * @param result List of Location items
514 void locationDataParsed(const QList<Location> &result);
517 * @brief Signal is emitted when location item is clicked on map.
519 * @param userIDs list of friends user IDs in the group
521 void locationItemClicked(const QList<QString> &userIDs);
524 * @brief Signal is emitted when location item is clicked in list.
526 * @param swBound south-west bound in GeoCoorinate
527 * @param neBound north-east bound in GeoCoordinate
529 void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
532 * @brief Signals when Login/Logout action is pressed
535 void loginActionPressed();
538 * @brief MapView has been resized
540 * @param size view size
542 void mapViewResized(const QSize &size);
545 * @brief Forwarding signal from MapView to MapEngine
547 * @param coordinate New center point coordinate
549 void mapViewScrolled(const SceneCoordinate &coordinate);
552 * @brief Forwarding signal from MapEngine to MapView
554 void maxZoomLevelReached();
557 * @brief Forwarding signal from MapEngine to MapView
559 void minZoomLevelReached();
562 * @brief Forwarding signal from MapEngine to MapScale
564 void newMapResolution(qreal scale);
567 * @brief Signal for refreshing user data.
570 void refreshUserData();
573 * @brief Requests contact dialog.
575 * @param facebookId contact's facebookId
577 void requestContactDialog(const QString &facebookId);
580 * @brief Signal for requesting reverseGeo from SituareEngine
583 void requestReverseGeo();
586 * @brief Signals, when address data is ready
588 * @param address Street address
590 void reverseGeoReady(const QString &address);
593 * @brief Emited when route is parsed and is ready for further processing
595 * @param route Route item containing parsed route details
597 void routeParsed(Route &route);
600 * @brief Signal for routing to geo coordinates.
602 * @param coordinates destination geo coordinates
604 void routeTo(const GeoCoordinate &coordinates);
607 * @brief Request routing to current cursor position
609 void routeToCursor();
612 * @brief Signal to save username to settings
614 * @param username Username
616 void saveUsername(const QString &username);
619 * @brief Signal for location search
621 * @param location QString location
623 void searchForLocation(QString location);
626 * @brief Signal is emitted when search history item is clicked.
628 * @param searchString search string used
630 void searchHistoryItemClicked(const QString &searchString);
633 * @brief Signal for requestLocationUpdate from SituareEngine
635 * @param status Status message
636 * @param publish Publish on Facebook
638 void statusUpdate(const QString &status, const bool &publish);
641 * @brief Signals when webview's urlChanged signal is emitted
645 void updateCredentials(const QUrl &url);
648 * @brief Signals when updateLocationDialog's data must be cleared
651 void clearUpdateLocationDialogData();
654 * @brief Dragging mode triggered.
656 void draggingModeTriggered();
659 * @brief MapView has finished zooming
661 void viewZoomFinished();
664 * @brief Signal for use location ready.
666 * @param user User object
668 void userLocationReady(User *user);
671 * @brief Map zoom in request
676 * @brief Forwarding signal from MapEngine to MapView
678 void zoomLevelChanged(int zoomLevel);
681 * @brief Map zoom out request
685 /*******************************************************************************
687 ******************************************************************************/
689 bool m_errorShown; ///< Indicates if error dialog/note is shown
690 bool m_loggedIn; ///< Indicates login state
691 bool m_refresh; ///< Indicates when webpage is refreshed
693 int m_mapCenterHorizontalShifting; ///< Amount of map center point horizontal shifting
694 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
696 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
697 QAction *m_loginAct; ///< Action to Login/Logout
698 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
700 QLabel *m_crosshair; ///< Label for center point crosshair
701 QLabel *m_osmLicense; ///< Label for Open Street Map license
703 QList<int> m_situareTabsIndexes; ///< List of Situare tab indexes
704 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
705 QList<QDialog *> m_queue; ///< QList type dialog queue
707 QMenu *m_viewMenu; ///< Object that hold the view menu items
709 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
711 QString m_email; ///< Placeholder for email
712 QString m_password; ///< Placeholder for password
714 QWebView *m_webView; ///< Shows facebook login page
716 FacebookLoginBrowser *m_facebookLoginBrowser;
717 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
718 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
719 IndicatorButtonPanel *m_indicatorButtonPanel; ///< Instance of direction indicator button
720 LocationSearchPanel *m_locationSearchPanel; ///< Location search panel
721 MapScale *m_mapScale; ///< Instance of the map scale
722 MapView *m_mapView; ///< Instance of the map view
723 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
724 RoutingPanel *m_routingPanel; ///< Instance of routing panel
725 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
726 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
727 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
730 #endif // MAINWINDOW_H