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;
45 class ZoomButtonPanel;
50 * @brief Main Window Class
52 class MainWindow : public QMainWindow
60 * @param parent Parent
62 MainWindow(QWidget *parent = 0);
70 /*******************************************************************************
71 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
72 ******************************************************************************/
75 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
77 void keyPressEvent(QKeyEvent* event);
79 /*******************************************************************************
80 * MEMBER FUNCTIONS AND SLOTS
81 ******************************************************************************/
84 * @brief Builds information box with message.
86 * @param message Information message
87 * @param modal Modal = true, non-modal false
89 void buildInformationBox(const QString &message, bool modal=false);
92 * @brief Clears cookie jar
95 void clearCookieJar();
102 void loggedIn(bool logged);
105 * @brief Enable / disable auto centering button.
107 * @param enabled true if shoud be enabled, false otherwise
109 void setAutoCenteringButtonEnabled(bool enabled);
112 * @brief Enable / disable GPS button.
114 * Does set visibilities for manual location cursor and auto centering menu button.
116 * @param enabled true if enabled, false otherwise
118 void setGPSButtonEnabled(bool enabled);
121 * @brief Set scene for MapView
123 * @param scene Scene to be set
125 void setMapViewScene(QGraphicsScene *scene);
128 * @brief Gets the username from member variable for saving purposes
130 * @return QString Username
132 const QString username();
136 * @brief Slot to intercept signal when login has failed (loginFailure signal)
142 * @brief Slot to intercept signal when login with cookies is requested
145 void loginUsingCookies();
148 * @brief Public slot, which open settings dialog
150 void openSettingsDialog();
153 * @brief Sets username to member variable for login dialog
155 * @param username Username to be set
157 void setUsername(const QString &username);
160 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
164 void startLoginProcess();
167 * @brief Toggle progress indicator.
169 * @param state true if progress indicator should be shown, false otherwise
171 void toggleProgressIndicator(bool state);
174 * @brief Shows / hides Situare related UI items
178 void updateItemVisibility(bool show);
182 * @brief Build fullscreen toggle button and connect slots
184 void buildFullScreenButton();
187 * @brief Build friend list panel and connect slots
189 void buildFriendListPanel();
192 * @brief Build manual location setting cross hair and connect slots
194 void buildManualLocationCrosshair();
197 * @brief Build map and connect slots
202 * @brief Build OSM license and connect slots
204 void buildOsmLicense();
207 * @brief Build user info panel and connect slots
209 void buildUserInfoPanel();
212 * @brief Build webview and connect slots
218 * @brief Build zoom button panel and connect slots
220 void buildZoomButtonPanel();
223 * @brief Private method to create the Menu items
228 * @brief Grab or release HW increase and decrease buttons.
230 * @param grab Use true for grabbing and false for releasing the keys
232 void grabZoomKeys(bool grab);
235 * @brief Queues dialog/information box
237 * @param dialog Dialog to be added into queue
239 void queueDialog(QDialog *dialog);
242 * @brief Set own location crosshair visibility
246 void setOwnLocationCrosshairVisibility(bool visible);
249 * @brief Shows queued error information box
252 void showErrorInformationBox();
255 * @brief Shows queued information box
257 * @fn showInformationBox
259 void showInformationBox();
263 * @brief Slot to intercept signal when dialog/information note is processed
265 * @param status Status of the dialog
267 void dialogFinished(int status);
270 * @brief Slot for drawing the fullscreen toggle button
272 * @param size Size of the screen
274 void drawFullScreenButton(const QSize &size);
277 * @brief Slot for drawing the Open Street Map license text
279 * @param size Size of the screen
281 void drawOsmLicense(const QSize &size);
284 * @brief Slot for drawing the own location crosshair
286 * @param width Width of the viewport
287 * @param height Height of the viewport
289 void drawOwnLocationCrosshair(int width, int height);
292 * @brief Slot to intercept signal when error dialog/information note is processed
294 * @param status Status of the dialog
296 void errorDialogFinished(int status);
299 * @brief Slot for gps timeout.
301 * Called when request timeout occurs.
306 * @brief Slot to load cookies from settings
312 * @brief Slot to intercept signal when webview has finished loading webpage
314 * @param done Status of the loading
316 void loadDone(bool done);
319 * @brief Slot to save cookies to settings
325 * @brief Set correnct view port size to datamembers
327 * @param width Width of the viewport
328 * @param height Height of the viewport
330 void setViewPortSize(const int width, const int height);
333 * @brief Toggle between fullscreen and normal window mode
335 void toggleFullScreen();
338 * @brief Slot to intercept signal from webview's networkaccessmanager
340 * @param reply Network reply (contains errors)
342 void webViewRequestFinished(QNetworkReply* reply);
344 /*******************************************************************************
346 ******************************************************************************/
349 * @brief Automatic centering setting changed by user
351 * @param enabled True if automatic centering is enabled, otherwise false
353 void autoCenteringTriggered(bool enabled);
356 * @brief Signal that indicates when user has cancelled login process
359 void cancelLoginProcess();
362 * @brief View should be centered to new location
364 * @param sceneCoordinate Scene coordinates of the new center point
366 void centerToSceneCoordinates(QPoint sceneCoordinate);
369 * @brief Signal for enabling automatic location update.
371 * @param enabled true if enabled, false otherwise
372 * @param updateIntervalMsecs update interval in milliseconds
374 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs);
377 * @brief Signal for requesting username from settings
380 void fetchUsernameFromSettings();
383 * @brief Signal for finding user.
385 * @param coordinates user geo coordinates
387 void findUser(const QPointF &coordinates);
390 * @brief GPS setting changed
392 * @param enabled True if GPS is enabled, otherwise false
394 void gpsTriggered(bool enabled);
397 * @brief Signal for finding friend.
399 * @param coordinates friend's geo coordinates
401 void findFriend(const QPointF &coordinates);
404 * @brief Signal for friend location ready.
408 void friendsLocationsReady(QList<User *> &friendsList);
411 * @brief Signal is emitted when location item is clicked.
413 * @param userIDs list of friends user IDs in the group
415 void locationItemClicked(const QList<QString> &userIDs);
418 * @brief Signals when Login/Logout action is pressed
421 void loginActionPressed();
424 * @brief MapView has been resized
426 * @param size view size
428 void mapViewResized(const QSize &size);
431 * @brief Forwarding signal from MapView to MapEngine
433 * @param sceneCoordinate
435 void mapViewScrolled(QPoint sceneCoordinate);
438 * @brief Forwarding signal from MapEngine to MapView
440 void maxZoomLevelReached();
443 * @brief Signal that informs that user's message/location failed to update on Situare server
444 * This signal is originally sended from SituareService with name error
445 * Signal is renamed on MainWindow
447 void messageSendingFailed(const QString &error);
450 * @brief Forwarding signal from MapEngine to MapView
452 void minZoomLevelReached();
455 * @brief Signal that used to inform user that his message/location update tp Situare server
457 * This signal is originally sended from UserInfo
459 void notificateUpdateFailing(const QString &message);
462 * @brief Signal for refreshing user data.
465 void refreshUserData();
468 * @brief Signal for requesting reverseGeo from SituareEngine
471 void requestReverseGeo();
474 * @brief Signals, when address data is ready
476 * @param address Street address
478 void reverseGeoReady(const QString &address);
481 * @brief Signal to save username to settings
483 * @param username Username
485 void saveUsername(const QString &username);
488 * @brief Signal for requestLocationUpdate from SituareEngine
490 * @param status Status message
491 * @param publish Publish on Facebook
493 void statusUpdate(const QString &status, const bool &publish);
496 * @brief Signals when webview's urlChanged signal is emitted
500 void updateCredentials(const QUrl &url);
503 * @brief Signals when updateLocation request finished successfully
506 void updateWasSuccessful();
509 * @brief MapView has finished zooming
511 void viewZoomFinished();
514 * @brief Signal for use location ready.
516 * @param user User object
518 void userLocationReady(User *user);
521 * @brief Map zoom in request
526 * @brief Forwarding signal from MapEngine to MapView
528 void zoomLevelChanged(int zoomLevel);
531 * @brief Map zoom out request
535 /*******************************************************************************
537 ******************************************************************************/
539 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
540 bool m_errorShown; ///< Indicates if error dialog/note is shown
541 bool m_loggedIn; ///< Indicates login state
542 bool m_refresh; ///< Indicates when webpage is refreshed
544 int m_viewPortHeight; ///< Height of view port
545 int m_viewPortWidth; ///< Width of view port
547 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
548 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
549 QAction *m_loginAct; ///< Action to Login/Logout
550 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
552 QLabel *m_osmLicense; ///< Label for Open Street Map license
553 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
555 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
556 QList<QDialog *> m_queue; ///< QList type dialog queue
558 QMenu *m_viewMenu; ///< Object that hold the view menu items
560 QString m_email; ///< Placeholder for email
561 QString m_password; ///< Placeholder for password
563 QToolButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
565 QWebView *m_webView; ///< Shows facebook login page
567 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
568 MapView *m_mapView; ///< Instance of the map view
569 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
570 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
571 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
572 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
573 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
575 SettingsDialog *m_settingsDialog; ///< Settings dialog
579 #endif // MAINWINDOW_H