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 Jussi Laitinen - jussi.laitinen@ixonos.com
8 Sami Rämö - sami.ramo@ixonos.com
9 Ville Tiensuu - ville.tiensuu@ixonos.com
10 Katri Kaikkonen - katri.kaikkonen@ixonos.com
12 Situare is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License
14 version 2 as published by the Free Software Foundation.
16 Situare is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with Situare; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
30 #include <QtGui/QMainWindow>
33 #include "network/networkcookiejar.h"
42 class FacebookAuthentication;
43 class FullScreenButton;
44 class FriendListPanel;
45 class IndicatorButtonPanel;
54 class SceneCoordinate;
59 class ZoomButtonPanel;
63 * @brief Main Window Class
65 class MainWindow : public QMainWindow
73 * @param parent Parent
75 MainWindow(QWidget *parent = 0);
82 /*******************************************************************************
83 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
84 ******************************************************************************/
87 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
89 void keyPressEvent(QKeyEvent* event);
91 /*******************************************************************************
92 * MEMBER FUNCTIONS AND SLOTS
93 ******************************************************************************/
96 * @brief Clears cookie jar
99 void clearCookieJar();
106 void loggedIn(bool logged);
109 * @brief Gets the login state (logged in/logged out)
111 * @return bool Login state
116 * @brief Reads automatic location update settings.
118 void readAutomaticLocationUpdateSettings();
121 * @brief Enable / disable GPS button.
123 * Does set visibilities for manual location cursor and auto centering menu button.
125 * @param enabled true if enabled, false otherwise
127 void setGPSButtonEnabled(bool enabled);
130 * @brief Enable / disable direction indicator button.
132 * @param enabled true if shoud be enabled, false otherwise
134 void setIndicatorButtonEnabled(bool enabled);
137 * @brief Set scene for MapView
139 * @param scene Scene to be set
141 void setMapViewScene(QGraphicsScene *scene);
144 * Shows dialog with enable automatic location update question.
146 * @param text text to show in dialog
148 void showEnableAutomaticUpdateLocationDialog(const QString &text);
151 * @brief Gets the username from member variable for saving purposes
153 * @return QString Username
155 const QString username();
159 * @brief Build direction indicator button panel and connect signals
161 void buildIndicatorButtonPanel();
164 * @brief Builds information box with message.
166 * @param message Information message
167 * @param modal Modal = true, non-modal false
169 void buildInformationBox(const QString &message, bool modal=false);
172 * @brief Slot for failed login
177 * @brief Slot to intercept signal when login with cookies is requested
179 void loginUsingCookies();
182 * @brief Public slot, which open settings dialog
184 void openSettingsDialog();
187 * @brief Set own location crosshair visibility
191 void setOwnLocationCrosshairVisibility(bool visible);
194 * @brief Sets username to member variable for login dialog
196 * @param username Username to be set
198 void setUsername(const QString &username);
201 * @brief Method to show panels
206 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
210 void startLoginProcess();
213 * @brief Toggle progress indicator.
215 * @param state true if progress indicator should be shown, false otherwise
217 void toggleProgressIndicator(bool state);
220 * @brief Shows / hides Situare related UI items
223 void updateItemVisibility();
227 * @brief Build fullscreen toggle button and connect slots
229 void buildFullScreenButton();
232 * @brief Build friend list panel and connect slots
234 void buildFriendListPanel();
237 * @brief Build manual location setting cross hair and connect slots
239 void buildManualLocationCrosshair();
242 * @brief Build map and connect slots
247 * @brief Build map scale and connect slots
249 void buildMapScale();
252 * @brief Build OSM license and connect slots
254 void buildOsmLicense();
257 * @brief Build application panels
262 * @brief Build routing panel and connect slots
264 void buildRoutingPanel();
267 * @brief Build user info panel and connect slots
269 void buildUserInfoPanel();
272 * @brief Build webview and connect slots
277 * @brief Build zoom button panel and connect slots
279 void buildZoomButtonPanel();
282 * @brief Private method to create the Menu items
287 * @brief Grab or release HW increase and decrease buttons.
289 * @param grab Use true for grabbing and false for releasing the keys
291 void grabZoomKeys(bool grab);
294 * @brief Queues dialog/information box
296 * @param dialog Dialog to be added into queue
298 void queueDialog(QDialog *dialog);
301 * @brief Shows queued error information box
304 void showErrorInformationBox();
307 * @brief Shows queued information box
309 * @fn showInformationBox
311 void showInformationBox();
315 * @brief Slot for automatic update dialog finished.
317 * @result result code
319 void automaticUpdateDialogFinished(int result);
322 * @brief Slot to intercept signal when dialog/information note is processed
324 * @param status Status of the dialog
326 void dialogFinished(int status);
329 * @brief Slot for drawing the fullscreen toggle button
331 * @param size Size of the screen
333 void drawFullScreenButton(const QSize &size);
336 * @brief Slot for drawing the map distance scale
338 * @param size Size of the screen
340 void drawMapScale(const QSize &size);
343 * @brief Slot for drawing the Open Street Map license text
345 * @param size Size of the screen
347 void drawOsmLicense(const QSize &size);
350 * @brief Slot for drawing the own location crosshair
352 * @param size Size of the screen
354 void drawOwnLocationCrosshair(const QSize &size);
357 * @brief Slot to intercept signal when error dialog/information note is processed
359 * @param status Status of the dialog
361 void errorDialogFinished(int status);
364 * @brief Slot for gps timeout.
366 * Called when request timeout occurs.
371 * @brief Slot to load cookies from settings
376 * @brief Slot to intercept signal when webview has finished loading webpage
378 * @param done Status of the loading
380 void loadDone(bool done);
383 * @brief Slot to save cookies to settings
388 * @brief Slot for settings dialog accepted.
390 void settingsDialogAccepted();
393 * @brief Set correnct view port size to datamembers
395 * @param size Size of the screen
397 void setViewPortSize(const QSize &size);
400 * @brief Start location search (open search dialog)
402 void startLocationSearch();
405 * @brief Toggle between fullscreen and normal window mode
407 void toggleFullScreen();
410 * @brief Slot to intercept signal from webview's networkaccessmanager
412 * @param reply Network reply (contains errors)
414 void webViewRequestFinished(QNetworkReply* reply);
416 /*******************************************************************************
418 ******************************************************************************/
421 * @brief Automatic centering setting changed by user
423 * @param enabled True if automatic centering is enabled, otherwise false
425 void autoCenteringTriggered(bool enabled);
428 * @brief Signal that indicates when user has cancelled login process
431 void cancelLoginProcess();
434 * @brief Signal for centering to coordinates.
436 * @param coordinates geo coordinates to center to.
438 void centerToCoordinates(const GeoCoordinate &coordinates);
441 * @brief View should be centered to new location
443 * @param coordinate Scene coordinates of the new center point
445 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
448 * @brief Signal when direction and distance from current map center point to current GPS
449 * location is changed
451 * @param direction Direction in degrees
452 * @param distance Distance in meters
453 * @param draw Should the indicator triangle be drawn or not
455 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
458 * @brief Signal for enabling automatic location update.
460 * @param enabled true if enabled, false otherwise
461 * @param updateIntervalMsecs update interval in milliseconds
463 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
466 * @brief Signals error
468 * @param context error context
469 * @param error error code
471 void error(const int context, const int error);
474 * @brief Signal for requesting username from settings
477 void fetchUsernameFromSettings();
480 * @brief Signals when friend's profile image is ready
484 void friendImageReady(User *user);
487 * @brief GPS setting changed
489 * @param enabled True if GPS is enabled, otherwise false
491 void gpsTriggered(bool enabled);
494 * @brief Signal for friend location ready.
498 void friendsLocationsReady(QList<User *> &friendsList);
501 * @brief Emited when location request is parsed and is ready for further processing
503 * @param result List of Location items
505 void locationDataParsed(const QList<Location> &result);
508 * @brief Signal is emitted when location item is clicked on map.
510 * @param userIDs list of friends user IDs in the group
512 void locationItemClicked(const QList<QString> &userIDs);
515 * @brief Signal is emitted when location item is clicked in list.
517 * @param swBound south-west bound in GeoCoorinate
518 * @param neBound north-east bound in GeoCoordinate
520 void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
523 * @brief Signals when Login/Logout action is pressed
526 void loginActionPressed();
529 * @brief MapView has been resized
531 * @param size view size
533 void mapViewResized(const QSize &size);
536 * @brief Forwarding signal from MapView to MapEngine
540 void mapViewScrolled(const SceneCoordinate &coordinate);
543 * @brief Forwarding signal from MapEngine to MapView
545 void maxZoomLevelReached();
548 * @brief Forwarding signal from MapEngine to MapView
550 void minZoomLevelReached();
553 * @brief Forwarding signal from MapEngine to MapScale
555 void newMapResolution(qreal scale);
558 * @brief Signal for refreshing user data.
561 void refreshUserData();
564 * @brief Signal for requesting reverseGeo from SituareEngine
567 void requestReverseGeo();
570 * @brief Signals, when address data is ready
572 * @param address Street address
574 void reverseGeoReady(const QString &address);
577 * @brief Emited when route is parsed and is ready for further processing
579 * @param route Route item containing parsed route details
581 void routeParsed(Route &route);
584 * @brief Signal for routing to geo coordinates.
586 * @param coordinates destination geo coordinates
588 void routeTo(const GeoCoordinate &coordinates);
591 * @brief Signal to save username to settings
593 * @param username Username
595 void saveUsername(const QString &username);
598 * @brief Signal for location search
600 * @param location QString location
602 void searchForLocation(QString location);
605 * @brief Signal for requestLocationUpdate from SituareEngine
607 * @param status Status message
608 * @param publish Publish on Facebook
610 void statusUpdate(const QString &status, const bool &publish);
613 * @brief Signals when webview's urlChanged signal is emitted
617 void updateCredentials(const QUrl &url);
620 * @brief Signals when updateLocationDialog's data must be cleared
623 void clearUpdateLocationDialogData();
626 * @brief Dragging mode triggered.
628 void draggingModeTriggered();
631 * @brief MapView has finished zooming
633 void viewZoomFinished();
636 * @brief Signal for use location ready.
638 * @param user User object
640 void userLocationReady(User *user);
643 * @brief Map zoom in request
648 * @brief Forwarding signal from MapEngine to MapView
650 void zoomLevelChanged(int zoomLevel);
653 * @brief Map zoom out request
657 /*******************************************************************************
659 ******************************************************************************/
661 bool m_errorShown; ///< Indicates if error dialog/note is shown
662 bool m_loggedIn; ///< Indicates login state
663 bool m_refresh; ///< Indicates when webpage is refreshed
665 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
667 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
668 QAction *m_loginAct; ///< Action to Login/Logout
669 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
670 QAction *m_searchLocationAct; /// @todo this is temporary, remove when not needed!
672 QLabel *m_osmLicense; ///< Label for Open Street Map license
673 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
675 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
676 QList<QDialog *> m_queue; ///< QList type dialog queue
678 QMenu *m_viewMenu; ///< Object that hold the view menu items
680 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
682 QSize m_viewPortSize; ///< Size of the viewport
684 QString m_email; ///< Placeholder for email
685 QString m_password; ///< Placeholder for password
687 QWebView *m_webView; ///< Shows facebook login page
689 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
690 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
691 IndicatorButtonPanel *m_indicatorButtonPanel; ///< Instance of direction indicator button
692 MapScale *m_mapScale; ///< Instance of the map scale
693 MapView *m_mapView; ///< Instance of the map view
694 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
695 RoutingPanel *m_routingPanel; ///< Instance of routing panel
696 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
697 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
698 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
701 #endif // MAINWINDOW_H