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;
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 Build and show login dialog with login browser
100 * @param browser Login browser instance
102 void buildLoginDialog(QWebView *browser);
109 void loggedIn(bool logged);
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);
148 * @brief Builds information box with message.
150 * @param message Information message
151 * @param modal Modal = true, non-modal false
153 void buildInformationBox(const QString &message, bool modal=false);
156 * @brief Hides and deletes login dialog
158 void destroyLoginDialog();
161 * @brief Public slot, which open settings dialog
163 void openSettingsDialog();
166 * @brief Set own location crosshair visibility
170 void setCrosshairVisibility(bool visible);
173 * @brief Shows contact dialog.
175 * Shows contact dialog with contact's information.
176 * @param guid globally unique ID of a contact
178 void showContactDialog(const QString &guid);
181 * @brief Toggle progress indicator.
183 * @param state true if progress indicator should be shown, false otherwise
185 void toggleProgressIndicator(bool state);
188 * @brief Shows / hides Situare related UI items based on login state
190 * @param loggedIn Is the user currently logged in
192 void updateItemVisibility(bool loggedIn);
196 * @brief Build manual location setting cross hair and connect slots
198 void buildCrosshair();
201 * @brief Build friend list panel and connect slots
203 void buildFriendListPanel();
206 * @brief Build fullscreen toggle button and connect slots
208 void buildFullScreenButton();
211 * @brief Build direction indicator button panel and connect signals
213 void buildIndicatorButtonPanel();
217 * @brief Build location search panel and connect signals
219 void buildLocationSearchPanel();
222 * @brief Build map and connect slots
227 * @brief Build map scale and connect slots
229 void buildMapScale();
232 * @brief Build OSM license and connect slots
234 void buildOsmLicense();
237 * @brief Build application panels
242 * @brief Build routing panel and connect slots
244 void buildRoutingPanel();
247 * @brief Build user info panel and connect slots
249 void buildUserInfoPanel();
252 * @brief Build zoom button panel and connect slots
254 void buildZoomButtonPanel();
257 * @brief Private method to create the Menu items
262 * @brief Grab or release HW increase and decrease buttons.
264 * @param grab Use true for grabbing and false for releasing the keys
266 void grabZoomKeys(bool grab);
269 * @brief Queues dialog/information box
271 * @param dialog Dialog to be added into queue
273 void queueDialog(QDialog *dialog);
276 * @brief Shows queued error information box
279 void showErrorInformationBox();
282 * @brief Shows queued information box
284 * @fn showInformationBox
286 void showInformationBox();
290 * @brief Slot for automatic update dialog finished.
292 * @result result code
294 void automaticUpdateDialogFinished(int result);
297 * @brief Slot to intercept signal when dialog/information note is processed
299 * @param status Status of the dialog
301 void dialogFinished(int status);
304 * @brief Slot for drawing the fullscreen toggle button
306 * @param size Size of the screen
308 void drawFullScreenButton(const QSize &size);
311 * @brief Slot for drawing the map distance scale
313 * @param size Size of the screen
315 void drawMapScale(const QSize &size);
318 * @brief Slot for drawing the Open Street Map license text
320 * @param size Size of the screen
322 void drawOsmLicense(const QSize &size);
325 * @brief Slot to intercept signal when error dialog/information note is processed
327 * @param status Status of the dialog
329 void errorDialogFinished(int status);
332 * @brief Slot for gps timeout.
334 * Called when request timeout occurs.
339 * @brief Called when map center point horizontal shifting is changed
341 * @param shifting New shifting value
343 void mapCenterHorizontalShiftingChanged(int shifting);
346 * @brief Move the crosshair
348 void moveCrosshair();
351 * @brief Slot for settings dialog accepted.
353 void settingsDialogAccepted();
356 * @brief Show update location dialog
358 void showUpdateLocationDialog();
361 * @brief Ignore SSL error from the reply
363 void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
366 * @brief Start location search (open search dialog)
368 void startLocationSearch();
371 * @brief Toggle between fullscreen and normal window mode
373 void toggleFullScreen();
375 /*******************************************************************************
377 ******************************************************************************/
380 * @brief Automatic centering setting changed by user
382 * @param enabled True if automatic centering is enabled, otherwise false
384 void autoCenteringTriggered(bool enabled);
387 * @brief Signal for centering to coordinates.
389 * @param coordinates geo coordinates to center to.
391 void centerToCoordinates(const GeoCoordinate &coordinates);
394 * @brief View should be centered to new location
396 * @param coordinate Scene coordinates of the new center point
398 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
401 * @brief Emitted when route is cleared
406 * @brief Signal when direction and distance from current map center point to current GPS
407 * location is changed
409 * @param direction Direction in degrees
410 * @param distance Distance in meters
411 * @param draw Should the indicator triangle be drawn or not
413 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
416 * @brief Signal for enabling automatic location update.
418 * @param enabled true if enabled, false otherwise
419 * @param updateIntervalMsecs update interval in milliseconds
421 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
424 * @brief Signals error
426 * @param context error context
427 * @param error error code
429 void error(const int context, const int error);
432 * @brief Signals when friend's profile image is ready
436 void friendImageReady(User *user);
439 * @brief GPS setting changed
441 * @param enabled True if GPS is enabled, otherwise false
443 void gpsTriggered(bool enabled);
446 * @brief Signal for friend location ready.
450 void friendsLocationsReady(QList<User *> &friendsList);
453 * @brief Emited when location request is parsed and is ready for further processing
455 * @param result List of Location items
457 void locationDataParsed(const QList<Location> &result);
460 * @brief Signal is emitted when location item is clicked on map.
462 * @param userIDs list of friends user IDs in the group
464 void locationItemClicked(const QList<QString> &userIDs);
467 * @brief Signal is emitted when location item is clicked in list.
469 * @param swBound south-west bound in GeoCoorinate
470 * @param neBound north-east bound in GeoCoordinate
472 void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
475 * @brief Send location update
477 * @param status Status message
478 * @param publish Publish on Facebook?
480 void locationUpdate(const QString &status, bool publish);
483 * @brief Signals when Login/Logout action is pressed
486 void loginActionPressed();
489 * @brief MapView has been resized
491 * @param size view size
493 void mapViewResized(const QSize &size);
496 * @brief Forwarding signal from MapView to MapEngine
498 * @param coordinate New center point coordinate
500 void mapViewScrolled(const SceneCoordinate &coordinate);
503 * @brief Forwarding signal from MapEngine to MapView
505 void maxZoomLevelReached();
508 * @brief Forwarding signal from MapEngine to MapView
510 void minZoomLevelReached();
513 * @brief Forwarding signal from MapEngine to MapScale
515 void newMapResolution(qreal scale);
518 * @brief Signal for refreshing user data.
521 void refreshUserData();
524 * @brief Requests contact dialog.
526 * @param facebookId contact's facebookId
528 void requestContactDialog(const QString &facebookId);
531 * @brief Signal for requesting reverseGeo from SituareEngine
534 void requestReverseGeo();
537 * @brief Signals, when address data is ready
539 * @param address Street address
541 void reverseGeoReady(const QString &address);
544 * @brief Emited when route is parsed and is ready for further processing
546 * @param route Route item containing parsed route details
548 void routeParsed(Route &route);
551 * @brief Signal for routing to geo coordinates.
553 * @param coordinates destination geo coordinates
555 void routeTo(const GeoCoordinate &coordinates);
558 * @brief Request routing to current cursor position
560 void routeToCursor();
563 * @brief Signal for location search
565 * @param location QString location
567 void searchForLocation(QString location);
570 * @brief Signal is emitted when search history item is clicked.
572 * @param searchString search string used
574 void searchHistoryItemClicked(const QString &searchString);
577 * @brief Dragging mode triggered.
579 void draggingModeTriggered();
582 * @brief MapView has finished zooming
584 void viewZoomFinished();
587 * @brief Signals when updateLocation request finished successfully
589 void updateWasSuccessful();
592 * @brief Signal for use location ready.
594 * @param user User object
596 void userLocationReady(User *user);
599 * @brief Map zoom in request
604 * @brief Forwarding signal from MapEngine to MapView
606 void zoomLevelChanged(int zoomLevel);
609 * @brief Map zoom out request
613 /*******************************************************************************
615 ******************************************************************************/
617 bool m_errorShown; ///< Indicates if error dialog/note is shown
618 bool m_loggedIn; ///< Indicates login state
619 bool m_refresh; ///< Indicates when webpage is refreshed
621 int m_mapCenterHorizontalShifting; ///< Amount of map center point horizontal shifting
622 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
624 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
625 QAction *m_loginAct; ///< Action to Login/Logout
626 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
628 QDialog *m_loginDialog; ///< Login dialog
630 QLabel *m_crosshair; ///< Label for center point crosshair
631 QLabel *m_osmLicense; ///< Label for Open Street Map license
633 QList<int> m_situareTabsIndexes; ///< List of Situare tab indexes
634 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
635 QList<QDialog *> m_queue; ///< QList type dialog queue
637 QMenu *m_viewMenu; ///< Object that hold the view menu items
639 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
641 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
642 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
643 IndicatorButtonPanel *m_indicatorButtonPanel; ///< Instance of direction indicator button
644 LocationSearchPanel *m_locationSearchPanel; ///< Location search panel
645 MapScale *m_mapScale; ///< Instance of the map scale
646 MapView *m_mapView; ///< Instance of the map view
647 RoutingPanel *m_routingPanel; ///< Instance of routing panel
648 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
649 UpdateLocation *m_updateLocationController; ///< Controller for update location dialog
650 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
651 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
654 #endif // MAINWINDOW_H