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;
51 class SceneCoordinate;
56 class ZoomButtonPanel;
59 * @brief Main Window Class
61 class MainWindow : public QMainWindow
69 * @param parent Parent
71 MainWindow(QWidget *parent = 0);
79 /*******************************************************************************
80 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
81 ******************************************************************************/
84 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
86 void keyPressEvent(QKeyEvent* event);
88 /*******************************************************************************
89 * MEMBER FUNCTIONS AND SLOTS
90 ******************************************************************************/
93 * @brief Clears cookie jar
96 void clearCookieJar();
103 void loggedIn(bool logged);
106 * @brief Gets the login state (logged in/logged out)
108 * @return bool Login state
113 * @brief Reads automatic location update settings.
115 void readAutomaticLocationUpdateSettings();
118 * @brief Enable / disable GPS button.
120 * Does set visibilities for manual location cursor and auto centering menu button.
122 * @param enabled true if enabled, false otherwise
124 void setGPSButtonEnabled(bool enabled);
127 * @brief Enable / disable direction indicator button.
129 * @param enabled true if shoud be enabled, false otherwise
131 void setIndicatorButtonEnabled(bool enabled);
134 * @brief Set scene for MapView
136 * @param scene Scene to be set
138 void setMapViewScene(QGraphicsScene *scene);
141 * Shows dialog with enable automatic location update question.
143 * @param text text to show in dialog
145 void showEnableAutomaticUpdateLocationDialog(const QString &text);
148 * @brief Gets the username from member variable for saving purposes
150 * @return QString Username
152 const QString username();
156 * @brief Build direction indicator button panel and connect signals
158 void buildIndicatorButtonPanel();
161 * @brief Builds information box with message.
163 * @param message Information message
164 * @param modal Modal = true, non-modal false
166 void buildInformationBox(const QString &message, bool modal=false);
169 * @brief Slot for failed login
174 * @brief Slot to intercept signal when login with cookies is requested
176 void loginUsingCookies();
179 * @brief Public slot, which open settings dialog
181 void openSettingsDialog();
184 * @brief Set own location crosshair visibility
188 void setOwnLocationCrosshairVisibility(bool visible);
191 * @brief Sets username to member variable for login dialog
193 * @param username Username to be set
195 void setUsername(const QString &username);
198 * @brief Method to show panels
203 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
207 void startLoginProcess();
210 * @brief Toggle progress indicator.
212 * @param state true if progress indicator should be shown, false otherwise
214 void toggleProgressIndicator(bool state);
217 * @brief Shows / hides Situare related UI items
220 void updateItemVisibility();
224 * @brief Build fullscreen toggle button and connect slots
226 void buildFullScreenButton();
229 * @brief Build friend list panel and connect slots
231 void buildFriendListPanel();
234 * @brief Build manual location setting cross hair and connect slots
236 void buildManualLocationCrosshair();
239 * @brief Build map and connect slots
244 * @brief Build map scale and connect slots
246 void buildMapScale();
249 * @brief Build OSM license and connect slots
251 void buildOsmLicense();
254 * @brief Build application panels
259 * @brief Build user info panel and connect slots
261 void buildUserInfoPanel();
264 * @brief Build webview and connect slots
269 * @brief Build zoom button panel and connect slots
271 void buildZoomButtonPanel();
274 * @brief Private method to create the Menu items
279 * @brief Grab or release HW increase and decrease buttons.
281 * @param grab Use true for grabbing and false for releasing the keys
283 void grabZoomKeys(bool grab);
286 * @brief Queues dialog/information box
288 * @param dialog Dialog to be added into queue
290 void queueDialog(QDialog *dialog);
293 * @brief Shows queued error information box
296 void showErrorInformationBox();
299 * @brief Shows queued information box
301 * @fn showInformationBox
303 void showInformationBox();
307 * @brief Slot for automatic update dialog finished.
309 * @result result code
311 void automaticUpdateDialogFinished(int result);
314 * @brief Slot to intercept signal when dialog/information note is processed
316 * @param status Status of the dialog
318 void dialogFinished(int status);
321 * @brief Slot for drawing the fullscreen toggle button
323 * @param size Size of the screen
325 void drawFullScreenButton(const QSize &size);
328 * @brief Slot for drawing the map distance scale
330 * @param size Size of the screen
332 void drawMapScale(const QSize &size);
335 * @brief Slot for drawing the Open Street Map license text
337 * @param size Size of the screen
339 void drawOsmLicense(const QSize &size);
342 * @brief Slot for drawing the own location crosshair
344 * @param size Size of the screen
346 void drawOwnLocationCrosshair(const QSize &size);
349 * @brief Slot to intercept signal when error dialog/information note is processed
351 * @param status Status of the dialog
353 void errorDialogFinished(int status);
356 * @brief Slot for gps timeout.
358 * Called when request timeout occurs.
363 * @brief Slot to load cookies from settings
368 * @brief Slot to intercept signal when webview has finished loading webpage
370 * @param done Status of the loading
372 void loadDone(bool done);
375 * @brief Slot to save cookies to settings
380 * @brief Slot for settings dialog accepted.
382 void settingsDialogAccepted();
385 * @brief Set correnct view port size to datamembers
387 * @param size Size of the screen
389 void setViewPortSize(const QSize &size);
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 View should be centered to new location
428 * @param coordinate Scene coordinates of the new center point
430 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
433 * @brief Signal when direction and distance from current map center point to current GPS
434 * location is changed
436 * @param direction Direction in degrees
437 * @param distance Distance in meters
438 * @param draw Should the indicator triangle be drawn or not
440 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
443 * @brief Signal for enabling automatic location update.
445 * @param enabled true if enabled, false otherwise
446 * @param updateIntervalMsecs update interval in milliseconds
448 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
451 * @brief Signals error
453 * @param context error context
454 * @param error error code
456 void error(const int context, const int error);
459 * @brief Signal for requesting username from settings
462 void fetchUsernameFromSettings();
465 * @brief Signal for finding user.
467 * @param coordinates user geo coordinates
469 void findUser(const GeoCoordinate &coordinates);
472 * @brief Signals when friend's profile image is ready
476 void friendImageReady(User *user);
479 * @brief GPS setting changed
481 * @param enabled True if GPS is enabled, otherwise false
483 void gpsTriggered(bool enabled);
486 * @brief Signal for finding friend.
488 * @param coordinates friend's geo coordinates
490 void findFriend(const GeoCoordinate &coordinates);
493 * @brief Signal for friend location ready.
497 void friendsLocationsReady(QList<User *> &friendsList);
500 * @brief Signal is emitted when location item is clicked.
502 * @param userIDs list of friends user IDs in the group
504 void locationItemClicked(const QList<QString> &userIDs);
507 * @brief Signals when Login/Logout action is pressed
510 void loginActionPressed();
513 * @brief MapView has been resized
515 * @param size view size
517 void mapViewResized(const QSize &size);
520 * @brief Forwarding signal from MapView to MapEngine
524 void mapViewScrolled(const SceneCoordinate &coordinate);
527 * @brief Forwarding signal from MapEngine to MapView
529 void maxZoomLevelReached();
532 * @brief Forwarding signal from MapEngine to MapView
534 void minZoomLevelReached();
537 * @brief Forwarding signal from MapEngine to MapScale
539 void newMapResolution(qreal scale);
542 * @brief Signal for refreshing user data.
545 void refreshUserData();
548 * @brief Signal for requesting reverseGeo from SituareEngine
551 void requestReverseGeo();
554 * @brief Signals, when address data is ready
556 * @param address Street address
558 void reverseGeoReady(const QString &address);
561 * @brief Signal to save username to settings
563 * @param username Username
565 void saveUsername(const QString &username);
568 * @brief Signal for location search
570 * @param location QString location
572 void searchForLocation(QString location);
575 * @brief Signal for requestLocationUpdate from SituareEngine
577 * @param status Status message
578 * @param publish Publish on Facebook
580 void statusUpdate(const QString &status, const bool &publish);
583 * @brief Signals when webview's urlChanged signal is emitted
587 void updateCredentials(const QUrl &url);
590 * @brief Signals when updateLocationDialog's data must be cleared
593 void clearUpdateLocationDialogData();
596 * @brief Dragging mode triggered.
598 void draggingModeTriggered();
601 * @brief MapView has finished zooming
603 void viewZoomFinished();
606 * @brief Signal for use location ready.
608 * @param user User object
610 void userLocationReady(User *user);
613 * @brief Map zoom in request
618 * @brief Forwarding signal from MapEngine to MapView
620 void zoomLevelChanged(int zoomLevel);
623 * @brief Map zoom out request
627 /*******************************************************************************
629 ******************************************************************************/
631 bool m_errorShown; ///< Indicates if error dialog/note is shown
632 bool m_loggedIn; ///< Indicates login state
633 bool m_refresh; ///< Indicates when webpage is refreshed
635 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
637 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
638 QAction *m_loginAct; ///< Action to Login/Logout
639 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
640 QAction *m_searchLocationAct; /// @todo this is temporary, remove when not needed!
642 QLabel *m_osmLicense; ///< Label for Open Street Map license
643 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
645 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
646 QList<QDialog *> m_queue; ///< QList type dialog queue
648 QMenu *m_viewMenu; ///< Object that hold the view menu items
650 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
652 QSize m_viewPortSize; ///< Size of the viewport
654 QString m_email; ///< Placeholder for email
655 QString m_password; ///< Placeholder for password
657 QWebView *m_webView; ///< Shows facebook login page
659 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
660 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
661 IndicatorButtonPanel *m_indicatorButtonPanel; ///< Instance of direction indicator button
662 MapScale *m_mapScale; ///< Instance of the map scale
663 MapView *m_mapView; ///< Instance of the map view
664 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
665 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
666 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
667 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
670 #endif // MAINWINDOW_H