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 Requests automatic location update settings.
101 void requestAutomaticLocationUpdateSettings();
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 * Shows dialog with enable automatic location update question.
130 * @param text text to show in dialog
132 void showEnableAutomaticUpdateLocationDialog(const QString &text);
135 * @brief Gets the username from member variable for saving purposes
137 * @return QString Username
139 const QString username();
143 * @brief Builds information box with message.
145 * @param message Information message
146 * @param modal Modal = true, non-modal false
148 void buildInformationBox(const QString &message, bool modal=false);
151 * @brief Slot to intercept signal when login has failed (loginFailure signal)
157 * @brief Slot to intercept signal when login with cookies is requested
160 void loginUsingCookies();
163 * @brief Public slot, which open settings dialog
165 void openSettingsDialog();
168 * @brief Set own location crosshair visibility
172 void setOwnLocationCrosshairVisibility(bool visible);
175 * @brief Sets username to member variable for login dialog
177 * @param username Username to be set
179 void setUsername(const QString &username);
182 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
186 void startLoginProcess();
189 * @brief Toggle progress indicator.
191 * @param state true if progress indicator should be shown, false otherwise
193 void toggleProgressIndicator(bool state);
196 * @brief Shows / hides Situare related UI items
200 void updateItemVisibility(bool show);
204 * @brief Build fullscreen toggle button and connect slots
206 void buildFullScreenButton();
209 * @brief Build friend list panel and connect slots
211 void buildFriendListPanel();
214 * @brief Build manual location setting cross hair and connect slots
216 void buildManualLocationCrosshair();
219 * @brief Build map and connect slots
224 * @brief Build map scale and connect slots
226 void buildMapScale();
229 * @brief Build OSM license and connect slots
231 void buildOsmLicense();
234 * @brief Build user info panel and connect slots
236 void buildUserInfoPanel();
239 * @brief Build webview and connect slots
245 * @brief Build zoom button panel and connect slots
247 void buildZoomButtonPanel();
250 * @brief Private method to create the Menu items
255 * @brief Grab or release HW increase and decrease buttons.
257 * @param grab Use true for grabbing and false for releasing the keys
259 void grabZoomKeys(bool grab);
262 * @brief Queues dialog/information box
264 * @param dialog Dialog to be added into queue
266 void queueDialog(QDialog *dialog);
269 // * @brief Set own location crosshair visibility
273 // void setOwnLocationCrosshairVisibility(bool visible);
276 * @brief Shows queued error information box
279 void showErrorInformationBox();
282 * @brief Shows queued information box
284 * @fn showInformationBox
286 void showInformationBox();
290 * @brief Slot for automatic update dialog finished.
292 * @result result code
294 void automaticUpdateDialogFinished(int result);
297 * @brief Slot to intercept signal when dialog/information note is processed
299 * @param status Status of the dialog
301 void dialogFinished(int status);
304 * @brief Slot for drawing the fullscreen toggle button
306 * @param size Size of the screen
308 void drawFullScreenButton(const QSize &size);
311 * @brief Slot for drawing the map distance scale
313 * @param size Size of the screen
315 void drawMapScale(const QSize &size);
318 * @brief Slot for drawing the Open Street Map license text
320 * @param size Size of the screen
322 void drawOsmLicense(const QSize &size);
325 * @brief Slot for drawing the own location crosshair
327 * @param size Size of the screen
329 void drawOwnLocationCrosshair(const QSize &size);
332 * @brief Slot to intercept signal when error dialog/information note is processed
334 * @param status Status of the dialog
336 void errorDialogFinished(int status);
339 * @brief Slot for gps timeout.
341 * Called when request timeout occurs.
346 * @brief Slot to load cookies from settings
352 * @brief Slot to intercept signal when webview has finished loading webpage
354 * @param done Status of the loading
356 void loadDone(bool done);
359 * @brief Slot to save cookies to settings
365 * @brief Set correnct view port size to datamembers
367 * @param size Size of the screen
369 void setViewPortSize(const QSize &size);
372 * @brief Toggle between fullscreen and normal window mode
374 void toggleFullScreen();
377 * @brief Slot to intercept signal from webview's networkaccessmanager
379 * @param reply Network reply (contains errors)
381 void webViewRequestFinished(QNetworkReply* reply);
383 /*******************************************************************************
385 ******************************************************************************/
388 * @brief Automatic centering setting changed by user
390 * @param enabled True if automatic centering is enabled, otherwise false
392 void autoCenteringTriggered(bool enabled);
395 * @brief Signal that indicates when user has cancelled login process
398 void cancelLoginProcess();
401 * @brief View should be centered to new location
403 * @param sceneCoordinate Scene coordinates of the new center point
405 void centerToSceneCoordinates(QPoint sceneCoordinate);
408 * @brief Signal for enabling automatic location update.
410 * @param enabled true if enabled, false otherwise
411 * @param updateIntervalMsecs update interval in milliseconds
413 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs);
416 * @brief Signals error
418 * @param error Error code
420 void error(const int error);
423 * @brief Signal for requesting username from settings
426 void fetchUsernameFromSettings();
429 * @brief Signal for finding user.
431 * @param coordinates user geo coordinates
433 void findUser(const QPointF &coordinates);
436 * @brief GPS setting changed
438 * @param enabled True if GPS is enabled, otherwise false
440 void gpsTriggered(bool enabled);
443 * @brief Signal for finding friend.
445 * @param coordinates friend's geo coordinates
447 void findFriend(const QPointF &coordinates);
450 * @brief Signal for friend location ready.
454 void friendsLocationsReady(QList<User *> &friendsList);
457 * @brief Signal is emitted when location item is clicked.
459 * @param userIDs list of friends user IDs in the group
461 void locationItemClicked(const QList<QString> &userIDs);
464 * @brief Signals when Login/Logout action is pressed
467 void loginActionPressed();
470 * @brief MapView has been resized
472 * @param size view size
474 void mapViewResized(const QSize &size);
477 * @brief Forwarding signal from MapView to MapEngine
479 * @param sceneCoordinate
481 void mapViewScrolled(QPoint sceneCoordinate);
484 * @brief Forwarding signal from MapEngine to MapView
486 void maxZoomLevelReached();
489 * @brief Signal that informs that user's message/location failed to update on Situare server
490 * This signal is originally sended from SituareService with name error
491 * Signal is renamed on MainWindow
493 * @param error error code
495 void messageSendingFailed(const int error);
498 * @brief Forwarding signal from MapEngine to MapView
500 void minZoomLevelReached();
503 * @brief Forwarding signal from MapEngine to MapScale
505 void newMapResolution(qreal scale);
508 * @brief Signal for refreshing user data.
511 void refreshUserData();
514 * @brief Signal for requesting reverseGeo from SituareEngine
517 void requestReverseGeo();
520 * @brief Signals, when address data is ready
522 * @param address Street address
524 void reverseGeoReady(const QString &address);
527 * @brief Signal to save username to settings
529 * @param username Username
531 void saveUsername(const QString &username);
534 * @brief Signal for requestLocationUpdate from SituareEngine
536 * @param status Status message
537 * @param publish Publish on Facebook
539 void statusUpdate(const QString &status, const bool &publish);
542 * @brief Signals when webview's urlChanged signal is emitted
546 void updateCredentials(const QUrl &url);
549 * @brief Signals when updateLocation request finished successfully
552 void updateWasSuccessful();
555 * @brief MapView has finished zooming
557 void viewZoomFinished();
560 * @brief Signal for use location ready.
562 * @param user User object
564 void userLocationReady(User *user);
567 * @brief Map zoom in request
572 * @brief Forwarding signal from MapEngine to MapView
574 void zoomLevelChanged(int zoomLevel);
577 * @brief Map zoom out request
581 /*******************************************************************************
583 ******************************************************************************/
585 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
586 bool m_errorShown; ///< Indicates if error dialog/note is shown
587 bool m_loggedIn; ///< Indicates login state
588 bool m_refresh; ///< Indicates when webpage is refreshed
590 int m_viewPortHeight; ///< Height of view port
591 int m_viewPortWidth; ///< Width of view port
593 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
594 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
595 QAction *m_loginAct; ///< Action to Login/Logout
596 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
598 QLabel *m_osmLicense; ///< Label for Open Street Map license
599 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
601 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
602 QList<QDialog *> m_queue; ///< QList type dialog queue
604 QMenu *m_viewMenu; ///< Object that hold the view menu items
606 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
608 QString m_email; ///< Placeholder for email
609 QString m_password; ///< Placeholder for password
611 QToolButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
613 QWebView *m_webView; ///< Shows facebook login page
615 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
616 MapScale *m_mapScale; ///< Instance of the map scale
617 MapView *m_mapView; ///< Instance of the map view
618 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
619 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
620 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
621 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
622 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
624 SettingsDialog *m_settingsDialog; ///< Settings dialog
627 #endif // MAINWINDOW_H