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>
34 #include <QNetworkReply>
37 #include "situareservice/message.h"
38 #include "network/networkcookiejar.h"
47 class FacebookAuthentication;
48 class FriendListPanel;
49 class FullScreenButton;
51 class IndicatorButtonPanel;
53 class LocationSearchPanel;
57 class MeetPeoplePanel;
61 class SceneCoordinate;
67 class ZoomButtonPanel;
70 * @brief Main Window Class
72 class MainWindow : public QMainWindow
80 * @param parent Parent
82 MainWindow(QWidget *parent = 0);
89 /*******************************************************************************
90 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
91 ******************************************************************************/
94 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
96 void keyPressEvent(QKeyEvent* event);
98 /*******************************************************************************
99 * MEMBER FUNCTIONS AND SLOTS
100 ******************************************************************************/
103 * @brief Clears cookie jar
106 void clearCookieJar();
113 void loggedIn(bool logged);
116 * @brief Gets the login state (logged in/logged out)
118 * @return bool Login state
123 * @brief Reads automatic location update settings.
125 void readAutomaticLocationUpdateSettings();
128 * @brief Enable / disable GPS button.
130 * Does set visibilities for manual location cursor and auto centering menu button.
132 * @param enabled true if enabled, false otherwise
134 void setGPSButtonEnabled(bool enabled);
137 * @brief Enable / disable direction indicator button.
139 * @param enabled true if shoud be enabled, false otherwise
141 void setIndicatorButtonEnabled(bool enabled);
144 * @brief Set scene for MapView
146 * @param scene Scene to be set
148 void setMapViewScene(QGraphicsScene *scene);
151 * Shows dialog with enable automatic location update question.
153 * @param text text to show in dialog
155 void showEnableAutomaticUpdateLocationDialog(const QString &text);
158 * @brief Gets the username from member variable for saving purposes
160 * @return QString Username
162 const QString username();
166 * @brief Builds information box with message.
168 * @param message Information message
169 * @param modal Modal = true, non-modal false
171 void buildInformationBox(const QString &message, bool modal=false);
174 * @brief Slot for failed login
179 * @brief Slot to intercept signal when login with cookies is requested
181 void loginUsingCookies();
184 * @brief Public slot, which open settings dialog
186 void openSettingsDialog();
189 * @brief Set own location crosshair visibility
193 void setCrosshairVisibility(bool visible);
196 * @brief Sets username to member variable for login dialog
198 * @param username Username to be set
200 void setUsername(const QString &username);
203 * @brief Shows contact dialog.
205 * Shows contact dialog with contact's information.
206 * @param guid globally unique ID of a contact
208 void showContactDialog(const QString &guid);
211 * @brief Shows message dialog.
213 * @param receiver receiver ID and name
215 void showMessageDialog(const QPair<QString, QString> &receiver);
218 * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
221 void startLoginProcess();
224 * @brief Toggle progress indicator.
226 * @param state true if progress indicator should be shown, false otherwise
228 void toggleProgressIndicator(bool state);
231 * @brief Shows / hides Situare related UI items
234 void updateItemVisibility();
238 * @brief Build manual location setting cross hair and connect slots
240 void buildCrosshair();
243 * @brief Build friend list panel and connect slots
245 void buildFriendListPanel();
248 * @brief Build fullscreen toggle button and connect slots
250 void buildFullScreenButton();
253 * @brief Build direction indicator button panel and connect signals
255 void buildIndicatorButtonPanel();
258 * @brief Build location search panel and connect signals
260 void buildLocationSearchPanel();
263 * @brief Build map and connect slots
268 * @brief Build map scale and connect slots
270 void buildMapScale();
273 * @brief Build meet people panel and connect slots
275 void buildMeetPeoplePanel();
278 * @brief Build message panel and connect slots
280 void buildMessagePanel();
283 * @brief Build OSM license and connect slots
285 void buildOsmLicense();
288 * @brief Build application panels
293 * @brief Build routing panel and connect slots
295 void buildRoutingPanel();
298 * @brief Build user info panel and connect slots
300 void buildUserInfoPanel();
303 * @brief Build webview and connect slots
308 * @brief Build zoom button panel and connect slots
310 void buildZoomButtonPanel();
313 * @brief Private method to create the Menu items
318 * @brief Grab or release HW increase and decrease buttons.
320 * @param grab Use true for grabbing and false for releasing the keys
322 void grabZoomKeys(bool grab);
325 * @brief Queues dialog/information box
327 * @param dialog Dialog to be added into queue
329 void queueDialog(QDialog *dialog);
332 * @brief Shows queued error information box
335 void showErrorInformationBox();
338 * @brief Shows queued information box
340 * @fn showInformationBox
342 void showInformationBox();
346 * @brief Slot for automatic update dialog finished.
348 * @result result code
350 void automaticUpdateDialogFinished(int result);
353 * @brief Slot to intercept signal when dialog/information note is processed
355 * @param status Status of the dialog
357 void dialogFinished(int status);
360 * @brief Slot for drawing the fullscreen toggle button
362 * @param size Size of the screen
364 void drawFullScreenButton(const QSize &size);
367 * @brief Slot for drawing the map distance scale
369 * @param size Size of the screen
371 void drawMapScale(const QSize &size);
374 * @brief Slot for drawing the Open Street Map license text
376 * @param size Size of the screen
378 void drawOsmLicense(const QSize &size);
381 * @brief Slot to intercept signal when error dialog/information note is processed
383 * @param status Status of the dialog
385 void errorDialogFinished(int status);
388 * @brief Slot for gps timeout.
390 * Called when request timeout occurs.
395 * @brief Slot to load cookies from settings
400 * @brief Slot to intercept signal when webview has finished loading webpage
402 * @param done Status of the loading
404 void loadDone(bool done);
407 * @brief Called when map center point horizontal shifting is changed
409 * @param shifting New shifting value
411 void mapCenterHorizontalShiftingChanged(int shifting);
414 * @brief Move the crosshair
416 void moveCrosshair();
419 * @brief Slot to save cookies to settings
424 * @brief Slot for settings dialog accepted.
426 void settingsDialogAccepted();
429 * @brief Start location search (open search dialog)
431 void startLocationSearch();
434 * @brief Start people search (open search dialog)
436 void startPeopleSearch();
439 * @brief Toggle between fullscreen and normal window mode
441 void toggleFullScreen();
444 * @brief Slot to intercept signal from webview's networkaccessmanager
446 * @param reply Network reply (contains errors)
448 void webViewRequestFinished(QNetworkReply* reply);
451 * REMOVE THIS, FIXES WEBVIEW BUG IN SCRATCHBOX
453 void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
455 /*******************************************************************************
457 ******************************************************************************/
460 * @brief Signal for adding tags.
462 * @param tags tags to add
464 void addTags(const QStringList &tags);
467 * @brief Automatic centering setting changed by user
469 * @param enabled True if automatic centering is enabled, otherwise false
471 void autoCenteringTriggered(bool enabled);
474 * @brief Signal that indicates when user has cancelled login process
477 void cancelLoginProcess();
480 * @brief Signal for centering to coordinates.
482 * @param coordinates geo coordinates to center to.
484 void centerToCoordinates(const GeoCoordinate &coordinates);
487 * @brief View should be centered to new location
489 * @param coordinate Scene coordinates of the new center point
491 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
494 * @brief Emitted when route is cleared
499 * @brief Signal when direction and distance from current map center point to current GPS
500 * location is changed
502 * @param direction Direction in degrees
503 * @param distance Distance in meters
504 * @param draw Should the indicator triangle be drawn or not
506 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
509 * @brief Signal for enabling automatic location update.
511 * @param enabled true if enabled, false otherwise
512 * @param updateIntervalMsecs update interval in milliseconds
514 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
517 * @brief Signals error
519 * @param context error context
520 * @param error error code
522 void error(const int context, const int error);
525 * @brief Signal for requesting username from settings
528 void fetchUsernameFromSettings();
531 * @brief Signals when friend's profile image is ready
535 void friendImageReady(User *user);
538 * @brief GPS setting changed
540 * @param enabled True if GPS is enabled, otherwise false
542 void gpsTriggered(bool enabled);
545 * @brief Signal when fetchPeopleWithSimilarInterest request is finished
547 * @param friends list of friends
548 * @param others list of other people
550 void interestingPeopleReceived(QList<User> &friends, QList<User> &others);
553 * @brief Signal for friend location ready.
557 void friendsLocationsReady(QList<User *> &friendsList);
560 * @brief Signals when image is downloaded
563 * @param image image pixmap
565 void friendImageReady(const QString &id, const QPixmap &image);
568 * @brief Emited when location request is parsed and is ready for further processing
570 * @param result List of Location items
572 void locationDataParsed(const QList<Location> &result);
575 * @brief Signal is emitted when location item is clicked on map.
577 * @param userIDs list of friends user IDs in the group
579 void locationItemClicked(const QList<QString> &userIDs);
582 * @brief Signal is emitted when location item is clicked in list.
584 * @param swBound south-west bound in GeoCoorinate
585 * @param neBound north-east bound in GeoCoordinate
587 void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
590 * @brief Signals when Login/Logout action is pressed
593 void loginActionPressed();
596 * @brief MapView has been resized
598 * @param size view size
600 void mapViewResized(const QSize &size);
603 * @brief Forwarding signal from MapView to MapEngine
605 * @param coordinate New center point coordinate
607 void mapViewScrolled(const SceneCoordinate &coordinate);
610 * @brief Forwarding signal from MapEngine to MapView
612 void maxZoomLevelReached();
615 * @brief Forwarding signal from MapEngine to MapView
617 void minZoomLevelReached();
620 * @brief Forwarding signal from MapEngine to MapScale
622 void newMapResolution(qreal scale);
625 * @brief Signal when fetchMessages request is finished
627 * @param messages list of messages sent to user
629 void messagesReceived(QList<Message> &received, QList<Message> &sent);
632 * @brief Signals when fetchPopularTags request is finished
634 * @param popularTags list of popular tags
636 void popularTagsReceived(QHash<QString, QString> &popularTags);
639 * @brief Signal for requesting popular tags
641 void requestPopularTags();
644 * @brief Signal for refreshing user data.
647 void refreshUserData();
650 * @brief Signal for removing tags.
652 * @param tags tags to add
654 void removeTags(const QStringList &tags);
657 * @brief Requests contact dialog.
659 * @param facebookId contact's facebookId
661 void requestContactDialog(const QString &facebookId);
664 * @brief Requests message remove.
666 * @param id message ID
668 void requestRemoveMessage(const QString &id);
671 * @brief Requests message dialog.
672 * @param receiver receiver facebook ID and name
674 void requestMessageDialog(const QPair<QString, QString> &receiver);
677 * @brief Signal for requesting reverseGeo from SituareEngine
680 void requestReverseGeo();
683 * @brief Requests search people by tag name.
685 * @param tag tag name
687 void requestSearchPeopleByTag(const QString &tag);
690 * @brief Signals, when address data is ready
692 * @param address Street address
694 void reverseGeoReady(const QString &address);
697 * @brief Emited when route is parsed and is ready for further processing
699 * @param route Route item containing parsed route details
701 void routeParsed(Route &route);
704 * @brief Signal for routing to geo coordinates.
706 * @param coordinates destination geo coordinates
708 void routeTo(const GeoCoordinate &coordinates);
711 * @brief Request routing to current cursor position
713 void routeToCursor();
716 * @brief Signal to save username to settings
718 * @param username Username
720 void saveUsername(const QString &username);
723 * @brief Signal for location search
725 * @param location QString location
727 void searchForLocation(QString location);
730 * @brief Signal is emitted when search history item is clicked.
732 * @param searchString search string used
734 void searchHistoryItemClicked(const QString &searchString);
737 * @brief Sends a message to a person.
739 * @param receiverId Facebook user ID
740 * @param message message text
741 * @param addCoordinates true if coordinates should be added, false otherwise
743 void sendMessage(const QString &receiverId, const QString &message, bool addCoordinates);
746 * @brief Signal for requestLocationUpdate from SituareEngine
748 * @param status Status message
749 * @param publish Publish on Facebook
751 void statusUpdate(const QString &status, const bool &publish);
754 * @brief Signals when webview's urlChanged signal is emitted
758 void updateCredentials(const QUrl &url);
761 * @brief Signals when image is downloaded
764 * @param image image pixmap
766 void userImageReady(const QString &id, const QPixmap &image);
769 * @brief Signals when updateLocationDialog's data must be cleared
772 void clearUpdateLocationDialogData();
775 * @brief Dragging mode triggered.
777 void draggingModeTriggered();
780 * @brief MapView has finished zooming
782 void viewZoomFinished();
785 * @brief Requests interesting people from current map viewport.
787 * Interesting people is defined by people with same tags as user has.
789 void requestInterestingPeople();
792 * @brief Requests messages sent to the user.
794 void requestMessages();
797 * @brief Signal for use location ready.
799 * @param user User object
801 void userLocationReady(User *user);
804 * @brief Map zoom in request
809 * @brief Forwarding signal from MapEngine to MapView
811 void zoomLevelChanged(int zoomLevel);
814 * @brief Map zoom out request
818 /*******************************************************************************
820 ******************************************************************************/
822 bool m_errorShown; ///< Indicates if error dialog/note is shown
823 bool m_loggedIn; ///< Indicates login state
824 bool m_refresh; ///< Indicates when webpage is refreshed
826 int m_mapCenterHorizontalShifting; ///< Amount of map center point horizontal shifting
827 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
829 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
830 QAction *m_loginAct; ///< Action to Login/Logout
831 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
833 QLabel *m_crosshair; ///< Label for center point crosshair
834 QLabel *m_osmLicense; ///< Label for Open Street Map license
836 QList<int> m_situareTabsIndexes; ///< List of Situare tab indexes
837 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
838 QList<QDialog *> m_queue; ///< QList type dialog queue
840 QMenu *m_viewMenu; ///< Object that hold the view menu items
842 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
844 QString m_email; ///< Placeholder for email
845 QString m_password; ///< Placeholder for password
847 QWebView *m_webView; ///< Shows facebook login page
849 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
850 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
851 IndicatorButtonPanel *m_indicatorButtonPanel; ///< Instance of direction indicator button
852 LocationSearchPanel *m_locationSearchPanel; ///< Location search panel
853 MapScale *m_mapScale; ///< Instance of the map scale
854 MapView *m_mapView; ///< Instance of the map view
855 MeetPeoplePanel *m_meetPeoplePanel; ///< Instance of MeetPeoplePanel
856 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
857 MessagePanel *m_messagePanel; ///< Instance of MessagePanel
858 RoutingPanel *m_routingPanel; ///< Instance of routing panel
859 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
860 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
861 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
864 #endif // MAINWINDOW_H