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 FriendListPanel;
46 class ZoomButtonPanel;
51 * @brief Main Window Class
53 class MainWindow : public QMainWindow
61 * @param parent Parent
63 MainWindow(QWidget *parent = 0);
71 /*******************************************************************************
72 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
73 ******************************************************************************/
76 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
78 void keyPressEvent(QKeyEvent* event);
80 /*******************************************************************************
81 * MEMBER FUNCTIONS AND SLOTS
82 ******************************************************************************/
85 * @brief Builds information box with message.
87 * @param message Information message
88 * @param modal Modal = true, non-modal false
90 void buildInformationBox(const QString &message, bool modal=false);
93 * @brief Clears cookie jar
96 void clearCookieJar();
103 void loggedIn(bool logged);
106 * @brief Enable / disable auto centering button.
108 * @param enabled true if shoud be enabled, false otherwise
110 void setAutoCenteringButtonEnabled(bool enabled);
113 * @brief Enable / disable GPS button.
115 * Does set visibilities for manual location cursor and auto centering menu button.
117 * @param enabled true if enabled, false otherwise
119 void setGPSButtonEnabled(bool enabled);
122 * @brief Set scene for MapView
124 * @param scene Scene to be set
126 void setMapViewScene(QGraphicsScene *scene);
129 * @brief Gets the username from member variable for saving purposes
131 * @return QString Username
133 const QString username();
137 * @brief Slot to intercept signal when login has failed (loginFailure signal)
143 * @brief Slot to intercept signal when login with cookies is requested
146 void loginUsingCookies();
149 * @brief Public slot, which open settings dialog
151 void openSettingsDialog();
154 * @brief Sets username to member variable for login dialog
156 * @param username Username to be set
158 void setUsername(const QString &username);
161 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
165 void startLoginProcess();
168 * @brief Toggle progress indicator.
170 * @param state true if progress indicator should be shown, false otherwise
172 void toggleProgressIndicator(bool state);
175 * @brief Shows / hides Situare related UI items
179 void updateItemVisibility(bool show);
183 * @brief Build fullscreen toggle button and connect slots
185 void buildFullScreenButton();
188 * @brief Build friend list panel and connect slots
190 void buildFriendListPanel();
193 * @brief Build manual location setting cross hair and connect slots
195 void buildManualLocationCrosshair();
198 * @brief Build map and connect slots
203 * @brief Build map scale and connect slots
205 void buildMapScale();
208 * @brief Build OSM license and connect slots
210 void buildOsmLicense();
213 * @brief Build user info panel and connect slots
215 void buildUserInfoPanel();
218 * @brief Build webview and connect slots
224 * @brief Build zoom button panel and connect slots
226 void buildZoomButtonPanel();
229 * @brief Private method to create the Menu items
234 * @brief Grab or release HW increase and decrease buttons.
236 * @param grab Use true for grabbing and false for releasing the keys
238 void grabZoomKeys(bool grab);
241 * @brief Queues dialog/information box
243 * @param dialog Dialog to be added into queue
245 void queueDialog(QDialog *dialog);
248 * @brief Set own location crosshair visibility
252 void setOwnLocationCrosshairVisibility(bool visible);
255 * @brief Shows queued error information box
258 void showErrorInformationBox();
261 * @brief Shows queued information box
263 * @fn showInformationBox
265 void showInformationBox();
269 * @brief Slot to intercept signal when dialog/information note is processed
271 * @param status Status of the dialog
273 void dialogFinished(int status);
276 * @brief Slot for drawing the fullscreen toggle button
278 * @param size Size of the screen
280 void drawFullScreenButton(const QSize &size);
283 * @brief Slot for drawing the map distance scale
285 * @param size Size of the screen
287 void drawMapScale(const QSize &size);
290 * @brief Slot for drawing the Open Street Map license text
292 * @param size Size of the screen
294 void drawOsmLicense(const QSize &size);
297 * @brief Slot for drawing the own location crosshair
299 * @param size Size of the screen
301 void drawOwnLocationCrosshair(const QSize &size);
304 * @brief Slot to intercept signal when error dialog/information note is processed
306 * @param status Status of the dialog
308 void errorDialogFinished(int status);
311 * @brief Slot for gps timeout.
313 * Called when request timeout occurs.
318 * @brief Slot to load cookies from settings
324 * @brief Slot to intercept signal when webview has finished loading webpage
326 * @param done Status of the loading
328 void loadDone(bool done);
331 * @brief Slot to save cookies to settings
337 * @brief Set correnct view port size to datamembers
339 * @param size Size of the screen
341 void setViewPortSize(const QSize &size);
344 * @brief Toggle between fullscreen and normal window mode
346 void toggleFullScreen();
349 * @brief Slot to intercept signal from webview's networkaccessmanager
351 * @param reply Network reply (contains errors)
353 void webViewRequestFinished(QNetworkReply* reply);
355 /*******************************************************************************
357 ******************************************************************************/
360 * @brief Automatic centering setting changed by user
362 * @param enabled True if automatic centering is enabled, otherwise false
364 void autoCenteringTriggered(bool enabled);
367 * @brief Signal that indicates when user has cancelled login process
370 void cancelLoginProcess();
373 * @brief View should be centered to new location
375 * @param sceneCoordinate Scene coordinates of the new center point
377 void centerToSceneCoordinates(QPoint sceneCoordinate);
380 * @brief Signal for enabling automatic location update.
382 * @param enabled true if enabled, false otherwise
383 * @param updateIntervalMsecs update interval in milliseconds
385 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs);
388 * @brief Signal for requesting username from settings
391 void fetchUsernameFromSettings();
394 * @brief Signal for finding user.
396 * @param coordinates user geo coordinates
398 void findUser(const QPointF &coordinates);
401 * @brief GPS setting changed
403 * @param enabled True if GPS is enabled, otherwise false
405 void gpsTriggered(bool enabled);
408 * @brief Signal for finding friend.
410 * @param coordinates friend's geo coordinates
412 void findFriend(const QPointF &coordinates);
415 * @brief Signal for friend location ready.
419 void friendsLocationsReady(QList<User *> &friendsList);
422 * @brief Signal is emitted when location item is clicked.
424 * @param userIDs list of friends user IDs in the group
426 void locationItemClicked(const QList<QString> &userIDs);
429 * @brief Signals when Login/Logout action is pressed
432 void loginActionPressed();
435 * @brief MapView has been resized
437 * @param size view size
439 void mapViewResized(const QSize &size);
442 * @brief Forwarding signal from MapView to MapEngine
444 * @param sceneCoordinate
446 void mapViewScrolled(QPoint sceneCoordinate);
449 * @brief Forwarding signal from MapEngine to MapView
451 void maxZoomLevelReached();
454 * @brief Signal that informs that user's message/location failed to update on Situare server
455 * This signal is originally sended from SituareService with name error
456 * Signal is renamed on MainWindow
458 void messageSendingFailed(const QString &error);
461 * @brief Forwarding signal from MapEngine to MapView
463 void minZoomLevelReached();
466 * @brief Signal that used to inform user that his message/location update tp Situare server
468 * This signal is originally sended from UserInfo
470 void notificateUpdateFailing(const QString &message);
473 * @brief Forwarding signal from MapEngine to MapScale
475 void newMapResolution(qreal scale);
478 * @brief Signal for refreshing user data.
481 void refreshUserData();
484 * @brief Signal for requesting reverseGeo from SituareEngine
487 void requestReverseGeo();
490 * @brief Signals, when address data is ready
492 * @param address Street address
494 void reverseGeoReady(const QString &address);
497 * @brief Signal to save username to settings
499 * @param username Username
501 void saveUsername(const QString &username);
504 * @brief Signal for requestLocationUpdate from SituareEngine
506 * @param status Status message
507 * @param publish Publish on Facebook
509 void statusUpdate(const QString &status, const bool &publish);
512 * @brief Signals when webview's urlChanged signal is emitted
516 void updateCredentials(const QUrl &url);
519 * @brief Signals when updateLocation request finished successfully
522 void updateWasSuccessful();
525 * @brief MapView has finished zooming
527 void viewZoomFinished();
530 * @brief Signal for use location ready.
532 * @param user User object
534 void userLocationReady(User *user);
537 * @brief Map zoom in request
542 * @brief Forwarding signal from MapEngine to MapView
544 void zoomLevelChanged(int zoomLevel);
547 * @brief Map zoom out request
551 /*******************************************************************************
553 ******************************************************************************/
555 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
556 bool m_errorShown; ///< Indicates if error dialog/note is shown
557 bool m_loggedIn; ///< Indicates login state
558 bool m_refresh; ///< Indicates when webpage is refreshed
560 int m_viewPortHeight; ///< Height of view port
561 int m_viewPortWidth; ///< Width of view port
563 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
564 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
565 QAction *m_loginAct; ///< Action to Login/Logout
566 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
568 QLabel *m_osmLicense; ///< Label for Open Street Map license
569 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
571 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
572 QList<QDialog *> m_queue; ///< QList type dialog queue
574 QMenu *m_viewMenu; ///< Object that hold the view menu items
576 QString m_email; ///< Placeholder for email
577 QString m_password; ///< Placeholder for password
579 QToolButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
581 QWebView *m_webView; ///< Shows facebook login page
583 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
584 MapScale *m_mapScale; ///< Instance of the map scale
585 MapView *m_mapView; ///< Instance of the map view
586 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
587 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
588 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
589 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
590 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
592 SettingsDialog *m_settingsDialog; ///< Settings dialog
595 #endif // MAINWINDOW_H