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 FullScreenButton;
44 class FriendListPanel;
45 class IndicatorButtonPanel;
54 class SceneCoordinate;
59 class ZoomButtonPanel;
63 * @brief Main Window Class
65 class MainWindow : public QMainWindow
73 * @param parent Parent
75 MainWindow(QWidget *parent = 0);
82 /*******************************************************************************
83 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
84 ******************************************************************************/
87 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
89 void keyPressEvent(QKeyEvent* event);
91 /*******************************************************************************
92 * MEMBER FUNCTIONS AND SLOTS
93 ******************************************************************************/
96 * @brief Clears cookie jar
99 void clearCookieJar();
106 void loggedIn(bool logged);
109 * @brief Gets the login state (logged in/logged out)
111 * @return bool Login state
116 * @brief Reads automatic location update settings.
118 void readAutomaticLocationUpdateSettings();
121 * @brief Enable / disable GPS button.
123 * Does set visibilities for manual location cursor and auto centering menu button.
125 * @param enabled true if enabled, false otherwise
127 void setGPSButtonEnabled(bool enabled);
130 * @brief Enable / disable direction indicator button.
132 * @param enabled true if shoud be enabled, false otherwise
134 void setIndicatorButtonEnabled(bool enabled);
137 * @brief Set scene for MapView
139 * @param scene Scene to be set
141 void setMapViewScene(QGraphicsScene *scene);
144 * Shows dialog with enable automatic location update question.
146 * @param text text to show in dialog
148 void showEnableAutomaticUpdateLocationDialog(const QString &text);
151 * @brief Gets the username from member variable for saving purposes
153 * @return QString Username
155 const QString username();
159 * @brief Build direction indicator button panel and connect signals
161 void buildIndicatorButtonPanel();
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 Sets username to member variable for login dialog
196 * @param username Username to be set
198 void setUsername(const QString &username);
201 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
204 void startLoginProcess();
207 * @brief Toggle progress indicator.
209 * @param state true if progress indicator should be shown, false otherwise
211 void toggleProgressIndicator(bool state);
214 * @brief Shows / hides Situare related UI items
217 void updateItemVisibility();
221 * @brief Build manual location setting cross hair and connect slots
223 void buildCrosshair();
226 * @brief Build friend list panel and connect slots
228 void buildFriendListPanel();
231 * @brief Build fullscreen toggle button and connect slots
233 void buildFullScreenButton();
236 * @brief Build map and connect slots
241 * @brief Build map scale and connect slots
243 void buildMapScale();
246 * @brief Build OSM license and connect slots
248 void buildOsmLicense();
251 * @brief Build application panels
256 * @brief Build routing panel and connect slots
258 void buildRoutingPanel();
261 * @brief Build user info panel and connect slots
263 void buildUserInfoPanel();
266 * @brief Build webview and connect slots
271 * @brief Build zoom button panel and connect slots
273 void buildZoomButtonPanel();
276 * @brief Private method to create the Menu items
281 * @brief Grab or release HW increase and decrease buttons.
283 * @param grab Use true for grabbing and false for releasing the keys
285 void grabZoomKeys(bool grab);
288 * @brief Queues dialog/information box
290 * @param dialog Dialog to be added into queue
292 void queueDialog(QDialog *dialog);
295 * @brief Shows queued error information box
298 void showErrorInformationBox();
301 * @brief Shows queued information box
303 * @fn showInformationBox
305 void showInformationBox();
309 * @brief Slot for automatic update dialog finished.
311 * @result result code
313 void automaticUpdateDialogFinished(int result);
316 * @brief Slot to intercept signal when dialog/information note is processed
318 * @param status Status of the dialog
320 void dialogFinished(int status);
323 * @brief Slot for drawing the fullscreen toggle button
325 * @param size Size of the screen
327 void drawFullScreenButton(const QSize &size);
330 * @brief Slot for drawing the map distance scale
332 * @param size Size of the screen
334 void drawMapScale(const QSize &size);
337 * @brief Slot for drawing the Open Street Map license text
339 * @param size Size of the screen
341 void drawOsmLicense(const QSize &size);
344 * @brief Slot to intercept signal when error dialog/information note is processed
346 * @param status Status of the dialog
348 void errorDialogFinished(int status);
351 * @brief Slot for gps timeout.
353 * Called when request timeout occurs.
358 * @brief Slot to load cookies from settings
363 * @brief Slot to intercept signal when webview has finished loading webpage
365 * @param done Status of the loading
367 void loadDone(bool done);
370 * @brief Called when map center point horizontal shifting is changed
372 * @param shifting New shifting value
374 void mapCenterHorizontalShiftingChanged(int shifting);
377 * @brief Move the crosshair
379 void moveCrosshair();
382 * @brief Slot to save cookies to settings
387 * @brief Slot for settings dialog accepted.
389 void settingsDialogAccepted();
392 * @brief Start location search (open search dialog)
394 void startLocationSearch();
397 * @brief Toggle between fullscreen and normal window mode
399 void toggleFullScreen();
402 * @brief Slot to intercept signal from webview's networkaccessmanager
404 * @param reply Network reply (contains errors)
406 void webViewRequestFinished(QNetworkReply* reply);
408 /*******************************************************************************
410 ******************************************************************************/
413 * @brief Automatic centering setting changed by user
415 * @param enabled True if automatic centering is enabled, otherwise false
417 void autoCenteringTriggered(bool enabled);
420 * @brief Signal that indicates when user has cancelled login process
423 void cancelLoginProcess();
426 * @brief Signal for centering to coordinates.
428 * @param coordinates geo coordinates to center to.
430 void centerToCoordinates(const GeoCoordinate &coordinates);
433 * @brief View should be centered to new location
435 * @param coordinate Scene coordinates of the new center point
437 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
440 * @brief Emitted when route is cleared
445 * @brief Signal when direction and distance from current map center point to current GPS
446 * location is changed
448 * @param direction Direction in degrees
449 * @param distance Distance in meters
450 * @param draw Should the indicator triangle be drawn or not
452 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
455 * @brief Signal for enabling automatic location update.
457 * @param enabled true if enabled, false otherwise
458 * @param updateIntervalMsecs update interval in milliseconds
460 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
463 * @brief Signals error
465 * @param context error context
466 * @param error error code
468 void error(const int context, const int error);
471 * @brief Signal for requesting username from settings
474 void fetchUsernameFromSettings();
477 * @brief Signals when friend's profile image is ready
481 void friendImageReady(User *user);
484 * @brief GPS setting changed
486 * @param enabled True if GPS is enabled, otherwise false
488 void gpsTriggered(bool enabled);
491 * @brief Signal for friend location ready.
495 void friendsLocationsReady(QList<User *> &friendsList);
498 * @brief Emited when location request is parsed and is ready for further processing
500 * @param result List of Location items
502 void locationDataParsed(const QList<Location> &result);
505 * @brief Signal is emitted when location item is clicked on map.
507 * @param userIDs list of friends user IDs in the group
509 void locationItemClicked(const QList<QString> &userIDs);
512 * @brief Signal is emitted when location item is clicked in list.
514 * @param swBound south-west bound in GeoCoorinate
515 * @param neBound north-east bound in GeoCoordinate
517 void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
520 * @brief Signals when Login/Logout action is pressed
523 void loginActionPressed();
526 * @brief MapView has been resized
528 * @param size view size
530 void mapViewResized(const QSize &size);
533 * @brief Forwarding signal from MapView to MapEngine
535 * @param coordinate New center point coordinate
537 void mapViewScrolled(const SceneCoordinate &coordinate);
540 * @brief Forwarding signal from MapEngine to MapView
542 void maxZoomLevelReached();
545 * @brief Forwarding signal from MapEngine to MapView
547 void minZoomLevelReached();
550 * @brief Forwarding signal from MapEngine to MapScale
552 void newMapResolution(qreal scale);
555 * @brief Signal for refreshing user data.
558 void refreshUserData();
561 * @brief Signal for requesting reverseGeo from SituareEngine
564 void requestReverseGeo();
567 * @brief Signals, when address data is ready
569 * @param address Street address
571 void reverseGeoReady(const QString &address);
574 * @brief Emited when route is parsed and is ready for further processing
576 * @param route Route item containing parsed route details
578 void routeParsed(Route &route);
581 * @brief Signal for routing to geo coordinates.
583 * @param coordinates destination geo coordinates
585 void routeTo(const GeoCoordinate &coordinates);
588 * @brief Signal to save username to settings
590 * @param username Username
592 void saveUsername(const QString &username);
595 * @brief Signal for location search
597 * @param location QString location
599 void searchForLocation(QString location);
602 * @brief Signal for requestLocationUpdate from SituareEngine
604 * @param status Status message
605 * @param publish Publish on Facebook
607 void statusUpdate(const QString &status, const bool &publish);
610 * @brief Signals when webview's urlChanged signal is emitted
614 void updateCredentials(const QUrl &url);
617 * @brief Signals when updateLocationDialog's data must be cleared
620 void clearUpdateLocationDialogData();
623 * @brief Dragging mode triggered.
625 void draggingModeTriggered();
628 * @brief MapView has finished zooming
630 void viewZoomFinished();
633 * @brief Signal for use location ready.
635 * @param user User object
637 void userLocationReady(User *user);
640 * @brief Map zoom in request
645 * @brief Forwarding signal from MapEngine to MapView
647 void zoomLevelChanged(int zoomLevel);
650 * @brief Map zoom out request
654 /*******************************************************************************
656 ******************************************************************************/
658 bool m_errorShown; ///< Indicates if error dialog/note is shown
659 bool m_loggedIn; ///< Indicates login state
660 bool m_refresh; ///< Indicates when webpage is refreshed
662 int m_mapCenterHorizontalShifting; ///< Amount of map center point horizontal shifting
663 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
665 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
666 QAction *m_loginAct; ///< Action to Login/Logout
667 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
669 QLabel *m_crosshair; ///< Label for center point crosshair
670 QLabel *m_osmLicense; ///< Label for Open Street Map license
672 QList<int> m_situareTabsIndexes; ///< List of Situare tab indexes
673 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
674 QList<QDialog *> m_queue; ///< QList type dialog queue
676 QMenu *m_viewMenu; ///< Object that hold the view menu items
678 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
680 QString m_email; ///< Placeholder for email
681 QString m_password; ///< Placeholder for password
683 QWebView *m_webView; ///< Shows facebook login page
685 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
686 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
687 IndicatorButtonPanel *m_indicatorButtonPanel; ///< Instance of direction indicator button
688 MapScale *m_mapScale; ///< Instance of the map scale
689 MapView *m_mapView; ///< Instance of the map view
690 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
691 RoutingPanel *m_routingPanel; ///< Instance of routing panel
692 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
693 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
694 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
697 #endif // MAINWINDOW_H