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 ******************************************************************************/
97 * @brief Build and show login dialog with login browser
99 * @param browser Login browser instance
101 void buildLoginDialog(QWebView *browser);
108 void loggedIn(bool logged);
111 * @brief Reads automatic location update settings.
113 void readAutomaticLocationUpdateSettings();
116 * @brief Enable / disable GPS button.
118 * Does set visibilities for manual location cursor and auto centering menu button.
120 * @param enabled true if enabled, false otherwise
122 void setGPSButtonEnabled(bool enabled);
125 * @brief Enable / disable direction indicator button.
127 * @param enabled true if shoud be enabled, false otherwise
129 void setIndicatorButtonEnabled(bool enabled);
132 * @brief Set scene for MapView
134 * @param scene Scene to be set
136 void setMapViewScene(QGraphicsScene *scene);
139 * Shows dialog with enable automatic location update question.
141 * @param text text to show in dialog
143 void showEnableAutomaticUpdateLocationDialog(const QString &text);
147 * @brief Builds information box with message.
149 * @param message Information message
150 * @param modal Modal = true, non-modal false
152 void buildInformationBox(const QString &message, bool modal=false);
155 * @brief Hides and deletes login dialog
157 void destroyLoginDialog();
160 * @brief Public slot, which open settings dialog
162 void openSettingsDialog();
165 * @brief Set own location crosshair visibility
169 void setCrosshairVisibility(bool visible);
172 * @brief Shows contact dialog.
174 * Shows contact dialog with contact's information.
175 * @param guid globally unique ID of a contact
177 void showContactDialog(const QString &guid);
180 * @brief Toggle progress indicator.
182 * @param state true if progress indicator should be shown, false otherwise
184 void toggleProgressIndicator(bool state);
187 * @brief Shows / hides Situare related UI items based on login state
189 * @param loggedIn Is the user currently logged in
191 void updateItemVisibility(bool loggedIn);
195 * @brief Build manual location setting cross hair and connect slots
197 void buildCrosshair();
200 * @brief Build friend list panel and connect slots
202 void buildFriendListPanel();
205 * @brief Build fullscreen toggle button and connect slots
207 void buildFullScreenButton();
210 * @brief Build direction indicator button panel and connect signals
212 void buildIndicatorButtonPanel();
216 * @brief Build location search panel and connect signals
218 void buildLocationSearchPanel();
221 * @brief Build map and connect slots
226 * @brief Build map scale and connect slots
228 void buildMapScale();
231 * @brief Build OSM license and connect slots
233 void buildOsmLicense();
236 * @brief Build application panels
241 * @brief Build routing panel and connect slots
243 void buildRoutingPanel();
246 * @brief Build user info panel and connect slots
248 void buildUserInfoPanel();
251 * @brief Build zoom button panel and connect slots
253 void buildZoomButtonPanel();
256 * @brief Private method to create the Menu items
261 * @brief Grab or release HW increase and decrease buttons.
263 * @param grab Use true for grabbing and false for releasing the keys
265 void grabZoomKeys(bool grab);
268 * @brief Queues dialog/information box
270 * @param dialog Dialog to be added into queue
272 void queueDialog(QDialog *dialog);
275 * @brief Shows queued error information box
278 void showErrorInformationBox();
281 * @brief Shows queued information box
283 * @fn showInformationBox
285 void showInformationBox();
289 * @brief Slot for automatic update dialog finished.
291 * @result result code
293 void automaticUpdateDialogFinished(int result);
296 * @brief Slot to intercept signal when dialog/information note is processed
298 * @param status Status of the dialog
300 void dialogFinished(int status);
303 * @brief Slot for drawing the fullscreen toggle button
305 * @param size Size of the screen
307 void drawFullScreenButton(const QSize &size);
310 * @brief Slot for drawing the map distance scale
312 * @param size Size of the screen
314 void drawMapScale(const QSize &size);
317 * @brief Slot for drawing the Open Street Map license text
319 * @param size Size of the screen
321 void drawOsmLicense(const QSize &size);
324 * @brief Slot to intercept signal when error dialog/information note is processed
326 * @param status Status of the dialog
328 void errorDialogFinished(int status);
331 * @brief Slot for gps timeout.
333 * Called when request timeout occurs.
338 * @brief Called when map center point horizontal shifting is changed
340 * @param shifting New shifting value
342 void mapCenterHorizontalShiftingChanged(int shifting);
345 * @brief Move the crosshair
347 void moveCrosshair();
350 * @brief Slot for settings dialog accepted.
352 void settingsDialogAccepted();
355 * @brief Ignore SSL error from the reply
357 void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
360 * @brief Start location search (open search dialog)
362 void startLocationSearch();
365 * @brief Toggle between fullscreen and normal window mode
367 void toggleFullScreen();
369 /*******************************************************************************
371 ******************************************************************************/
374 * @brief Automatic centering setting changed by user
376 * @param enabled True if automatic centering is enabled, otherwise false
378 void autoCenteringTriggered(bool enabled);
381 * @brief Signal for centering to coordinates.
383 * @param coordinates geo coordinates to center to.
385 void centerToCoordinates(const GeoCoordinate &coordinates);
388 * @brief View should be centered to new location
390 * @param coordinate Scene coordinates of the new center point
392 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
395 * @brief Emitted when route is cleared
400 * @brief Signal when direction and distance from current map center point to current GPS
401 * location is changed
403 * @param direction Direction in degrees
404 * @param distance Distance in meters
405 * @param draw Should the indicator triangle be drawn or not
407 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
410 * @brief Signal for enabling automatic location update.
412 * @param enabled true if enabled, false otherwise
413 * @param updateIntervalMsecs update interval in milliseconds
415 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
418 * @brief Signals error
420 * @param context error context
421 * @param error error code
423 void error(const int context, const int error);
426 * @brief Signals when friend's profile image is ready
430 void friendImageReady(User *user);
433 * @brief GPS setting changed
435 * @param enabled True if GPS is enabled, otherwise false
437 void gpsTriggered(bool enabled);
440 * @brief Signal for friend location ready.
444 void friendsLocationsReady(QList<User *> &friendsList);
447 * @brief Emited when location request is parsed and is ready for further processing
449 * @param result List of Location items
451 void locationDataParsed(const QList<Location> &result);
454 * @brief Signal is emitted when location item is clicked on map.
456 * @param userIDs list of friends user IDs in the group
458 void locationItemClicked(const QList<QString> &userIDs);
461 * @brief Signal is emitted when location item is clicked in list.
463 * @param swBound south-west bound in GeoCoorinate
464 * @param neBound north-east bound in GeoCoordinate
466 void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
469 * @brief Signals when Login/Logout action is pressed
472 void loginActionPressed();
475 * @brief MapView has been resized
477 * @param size view size
479 void mapViewResized(const QSize &size);
482 * @brief Forwarding signal from MapView to MapEngine
484 * @param coordinate New center point coordinate
486 void mapViewScrolled(const SceneCoordinate &coordinate);
489 * @brief Forwarding signal from MapEngine to MapView
491 void maxZoomLevelReached();
494 * @brief Forwarding signal from MapEngine to MapView
496 void minZoomLevelReached();
499 * @brief Forwarding signal from MapEngine to MapScale
501 void newMapResolution(qreal scale);
504 * @brief Signal for refreshing user data.
507 void refreshUserData();
510 * @brief Requests contact dialog.
512 * @param facebookId contact's facebookId
514 void requestContactDialog(const QString &facebookId);
517 * @brief Signal for requesting reverseGeo from SituareEngine
520 void requestReverseGeo();
523 * @brief Signals, when address data is ready
525 * @param address Street address
527 void reverseGeoReady(const QString &address);
530 * @brief Emited when route is parsed and is ready for further processing
532 * @param route Route item containing parsed route details
534 void routeParsed(Route &route);
537 * @brief Signal for routing to geo coordinates.
539 * @param coordinates destination geo coordinates
541 void routeTo(const GeoCoordinate &coordinates);
544 * @brief Request routing to current cursor position
546 void routeToCursor();
549 * @brief Signal for location search
551 * @param location QString location
553 void searchForLocation(QString location);
556 * @brief Signal is emitted when search history item is clicked.
558 * @param searchString search string used
560 void searchHistoryItemClicked(const QString &searchString);
563 * @brief Signal for requestLocationUpdate from SituareEngine
565 * @param status Status message
566 * @param publish Publish on Facebook
568 void statusUpdate(const QString &status, const bool &publish);
571 * @brief Signals when updateLocationDialog's data must be cleared
574 void clearUpdateLocationDialogData();
577 * @brief Dragging mode triggered.
579 void draggingModeTriggered();
582 * @brief MapView has finished zooming
584 void viewZoomFinished();
587 * @brief Signal for use location ready.
589 * @param user User object
591 void userLocationReady(User *user);
594 * @brief Map zoom in request
599 * @brief Forwarding signal from MapEngine to MapView
601 void zoomLevelChanged(int zoomLevel);
604 * @brief Map zoom out request
608 /*******************************************************************************
610 ******************************************************************************/
612 bool m_errorShown; ///< Indicates if error dialog/note is shown
613 bool m_loggedIn; ///< Indicates login state
614 bool m_refresh; ///< Indicates when webpage is refreshed
616 int m_mapCenterHorizontalShifting; ///< Amount of map center point horizontal shifting
617 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
619 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
620 QAction *m_loginAct; ///< Action to Login/Logout
621 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
623 QDialog *m_loginDialog; ///< Login dialog
625 QLabel *m_crosshair; ///< Label for center point crosshair
626 QLabel *m_osmLicense; ///< Label for Open Street Map license
628 QList<int> m_situareTabsIndexes; ///< List of Situare tab indexes
629 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
630 QList<QDialog *> m_queue; ///< QList type dialog queue
632 QMenu *m_viewMenu; ///< Object that hold the view menu items
634 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
636 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
637 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
638 IndicatorButtonPanel *m_indicatorButtonPanel; ///< Instance of direction indicator button
639 LocationSearchPanel *m_locationSearchPanel; ///< Location search panel
640 MapScale *m_mapScale; ///< Instance of the map scale
641 MapView *m_mapView; ///< Instance of the map view
642 RoutingPanel *m_routingPanel; ///< Instance of routing panel
643 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
644 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
645 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
648 #endif // MAINWINDOW_H