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"
32 #include "panelsidebar.h"
41 class FacebookAuthentication;
42 class FullScreenButton;
43 class FriendListPanel;
44 class IndicatorButton;
50 class SceneCoordinate;
54 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();
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 user info panel and connect slots
257 void buildUserInfoPanel();
260 * @brief Build webview and connect slots
265 * @brief Build zoom button panel and connect slots
267 void buildZoomButtonPanel();
270 * @brief Private method to create the Menu items
275 * @brief Grab or release HW increase and decrease buttons.
277 * @param grab Use true for grabbing and false for releasing the keys
279 void grabZoomKeys(bool grab);
282 * @brief Queues dialog/information box
284 * @param dialog Dialog to be added into queue
286 void queueDialog(QDialog *dialog);
289 * @brief Shows queued error information box
292 void showErrorInformationBox();
295 * @brief Shows queued information box
297 * @fn showInformationBox
299 void showInformationBox();
303 * @brief Slot for automatic update dialog finished.
305 * @result result code
307 void automaticUpdateDialogFinished(int result);
310 * @brief Slot to intercept signal when dialog/information note is processed
312 * @param status Status of the dialog
314 void dialogFinished(int status);
317 * @brief Slot for drawing the fullscreen toggle button
319 * @param size Size of the screen
321 void drawFullScreenButton(const QSize &size);
324 * @brief Slot for drawing the map distance scale
326 * @param size Size of the screen
328 void drawMapScale(const QSize &size);
331 * @brief Slot for drawing the Open Street Map license text
333 * @param size Size of the screen
335 void drawOsmLicense(const QSize &size);
338 * @brief Slot for drawing the own location crosshair
340 * @param size Size of the screen
342 void drawOwnLocationCrosshair(const QSize &size);
345 * @brief Slot to intercept signal when error dialog/information note is processed
347 * @param status Status of the dialog
349 void errorDialogFinished(int status);
352 * @brief Slot for gps timeout.
354 * Called when request timeout occurs.
359 * @brief Slot to load cookies from settings
364 * @brief Slot to intercept signal when webview has finished loading webpage
366 * @param done Status of the loading
368 void loadDone(bool done);
371 * @brief Slot to save cookies to settings
376 * @brief Slot for settings dialog accepted.
378 void settingsDialogAccepted();
381 * @brief Set correnct view port size to datamembers
383 * @param size Size of the screen
385 void setViewPortSize(const QSize &size);
388 * @brief Start location search (open search dialog)
390 void startLocationSearch();
393 * @brief Toggle between fullscreen and normal window mode
395 void toggleFullScreen();
398 * @brief Slot to intercept signal from webview's networkaccessmanager
400 * @param reply Network reply (contains errors)
402 void webViewRequestFinished(QNetworkReply* reply);
404 /*******************************************************************************
406 ******************************************************************************/
409 * @brief Automatic centering setting changed by user
411 * @param enabled True if automatic centering is enabled, otherwise false
413 void autoCenteringTriggered(bool enabled);
416 * @brief Signal that indicates when user has cancelled login process
419 void cancelLoginProcess();
422 * @brief View should be centered to new location
424 * @param coordinate Scene coordinates of the new center point
426 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
429 * @brief Signal for enabling automatic location update.
431 * @param enabled true if enabled, false otherwise
432 * @param updateIntervalMsecs update interval in milliseconds
434 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
437 * @brief Signals error
439 * @param context error context
440 * @param error error code
442 void error(const int context, const int error);
445 * @brief Signal for requesting username from settings
448 void fetchUsernameFromSettings();
451 * @brief Signal for finding user.
453 * @param coordinates user geo coordinates
455 void findUser(const GeoCoordinate &coordinates);
458 * @brief Signals when friend's profile image is ready
462 void friendImageReady(User *user);
465 * @brief GPS setting changed
467 * @param enabled True if GPS is enabled, otherwise false
469 void gpsTriggered(bool enabled);
472 * @brief Signal for finding friend.
474 * @param coordinates friend's geo coordinates
476 void findFriend(const GeoCoordinate &coordinates);
479 * @brief Signal for friend location ready.
483 void friendsLocationsReady(QList<User *> &friendsList);
486 * @brief Emited when location request is parsed and is ready for further processing
488 * @param result List of Location items
490 void locationDataParsed(QList<Location> &result);
493 * @brief Signal is emitted when location item is clicked.
495 * @param userIDs list of friends user IDs in the group
497 void locationItemClicked(const QList<QString> &userIDs);
499 void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
502 * @brief Signals when Login/Logout action is pressed
505 void loginActionPressed();
508 * @brief MapView has been resized
510 * @param size view size
512 void mapViewResized(const QSize &size);
515 * @brief Forwarding signal from MapView to MapEngine
519 void mapViewScrolled(const SceneCoordinate &coordinate);
522 * @brief Forwarding signal from MapEngine to MapView
524 void maxZoomLevelReached();
527 * @brief Forwarding signal from MapEngine to MapView
529 void minZoomLevelReached();
532 * @brief Forwarding signal from MapEngine to MapScale
534 void newMapResolution(qreal scale);
537 * @brief Signal for refreshing user data.
540 void refreshUserData();
543 * @brief Signal for requesting reverseGeo from SituareEngine
546 void requestReverseGeo();
549 * @brief Signals, when address data is ready
551 * @param address Street address
553 void reverseGeoReady(const QString &address);
556 * @brief Signal to save username to settings
558 * @param username Username
560 void saveUsername(const QString &username);
563 * @brief Signal for location search
565 * @param location QString location
567 void searchForLocation(QString location);
570 * @brief Signal for requestLocationUpdate from SituareEngine
572 * @param status Status message
573 * @param publish Publish on Facebook
575 void statusUpdate(const QString &status, const bool &publish);
578 * @brief Signals when webview's urlChanged signal is emitted
582 void updateCredentials(const QUrl &url);
585 * @brief Signals when updateLocationDialog's data must be cleared
588 void clearUpdateLocationDialogData();
591 * @brief Dragging mode triggered.
593 void draggingModeTriggered();
596 * @brief MapView has finished zooming
598 void viewZoomFinished();
601 * @brief Signal for use location ready.
603 * @param user User object
605 void userLocationReady(User *user);
608 * @brief Map zoom in request
613 * @brief Forwarding signal from MapEngine to MapView
615 void zoomLevelChanged(int zoomLevel);
618 * @brief Map zoom out request
622 /*******************************************************************************
624 ******************************************************************************/
626 bool m_errorShown; ///< Indicates if error dialog/note is shown
627 bool m_loggedIn; ///< Indicates login state
628 bool m_refresh; ///< Indicates when webpage is refreshed
630 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
632 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
633 QAction *m_loginAct; ///< Action to Login/Logout
634 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
635 QAction *m_searchLocationAct; /// @todo this is temporary, remove when not needed!
637 QLabel *m_osmLicense; ///< Label for Open Street Map license
638 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
640 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
641 QList<QDialog *> m_queue; ///< QList type dialog queue
643 QMenu *m_viewMenu; ///< Object that hold the view menu items
645 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
647 QSize m_viewPortSize; ///< Size of the viewport
649 QString m_email; ///< Placeholder for email
650 QString m_password; ///< Placeholder for password
652 QWebView *m_webView; ///< Shows facebook login page
654 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
655 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
656 IndicatorButton *m_indicatorButton; ///< Instance of direction indicator button
657 MapScale *m_mapScale; ///< Instance of the map scale
658 MapView *m_mapView; ///< Instance of the map view
659 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
660 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
661 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
662 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
663 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
666 #endif // MAINWINDOW_H