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;
52 class SceneCoordinate;
56 class ZoomButtonPanel;
59 * @brief Main Window Class
61 class MainWindow : public QMainWindow
69 * @param parent Parent
71 MainWindow(QWidget *parent = 0);
78 /*******************************************************************************
79 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
80 ******************************************************************************/
83 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
85 void keyPressEvent(QKeyEvent* event);
87 /*******************************************************************************
88 * MEMBER FUNCTIONS AND SLOTS
89 ******************************************************************************/
92 * @brief Clears cookie jar
95 void clearCookieJar();
102 void loggedIn(bool logged);
105 * @brief Gets the login state (logged in/logged out)
107 * @return bool Login state
112 * @brief Reads automatic location update settings.
114 void readAutomaticLocationUpdateSettings();
117 * @brief Enable / disable GPS button.
119 * Does set visibilities for manual location cursor and auto centering menu button.
121 * @param enabled true if enabled, false otherwise
123 void setGPSButtonEnabled(bool enabled);
126 * @brief Enable / disable direction indicator button.
128 * @param enabled true if shoud be enabled, false otherwise
130 void setIndicatorButtonEnabled(bool enabled);
133 * @brief Set scene for MapView
135 * @param scene Scene to be set
137 void setMapViewScene(QGraphicsScene *scene);
140 * Shows dialog with enable automatic location update question.
142 * @param text text to show in dialog
144 void showEnableAutomaticUpdateLocationDialog(const QString &text);
147 * @brief Gets the username from member variable for saving purposes
149 * @return QString Username
151 const QString username();
155 * @brief Build direction indicator button panel and connect signals
157 void buildIndicatorButtonPanel();
160 * @brief Builds information box with message.
162 * @param message Information message
163 * @param modal Modal = true, non-modal false
165 void buildInformationBox(const QString &message, bool modal=false);
168 * @brief Slot for failed login
173 * @brief Slot to intercept signal when login with cookies is requested
175 void loginUsingCookies();
178 * @brief Public slot, which open settings dialog
180 void openSettingsDialog();
183 * @brief Set own location crosshair visibility
187 void setOwnLocationCrosshairVisibility(bool visible);
190 * @brief Sets username to member variable for login dialog
192 * @param username Username to be set
194 void setUsername(const QString &username);
197 * @brief Method to show panels
202 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
206 void startLoginProcess();
209 * @brief Toggle progress indicator.
211 * @param state true if progress indicator should be shown, false otherwise
213 void toggleProgressIndicator(bool state);
216 * @brief Shows / hides Situare related UI items
219 void updateItemVisibility();
223 * @brief Build fullscreen toggle button and connect slots
225 void buildFullScreenButton();
228 * @brief Build friend list panel and connect slots
230 void buildFriendListPanel();
233 * @brief Build manual location setting cross hair and connect slots
235 void buildManualLocationCrosshair();
238 * @brief Build map and connect slots
243 * @brief Build map scale and connect slots
245 void buildMapScale();
248 * @brief Build OSM license and connect slots
250 void buildOsmLicense();
253 * @brief Build application panels
258 * @brief Build user info panel and connect slots
260 void buildUserInfoPanel();
263 * @brief Build webview and connect slots
268 * @brief Build zoom button panel and connect slots
270 void buildZoomButtonPanel();
273 * @brief Private method to create the Menu items
278 * @brief Grab or release HW increase and decrease buttons.
280 * @param grab Use true for grabbing and false for releasing the keys
282 void grabZoomKeys(bool grab);
285 * @brief Queues dialog/information box
287 * @param dialog Dialog to be added into queue
289 void queueDialog(QDialog *dialog);
292 * @brief Shows queued error information box
295 void showErrorInformationBox();
298 * @brief Shows queued information box
300 * @fn showInformationBox
302 void showInformationBox();
306 * @brief Slot for automatic update dialog finished.
308 * @result result code
310 void automaticUpdateDialogFinished(int result);
313 * @brief Slot to intercept signal when dialog/information note is processed
315 * @param status Status of the dialog
317 void dialogFinished(int status);
320 * @brief Slot for drawing the fullscreen toggle button
322 * @param size Size of the screen
324 void drawFullScreenButton(const QSize &size);
327 * @brief Slot for drawing the map distance scale
329 * @param size Size of the screen
331 void drawMapScale(const QSize &size);
334 * @brief Slot for drawing the Open Street Map license text
336 * @param size Size of the screen
338 void drawOsmLicense(const QSize &size);
341 * @brief Slot for drawing the own location crosshair
343 * @param size Size of the screen
345 void drawOwnLocationCrosshair(const QSize &size);
348 * @brief Slot to intercept signal when error dialog/information note is processed
350 * @param status Status of the dialog
352 void errorDialogFinished(int status);
355 * @brief Slot for gps timeout.
357 * Called when request timeout occurs.
362 * @brief Slot to load cookies from settings
367 * @brief Slot to intercept signal when webview has finished loading webpage
369 * @param done Status of the loading
371 void loadDone(bool done);
374 * @brief Slot to save cookies to settings
379 * @brief Slot for settings dialog accepted.
381 void settingsDialogAccepted();
384 * @brief Set correnct view port size to datamembers
386 * @param size Size of the screen
388 void setViewPortSize(const QSize &size);
391 * @brief Start location search (open search dialog)
393 void startLocationSearch();
396 * @brief Toggle between fullscreen and normal window mode
398 void toggleFullScreen();
401 * @brief Slot to intercept signal from webview's networkaccessmanager
403 * @param reply Network reply (contains errors)
405 void webViewRequestFinished(QNetworkReply* reply);
407 /*******************************************************************************
409 ******************************************************************************/
412 * @brief Automatic centering setting changed by user
414 * @param enabled True if automatic centering is enabled, otherwise false
416 void autoCenteringTriggered(bool enabled);
419 * @brief Signal that indicates when user has cancelled login process
422 void cancelLoginProcess();
425 * @brief View should be centered to new location
427 * @param coordinate Scene coordinates of the new center point
429 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
432 * @brief Signal when direction and distance from current map center point to current GPS
433 * location is changed
435 * @param direction Direction in degrees
436 * @param distance Distance in meters
437 * @param draw Should the indicator triangle be drawn or not
439 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
442 * @brief Signal for enabling automatic location update.
444 * @param enabled true if enabled, false otherwise
445 * @param updateIntervalMsecs update interval in milliseconds
447 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
450 * @brief Signals error
452 * @param context error context
453 * @param error error code
455 void error(const int context, const int error);
458 * @brief Signal for requesting username from settings
461 void fetchUsernameFromSettings();
464 * @brief Signal for finding user.
466 * @param coordinates user geo coordinates
468 void findUser(const GeoCoordinate &coordinates);
471 * @brief Signals when friend's profile image is ready
475 void friendImageReady(User *user);
478 * @brief GPS setting changed
480 * @param enabled True if GPS is enabled, otherwise false
482 void gpsTriggered(bool enabled);
485 * @brief Signal for finding friend.
487 * @param coordinates friend's geo coordinates
489 void findFriend(const GeoCoordinate &coordinates);
492 * @brief Signal for friend location ready.
496 void friendsLocationsReady(QList<User *> &friendsList);
499 * @brief Signal is emitted when location item is clicked.
501 * @param userIDs list of friends user IDs in the group
503 void locationItemClicked(const QList<QString> &userIDs);
506 * @brief Signals when Login/Logout action is pressed
509 void loginActionPressed();
512 * @brief MapView has been resized
514 * @param size view size
516 void mapViewResized(const QSize &size);
519 * @brief Forwarding signal from MapView to MapEngine
523 void mapViewScrolled(const SceneCoordinate &coordinate);
526 * @brief Forwarding signal from MapEngine to MapView
528 void maxZoomLevelReached();
531 * @brief Forwarding signal from MapEngine to MapView
533 void minZoomLevelReached();
536 * @brief Forwarding signal from MapEngine to MapScale
538 void newMapResolution(qreal scale);
541 * @brief Signal for refreshing user data.
544 void refreshUserData();
547 * @brief Signal for requesting reverseGeo from SituareEngine
550 void requestReverseGeo();
553 * @brief Signals, when address data is ready
555 * @param address Street address
557 void reverseGeoReady(const QString &address);
560 * @brief Signal to save username to settings
562 * @param username Username
564 void saveUsername(const QString &username);
567 * @brief Signal for location search
569 * @param location QString location
571 void searchForLocation(QString location);
574 * @brief Signal for requestLocationUpdate from SituareEngine
576 * @param status Status message
577 * @param publish Publish on Facebook
579 void statusUpdate(const QString &status, const bool &publish);
582 * @brief Signals when webview's urlChanged signal is emitted
586 void updateCredentials(const QUrl &url);
589 * @brief Signals when updateLocationDialog's data must be cleared
592 void clearUpdateLocationDialogData();
595 * @brief Dragging mode triggered.
597 void draggingModeTriggered();
600 * @brief MapView has finished zooming
602 void viewZoomFinished();
605 * @brief Signal for use location ready.
607 * @param user User object
609 void userLocationReady(User *user);
612 * @brief Map zoom in request
617 * @brief Forwarding signal from MapEngine to MapView
619 void zoomLevelChanged(int zoomLevel);
622 * @brief Map zoom out request
626 /*******************************************************************************
628 ******************************************************************************/
630 bool m_errorShown; ///< Indicates if error dialog/note is shown
631 bool m_loggedIn; ///< Indicates login state
632 bool m_refresh; ///< Indicates when webpage is refreshed
634 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
636 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
637 QAction *m_loginAct; ///< Action to Login/Logout
638 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
639 QAction *m_searchLocationAct; /// @todo this is temporary, remove when not needed!
641 QLabel *m_osmLicense; ///< Label for Open Street Map license
642 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
644 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
645 QList<QDialog *> m_queue; ///< QList type dialog queue
647 QMenu *m_viewMenu; ///< Object that hold the view menu items
649 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
651 QSize m_viewPortSize; ///< Size of the viewport
653 QString m_email; ///< Placeholder for email
654 QString m_password; ///< Placeholder for password
656 QWebView *m_webView; ///< Shows facebook login page
658 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
659 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
660 IndicatorButtonPanel *m_indicatorButtonPanel; ///< Instance of direction indicator button
661 MapScale *m_mapScale; ///< Instance of the map scale
662 MapView *m_mapView; ///< Instance of the map view
663 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
664 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
665 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
666 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
669 #endif // MAINWINDOW_H