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"
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 void buildLoginDialog(QWebView *browser);
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 GPS button.
120 * Does set visibilities for manual location cursor and auto centering menu button.
122 * @param enabled true if enabled, false otherwise
124 void setGPSButtonEnabled(bool enabled);
127 * @brief Enable / disable direction indicator button.
129 * @param enabled true if shoud be enabled, false otherwise
131 void setIndicatorButtonEnabled(bool enabled);
134 * @brief Set scene for MapView
136 * @param scene Scene to be set
138 void setMapViewScene(QGraphicsScene *scene);
141 * Shows dialog with enable automatic location update question.
143 * @param text text to show in dialog
145 void showEnableAutomaticUpdateLocationDialog(const QString &text);
148 * @brief Gets the username from member variable for saving purposes
150 * @return QString Username
152 const QString username();
156 * @brief Builds information box with message.
158 * @param message Information message
159 * @param modal Modal = true, non-modal false
161 void buildInformationBox(const QString &message, bool modal=false);
163 void destroyLoginDialog();
166 * @brief Slot for failed login
171 * @brief Public slot, which open settings dialog
173 void openSettingsDialog();
176 * @brief Set own location crosshair visibility
180 void setCrosshairVisibility(bool visible);
183 * @brief Shows contact dialog.
185 * Shows contact dialog with contact's information.
186 * @param guid globally unique ID of a contact
188 void showContactDialog(const QString &guid);
191 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
194 void startLoginProcess();
197 * @brief Toggle progress indicator.
199 * @param state true if progress indicator should be shown, false otherwise
201 void toggleProgressIndicator(bool state);
204 * @brief Shows / hides Situare related UI items
207 void updateItemVisibility();
211 * @brief Build manual location setting cross hair and connect slots
213 void buildCrosshair();
216 * @brief Build friend list panel and connect slots
218 void buildFriendListPanel();
221 * @brief Build fullscreen toggle button and connect slots
223 void buildFullScreenButton();
226 * @brief Build direction indicator button panel and connect signals
228 void buildIndicatorButtonPanel();
232 * @brief Build location search panel and connect signals
234 void buildLocationSearchPanel();
237 * @brief Build map and connect slots
242 * @brief Build map scale and connect slots
244 void buildMapScale();
247 * @brief Build OSM license and connect slots
249 void buildOsmLicense();
252 * @brief Build application panels
257 * @brief Build routing panel and connect slots
259 void buildRoutingPanel();
262 * @brief Build user info panel and connect slots
264 void buildUserInfoPanel();
267 * @brief Build zoom button panel and connect slots
269 void buildZoomButtonPanel();
272 * @brief Private method to create the Menu items
277 * @brief Grab or release HW increase and decrease buttons.
279 * @param grab Use true for grabbing and false for releasing the keys
281 void grabZoomKeys(bool grab);
284 * @brief Queues dialog/information box
286 * @param dialog Dialog to be added into queue
288 void queueDialog(QDialog *dialog);
291 * @brief Shows queued error information box
294 void showErrorInformationBox();
297 * @brief Shows queued information box
299 * @fn showInformationBox
301 void showInformationBox();
305 * @brief Slot for automatic update dialog finished.
307 * @result result code
309 void automaticUpdateDialogFinished(int result);
312 * @brief Slot to intercept signal when dialog/information note is processed
314 * @param status Status of the dialog
316 void dialogFinished(int status);
319 * @brief Slot for drawing the fullscreen toggle button
321 * @param size Size of the screen
323 void drawFullScreenButton(const QSize &size);
326 * @brief Slot for drawing the map distance scale
328 * @param size Size of the screen
330 void drawMapScale(const QSize &size);
333 * @brief Slot for drawing the Open Street Map license text
335 * @param size Size of the screen
337 void drawOsmLicense(const QSize &size);
340 * @brief Slot to intercept signal when error dialog/information note is processed
342 * @param status Status of the dialog
344 void errorDialogFinished(int status);
347 * @brief Slot for gps timeout.
349 * Called when request timeout occurs.
354 * @brief Called when map center point horizontal shifting is changed
356 * @param shifting New shifting value
358 void mapCenterHorizontalShiftingChanged(int shifting);
361 * @brief Move the crosshair
363 void moveCrosshair();
366 * @brief Slot for settings dialog accepted.
368 void settingsDialogAccepted();
371 * @brief Ignore SSL error from the reply
373 void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
376 * @brief Start location search (open search dialog)
378 void startLocationSearch();
381 * @brief Toggle between fullscreen and normal window mode
383 void toggleFullScreen();
385 /*******************************************************************************
387 ******************************************************************************/
390 * @brief Automatic centering setting changed by user
392 * @param enabled True if automatic centering is enabled, otherwise false
394 void autoCenteringTriggered(bool enabled);
397 * @brief Signal that indicates when user has cancelled login process
400 void cancelLoginProcess();
403 * @brief Signal for centering to coordinates.
405 * @param coordinates geo coordinates to center to.
407 void centerToCoordinates(const GeoCoordinate &coordinates);
410 * @brief View should be centered to new location
412 * @param coordinate Scene coordinates of the new center point
414 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
417 * @brief Emitted when route is cleared
422 * @brief Signal when direction and distance from current map center point to current GPS
423 * location is changed
425 * @param direction Direction in degrees
426 * @param distance Distance in meters
427 * @param draw Should the indicator triangle be drawn or not
429 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
432 * @brief Signal for enabling automatic location update.
434 * @param enabled true if enabled, false otherwise
435 * @param updateIntervalMsecs update interval in milliseconds
437 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
440 * @brief Signals error
442 * @param context error context
443 * @param error error code
445 void error(const int context, const int error);
448 * @brief Signal for requesting username from settings
451 void fetchUsernameFromSettings();
454 * @brief Signals when friend's profile image is ready
458 void friendImageReady(User *user);
461 * @brief GPS setting changed
463 * @param enabled True if GPS is enabled, otherwise false
465 void gpsTriggered(bool enabled);
468 * @brief Signal for friend location ready.
472 void friendsLocationsReady(QList<User *> &friendsList);
475 * @brief Emited when location request is parsed and is ready for further processing
477 * @param result List of Location items
479 void locationDataParsed(const QList<Location> &result);
482 * @brief Signal is emitted when location item is clicked on map.
484 * @param userIDs list of friends user IDs in the group
486 void locationItemClicked(const QList<QString> &userIDs);
489 * @brief Signal is emitted when location item is clicked in list.
491 * @param swBound south-west bound in GeoCoorinate
492 * @param neBound north-east bound in GeoCoordinate
494 void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
497 * @brief Signals when Login/Logout action is pressed
500 void loginActionPressed();
503 * @brief MapView has been resized
505 * @param size view size
507 void mapViewResized(const QSize &size);
510 * @brief Forwarding signal from MapView to MapEngine
512 * @param coordinate New center point coordinate
514 void mapViewScrolled(const SceneCoordinate &coordinate);
517 * @brief Forwarding signal from MapEngine to MapView
519 void maxZoomLevelReached();
522 * @brief Forwarding signal from MapEngine to MapView
524 void minZoomLevelReached();
527 * @brief Forwarding signal from MapEngine to MapScale
529 void newMapResolution(qreal scale);
532 * @brief Signal for refreshing user data.
535 void refreshUserData();
538 * @brief Requests contact dialog.
540 * @param facebookId contact's facebookId
542 void requestContactDialog(const QString &facebookId);
545 * @brief Signal for requesting reverseGeo from SituareEngine
548 void requestReverseGeo();
551 * @brief Signals, when address data is ready
553 * @param address Street address
555 void reverseGeoReady(const QString &address);
558 * @brief Emited when route is parsed and is ready for further processing
560 * @param route Route item containing parsed route details
562 void routeParsed(Route &route);
565 * @brief Signal for routing to geo coordinates.
567 * @param coordinates destination geo coordinates
569 void routeTo(const GeoCoordinate &coordinates);
572 * @brief Request routing to current cursor position
574 void routeToCursor();
577 * @brief Signal for location search
579 * @param location QString location
581 void searchForLocation(QString location);
584 * @brief Signal is emitted when search history item is clicked.
586 * @param searchString search string used
588 void searchHistoryItemClicked(const QString &searchString);
591 * @brief Signal for requestLocationUpdate from SituareEngine
593 * @param status Status message
594 * @param publish Publish on Facebook
596 void statusUpdate(const QString &status, const bool &publish);
599 * @brief Signals when updateLocationDialog's data must be cleared
602 void clearUpdateLocationDialogData();
605 * @brief Dragging mode triggered.
607 void draggingModeTriggered();
610 * @brief MapView has finished zooming
612 void viewZoomFinished();
615 * @brief Signal for use location ready.
617 * @param user User object
619 void userLocationReady(User *user);
622 * @brief Map zoom in request
627 * @brief Forwarding signal from MapEngine to MapView
629 void zoomLevelChanged(int zoomLevel);
632 * @brief Map zoom out request
636 /*******************************************************************************
638 ******************************************************************************/
640 bool m_errorShown; ///< Indicates if error dialog/note is shown
641 bool m_loggedIn; ///< Indicates login state
642 bool m_refresh; ///< Indicates when webpage is refreshed
644 int m_mapCenterHorizontalShifting; ///< Amount of map center point horizontal shifting
645 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
647 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
648 QAction *m_loginAct; ///< Action to Login/Logout
649 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
651 QDialog *m_loginDialog; ///< Login dialog
653 QLabel *m_crosshair; ///< Label for center point crosshair
654 QLabel *m_osmLicense; ///< Label for Open Street Map license
656 QList<int> m_situareTabsIndexes; ///< List of Situare tab indexes
657 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
658 QList<QDialog *> m_queue; ///< QList type dialog queue
660 QMenu *m_viewMenu; ///< Object that hold the view menu items
662 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
664 QString m_email; ///< Placeholder for email
665 QString m_password; ///< Placeholder for password
667 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
668 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
669 IndicatorButtonPanel *m_indicatorButtonPanel; ///< Instance of direction indicator button
670 LocationSearchPanel *m_locationSearchPanel; ///< Location search panel
671 MapScale *m_mapScale; ///< Instance of the map scale
672 MapView *m_mapView; ///< Instance of the map view
673 RoutingPanel *m_routingPanel; ///< Instance of routing panel
674 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
675 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
676 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
679 #endif // MAINWINDOW_H