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
9 Situare is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 version 2 as published by the Free Software Foundation.
13 Situare is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Situare; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
27 #include <QtGui/QMainWindow>
30 #include "network/networkcookiejar.h"
31 #include "panelsidebar.h"
38 class FacebookAuthentication;
39 class FullScreenButton;
40 class FriendListPanel;
47 class ZoomButtonPanel;
53 * @brief Main Window Class
55 class MainWindow : public QMainWindow
63 * @param parent Parent
65 MainWindow(QWidget *parent = 0);
73 /*******************************************************************************
74 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
75 ******************************************************************************/
78 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
80 void keyPressEvent(QKeyEvent* event);
82 /*******************************************************************************
83 * MEMBER FUNCTIONS AND SLOTS
84 ******************************************************************************/
87 * @brief Clears cookie jar
90 void clearCookieJar();
97 void loggedIn(bool logged);
100 * @brief Gets the login state (logged in/logged out)
102 * @return bool Login state
107 * @brief Reads automatic location update settings.
109 void readAutomaticLocationUpdateSettings();
112 * @brief Enable / disable auto centering button.
114 * @param enabled true if shoud be enabled, false otherwise
116 void setAutoCenteringButtonEnabled(bool enabled);
119 * @brief Enable / disable GPS button.
121 * Does set visibilities for manual location cursor and auto centering menu button.
123 * @param enabled true if enabled, false otherwise
125 void setGPSButtonEnabled(bool enabled);
128 * @brief Set scene for MapView
130 * @param scene Scene to be set
132 void setMapViewScene(QGraphicsScene *scene);
135 * Shows dialog with enable automatic location update question.
137 * @param text text to show in dialog
139 void showEnableAutomaticUpdateLocationDialog(const QString &text);
142 * @brief Gets the username from member variable for saving purposes
144 * @return QString Username
146 const QString username();
150 * @brief Builds information box with message.
152 * @param message Information message
153 * @param modal Modal = true, non-modal false
155 void buildInformationBox(const QString &message, bool modal=false);
158 * @brief Slot for failed login
164 * @brief Slot to intercept signal when login with cookies is requested
167 void loginUsingCookies();
170 * @brief Public slot, which open settings dialog
172 void openSettingsDialog();
175 * @brief Set own location crosshair visibility
179 void setOwnLocationCrosshairVisibility(bool visible);
182 * @brief Sets username to member variable for login dialog
184 * @param username Username to be set
186 void setUsername(const QString &username);
189 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
193 void startLoginProcess();
196 * @brief Toggle progress indicator.
198 * @param state true if progress indicator should be shown, false otherwise
200 void toggleProgressIndicator(bool state);
203 * @brief Shows / hides Situare related UI items
206 void updateItemVisibility();
210 * @brief Build fullscreen toggle button and connect slots
212 void buildFullScreenButton();
215 * @brief Build friend list panel and connect slots
217 void buildFriendListPanel();
220 * @brief Build manual location setting cross hair and connect slots
222 void buildManualLocationCrosshair();
225 * @brief Build map and connect slots
230 * @brief Build map scale and connect slots
232 void buildMapScale();
235 * @brief Build OSM license and connect slots
237 void buildOsmLicense();
240 * @brief Build user info panel and connect slots
242 void buildUserInfoPanel();
245 * @brief Build webview and connect slots
251 * @brief Build zoom button panel and connect slots
253 void buildZoomButtonPanel();
256 * @brief Private method to create the Menu items
261 * @brief Grab or release HW increase and decrease buttons.
263 * @param grab Use true for grabbing and false for releasing the keys
265 void grabZoomKeys(bool grab);
268 * @brief Queues dialog/information box
270 * @param dialog Dialog to be added into queue
272 void queueDialog(QDialog *dialog);
275 * @brief Shows queued error information box
278 void showErrorInformationBox();
281 * @brief Shows queued information box
283 * @fn showInformationBox
285 void showInformationBox();
289 * @brief Slot for automatic update dialog finished.
291 * @result result code
293 void automaticUpdateDialogFinished(int result);
296 * @brief Slot to intercept signal when dialog/information note is processed
298 * @param status Status of the dialog
300 void dialogFinished(int status);
303 * @brief Slot for drawing the fullscreen toggle button
305 * @param size Size of the screen
307 void drawFullScreenButton(const QSize &size);
310 * @brief Slot for drawing the map distance scale
312 * @param size Size of the screen
314 void drawMapScale(const QSize &size);
317 * @brief Slot for drawing the Open Street Map license text
319 * @param size Size of the screen
321 void drawOsmLicense(const QSize &size);
324 * @brief Slot for drawing the own location crosshair
326 * @param size Size of the screen
328 void drawOwnLocationCrosshair(const QSize &size);
331 * @brief Slot to intercept signal when error dialog/information note is processed
333 * @param status Status of the dialog
335 void errorDialogFinished(int status);
338 * @brief Slot for gps timeout.
340 * Called when request timeout occurs.
345 * @brief Slot to load cookies from settings
351 * @brief Slot to intercept signal when webview has finished loading webpage
353 * @param done Status of the loading
355 void loadDone(bool done);
358 * @brief Slot to save cookies to settings
364 * @brief Slot for settings dialog accepted.
366 void settingsDialogAccepted();
369 * @brief Set correnct view port size to datamembers
371 * @param size Size of the screen
373 void setViewPortSize(const QSize &size);
376 * @brief Toggle between fullscreen and normal window mode
378 void toggleFullScreen();
381 * @brief Slot to intercept signal from webview's networkaccessmanager
383 * @param reply Network reply (contains errors)
385 void webViewRequestFinished(QNetworkReply* reply);
387 /*******************************************************************************
389 ******************************************************************************/
392 * @brief Automatic centering setting changed by user
394 * @param enabled True if automatic centering is enabled, otherwise false
396 void autoCenteringTriggered(bool enabled);
399 * @brief Signal that indicates when user has cancelled login process
402 void cancelLoginProcess();
405 * @brief View should be centered to new location
407 * @param sceneCoordinate Scene coordinates of the new center point
409 void centerToSceneCoordinates(QPoint sceneCoordinate);
412 * @brief Signal for enabling automatic location update.
414 * @param enabled true if enabled, false otherwise
415 * @param updateIntervalMsecs update interval in milliseconds
417 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
420 * @brief Signals error
422 * @param error Error code
424 void error(const int error);
427 * @brief Signal for requesting username from settings
430 void fetchUsernameFromSettings();
433 * @brief Signal for finding user.
435 * @param coordinates user geo coordinates
437 void findUser(const QPointF &coordinates);
440 * @brief GPS setting changed
442 * @param enabled True if GPS is enabled, otherwise false
444 void gpsTriggered(bool enabled);
447 * @brief Signal for finding friend.
449 * @param coordinates friend's geo coordinates
451 void findFriend(const QPointF &coordinates);
454 * @brief Signal for friend location ready.
458 void friendsLocationsReady(QList<User *> &friendsList);
461 * @brief Signal is emitted when location item is clicked.
463 * @param userIDs list of friends user IDs in the group
465 void locationItemClicked(const QList<QString> &userIDs);
468 * @brief Signals when Login/Logout action is pressed
471 void loginActionPressed();
474 * @brief MapView has been resized
476 * @param size view size
478 void mapViewResized(const QSize &size);
481 * @brief Forwarding signal from MapView to MapEngine
483 * @param sceneCoordinate
485 void mapViewScrolled(QPoint sceneCoordinate);
488 * @brief Forwarding signal from MapEngine to MapView
490 void maxZoomLevelReached();
493 * @brief Signal that informs that user's message/location failed to update on Situare server
494 * This signal is originally sended from SituareService with name error
495 * Signal is renamed on MainWindow
497 * @param error error code
499 void messageSendingFailed(const int error);
502 * @brief Forwarding signal from MapEngine to MapView
504 void minZoomLevelReached();
507 * @brief Forwarding signal from MapEngine to MapScale
509 void newMapResolution(qreal scale);
512 * @brief Signal for refreshing user data.
515 void refreshUserData();
518 * @brief Signal for requesting reverseGeo from SituareEngine
521 void requestReverseGeo();
524 * @brief Signals, when address data is ready
526 * @param address Street address
528 void reverseGeoReady(const QString &address);
531 * @brief Signal to save username to settings
533 * @param username Username
535 void saveUsername(const QString &username);
538 * @brief Signal for requestLocationUpdate from SituareEngine
540 * @param status Status message
541 * @param publish Publish on Facebook
543 void statusUpdate(const QString &status, const bool &publish);
546 * @brief Signals when webview's urlChanged signal is emitted
550 void updateCredentials(const QUrl &url);
553 * @brief Signals when updateLocationDialog's data must be cleared
556 void clearUpdateLocationDialogData();
559 * @brief MapView has finished zooming
561 void viewZoomFinished();
564 * @brief Signal for use location ready.
566 * @param user User object
568 void userLocationReady(User *user);
571 * @brief Map zoom in request
576 * @brief Forwarding signal from MapEngine to MapView
578 void zoomLevelChanged(int zoomLevel);
581 * @brief Map zoom out request
585 /*******************************************************************************
587 ******************************************************************************/
589 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
590 bool m_errorShown; ///< Indicates if error dialog/note is shown
591 bool m_loggedIn; ///< Indicates login state
592 bool m_refresh; ///< Indicates when webpage is refreshed
594 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
596 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
597 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
598 QAction *m_loginAct; ///< Action to Login/Logout
599 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
601 QLabel *m_osmLicense; ///< Label for Open Street Map license
602 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
604 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
605 QList<QDialog *> m_queue; ///< QList type dialog queue
607 QMenu *m_viewMenu; ///< Object that hold the view menu items
609 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
611 QSize m_viewPortSize; ///< Size of the viewport
613 QString m_email; ///< Placeholder for email
614 QString m_password; ///< Placeholder for password
616 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
618 QWebView *m_webView; ///< Shows facebook login page
620 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
621 MapScale *m_mapScale; ///< Instance of the map scale
622 MapView *m_mapView; ///< Instance of the map view
623 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
624 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
625 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
626 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
627 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
630 #endif // MAINWINDOW_H