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 user info panel and connect slots
254 void buildUserInfoPanel();
257 * @brief Build webview and connect slots
262 * @brief Build zoom button panel and connect slots
264 void buildZoomButtonPanel();
267 * @brief Private method to create the Menu items
272 * @brief Grab or release HW increase and decrease buttons.
274 * @param grab Use true for grabbing and false for releasing the keys
276 void grabZoomKeys(bool grab);
279 * @brief Queues dialog/information box
281 * @param dialog Dialog to be added into queue
283 void queueDialog(QDialog *dialog);
286 * @brief Shows queued error information box
289 void showErrorInformationBox();
292 * @brief Shows queued information box
294 * @fn showInformationBox
296 void showInformationBox();
300 * @brief Slot for automatic update dialog finished.
302 * @result result code
304 void automaticUpdateDialogFinished(int result);
307 * @brief Slot to intercept signal when dialog/information note is processed
309 * @param status Status of the dialog
311 void dialogFinished(int status);
314 * @brief Slot for drawing the fullscreen toggle button
316 * @param size Size of the screen
318 void drawFullScreenButton(const QSize &size);
321 * @brief Slot for drawing the map distance scale
323 * @param size Size of the screen
325 void drawMapScale(const QSize &size);
328 * @brief Slot for drawing the Open Street Map license text
330 * @param size Size of the screen
332 void drawOsmLicense(const QSize &size);
335 * @brief Slot for drawing the own location crosshair
337 * @param size Size of the screen
339 void drawOwnLocationCrosshair(const QSize &size);
342 * @brief Slot to intercept signal when error dialog/information note is processed
344 * @param status Status of the dialog
346 void errorDialogFinished(int status);
349 * @brief Slot for gps timeout.
351 * Called when request timeout occurs.
356 * @brief Slot to load cookies from settings
361 * @brief Slot to intercept signal when webview has finished loading webpage
363 * @param done Status of the loading
365 void loadDone(bool done);
368 * @brief Slot to save cookies to settings
373 * @brief Slot for settings dialog accepted.
375 void settingsDialogAccepted();
378 * @brief Set correnct view port size to datamembers
380 * @param size Size of the screen
382 void setViewPortSize(const QSize &size);
385 * @brief Start location search (open search dialog)
387 void startLocationSearch();
390 * @brief Toggle between fullscreen and normal window mode
392 void toggleFullScreen();
395 * @brief Slot to intercept signal from webview's networkaccessmanager
397 * @param reply Network reply (contains errors)
399 void webViewRequestFinished(QNetworkReply* reply);
401 /*******************************************************************************
403 ******************************************************************************/
406 * @brief Automatic centering setting changed by user
408 * @param enabled True if automatic centering is enabled, otherwise false
410 void autoCenteringTriggered(bool enabled);
413 * @brief Signal that indicates when user has cancelled login process
416 void cancelLoginProcess();
419 * @brief View should be centered to new location
421 * @param coordinate Scene coordinates of the new center point
423 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
426 * @brief Signal for enabling automatic location update.
428 * @param enabled true if enabled, false otherwise
429 * @param updateIntervalMsecs update interval in milliseconds
431 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
434 * @brief Signals error
436 * @param context error context
437 * @param error error code
439 void error(const int context, const int error);
442 * @brief Signal for requesting username from settings
445 void fetchUsernameFromSettings();
448 * @brief Signal for finding user.
450 * @param coordinates user geo coordinates
452 void findUser(const GeoCoordinate &coordinates);
455 * @brief Signals when friend's profile image is ready
459 void friendImageReady(User *user);
462 * @brief GPS setting changed
464 * @param enabled True if GPS is enabled, otherwise false
466 void gpsTriggered(bool enabled);
469 * @brief Signal for finding friend.
471 * @param coordinates friend's geo coordinates
473 void findFriend(const GeoCoordinate &coordinates);
476 * @brief Signal for friend location ready.
480 void friendsLocationsReady(QList<User *> &friendsList);
483 * @brief Signal is emitted when location item is clicked.
485 * @param userIDs list of friends user IDs in the group
487 void locationItemClicked(const QList<QString> &userIDs);
490 * @brief Signals when Login/Logout action is pressed
493 void loginActionPressed();
496 * @brief MapView has been resized
498 * @param size view size
500 void mapViewResized(const QSize &size);
503 * @brief Forwarding signal from MapView to MapEngine
507 void mapViewScrolled(const SceneCoordinate &coordinate);
510 * @brief Forwarding signal from MapEngine to MapView
512 void maxZoomLevelReached();
515 * @brief Forwarding signal from MapEngine to MapView
517 void minZoomLevelReached();
520 * @brief Forwarding signal from MapEngine to MapScale
522 void newMapResolution(qreal scale);
525 * @brief Signal for refreshing user data.
528 void refreshUserData();
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 Signal to save username to settings
546 * @param username Username
548 void saveUsername(const QString &username);
551 * @brief Signal for location search
553 * @param location QString location
555 void searchForLocation(QString location);
558 * @brief Signal for requestLocationUpdate from SituareEngine
560 * @param status Status message
561 * @param publish Publish on Facebook
563 void statusUpdate(const QString &status, const bool &publish);
566 * @brief Signals when webview's urlChanged signal is emitted
570 void updateCredentials(const QUrl &url);
573 * @brief Signals when updateLocationDialog's data must be cleared
576 void clearUpdateLocationDialogData();
579 * @brief Dragging mode triggered.
581 void draggingModeTriggered();
584 * @brief MapView has finished zooming
586 void viewZoomFinished();
589 * @brief Signal for use location ready.
591 * @param user User object
593 void userLocationReady(User *user);
596 * @brief Map zoom in request
601 * @brief Forwarding signal from MapEngine to MapView
603 void zoomLevelChanged(int zoomLevel);
606 * @brief Map zoom out request
610 /*******************************************************************************
612 ******************************************************************************/
614 bool m_errorShown; ///< Indicates if error dialog/note is shown
615 bool m_loggedIn; ///< Indicates login state
616 bool m_refresh; ///< Indicates when webpage is refreshed
618 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
620 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
621 QAction *m_loginAct; ///< Action to Login/Logout
622 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
623 QAction *m_searchLocationAct; /// @todo this is temporary, remove when not needed!
625 QLabel *m_osmLicense; ///< Label for Open Street Map license
626 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
628 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
629 QList<QDialog *> m_queue; ///< QList type dialog queue
631 QMenu *m_viewMenu; ///< Object that hold the view menu items
633 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
635 QSize m_viewPortSize; ///< Size of the viewport
637 QString m_email; ///< Placeholder for email
638 QString m_password; ///< Placeholder for password
640 QWebView *m_webView; ///< Shows facebook login page
642 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
643 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
644 IndicatorButton *m_indicatorButton; ///< Instance of direction indicator button
645 MapScale *m_mapScale; ///< Instance of the map scale
646 MapView *m_mapView; ///< Instance of the map view
647 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
648 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
649 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
650 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
653 #endif // MAINWINDOW_H