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>
35 #include <QNetworkReply>
38 #include "situareservice/message.h"
39 #include "network/networkcookiejar.h"
49 class FriendListPanel;
50 class FullScreenButton;
52 class IndicatorButtonPanel;
54 class LocationSearchPanel;
58 class MeetPeoplePanel;
62 class SceneCoordinate;
69 class ZoomButtonPanel;
72 * @brief Main Window Class
74 class MainWindow : public QMainWindow
82 * @param parent Parent
84 MainWindow(QWidget *parent = 0);
91 /*******************************************************************************
92 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
93 ******************************************************************************/
96 * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
98 void keyPressEvent(QKeyEvent* event);
100 /*******************************************************************************
101 * MEMBER FUNCTIONS AND SLOTS
102 ******************************************************************************/
105 * @brief Build and show login dialog with login browser
107 * @param browser Login browser instance
109 void buildLoginDialog(QWebView *browser);
116 void loggedIn(bool logged);
119 * @brief Reads automatic location update settings.
121 void readAutomaticLocationUpdateSettings();
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);
155 * @brief Builds information box with message.
157 * @param message Information message
158 * @param modal Modal = true, non-modal false
160 void buildInformationBox(const QString &message, bool modal=false);
163 * @brief Hides and deletes login dialog
165 void destroyLoginDialog();
168 * @brief Public slot, which open settings dialog
170 void openSettingsDialog();
173 * @brief Set own location crosshair visibility
177 void setCrosshairVisibility(bool visible);
180 * @brief Shows contact dialog.
182 * Shows contact dialog with contact's information.
183 * @param guid globally unique ID of a contact
185 void showContactDialog(const QString &guid);
188 * @brief Shows message dialog.
190 * @param receiver receiver ID and name
192 void showMessageDialog(const QPair<QString, QString> &receiver);
195 * @brief Toggle progress indicator.
197 * @param state true if progress indicator should be shown, false otherwise
199 void toggleProgressIndicator(bool state);
202 * @brief Shows / hides Situare related UI items based on login state
204 * @param loggedIn Is the user currently logged in
206 void updateItemVisibility(bool loggedIn);
210 * @brief Build manual location setting cross hair and connect slots
212 void buildCrosshair();
215 * @brief Build friend list panel and connect slots
217 void buildFriendListPanel();
220 * @brief Build fullscreen toggle button and connect slots
222 void buildFullScreenButton();
225 * @brief Build direction indicator button panel and connect signals
227 void buildIndicatorButtonPanel();
230 * @brief Build location search panel and connect signals
232 void buildLocationSearchPanel();
235 * @brief Build map and connect slots
240 * @brief Build map scale and connect slots
242 void buildMapScale();
245 * @brief Build meet people panel and connect slots
247 void buildMeetPeoplePanel();
250 * @brief Build message panel and connect slots
252 void buildMessagePanel();
255 * @brief Build OSM license and connect slots
257 void buildOsmLicense();
260 * @brief Build application panels
265 * @brief Build routing panel and connect slots
267 void buildRoutingPanel();
270 * @brief Build user info panel and connect slots
272 void buildUserInfoPanel();
275 * @brief Build zoom button panel and connect slots
277 void buildZoomButtonPanel();
280 * @brief Private method to create the Menu items
285 * @brief Grab or release HW increase and decrease buttons.
287 * @param grab Use true for grabbing and false for releasing the keys
289 void grabZoomKeys(bool grab);
292 * @brief Queues dialog/information box
294 * @param dialog Dialog to be added into queue
296 void queueDialog(QDialog *dialog);
299 * @brief Shows queued error information box
302 void showErrorInformationBox();
305 * @brief Shows queued information box
307 * @fn showInformationBox
309 void showInformationBox();
313 * @brief Slot for automatic update dialog finished.
315 * @result result code
317 void automaticUpdateDialogFinished(int result);
320 * @brief Slot to intercept signal when dialog/information note is processed
322 * @param status Status of the dialog
324 void dialogFinished(int status);
327 * @brief Slot for drawing the fullscreen toggle button
329 * @param size Size of the screen
331 void drawFullScreenButton(const QSize &size);
334 * @brief Slot for drawing the map distance scale
336 * @param size Size of the screen
338 void drawMapScale(const QSize &size);
341 * @brief Slot for drawing the Open Street Map license text
343 * @param size Size of the screen
345 void drawOsmLicense(const QSize &size);
348 * @brief Slot to intercept signal when error dialog/information note is processed
350 * @param status Status of the dialog
352 void errorDialogFinished(int status);
355 * @brief Slot for gps timeout.
357 * Called when request timeout occurs.
362 * @brief Called when map center point horizontal shifting is changed
364 * @param shifting New shifting value
366 void mapCenterHorizontalShiftingChanged(int shifting);
369 * @brief Move the crosshair
371 void moveCrosshair();
374 * @brief Slot for settings dialog accepted.
376 void settingsDialogAccepted();
379 * @brief Show update location dialog
381 void showUpdateLocationDialog();
384 * @brief Start location search (open search dialog)
386 void startLocationSearch();
389 * @brief Start people search (open search dialog)
391 void startPeopleSearch();
394 * @brief Toggle between fullscreen and normal window mode
396 void toggleFullScreen();
399 * REMOVE THIS, FIXES WEBVIEW BUG IN SCRATCHBOX
401 void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
403 /*******************************************************************************
405 ******************************************************************************/
408 * @brief Signal for adding tags.
410 * @param tags tags to add
412 void addTags(const QStringList &tags);
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 for centering to coordinates.
424 * @param coordinates geo coordinates to center to.
426 void centerToCoordinates(const GeoCoordinate &coordinates);
429 * @brief View should be centered to new location
431 * @param coordinate Scene coordinates of the new center point
433 void centerToSceneCoordinates(const SceneCoordinate &coordinate);
436 * @brief Emitted when route is cleared
441 * @brief Signal when direction and distance from current map center point to current GPS
442 * location is changed
444 * @param direction Direction in degrees
445 * @param distance Distance in meters
446 * @param draw Should the indicator triangle be drawn or not
448 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
451 * @brief Signal for enabling automatic location update.
453 * @param enabled true if enabled, false otherwise
454 * @param updateIntervalMsecs update interval in milliseconds
456 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
459 * @brief Signals error
461 * @param context error context
462 * @param error error code
464 void error(const int context, const int error);
467 * @brief Signals when friend's profile image is ready
471 void friendImageReady(User *user);
474 * @brief GPS setting changed
476 * @param enabled True if GPS is enabled, otherwise false
478 void gpsTriggered(bool enabled);
481 * @brief Signal when fetchPeopleWithSimilarInterest request is finished
483 * @param friends list of friends
484 * @param others list of other people
486 void interestingPeopleReceived(QList<User> &friends, QList<User> &others);
489 * @brief Signal for friend location ready.
493 void friendsLocationsReady(QList<User *> &friendsList);
496 * @brief Signals when image is downloaded
499 * @param image image pixmap
501 void friendImageReady(const QString &id, const QPixmap &image);
504 * @brief Emited when location request is parsed and is ready for further processing
506 * @param result List of Location items
508 void locationDataParsed(const QList<Location> &result);
511 * @brief Signal is emitted when location item is clicked on map.
513 * @param userIDs list of friends user IDs in the group
515 void locationItemClicked(const QList<QString> &userIDs);
518 * @brief Signal is emitted when location item is clicked in list.
520 * @param swBound south-west bound in GeoCoorinate
521 * @param neBound north-east bound in GeoCoordinate
523 void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
526 * @brief Send location update
528 * @param status Status message
529 * @param publish Publish on Facebook?
531 void locationUpdate(const QString &status, bool publish);
534 * @brief Signals when Login/Logout action is pressed
537 void loginActionPressed();
540 * @brief MapView has been resized
542 * @param size view size
544 void mapViewResized(const QSize &size);
547 * @brief Forwarding signal from MapView to MapEngine
549 * @param coordinate New center point coordinate
551 void mapViewScrolled(const SceneCoordinate &coordinate);
554 * @brief Forwarding signal from MapEngine to MapView
556 void maxZoomLevelReached();
559 * @brief Forwarding signal from MapEngine to MapView
561 void minZoomLevelReached();
564 * @brief Forwarding signal from MapEngine to MapScale
566 void newMapResolution(qreal scale);
569 * @brief Signal when fetchMessages request is finished
571 * @param messages list of messages sent to user
573 void messagesReceived(QList<Message> &received, QList<Message> &sent);
576 * @brief Signals when fetchPopularTags request is finished
578 * @param popularTags list of popular tags
580 void popularTagsReceived(QHash<QString, QString> &popularTags);
583 * @brief Signal for requesting popular tags
585 void requestPopularTags();
588 * @brief Signal for refreshing user data.
591 void refreshUserData();
594 * @brief Signal for removing tags.
596 * @param tags tags to add
598 void removeTags(const QStringList &tags);
601 * @brief Requests contact dialog.
603 * @param facebookId contact's facebookId
605 void requestContactDialog(const QString &facebookId);
608 * @brief Requests message remove.
610 * @param id message ID
612 void requestRemoveMessage(const QString &id);
615 * @brief Requests message dialog.
616 * @param receiver receiver facebook ID and name
618 void requestMessageDialog(const QPair<QString, QString> &receiver);
621 * @brief Signal for requesting reverseGeo from SituareEngine
624 void requestReverseGeo();
627 * @brief Requests search people by tag name.
629 * @param tag tag name
631 void requestSearchPeopleByTag(const QString &tag);
634 * @brief Signals, when address data is ready
636 * @param address Street address
638 void reverseGeoReady(const QString &address);
641 * @brief Emited when route is parsed and is ready for further processing
643 * @param route Route item containing parsed route details
645 void routeParsed(Route &route);
648 * @brief Signal for routing to geo coordinates.
650 * @param coordinates destination geo coordinates
652 void routeTo(const GeoCoordinate &coordinates);
655 * @brief Request routing to current cursor position
657 void routeToCursor();
660 * @brief Signal for location search
662 * @param location QString location
664 void searchForLocation(QString location);
667 * @brief Signal is emitted when search history item is clicked.
669 * @param searchString search string used
671 void searchHistoryItemClicked(const QString &searchString);
674 * @brief Sends a message to a person.
676 * @param receiverId Facebook user ID
677 * @param message message text
678 * @param addCoordinates true if coordinates should be added, false otherwise
680 void sendMessage(const QString &receiverId, const QString &message, bool addCoordinates);
683 * @brief Signals when image is downloaded
686 * @param image image pixmap
688 void userImageReady(const QString &id, const QPixmap &image);
691 * @brief Dragging mode triggered.
693 void draggingModeTriggered();
696 * @brief MapView has finished zooming
698 void viewZoomFinished();
701 * @brief Requests interesting people from current map viewport.
703 * Interesting people is defined by people with same tags as user has.
705 void requestInterestingPeople();
708 * @brief Requests messages sent to the user.
710 void requestMessages();
713 * @brief Signals when updateLocation request finished successfully
715 void updateWasSuccessful();
718 * @brief Signal for use location ready.
720 * @param user User object
722 void userLocationReady(User *user);
725 * @brief Map zoom in request
730 * @brief Forwarding signal from MapEngine to MapView
732 void zoomLevelChanged(int zoomLevel);
735 * @brief Map zoom out request
739 /*******************************************************************************
741 ******************************************************************************/
743 bool m_errorShown; ///< Indicates if error dialog/note is shown
744 bool m_loggedIn; ///< Indicates login state
745 bool m_refresh; ///< Indicates when webpage is refreshed
747 int m_mapCenterHorizontalShifting; ///< Amount of map center point horizontal shifting
748 int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
750 QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
751 QAction *m_loginAct; ///< Action to Login/Logout
752 QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
754 QDialog *m_loginDialog; ///< Login dialog
756 QLabel *m_crosshair; ///< Label for center point crosshair
757 QLabel *m_osmLicense; ///< Label for Open Street Map license
759 QList<int> m_situareTabsIndexes; ///< List of Situare tab indexes
760 QList<QDialog *> m_error_queue; ///< QList type error dialog queue
761 QList<QDialog *> m_queue; ///< QList type dialog queue
763 QMenu *m_viewMenu; ///< Object that hold the view menu items
765 QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
767 FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
768 FullScreenButton *m_fullScreenButton; ///< Instance of the fullscreen toggle button
769 IndicatorButtonPanel *m_indicatorButtonPanel; ///< Instance of direction indicator button
770 LocationSearchPanel *m_locationSearchPanel; ///< Location search panel
771 MapScale *m_mapScale; ///< Instance of the map scale
772 MapView *m_mapView; ///< Instance of the map view
773 MeetPeoplePanel *m_meetPeoplePanel; ///< Instance of MeetPeoplePanel
774 MessagePanel *m_messagePanel; ///< Instance of MessagePanel
775 RoutingPanel *m_routingPanel; ///< Instance of routing panel
776 TabbedPanel *m_tabbedPanel; ///< Widget for tabbed panels
777 UpdateLocation *m_updateLocationController; ///< Controller for update location dialog
778 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel
779 ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel
782 #endif // MAINWINDOW_H