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 Katri Kaikkonen - katri.kaikkonen@ixonos.com
11 Situare is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 version 2 as published by the Free Software Foundation.
15 Situare is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with Situare; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
29 #include <QtGui/QMainWindow>
32 #include "network/networkcookiejar.h"
41 class FacebookAuthentication;
42 class FullScreenButton;
43 class FriendListPanel;
44 class IndicatorButton;
52 class SceneCoordinate;
56 class ZoomButtonPanel;
60 * @brief Main Window Class
62 class MainWindow : public QMainWindow
70 * @param parent Parent
72 MainWindow(QWidget *parent = 0);
80 /*******************************************************************************
81 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
82 ******************************************************************************/
85 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
87 void keyPressEvent(QKeyEvent* event);
89 /*******************************************************************************
90 * MEMBER FUNCTIONS AND SLOTS
91 ******************************************************************************/
94 * @brief Clears cookie jar
97 void clearCookieJar();
104 void loggedIn(bool logged);
107 * @brief Gets the login state (logged in/logged out)
109 * @return bool Login state
114 * @brief Reads automatic location update settings.
116 void readAutomaticLocationUpdateSettings();
119 * @brief Enable / disable GPS button.
121 * Does set visibilities for manual location cursor and auto centering menu button.
123 * @param enabled true if enabled, false otherwise
125 void setGPSButtonEnabled(bool enabled);
128 * @brief Enable / disable direction indicator button.
130 * @param enabled true if shoud be enabled, false otherwise
132 void setIndicatorButtonEnabled(bool enabled);
135 * @brief Set scene for MapView
137 * @param scene Scene to be set
139 void setMapViewScene(QGraphicsScene *scene);
142 * Shows dialog with enable automatic location update question.
144 * @param text text to show in dialog
146 void showEnableAutomaticUpdateLocationDialog(const QString &text);
149 * @brief Gets the username from member variable for saving purposes
151 * @return QString Username
153 const QString username();
157 * @brief Build direction indicator button and connect slots
159 void buildIndicatorButton();
162 * @brief Builds information box with message.
164 * @param message Information message
165 * @param modal Modal = true, non-modal false
167 void buildInformationBox(const QString &message, bool modal=false);
170 * @brief Slot for failed login
175 * @brief Slot to intercept signal when login with cookies is requested
177 void loginUsingCookies();
180 * @brief Public slot, which open settings dialog
182 void openSettingsDialog();
185 * @brief Set own location crosshair visibility
189 void setOwnLocationCrosshairVisibility(bool visible);
192 * @brief Sets username to member variable for login dialog
194 * @param username Username to be set
196 void setUsername(const QString &username);
199 * @brief Method to show panels
204 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
208 void startLoginProcess();
211 * @brief Toggle progress indicator.
213 * @param state true if progress indicator should be shown, false otherwise
215 void toggleProgressIndicator(bool state);
218 * @brief Shows / hides Situare related UI items
221 void updateItemVisibility();
225 * @brief Build fullscreen toggle button and connect slots
227 void buildFullScreenButton();
230 * @brief Build friend list panel and connect slots
232 void buildFriendListPanel();
235 * @brief Build manual location setting cross hair and connect slots
237 void buildManualLocationCrosshair();
240 * @brief Build map and connect slots
245 * @brief Build map scale and connect slots
247 void buildMapScale();
250 * @brief Build OSM license and connect slots
252 void buildOsmLicense();
255 * @brief Build application panels
260 * @brief Build routing panel and connect slots
262 void buildRoutingPanel();
265 * @brief Build user info panel and connect slots
267 void buildUserInfoPanel();
270 * @brief Build webview and connect slots
275 * @brief Build zoom button panel and connect slots
277 void buildZoomButtonPanel();
280 * @brief Private method to create the Menu items
285 * @brief Grab or release HW increase and decrease buttons.
287 * @param grab Use true for grabbing and false for releasing the keys
289 void grabZoomKeys(bool grab);
292 * @brief Queues dialog/information box
294 * @param dialog Dialog to be added into queue
296 void queueDialog(QDialog *dialog);
299 * @brief Shows queued error information box
302 void showErrorInformationBox();
305 * @brief Shows queued information box
307 * @fn showInformationBox
309 void showInformationBox();
313 * @brief Slot for automatic update dialog finished.
315 * @result result code
317 void automaticUpdateDialogFinished(int result);
320 * @brief Slot to intercept signal when dialog/information note is processed
322 * @param status Status of the dialog
324 void dialogFinished(int status);
327 * @brief Slot for drawing the fullscreen toggle button
329 * @param size Size of the screen
331 void drawFullScreenButton(const QSize &size);
334 * @brief Slot for drawing the map distance scale
336 * @param size Size of the screen
338 void drawMapScale(const QSize &size);
341 * @brief Slot for drawing the Open Street Map license text
343 * @param size Size of the screen
345 void drawOsmLicense(const QSize &size);
348 * @brief Slot for drawing the own location crosshair
350 * @param size Size of the screen
352 void drawOwnLocationCrosshair(const QSize &size);
355 * @brief Slot to intercept signal when error dialog/information note is processed
357 * @param status Status of the dialog
359 void errorDialogFinished(int status);
362 * @brief Slot for gps timeout.
364 * Called when request timeout occurs.
369 * @brief Slot to load cookies from settings
374 * @brief Slot to intercept signal when webview has finished loading webpage
376 * @param done Status of the loading
378 void loadDone(bool done);
381 * @brief Slot to save cookies to settings
386 * @brief Slot for settings dialog accepted.
388 void settingsDialogAccepted();
391 * @brief Set correnct view port size to datamembers
393 * @param size Size of the screen
395 void setViewPortSize(const QSize &size);
398 * @brief Start location search (open search dialog)
400 void startLocationSearch();
403 * @brief Toggle between fullscreen and normal window mode
405 void toggleFullScreen();
408 * @brief Slot to intercept signal from webview's networkaccessmanager
410 * @param reply Network reply (contains errors)
412 void webViewRequestFinished(QNetworkReply* reply);
414 /*******************************************************************************
416 ******************************************************************************/
419 * @brief Automatic centering setting changed by user
421 * @param enabled True if automatic centering is enabled, otherwise false
423 void autoCenteringTriggered(bool enabled);
426 * @brief Signal that indicates when user has cancelled login process
429 void cancelLoginProcess();
432 * @brief View should be centered to new location
434 * @param coordinate Scene coordinates of the new center point
436 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
439 * @brief Signal for enabling automatic location update.
441 * @param enabled true if enabled, false otherwise
442 * @param updateIntervalMsecs update interval in milliseconds
444 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
447 * @brief Signals error
449 * @param context error context
450 * @param error error code
452 void error(const int context, const int error);
455 * @brief Signal for requesting username from settings
458 void fetchUsernameFromSettings();
461 * @brief Signal for finding user.
463 * @param coordinates user geo coordinates
465 void findUser(const GeoCoordinate &coordinates);
468 * @brief Signals when friend's profile image is ready
472 void friendImageReady(User *user);
475 * @brief GPS setting changed
477 * @param enabled True if GPS is enabled, otherwise false
479 void gpsTriggered(bool enabled);
482 * @brief Signal for finding friend.
484 * @param coordinates friend's geo coordinates
486 void findFriend(const GeoCoordinate &coordinates);
489 * @brief Signal for friend location ready.
493 void friendsLocationsReady(QList<User *> &friendsList);
496 * @brief Emited when location request is parsed and is ready for further processing
498 * @param result List of Location items
500 void locationDataParsed(const QList<Location> &result);
503 * @brief Signal is emitted when location item is clicked on map.
505 * @param userIDs list of friends user IDs in the group
507 void locationItemClicked(const QList<QString> &userIDs);
510 * @brief Signal is emitted when location item is clicked in list.
512 * @param swBound south-west bound in GeoCoorinate
513 * @param neBound north-east bound in GeoCoordinate
515 void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
518 * @brief Signals when Login/Logout action is pressed
521 void loginActionPressed();
524 * @brief MapView has been resized
526 * @param size view size
528 void mapViewResized(const QSize &size);
531 * @brief Forwarding signal from MapView to MapEngine
535 void mapViewScrolled(const SceneCoordinate &coordinate);
538 * @brief Forwarding signal from MapEngine to MapView
540 void maxZoomLevelReached();
543 * @brief Forwarding signal from MapEngine to MapView
545 void minZoomLevelReached();
548 * @brief Forwarding signal from MapEngine to MapScale
550 void newMapResolution(qreal scale);
553 * @brief Signal for refreshing user data.
556 void refreshUserData();
559 * @brief Signal for requesting reverseGeo from SituareEngine
562 void requestReverseGeo();
565 * @brief Signals, when address data is ready
567 * @param address Street address
569 void reverseGeoReady(const QString &address);
572 * @brief Signal to save username to settings
574 * @param username Username
576 void saveUsername(const QString &username);
579 * @brief Signal for location search
581 * @param location QString location
583 void searchForLocation(QString location);
586 * @brief Signal for requestLocationUpdate from SituareEngine
588 * @param status Status message
589 * @param publish Publish on Facebook
591 void statusUpdate(const QString &status, const bool &publish);
594 * @brief Signals when webview's urlChanged signal is emitted
598 void updateCredentials(const QUrl &url);
601 * @brief Signals when updateLocationDialog's data must be cleared
604 void clearUpdateLocationDialogData();
607 * @brief Dragging mode triggered.
609 void draggingModeTriggered();
612 * @brief MapView has finished zooming
614 void viewZoomFinished();
617 * @brief Signal for use location ready.
619 * @param user User object
621 void userLocationReady(User *user);
624 * @brief Map zoom in request
629 * @brief Forwarding signal from MapEngine to MapView
631 void zoomLevelChanged(int zoomLevel);
634 * @brief Map zoom out request
638 /*******************************************************************************
640 ******************************************************************************/
642 bool m_errorShown; ///< Indicates if error dialog/note is shown
643 bool m_loggedIn; ///< Indicates login state
644 bool m_refresh; ///< Indicates when webpage is refreshed
646 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
648 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
649 QAction *m_loginAct; ///< Action to Login/Logout
650 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
651 QAction *m_searchLocationAct; /// @todo this is temporary, remove when not needed!
653 QLabel *m_osmLicense; ///< Label for Open Street Map license
654 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
656 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
657 QList<QDialog *> m_queue; ///< QList type dialog queue
659 QMenu *m_viewMenu; ///< Object that hold the view menu items
661 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
663 QSize m_viewPortSize; ///< Size of the viewport
665 QString m_email; ///< Placeholder for email
666 QString m_password; ///< Placeholder for password
668 QWebView *m_webView; ///< Shows facebook login page
670 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
671 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
672 IndicatorButton *m_indicatorButton; ///< Instance of direction indicator button
673 MapScale *m_mapScale; ///< Instance of the map scale
674 MapView *m_mapView; ///< Instance of the map view
675 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
676 RoutingPanel *m_routingPanel; ///< Instance of routing panel
677 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
678 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
679 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
682 #endif // MAINWINDOW_H