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 ******************************************************************************/
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 GPS button.
119 * Does set visibilities for manual location cursor and auto centering menu button.
121 * @param enabled true if enabled, false otherwise
123 void setGPSButtonEnabled(bool enabled);
126 * @brief Enable / disable direction indicator button.
128 * @param enabled true if shoud be enabled, false otherwise
130 void setIndicatorButtonEnabled(bool enabled);
133 * @brief Set scene for MapView
135 * @param scene Scene to be set
137 void setMapViewScene(QGraphicsScene *scene);
140 * Shows dialog with enable automatic location update question.
142 * @param text text to show in dialog
144 void showEnableAutomaticUpdateLocationDialog(const QString &text);
147 * @brief Gets the username from member variable for saving purposes
149 * @return QString Username
151 const QString username();
154 void buildFacebookLoginBrowser();
156 void destroyFacebookLoginBrowser();
159 * @brief Builds information box with message.
161 * @param message Information message
162 * @param modal Modal = true, non-modal false
164 void buildInformationBox(const QString &message, bool modal=false);
167 * @brief Slot for failed login
172 * @brief Public slot, which open settings dialog
174 void openSettingsDialog();
177 * @brief Set own location crosshair visibility
181 void setCrosshairVisibility(bool visible);
184 * @brief Shows contact dialog.
186 * Shows contact dialog with contact's information.
187 * @param guid globally unique ID of a contact
189 void showContactDialog(const QString &guid);
192 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
195 void startLoginProcess();
198 * @brief Toggle progress indicator.
200 * @param state true if progress indicator should be shown, false otherwise
202 void toggleProgressIndicator(bool state);
205 * @brief Shows / hides Situare related UI items
208 void updateItemVisibility();
212 * @brief Build manual location setting cross hair and connect slots
214 void buildCrosshair();
217 * @brief Build friend list panel and connect slots
219 void buildFriendListPanel();
222 * @brief Build fullscreen toggle button and connect slots
224 void buildFullScreenButton();
227 * @brief Build direction indicator button panel and connect signals
229 void buildIndicatorButtonPanel();
233 * @brief Build location search panel and connect signals
235 void buildLocationSearchPanel();
238 * @brief Build map and connect slots
243 * @brief Build map scale and connect slots
245 void buildMapScale();
248 * @brief Build OSM license and connect slots
250 void buildOsmLicense();
253 * @brief Build application panels
258 * @brief Build routing panel and connect slots
260 void buildRoutingPanel();
263 * @brief Build user info panel and connect slots
265 void buildUserInfoPanel();
268 * @brief Build zoom button panel and connect slots
270 void buildZoomButtonPanel();
273 * @brief Private method to create the Menu items
278 * @brief Grab or release HW increase and decrease buttons.
280 * @param grab Use true for grabbing and false for releasing the keys
282 void grabZoomKeys(bool grab);
285 * @brief Queues dialog/information box
287 * @param dialog Dialog to be added into queue
289 void queueDialog(QDialog *dialog);
292 * @brief Shows queued error information box
295 void showErrorInformationBox();
298 * @brief Shows queued information box
300 * @fn showInformationBox
302 void showInformationBox();
306 * @brief Slot for automatic update dialog finished.
308 * @result result code
310 void automaticUpdateDialogFinished(int result);
313 * @brief Slot to intercept signal when dialog/information note is processed
315 * @param status Status of the dialog
317 void dialogFinished(int status);
320 * @brief Slot for drawing the fullscreen toggle button
322 * @param size Size of the screen
324 void drawFullScreenButton(const QSize &size);
327 * @brief Slot for drawing the map distance scale
329 * @param size Size of the screen
331 void drawMapScale(const QSize &size);
334 * @brief Slot for drawing the Open Street Map license text
336 * @param size Size of the screen
338 void drawOsmLicense(const QSize &size);
341 * @brief Slot to intercept signal when error dialog/information note is processed
343 * @param status Status of the dialog
345 void errorDialogFinished(int status);
348 * @brief Slot for gps timeout.
350 * Called when request timeout occurs.
355 * @brief Called when map center point horizontal shifting is changed
357 * @param shifting New shifting value
359 void mapCenterHorizontalShiftingChanged(int shifting);
362 * @brief Move the crosshair
364 void moveCrosshair();
367 * @brief Slot for settings dialog accepted.
369 void settingsDialogAccepted();
372 * @brief Ignore SSL error from the reply
374 void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
377 * @brief Start location search (open search dialog)
379 void startLocationSearch();
382 * @brief Toggle between fullscreen and normal window mode
384 void toggleFullScreen();
386 /*******************************************************************************
388 ******************************************************************************/
391 * @brief Automatic centering setting changed by user
393 * @param enabled True if automatic centering is enabled, otherwise false
395 void autoCenteringTriggered(bool enabled);
398 * @brief Signal that indicates when user has cancelled login process
401 void cancelLoginProcess();
404 * @brief Signal for centering to coordinates.
406 * @param coordinates geo coordinates to center to.
408 void centerToCoordinates(const GeoCoordinate &coordinates);
411 * @brief View should be centered to new location
413 * @param coordinate Scene coordinates of the new center point
415 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
418 * @brief Emitted when route is cleared
423 * @brief Signal when direction and distance from current map center point to current GPS
424 * location is changed
426 * @param direction Direction in degrees
427 * @param distance Distance in meters
428 * @param draw Should the indicator triangle be drawn or not
430 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
433 * @brief Signal for enabling automatic location update.
435 * @param enabled true if enabled, false otherwise
436 * @param updateIntervalMsecs update interval in milliseconds
438 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
441 * @brief Signals error
443 * @param context error context
444 * @param error error code
446 void error(const int context, const int error);
449 * @brief Signal for requesting username from settings
452 void fetchUsernameFromSettings();
455 * @brief Signals when friend's profile image is ready
459 void friendImageReady(User *user);
462 * @brief GPS setting changed
464 * @param enabled True if GPS is enabled, otherwise false
466 void gpsTriggered(bool enabled);
469 * @brief Signal for friend location ready.
473 void friendsLocationsReady(QList<User *> &friendsList);
476 * @brief Emited when location request is parsed and is ready for further processing
478 * @param result List of Location items
480 void locationDataParsed(const QList<Location> &result);
483 * @brief Signal is emitted when location item is clicked on map.
485 * @param userIDs list of friends user IDs in the group
487 void locationItemClicked(const QList<QString> &userIDs);
490 * @brief Signal is emitted when location item is clicked in list.
492 * @param swBound south-west bound in GeoCoorinate
493 * @param neBound north-east bound in GeoCoordinate
495 void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
498 * @brief Signals when Login/Logout action is pressed
501 void loginActionPressed();
503 void loginBrowserCreated(FacebookLoginBrowser *);
506 * @brief MapView has been resized
508 * @param size view size
510 void mapViewResized(const QSize &size);
513 * @brief Forwarding signal from MapView to MapEngine
515 * @param coordinate New center point coordinate
517 void mapViewScrolled(const SceneCoordinate &coordinate);
520 * @brief Forwarding signal from MapEngine to MapView
522 void maxZoomLevelReached();
525 * @brief Forwarding signal from MapEngine to MapView
527 void minZoomLevelReached();
530 * @brief Forwarding signal from MapEngine to MapScale
532 void newMapResolution(qreal scale);
535 * @brief Signal for refreshing user data.
538 void refreshUserData();
541 * @brief Requests contact dialog.
543 * @param facebookId contact's facebookId
545 void requestContactDialog(const QString &facebookId);
548 * @brief Signal for requesting reverseGeo from SituareEngine
551 void requestReverseGeo();
554 * @brief Signals, when address data is ready
556 * @param address Street address
558 void reverseGeoReady(const QString &address);
561 * @brief Emited when route is parsed and is ready for further processing
563 * @param route Route item containing parsed route details
565 void routeParsed(Route &route);
568 * @brief Signal for routing to geo coordinates.
570 * @param coordinates destination geo coordinates
572 void routeTo(const GeoCoordinate &coordinates);
575 * @brief Request routing to current cursor position
577 void routeToCursor();
580 * @brief Signal for location search
582 * @param location QString location
584 void searchForLocation(QString location);
587 * @brief Signal is emitted when search history item is clicked.
589 * @param searchString search string used
591 void searchHistoryItemClicked(const QString &searchString);
594 * @brief Signal for requestLocationUpdate from SituareEngine
596 * @param status Status message
597 * @param publish Publish on Facebook
599 void statusUpdate(const QString &status, const bool &publish);
602 * @brief Signals when updateLocationDialog's data must be cleared
605 void clearUpdateLocationDialogData();
608 * @brief Dragging mode triggered.
610 void draggingModeTriggered();
613 * @brief MapView has finished zooming
615 void viewZoomFinished();
618 * @brief Signal for use location ready.
620 * @param user User object
622 void userLocationReady(User *user);
625 * @brief Map zoom in request
630 * @brief Forwarding signal from MapEngine to MapView
632 void zoomLevelChanged(int zoomLevel);
635 * @brief Map zoom out request
639 /*******************************************************************************
641 ******************************************************************************/
643 bool m_errorShown; ///< Indicates if error dialog/note is shown
644 bool m_loggedIn; ///< Indicates login state
645 bool m_refresh; ///< Indicates when webpage is refreshed
647 int m_mapCenterHorizontalShifting; ///< Amount of map center point horizontal shifting
648 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
650 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
651 QAction *m_loginAct; ///< Action to Login/Logout
652 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
654 QLabel *m_crosshair; ///< Label for center point crosshair
655 QLabel *m_osmLicense; ///< Label for Open Street Map license
657 QList<int> m_situareTabsIndexes; ///< List of Situare tab indexes
658 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
659 QList<QDialog *> m_queue; ///< QList type dialog queue
661 QMenu *m_viewMenu; ///< Object that hold the view menu items
663 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
665 QString m_email; ///< Placeholder for email
666 QString m_password; ///< Placeholder for password
668 FacebookLoginBrowser *m_facebookLoginBrowser;
669 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
670 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
671 IndicatorButtonPanel *m_indicatorButtonPanel; ///< Instance of direction indicator button
672 LocationSearchPanel *m_locationSearchPanel; ///< Location search panel
673 MapScale *m_mapScale; ///< Instance of the map scale
674 MapView *m_mapView; ///< Instance of the map view
675 RoutingPanel *m_routingPanel; ///< Instance of routing panel
676 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
677 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
678 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
681 #endif // MAINWINDOW_H