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 interestingPeople list of interesting people
549 void interestingPeopleReceived(QList<User> &interestingPeople);
552 * @brief Signal for friend location ready.
556 void friendsLocationsReady(QList<User *> &friendsList);
559 * @brief Signals when image is downloaded
562 * @param image image pixmap
564 void friendImageReady(const QString &id, const QPixmap &image);
567 * @brief Emited when location request is parsed and is ready for further processing
569 * @param result List of Location items
571 void locationDataParsed(const QList<Location> &result);
574 * @brief Signal is emitted when location item is clicked on map.
576 * @param userIDs list of friends user IDs in the group
578 void locationItemClicked(const QList<QString> &userIDs);
581 * @brief Signal is emitted when location item is clicked in list.
583 * @param swBound south-west bound in GeoCoorinate
584 * @param neBound north-east bound in GeoCoordinate
586 void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
589 * @brief Signals when Login/Logout action is pressed
592 void loginActionPressed();
595 * @brief MapView has been resized
597 * @param size view size
599 void mapViewResized(const QSize &size);
602 * @brief Forwarding signal from MapView to MapEngine
604 * @param coordinate New center point coordinate
606 void mapViewScrolled(const SceneCoordinate &coordinate);
609 * @brief Forwarding signal from MapEngine to MapView
611 void maxZoomLevelReached();
614 * @brief Forwarding signal from MapEngine to MapView
616 void minZoomLevelReached();
619 * @brief Forwarding signal from MapEngine to MapScale
621 void newMapResolution(qreal scale);
624 * @brief Signal when fetchMessages request is finished
626 * @param messages list of messages sent to user
628 void messagesReceived(QList<Message> &messages);
631 * @brief Signal for refreshing user data.
634 void refreshUserData();
637 * @brief Signal for removing tags.
639 * @param tags tags to add
641 void removeTags(const QStringList &tags);
644 * @brief Requests contact dialog.
646 * @param facebookId contact's facebookId
648 void requestContactDialog(const QString &facebookId);
651 * @brief Requests message remove.
653 * @param id message ID
655 void requestRemoveMessage(const QString &id);
658 * @brief Requests message dialog.
659 * @param receiver receiver facebook ID and name
661 void requestMessageDialog(const QPair<QString, QString> &receiver);
664 * @brief Signal for requesting reverseGeo from SituareEngine
667 void requestReverseGeo();
670 * @brief Requests search people by tag name.
672 * @param tag tag name
674 void requestSearchPeopleByTag(const QString &tag);
677 * @brief Signals, when address data is ready
679 * @param address Street address
681 void reverseGeoReady(const QString &address);
684 * @brief Emited when route is parsed and is ready for further processing
686 * @param route Route item containing parsed route details
688 void routeParsed(Route &route);
691 * @brief Signal for routing to geo coordinates.
693 * @param coordinates destination geo coordinates
695 void routeTo(const GeoCoordinate &coordinates);
698 * @brief Request routing to current cursor position
700 void routeToCursor();
703 * @brief Signal to save username to settings
705 * @param username Username
707 void saveUsername(const QString &username);
710 * @brief Signal for location search
712 * @param location QString location
714 void searchForLocation(QString location);
717 * @brief Signal is emitted when search history item is clicked.
719 * @param searchString search string used
721 void searchHistoryItemClicked(const QString &searchString);
724 * @brief Sends a message to a person.
726 * @param receiverId Facebook user ID
727 * @param message message text
728 * @param addCoordinates true if coordinates should be added, false otherwise
730 void sendMessage(const QString &receiverId, const QString &message, bool addCoordinates);
733 * @brief Signal for requestLocationUpdate from SituareEngine
735 * @param status Status message
736 * @param publish Publish on Facebook
738 void statusUpdate(const QString &status, const bool &publish);
741 * @brief Signals when webview's urlChanged signal is emitted
745 void updateCredentials(const QUrl &url);
748 * @brief Signals when image is downloaded
751 * @param image image pixmap
753 void userImageReady(const QString &id, const QPixmap &image);
756 * @brief Signals when updateLocationDialog's data must be cleared
759 void clearUpdateLocationDialogData();
762 * @brief Dragging mode triggered.
764 void draggingModeTriggered();
767 * @brief MapView has finished zooming
769 void viewZoomFinished();
772 * @brief Requests interesting people from current map viewport.
774 * Interesting people is defined by people with same tags as user has.
776 void requestInterestingPeople();
779 * @brief Requests messages sent to the user.
781 void requestMessages();
784 * @brief Signal for use location ready.
786 * @param user User object
788 void userLocationReady(User *user);
791 * @brief Map zoom in request
796 * @brief Forwarding signal from MapEngine to MapView
798 void zoomLevelChanged(int zoomLevel);
801 * @brief Map zoom out request
805 /*******************************************************************************
807 ******************************************************************************/
809 bool m_errorShown; ///< Indicates if error dialog/note is shown
810 bool m_loggedIn; ///< Indicates login state
811 bool m_refresh; ///< Indicates when webpage is refreshed
813 int m_mapCenterHorizontalShifting; ///< Amount of map center point horizontal shifting
814 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
816 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
817 QAction *m_loginAct; ///< Action to Login/Logout
818 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
820 QLabel *m_crosshair; ///< Label for center point crosshair
821 QLabel *m_osmLicense; ///< Label for Open Street Map license
823 QList<int> m_situareTabsIndexes; ///< List of Situare tab indexes
824 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
825 QList<QDialog *> m_queue; ///< QList type dialog queue
827 QMenu *m_viewMenu; ///< Object that hold the view menu items
829 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
831 QString m_email; ///< Placeholder for email
832 QString m_password; ///< Placeholder for password
834 QWebView *m_webView; ///< Shows facebook login page
836 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
837 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
838 IndicatorButtonPanel *m_indicatorButtonPanel; ///< Instance of direction indicator button
839 LocationSearchPanel *m_locationSearchPanel; ///< Location search panel
840 MapScale *m_mapScale; ///< Instance of the map scale
841 MapView *m_mapView; ///< Instance of the map view
842 MeetPeoplePanel *m_meetPeoplePanel; ///< Instance of MeetPeoplePanel
843 NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
844 MessagePanel *m_messagePanel; ///< Instance of MessagePanel
845 RoutingPanel *m_routingPanel; ///< Instance of routing panel
846 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
847 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
848 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
851 #endif // MAINWINDOW_H