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 Sami Rämö - sami.ramo@ixonos.com
8 Katri Kaikkonen - katri.kaikkonen@ixonos.com
10 Situare is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 version 2 as published by the Free Software Foundation.
14 Situare is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Situare; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
28 #include <QtGui/QMainWindow>
31 #include "network/networkcookiejar.h"
40 class FacebookAuthentication;
41 class FullScreenButton;
42 class FriendListPanel;
43 class IndicatorButton;
50 class SceneCoordinate;
54 class ZoomButtonPanel;
57 * @brief Main Window Class
59 class MainWindow : public QMainWindow
67 * @param parent Parent
69 MainWindow(QWidget *parent = 0);
77 /*******************************************************************************
78 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
79 ******************************************************************************/
82 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
84 void keyPressEvent(QKeyEvent* event);
86 /*******************************************************************************
87 * MEMBER FUNCTIONS AND SLOTS
88 ******************************************************************************/
91 * @brief Clears cookie jar
94 void clearCookieJar();
101 void loggedIn(bool logged);
104 * @brief Gets the login state (logged in/logged out)
106 * @return bool Login state
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);
146 * @brief Gets the username from member variable for saving purposes
148 * @return QString Username
150 const QString username();
154 * @brief Build direction indicator button and connect slots
156 void buildIndicatorButton();
159 * @brief Builds information box with message.
161 * @param message Information message
162 * @param modal Modal = true, non-modal false
164 void buildInformationBox(const QString &message, bool modal=false);
167 * @brief Slot for failed login
172 * @brief Slot to intercept signal when login with cookies is requested
174 void loginUsingCookies();
177 * @brief Public slot, which open settings dialog
179 void openSettingsDialog();
182 * @brief Set own location crosshair visibility
186 void setOwnLocationCrosshairVisibility(bool visible);
189 * @brief Sets username to member variable for login dialog
191 * @param username Username to be set
193 void setUsername(const QString &username);
196 * @brief Method to show panels
201 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
205 void startLoginProcess();
208 * @brief Toggle progress indicator.
210 * @param state true if progress indicator should be shown, false otherwise
212 void toggleProgressIndicator(bool state);
215 * @brief Shows / hides Situare related UI items
218 void updateItemVisibility();
222 * @brief Build fullscreen toggle button and connect slots
224 void buildFullScreenButton();
227 * @brief Build friend list panel and connect slots
229 void buildFriendListPanel();
232 * @brief Build manual location setting cross hair and connect slots
234 void buildManualLocationCrosshair();
237 * @brief Build map and connect slots
242 * @brief Build map scale and connect slots
244 void buildMapScale();
247 * @brief Build OSM license and connect slots
249 void buildOsmLicense();
252 * @brief Build application panels
257 * @brief Build user info panel and connect slots
259 void buildUserInfoPanel();
262 * @brief Build webview and connect slots
267 * @brief Build zoom button panel and connect slots
269 void buildZoomButtonPanel();
272 * @brief Private method to create the Menu items
277 * @brief Grab or release HW increase and decrease buttons.
279 * @param grab Use true for grabbing and false for releasing the keys
281 void grabZoomKeys(bool grab);
284 * @brief Queues dialog/information box
286 * @param dialog Dialog to be added into queue
288 void queueDialog(QDialog *dialog);
291 * @brief Shows queued error information box
294 void showErrorInformationBox();
297 * @brief Shows queued information box
299 * @fn showInformationBox
301 void showInformationBox();
305 * @brief Slot for automatic update dialog finished.
307 * @result result code
309 void automaticUpdateDialogFinished(int result);
312 * @brief Slot to intercept signal when dialog/information note is processed
314 * @param status Status of the dialog
316 void dialogFinished(int status);
319 * @brief Slot for drawing the fullscreen toggle button
321 * @param size Size of the screen
323 void drawFullScreenButton(const QSize &size);
326 * @brief Slot for drawing the map distance scale
328 * @param size Size of the screen
330 void drawMapScale(const QSize &size);
333 * @brief Slot for drawing the Open Street Map license text
335 * @param size Size of the screen
337 void drawOsmLicense(const QSize &size);
340 * @brief Slot for drawing the own location crosshair
342 * @param size Size of the screen
344 void drawOwnLocationCrosshair(const QSize &size);
347 * @brief Slot to intercept signal when error dialog/information note is processed
349 * @param status Status of the dialog
351 void errorDialogFinished(int status);
354 * @brief Slot for gps timeout.
356 * Called when request timeout occurs.
361 * @brief Slot to load cookies from settings
366 * @brief Slot to intercept signal when webview has finished loading webpage
368 * @param done Status of the loading
370 void loadDone(bool done);
373 * @brief Slot to save cookies to settings
378 * @brief Slot for settings dialog accepted.
380 void settingsDialogAccepted();
383 * @brief Set correnct view port size to datamembers
385 * @param size Size of the screen
387 void setViewPortSize(const QSize &size);
390 * @brief Start location search (open search dialog)
392 void startLocationSearch();
395 * @brief Toggle between fullscreen and normal window mode
397 void toggleFullScreen();
400 * @brief Slot to intercept signal from webview's networkaccessmanager
402 * @param reply Network reply (contains errors)
404 void webViewRequestFinished(QNetworkReply* reply);
406 /*******************************************************************************
408 ******************************************************************************/
411 * @brief Automatic centering setting changed by user
413 * @param enabled True if automatic centering is enabled, otherwise false
415 void autoCenteringTriggered(bool enabled);
418 * @brief Signal that indicates when user has cancelled login process
421 void cancelLoginProcess();
424 * @brief View should be centered to new location
426 * @param coordinate Scene coordinates of the new center point
428 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
431 * @brief Signal for enabling automatic location update.
433 * @param enabled true if enabled, false otherwise
434 * @param updateIntervalMsecs update interval in milliseconds
436 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
439 * @brief Signals error
441 * @param context error context
442 * @param error error code
444 void error(const int context, const int error);
447 * @brief Signal for requesting username from settings
450 void fetchUsernameFromSettings();
453 * @brief Signal for finding user.
455 * @param coordinates user geo coordinates
457 void findUser(const GeoCoordinate &coordinates);
460 * @brief Signals when friend's profile image is ready
464 void friendImageReady(User *user);
467 * @brief GPS setting changed
469 * @param enabled True if GPS is enabled, otherwise false
471 void gpsTriggered(bool enabled);
474 * @brief Signal for finding friend.
476 * @param coordinates friend's geo coordinates
478 void findFriend(const GeoCoordinate &coordinates);
481 * @brief Signal for friend location ready.
485 void friendsLocationsReady(QList<User *> &friendsList);
488 * @brief Signal is emitted when location item is clicked.
490 * @param userIDs list of friends user IDs in the group
492 void locationItemClicked(const QList<QString> &userIDs);
495 * @brief Signals when Login/Logout action is pressed
498 void loginActionPressed();
501 * @brief MapView has been resized
503 * @param size view size
505 void mapViewResized(const QSize &size);
508 * @brief Forwarding signal from MapView to MapEngine
512 void mapViewScrolled(const SceneCoordinate &coordinate);
515 * @brief Forwarding signal from MapEngine to MapView
517 void maxZoomLevelReached();
520 * @brief Forwarding signal from MapEngine to MapView
522 void minZoomLevelReached();
525 * @brief Forwarding signal from MapEngine to MapScale
527 void newMapResolution(qreal scale);
530 * @brief Signal for refreshing user data.
533 void refreshUserData();
536 * @brief Signal for requesting reverseGeo from SituareEngine
539 void requestReverseGeo();
542 * @brief Signals, when address data is ready
544 * @param address Street address
546 void reverseGeoReady(const QString &address);
549 * @brief Signal to save username to settings
551 * @param username Username
553 void saveUsername(const QString &username);
556 * @brief Signal for location search
558 * @param location QString location
560 void searchForLocation(QString location);
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 webview's urlChanged signal is emitted
575 void updateCredentials(const QUrl &url);
578 * @brief Signals when updateLocationDialog's data must be cleared
581 void clearUpdateLocationDialogData();
584 * @brief Dragging mode triggered.
586 void draggingModeTriggered();
589 * @brief MapView has finished zooming
591 void viewZoomFinished();
594 * @brief Signal for use location ready.
596 * @param user User object
598 void userLocationReady(User *user);
601 * @brief Map zoom in request
606 * @brief Forwarding signal from MapEngine to MapView
608 void zoomLevelChanged(int zoomLevel);
611 * @brief Map zoom out request
615 /*******************************************************************************
617 ******************************************************************************/
619 bool m_errorShown; ///< Indicates if error dialog/note is shown
620 bool m_loggedIn; ///< Indicates login state
621 bool m_refresh; ///< Indicates when webpage is refreshed
623 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
625 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
626 QAction *m_loginAct; ///< Action to Login/Logout
627 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
628 QAction *m_searchLocationAct; /// @todo this is temporary, remove when not needed!
630 QLabel *m_osmLicense; ///< Label for Open Street Map license
631 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
633 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
634 QList<QDialog *> m_queue; ///< QList type dialog queue
636 QMenu *m_viewMenu; ///< Object that hold the view menu items
638 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
640 QSize m_viewPortSize; ///< Size of the viewport
642 QString m_email; ///< Placeholder for email
643 QString m_password; ///< Placeholder for password
645 QWebView *m_webView; ///< Shows facebook login page
647 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
648 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
649 IndicatorButton *m_indicatorButton; ///< Instance of direction indicator button
650 MapScale *m_mapScale; ///< Instance of the map scale
651 MapView *m_mapView; ///< Instance of the map view
652 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
653 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
654 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
655 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
658 #endif // MAINWINDOW_H