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
8 Katri Kaikkonen - katri.kaikkonen@ixonos.com
10 Situare is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 version 2 as published by the Free Software Foundation.
14 Situare is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Situare; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
28 #include <QtGui/QMainWindow>
31 #include "network/networkcookiejar.h"
32 #include "panelsidebar.h"
41 class FacebookAuthentication;
42 class FullScreenButton;
43 class FriendListPanel;
44 class IndicatorButton;
50 class SceneCoordinate;
54 class ZoomButtonPanel;
58 * @brief Main Window Class
60 class MainWindow : public QMainWindow
68 * @param parent Parent
70 MainWindow(QWidget *parent = 0);
78 /*******************************************************************************
79 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
80 ******************************************************************************/
83 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
85 void keyPressEvent(QKeyEvent* event);
87 /*******************************************************************************
88 * MEMBER FUNCTIONS AND SLOTS
89 ******************************************************************************/
92 * @brief Clears cookie jar
95 void clearCookieJar();
102 void loggedIn(bool logged);
105 * @brief Gets the login state (logged in/logged out)
107 * @return bool Login state
112 * @brief Reads automatic location update settings.
114 void readAutomaticLocationUpdateSettings();
117 // * @brief Enable / disable auto centering button.
119 // * @param enabled true if shoud be enabled, false otherwise
121 // void setAutoCenteringButtonEnabled(bool enabled);
124 * @brief Enable / disable GPS button.
126 * Does set visibilities for manual location cursor and auto centering menu button.
128 * @param enabled true if enabled, false otherwise
130 void setGPSButtonEnabled(bool enabled);
133 * @brief Enable / disable direction indicator button.
135 * @param enabled true if shoud be enabled, false otherwise
137 void setIndicatorButtonEnabled(bool enabled);
140 * @brief Set scene for MapView
142 * @param scene Scene to be set
144 void setMapViewScene(QGraphicsScene *scene);
147 * Shows dialog with enable automatic location update question.
149 * @param text text to show in dialog
151 void showEnableAutomaticUpdateLocationDialog(const QString &text);
154 * @brief Gets the username from member variable for saving purposes
156 * @return QString Username
158 const QString username();
163 * @brief Build direction indicator button and connect slots
165 void buildIndicatorButton();
168 * @brief Builds information box with message.
170 * @param message Information message
171 * @param modal Modal = true, non-modal false
173 void buildInformationBox(const QString &message, bool modal=false);
176 * @brief Slot for failed login
181 * @brief Slot to intercept signal when login with cookies is requested
183 void loginUsingCookies();
186 * @brief Public slot, which open settings dialog
188 void openSettingsDialog();
191 * @brief Set own location crosshair visibility
195 void setOwnLocationCrosshairVisibility(bool visible);
198 * @brief Sets username to member variable for login dialog
200 * @param username Username to be set
202 void setUsername(const QString &username);
205 * @brief Method to show panels
210 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
214 void startLoginProcess();
217 * @brief Toggle progress indicator.
219 * @param state true if progress indicator should be shown, false otherwise
221 void toggleProgressIndicator(bool state);
224 * @brief Shows / hides Situare related UI items
227 void updateItemVisibility();
231 * @brief Build fullscreen toggle button and connect slots
233 void buildFullScreenButton();
236 * @brief Build friend list panel and connect slots
238 void buildFriendListPanel();
241 * @brief Build manual location setting cross hair and connect slots
243 void buildManualLocationCrosshair();
246 * @brief Build map and connect slots
251 * @brief Build map scale and connect slots
253 void buildMapScale();
256 * @brief Build OSM license and connect slots
258 void buildOsmLicense();
261 * @brief Build user info panel and connect slots
263 void buildUserInfoPanel();
266 * @brief Build webview and connect slots
271 * @brief Build zoom button panel and connect slots
273 void buildZoomButtonPanel();
276 * @brief Private method to create the Menu items
281 * @brief Grab or release HW increase and decrease buttons.
283 * @param grab Use true for grabbing and false for releasing the keys
285 void grabZoomKeys(bool grab);
288 * @brief Queues dialog/information box
290 * @param dialog Dialog to be added into queue
292 void queueDialog(QDialog *dialog);
295 * @brief Shows queued error information box
298 void showErrorInformationBox();
301 * @brief Shows queued information box
303 * @fn showInformationBox
305 void showInformationBox();
309 * @brief Slot for automatic update dialog finished.
311 * @result result code
313 void automaticUpdateDialogFinished(int result);
316 * @brief Slot to intercept signal when dialog/information note is processed
318 * @param status Status of the dialog
320 void dialogFinished(int status);
323 * @brief Slot for drawing the fullscreen toggle button
325 * @param size Size of the screen
327 void drawFullScreenButton(const QSize &size);
330 * @brief Slot for drawing the map distance scale
332 * @param size Size of the screen
334 void drawMapScale(const QSize &size);
337 * @brief Slot for drawing the Open Street Map license text
339 * @param size Size of the screen
341 void drawOsmLicense(const QSize &size);
344 * @brief Slot for drawing the own location crosshair
346 * @param size Size of the screen
348 void drawOwnLocationCrosshair(const QSize &size);
351 * @brief Slot to intercept signal when error dialog/information note is processed
353 * @param status Status of the dialog
355 void errorDialogFinished(int status);
358 * @brief Slot for gps timeout.
360 * Called when request timeout occurs.
365 * @brief Slot to load cookies from settings
370 * @brief Slot to intercept signal when webview has finished loading webpage
372 * @param done Status of the loading
374 void loadDone(bool done);
377 * @brief Slot to save cookies to settings
382 * @brief Slot for settings dialog accepted.
384 void settingsDialogAccepted();
387 * @brief Set correnct view port size to datamembers
389 * @param size Size of the screen
391 void setViewPortSize(const QSize &size);
394 * @brief Start location search (open search dialog)
396 void startLocationSearch();
399 * @brief Toggle between fullscreen and normal window mode
401 void toggleFullScreen();
404 * @brief Slot to intercept signal from webview's networkaccessmanager
406 * @param reply Network reply (contains errors)
408 void webViewRequestFinished(QNetworkReply* reply);
410 /*******************************************************************************
412 ******************************************************************************/
415 * @brief Automatic centering setting changed by user
417 * @param enabled True if automatic centering is enabled, otherwise false
419 void autoCenteringTriggered(bool enabled);
422 * @brief Signal that indicates when user has cancelled login process
425 void cancelLoginProcess();
428 * @brief View should be centered to new location
430 * @param coordinate Scene coordinates of the new center point
432 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
435 * @brief Signal for enabling automatic location update.
437 * @param enabled true if enabled, false otherwise
438 * @param updateIntervalMsecs update interval in milliseconds
440 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
443 * @brief Signals error
445 * @param context error context
446 * @param error error code
448 void error(const int context, const int error);
451 * @brief Signal for requesting username from settings
454 void fetchUsernameFromSettings();
457 * @brief Signal for finding user.
459 * @param coordinates user geo coordinates
461 void findUser(const GeoCoordinate &coordinates);
464 * @brief Signals when friend's profile image is ready
468 void friendImageReady(User *user);
471 * @brief GPS setting changed
473 * @param enabled True if GPS is enabled, otherwise false
475 void gpsTriggered(bool enabled);
478 * @brief Signal for finding friend.
480 * @param coordinates friend's geo coordinates
482 void findFriend(const GeoCoordinate &coordinates);
485 * @brief Signal for friend location ready.
489 void friendsLocationsReady(QList<User *> &friendsList);
492 * @brief Signal is emitted when location item is clicked.
494 * @param userIDs list of friends user IDs in the group
496 void locationItemClicked(const QList<QString> &userIDs);
499 * @brief Signals when Login/Logout action is pressed
502 void loginActionPressed();
505 * @brief MapView has been resized
507 * @param size view size
509 void mapViewResized(const QSize &size);
512 * @brief Forwarding signal from MapView to MapEngine
516 void mapViewScrolled(const SceneCoordinate &coordinate);
519 * @brief Forwarding signal from MapEngine to MapView
521 void maxZoomLevelReached();
524 * @brief Forwarding signal from MapEngine to MapView
526 void minZoomLevelReached();
529 * @brief Forwarding signal from MapEngine to MapScale
531 void newMapResolution(qreal scale);
534 * @brief Signal for refreshing user data.
537 void refreshUserData();
540 * @brief Signal for requesting reverseGeo from SituareEngine
543 void requestReverseGeo();
546 * @brief Signals, when address data is ready
548 * @param address Street address
550 void reverseGeoReady(const QString &address);
553 * @brief Signal to save username to settings
555 * @param username Username
557 void saveUsername(const QString &username);
560 * @brief Signal for location search
562 * @param location QString location
564 void searchForLocation(QString location);
567 * @brief Signal for requestLocationUpdate from SituareEngine
569 * @param status Status message
570 * @param publish Publish on Facebook
572 void statusUpdate(const QString &status, const bool &publish);
575 * @brief Signals when webview's urlChanged signal is emitted
579 void updateCredentials(const QUrl &url);
582 * @brief Signals when updateLocationDialog's data must be cleared
585 void clearUpdateLocationDialogData();
588 * @brief MapView has finished zooming
590 void viewZoomFinished();
593 * @brief Signal for use location ready.
595 * @param user User object
597 void userLocationReady(User *user);
600 * @brief Map zoom in request
605 * @brief Forwarding signal from MapEngine to MapView
607 void zoomLevelChanged(int zoomLevel);
610 * @brief Map zoom out request
614 /*******************************************************************************
616 ******************************************************************************/
618 bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
619 bool m_errorShown; ///< Indicates if error dialog/note is shown
620 bool m_loggedIn; ///< Indicates login state
621 bool m_refresh; ///< Indicates when webpage is refreshed
623 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
625 QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
626 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
627 QAction *m_loginAct; ///< Action to Login/Logout
628 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
629 QAction *m_searchLocationAct; /// @todo this is temporary, remove when not needed!
631 QLabel *m_osmLicense; ///< Label for Open Street Map license
632 QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
634 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
635 QList<QDialog *> m_queue; ///< QList type dialog queue
637 QMenu *m_viewMenu; ///< Object that hold the view menu items
639 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
641 QSize m_viewPortSize; ///< Size of the viewport
643 QString m_email; ///< Placeholder for email
644 QString m_password; ///< Placeholder for password
646 QWebView *m_webView; ///< Shows facebook login page
648 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
649 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
650 IndicatorButton *m_indicatorButton; ///< Instance of direction indicator button
651 MapScale *m_mapScale; ///< Instance of the map scale
652 MapView *m_mapView; ///< Instance of the map view
653 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
654 PanelSideBar *m_userPanelSidebar; ///< User panel side bar
655 PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
656 UserInfoPanel *m_userPanel; ///< Instance of the user information panel
657 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
660 #endif // MAINWINDOW_H