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;
53 class SceneCoordinate;
57 class ZoomButtonPanel;
61 * @brief Main Window Class
63 class MainWindow : public QMainWindow
71 * @param parent Parent
73 MainWindow(QWidget *parent = 0);
81 /*******************************************************************************
82 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
83 ******************************************************************************/
86 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
88 void keyPressEvent(QKeyEvent* event);
90 /*******************************************************************************
91 * MEMBER FUNCTIONS AND SLOTS
92 ******************************************************************************/
95 * @brief Clears cookie jar
98 void clearCookieJar();
105 void loggedIn(bool logged);
108 * @brief Gets the login state (logged in/logged out)
110 * @return bool Login state
115 * @brief Reads automatic location update settings.
117 void readAutomaticLocationUpdateSettings();
120 * @brief Enable / disable GPS button.
122 * Does set visibilities for manual location cursor and auto centering menu button.
124 * @param enabled true if enabled, false otherwise
126 void setGPSButtonEnabled(bool enabled);
129 * @brief Enable / disable direction indicator button.
131 * @param enabled true if shoud be enabled, false otherwise
133 void setIndicatorButtonEnabled(bool enabled);
136 * @brief Set scene for MapView
138 * @param scene Scene to be set
140 void setMapViewScene(QGraphicsScene *scene);
143 * Shows dialog with enable automatic location update question.
145 * @param text text to show in dialog
147 void showEnableAutomaticUpdateLocationDialog(const QString &text);
150 * @brief Gets the username from member variable for saving purposes
152 * @return QString Username
154 const QString username();
158 * @brief Build direction indicator button panel and connect signals
160 void buildIndicatorButtonPanel();
163 * @brief Builds information box with message.
165 * @param message Information message
166 * @param modal Modal = true, non-modal false
168 void buildInformationBox(const QString &message, bool modal=false);
171 * @brief Slot for failed login
176 * @brief Slot to intercept signal when login with cookies is requested
178 void loginUsingCookies();
181 * @brief Public slot, which open settings dialog
183 void openSettingsDialog();
186 * @brief Set own location crosshair visibility
190 void setOwnLocationCrosshairVisibility(bool visible);
193 * @brief Sets username to member variable for login dialog
195 * @param username Username to be set
197 void setUsername(const QString &username);
200 * @brief Method to show panels
205 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
209 void startLoginProcess();
212 * @brief Toggle progress indicator.
214 * @param state true if progress indicator should be shown, false otherwise
216 void toggleProgressIndicator(bool state);
219 * @brief Shows / hides Situare related UI items
222 void updateItemVisibility();
226 * @brief Build fullscreen toggle button and connect slots
228 void buildFullScreenButton();
231 * @brief Build friend list panel and connect slots
233 void buildFriendListPanel();
236 * @brief Build manual location setting cross hair and connect slots
238 void buildManualLocationCrosshair();
241 * @brief Build map and connect slots
246 * @brief Build map scale and connect slots
248 void buildMapScale();
251 * @brief Build OSM license and connect slots
253 void buildOsmLicense();
256 * @brief Build application panels
261 * @brief Build routing panel and connect slots
263 void buildRoutingPanel();
266 * @brief Build user info panel and connect slots
268 void buildUserInfoPanel();
271 * @brief Build webview and connect slots
276 * @brief Build zoom button panel and connect slots
278 void buildZoomButtonPanel();
281 * @brief Private method to create the Menu items
286 * @brief Grab or release HW increase and decrease buttons.
288 * @param grab Use true for grabbing and false for releasing the keys
290 void grabZoomKeys(bool grab);
293 * @brief Queues dialog/information box
295 * @param dialog Dialog to be added into queue
297 void queueDialog(QDialog *dialog);
300 * @brief Shows queued error information box
303 void showErrorInformationBox();
306 * @brief Shows queued information box
308 * @fn showInformationBox
310 void showInformationBox();
314 * @brief Slot for automatic update dialog finished.
316 * @result result code
318 void automaticUpdateDialogFinished(int result);
321 * @brief Slot to intercept signal when dialog/information note is processed
323 * @param status Status of the dialog
325 void dialogFinished(int status);
328 * @brief Slot for drawing the fullscreen toggle button
330 * @param size Size of the screen
332 void drawFullScreenButton(const QSize &size);
335 * @brief Slot for drawing the map distance scale
337 * @param size Size of the screen
339 void drawMapScale(const QSize &size);
342 * @brief Slot for drawing the Open Street Map license text
344 * @param size Size of the screen
346 void drawOsmLicense(const QSize &size);
349 * @brief Slot for drawing the own location crosshair
351 * @param size Size of the screen
353 void drawOwnLocationCrosshair(const QSize &size);
356 * @brief Slot to intercept signal when error dialog/information note is processed
358 * @param status Status of the dialog
360 void errorDialogFinished(int status);
363 * @brief Slot for gps timeout.
365 * Called when request timeout occurs.
370 * @brief Slot to load cookies from settings
375 * @brief Slot to intercept signal when webview has finished loading webpage
377 * @param done Status of the loading
379 void loadDone(bool done);
382 * @brief Slot to save cookies to settings
387 * @brief Slot for settings dialog accepted.
389 void settingsDialogAccepted();
392 * @brief Set correnct view port size to datamembers
394 * @param size Size of the screen
396 void setViewPortSize(const QSize &size);
399 * @brief Start location search (open search dialog)
401 void startLocationSearch();
404 * @brief Toggle between fullscreen and normal window mode
406 void toggleFullScreen();
409 * @brief Slot to intercept signal from webview's networkaccessmanager
411 * @param reply Network reply (contains errors)
413 void webViewRequestFinished(QNetworkReply* reply);
415 /*******************************************************************************
417 ******************************************************************************/
420 * @brief Automatic centering setting changed by user
422 * @param enabled True if automatic centering is enabled, otherwise false
424 void autoCenteringTriggered(bool enabled);
427 * @brief Signal that indicates when user has cancelled login process
430 void cancelLoginProcess();
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 Signal when direction and distance from current map center point to current GPS
441 * location is changed
443 * @param direction Direction in degrees
444 * @param distance Distance in meters
445 * @param draw Should the indicator triangle be drawn or not
447 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
450 * @brief Signal for enabling automatic location update.
452 * @param enabled true if enabled, false otherwise
453 * @param updateIntervalMsecs update interval in milliseconds
455 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
458 * @brief Signals error
460 * @param context error context
461 * @param error error code
463 void error(const int context, const int error);
466 * @brief Signal for requesting username from settings
469 void fetchUsernameFromSettings();
472 * @brief Signal for finding user.
474 * @param coordinates user geo coordinates
476 void findUser(const GeoCoordinate &coordinates);
479 * @brief Signals when friend's profile image is ready
483 void friendImageReady(User *user);
486 * @brief GPS setting changed
488 * @param enabled True if GPS is enabled, otherwise false
490 void gpsTriggered(bool enabled);
493 * @brief Signal for finding friend.
495 * @param coordinates friend's geo coordinates
497 void findFriend(const GeoCoordinate &coordinates);
500 * @brief Signal for friend location ready.
504 void friendsLocationsReady(QList<User *> &friendsList);
507 * @brief Emited when location request is parsed and is ready for further processing
509 * @param result List of Location items
511 void locationDataParsed(const QList<Location> &result);
514 * @brief Signal is emitted when location item is clicked on map.
516 * @param userIDs list of friends user IDs in the group
518 void locationItemClicked(const QList<QString> &userIDs);
521 * @brief Signal is emitted when location item is clicked in list.
523 * @param swBound south-west bound in GeoCoorinate
524 * @param neBound north-east bound in GeoCoordinate
526 void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
529 * @brief Signals when Login/Logout action is pressed
532 void loginActionPressed();
535 * @brief MapView has been resized
537 * @param size view size
539 void mapViewResized(const QSize &size);
542 * @brief Forwarding signal from MapView to MapEngine
546 void mapViewScrolled(const SceneCoordinate &coordinate);
549 * @brief Forwarding signal from MapEngine to MapView
551 void maxZoomLevelReached();
554 * @brief Forwarding signal from MapEngine to MapView
556 void minZoomLevelReached();
559 * @brief Forwarding signal from MapEngine to MapScale
561 void newMapResolution(qreal scale);
564 * @brief Signal for refreshing user data.
567 void refreshUserData();
570 * @brief Signal for requesting reverseGeo from SituareEngine
573 void requestReverseGeo();
576 * @brief Signals, when address data is ready
578 * @param address Street address
580 void reverseGeoReady(const QString &address);
583 * @brief Signal for routing to geo coordinates.
585 * @param coordinates destination geo coordinates
587 void routeTo(const GeoCoordinate &coordinates);
590 * @brief Signal to save username to settings
592 * @param username Username
594 void saveUsername(const QString &username);
597 * @brief Signal for location search
599 * @param location QString location
601 void searchForLocation(QString location);
604 * @brief Signal for requestLocationUpdate from SituareEngine
606 * @param status Status message
607 * @param publish Publish on Facebook
609 void statusUpdate(const QString &status, const bool &publish);
612 * @brief Signals when webview's urlChanged signal is emitted
616 void updateCredentials(const QUrl &url);
619 * @brief Signals when updateLocationDialog's data must be cleared
622 void clearUpdateLocationDialogData();
625 * @brief Dragging mode triggered.
627 void draggingModeTriggered();
630 * @brief MapView has finished zooming
632 void viewZoomFinished();
635 * @brief Signal for use location ready.
637 * @param user User object
639 void userLocationReady(User *user);
642 * @brief Map zoom in request
647 * @brief Forwarding signal from MapEngine to MapView
649 void zoomLevelChanged(int zoomLevel);
652 * @brief Map zoom out request
656 /*******************************************************************************
658 ******************************************************************************/
660 bool m_errorShown; ///< Indicates if error dialog/note is shown
661 bool m_loggedIn; ///< Indicates login state
662 bool m_refresh; ///< Indicates when webpage is refreshed
664 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
666 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
667 QAction *m_loginAct; ///< Action to Login/Logout
668 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
669 QAction *m_searchLocationAct; /// @todo this is temporary, remove when not needed!
671 QLabel *m_osmLicense; ///< Label for Open Street Map license
672 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
674 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
675 QList<QDialog *> m_queue; ///< QList type dialog queue
677 QMenu *m_viewMenu; ///< Object that hold the view menu items
679 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
681 QSize m_viewPortSize; ///< Size of the viewport
683 QString m_email; ///< Placeholder for email
684 QString m_password; ///< Placeholder for password
686 QWebView *m_webView; ///< Shows facebook login page
688 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
689 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
690 IndicatorButtonPanel *m_indicatorButtonPanel; ///< Instance of direction indicator button
691 MapScale *m_mapScale; ///< Instance of the map scale
692 MapView *m_mapView; ///< Instance of the map view
693 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
694 RoutingPanel *m_routingPanel; ///< Instance of routing panel
695 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
696 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
697 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
700 #endif // MAINWINDOW_H