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;
52 * @brief Main Window Class
54 class MainWindow : public QMainWindow
62 * @param parent Parent
64 MainWindow(QWidget *parent = 0);
72 /*******************************************************************************
73 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
74 ******************************************************************************/
77 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
79 void keyPressEvent(QKeyEvent* event);
81 /*******************************************************************************
82 * MEMBER FUNCTIONS AND SLOTS
83 ******************************************************************************/
86 * @brief Clears cookie jar
89 void clearCookieJar();
96 void loggedIn(bool logged);
99 * @brief Gets the login state (logged in/logged out)
101 * @return bool Login state
106 * @brief Reads automatic location update settings.
108 void readAutomaticLocationUpdateSettings();
111 * @brief Enable / disable auto centering button.
113 * @param enabled true if shoud be enabled, false otherwise
115 void setAutoCenteringButtonEnabled(bool enabled);
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 Set scene for MapView
129 * @param scene Scene to be set
131 void setMapViewScene(QGraphicsScene *scene);
134 * Shows dialog with enable automatic location update question.
136 * @param text text to show in dialog
138 void showEnableAutomaticUpdateLocationDialog(const QString &text);
141 * @brief Gets the username from member variable for saving purposes
143 * @return QString Username
145 const QString username();
149 * @brief Builds information box with message.
151 * @param message Information message
152 * @param modal Modal = true, non-modal false
154 void buildInformationBox(const QString &message, bool modal=false);
157 * @brief Slot to intercept signal when login has failed (loginFailure signal)
163 * @brief Slot to intercept signal when login with cookies is requested
166 void loginUsingCookies();
169 * @brief Public slot, which open settings dialog
171 void openSettingsDialog();
174 * @brief Set own location crosshair visibility
178 void setOwnLocationCrosshairVisibility(bool visible);
181 * @brief Sets username to member variable for login dialog
183 * @param username Username to be set
185 void setUsername(const QString &username);
188 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
192 void startLoginProcess();
195 * @brief Toggle progress indicator.
197 * @param state true if progress indicator should be shown, false otherwise
199 void toggleProgressIndicator(bool state);
202 * @brief Shows / hides Situare related UI items
205 void updateItemVisibility();
209 * @brief Build fullscreen toggle button and connect slots
211 void buildFullScreenButton();
214 * @brief Build friend list panel and connect slots
216 void buildFriendListPanel();
219 * @brief Build manual location setting cross hair and connect slots
221 void buildManualLocationCrosshair();
224 * @brief Build map and connect slots
229 * @brief Build map scale and connect slots
231 void buildMapScale();
234 * @brief Build OSM license and connect slots
236 void buildOsmLicense();
239 * @brief Build user info panel and connect slots
241 void buildUserInfoPanel();
244 * @brief Build webview and connect slots
250 * @brief Build zoom button panel and connect slots
252 void buildZoomButtonPanel();
255 * @brief Private method to create the Menu items
260 * @brief Grab or release HW increase and decrease buttons.
262 * @param grab Use true for grabbing and false for releasing the keys
264 void grabZoomKeys(bool grab);
267 * @brief Queues dialog/information box
269 * @param dialog Dialog to be added into queue
271 void queueDialog(QDialog *dialog);
274 * @brief Shows queued error information box
277 void showErrorInformationBox();
280 * @brief Shows queued information box
282 * @fn showInformationBox
284 void showInformationBox();
288 * @brief Slot for automatic update dialog finished.
290 * @result result code
292 void automaticUpdateDialogFinished(int result);
295 * @brief Slot to intercept signal when dialog/information note is processed
297 * @param status Status of the dialog
299 void dialogFinished(int status);
302 * @brief Slot for drawing the fullscreen toggle button
304 * @param size Size of the screen
306 void drawFullScreenButton(const QSize &size);
309 * @brief Slot for drawing the map distance scale
311 * @param size Size of the screen
313 void drawMapScale(const QSize &size);
316 * @brief Slot for drawing the Open Street Map license text
318 * @param size Size of the screen
320 void drawOsmLicense(const QSize &size);
323 * @brief Slot for drawing the own location crosshair
325 * @param size Size of the screen
327 void drawOwnLocationCrosshair(const QSize &size);
330 * @brief Slot to intercept signal when error dialog/information note is processed
332 * @param status Status of the dialog
334 void errorDialogFinished(int status);
337 * @brief Slot for gps timeout.
339 * Called when request timeout occurs.
344 * @brief Slot to load cookies from settings
350 * @brief Slot to intercept signal when webview has finished loading webpage
352 * @param done Status of the loading
354 void loadDone(bool done);
357 * @brief Slot to save cookies to settings
363 * @brief Slot for settings dialog accepted.
365 void settingsDialogAccepted();
368 * @brief Set correnct view port size to datamembers
370 * @param size Size of the screen
372 void setViewPortSize(const QSize &size);
375 * @brief Toggle between fullscreen and normal window mode
377 void toggleFullScreen();
380 * @brief Slot to intercept signal from webview's networkaccessmanager
382 * @param reply Network reply (contains errors)
384 void webViewRequestFinished(QNetworkReply* reply);
386 /*******************************************************************************
388 ******************************************************************************/
391 * @brief Automatic centering setting changed by user
393 * @param enabled True if automatic centering is enabled, otherwise false
395 void autoCenteringTriggered(bool enabled);
398 * @brief Signal that indicates when user has cancelled login process
401 void cancelLoginProcess();
404 * @brief View should be centered to new location
406 * @param sceneCoordinate Scene coordinates of the new center point
408 void centerToSceneCoordinates(QPoint sceneCoordinate);
411 * @brief Signal for enabling automatic location update.
413 * @param enabled true if enabled, false otherwise
414 * @param updateIntervalMsecs update interval in milliseconds
416 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
419 * @brief Signals error
421 * @param error Error code
423 void error(const int error);
426 * @brief Signal for requesting username from settings
429 void fetchUsernameFromSettings();
432 * @brief Signal for finding user.
434 * @param coordinates user geo coordinates
436 void findUser(const QPointF &coordinates);
439 * @brief GPS setting changed
441 * @param enabled True if GPS is enabled, otherwise false
443 void gpsTriggered(bool enabled);
446 * @brief Signal for finding friend.
448 * @param coordinates friend's geo coordinates
450 void findFriend(const QPointF &coordinates);
453 * @brief Signal for friend location ready.
457 void friendsLocationsReady(QList<User *> &friendsList);
460 * @brief Signal is emitted when location item is clicked.
462 * @param userIDs list of friends user IDs in the group
464 void locationItemClicked(const QList<QString> &userIDs);
467 * @brief Signals when Login/Logout action is pressed
470 void loginActionPressed();
473 * @brief MapView has been resized
475 * @param size view size
477 void mapViewResized(const QSize &size);
480 * @brief Forwarding signal from MapView to MapEngine
482 * @param sceneCoordinate
484 void mapViewScrolled(QPoint sceneCoordinate);
487 * @brief Forwarding signal from MapEngine to MapView
489 void maxZoomLevelReached();
492 * @brief Signal that informs that user's message/location failed to update on Situare server
493 * This signal is originally sended from SituareService with name error
494 * Signal is renamed on MainWindow
496 * @param error error code
498 void messageSendingFailed(const int error);
501 * @brief Forwarding signal from MapEngine to MapView
503 void minZoomLevelReached();
506 * @brief Forwarding signal from MapEngine to MapScale
508 void newMapResolution(qreal scale);
511 * @brief Signal for refreshing user data.
514 void refreshUserData();
517 * @brief Signal for requesting reverseGeo from SituareEngine
520 void requestReverseGeo();
523 * @brief Signals, when address data is ready
525 * @param address Street address
527 void reverseGeoReady(const QString &address);
530 * @brief Signal to save username to settings
532 * @param username Username
534 void saveUsername(const QString &username);
537 * @brief Signal for requestLocationUpdate from SituareEngine
539 * @param status Status message
540 * @param publish Publish on Facebook
542 void statusUpdate(const QString &status, const bool &publish);
545 * @brief Signals when webview's urlChanged signal is emitted
549 void updateCredentials(const QUrl &url);
552 * @brief Signals when updateLocationDialog's data must be cleared
555 void clearUpdateLocationDialogData();
558 * @brief MapView has finished zooming
560 void viewZoomFinished();
563 * @brief Signal for use location ready.
565 * @param user User object
567 void userLocationReady(User *user);
570 * @brief Map zoom in request
575 * @brief Forwarding signal from MapEngine to MapView
577 void zoomLevelChanged(int zoomLevel);
580 * @brief Map zoom out request
584 /*******************************************************************************
586 ******************************************************************************/
588 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
589 bool m_errorShown; ///< Indicates if error dialog/note is shown
590 bool m_loggedIn; ///< Indicates login state
591 bool m_refresh; ///< Indicates when webpage is refreshed
593 int m_viewPortHeight; ///< Height of view port
594 int m_viewPortWidth; ///< Width of view port
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 QString m_email; ///< Placeholder for email
612 QString m_password; ///< Placeholder for password
614 QToolButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
616 QWebView *m_webView; ///< Shows facebook login page
618 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
619 MapScale *m_mapScale; ///< Instance of the map scale
620 MapView *m_mapView; ///< Instance of the map view
621 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
622 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
623 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
624 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
625 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
628 #endif // MAINWINDOW_H