00001 /* 00002 Situare - A location system for Facebook 00003 Copyright (C) 2010 Ixonos Plc. Authors: 00004 00005 Henri Lampela - henri.lampela@ixonos.com 00006 Kaj Wallin - kaj.wallin@ixonos.com 00007 Jussi Laitinen - jussi.laitinen@ixonos.com 00008 Sami Rämö - sami.ramo@ixonos.com 00009 Ville Tiensuu - ville.tiensuu@ixonos.com 00010 Katri Kaikkonen - katri.kaikkonen@ixonos.com 00011 00012 Situare is free software; you can redistribute it and/or 00013 modify it under the terms of the GNU General Public License 00014 version 2 as published by the Free Software Foundation. 00015 00016 Situare is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 GNU General Public License for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with Situare; if not, write to the Free Software 00023 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00024 USA. 00025 */ 00026 00027 #ifndef MAINWINDOW_H 00028 #define MAINWINDOW_H 00029 00030 #include <QtGui/QMainWindow> 00031 #include <QUrl> 00032 00033 #include "network/networkcookiejar.h" 00034 00035 class QGraphicsScene; 00036 class QLabel; 00037 class QMessageBox; 00038 class QNetworkReply; 00039 class QToolButton; 00040 class QWebView; 00041 00042 class FacebookAuthentication; 00043 class FriendListPanel; 00044 class FullScreenButton; 00045 class GeoCoordinate; 00046 class IndicatorButtonPanel; 00047 class Location; 00048 class LocationSearchPanel; 00049 class MapScale; 00050 class MapScene; 00051 class MapView; 00052 class Route; 00053 class RoutingPanel; 00054 class SceneCoordinate; 00055 class SettingsDialog; 00056 class SituareService; 00057 class TabbedPanel; 00058 class User; 00059 class UserInfoPanel; 00060 class ZoomButtonPanel; 00061 00065 class MainWindow : public QMainWindow 00066 { 00067 Q_OBJECT 00068 00069 public: 00075 MainWindow(QWidget *parent = 0); 00076 00080 ~MainWindow(); 00081 00082 /******************************************************************************* 00083 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS 00084 ******************************************************************************/ 00085 private: 00089 void keyPressEvent(QKeyEvent* event); 00090 00091 /******************************************************************************* 00092 * MEMBER FUNCTIONS AND SLOTS 00093 ******************************************************************************/ 00094 public: 00099 void clearCookieJar(); 00100 00106 void loggedIn(bool logged); 00107 00113 bool loginState(); 00114 00118 void readAutomaticLocationUpdateSettings(); 00119 00127 void setGPSButtonEnabled(bool enabled); 00128 00134 void setIndicatorButtonEnabled(bool enabled); 00135 00141 void setMapViewScene(QGraphicsScene *scene); 00142 00148 void showEnableAutomaticUpdateLocationDialog(const QString &text); 00149 00155 const QString username(); 00156 00157 public slots: 00164 void buildInformationBox(const QString &message, bool modal=false); 00165 00169 void loginFailed(); 00170 00174 void loginUsingCookies(); 00175 00179 void openSettingsDialog(); 00180 00186 void setCrosshairVisibility(bool visible); 00187 00193 void setUsername(const QString &username); 00194 00201 void showContactDialog(const QString &guid); 00202 00207 void startLoginProcess(); 00208 00214 void toggleProgressIndicator(bool state); 00215 00220 void updateItemVisibility(); 00221 00222 private: 00226 void buildCrosshair(); 00227 00231 void buildFriendListPanel(); 00232 00236 void buildFullScreenButton(); 00237 00241 void buildIndicatorButtonPanel(); 00242 00243 00247 void buildLocationSearchPanel(); 00248 00252 void buildMap(); 00253 00257 void buildMapScale(); 00258 00262 void buildOsmLicense(); 00263 00267 void buildPanels(); 00268 00272 void buildRoutingPanel(); 00273 00277 void buildUserInfoPanel(); 00278 00282 void buildWebView(); 00283 00287 void buildZoomButtonPanel(); 00288 00292 void createMenus(); 00293 00299 void grabZoomKeys(bool grab); 00300 00306 void queueDialog(QDialog *dialog); 00307 00312 void showErrorInformationBox(); 00313 00319 void showInformationBox(); 00320 00321 private slots: 00327 void automaticUpdateDialogFinished(int result); 00328 00334 void dialogFinished(int status); 00335 00341 void drawFullScreenButton(const QSize &size); 00342 00348 void drawMapScale(const QSize &size); 00349 00355 void drawOsmLicense(const QSize &size); 00356 00362 void errorDialogFinished(int status); 00363 00369 void gpsTimeout(); 00370 00374 void loadCookies(); 00375 00381 void loadDone(bool done); 00382 00388 void mapCenterHorizontalShiftingChanged(int shifting); 00389 00393 void moveCrosshair(); 00394 00398 void saveCookies(); 00399 00403 void settingsDialogAccepted(); 00404 00408 void startLocationSearch(); 00409 00413 void toggleFullScreen(); 00414 00420 void webViewRequestFinished(QNetworkReply* reply); 00421 00422 /******************************************************************************* 00423 * SIGNALS 00424 ******************************************************************************/ 00425 signals: 00431 void autoCenteringTriggered(bool enabled); 00432 00437 void cancelLoginProcess(); 00438 00444 void centerToCoordinates(const GeoCoordinate &coordinates); 00445 00451 void centerToSceneCoordinates(const SceneCoordinate &coordinate); 00452 00456 void clearRoute(); 00457 00466 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw); 00467 00474 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0); 00475 00482 void error(const int context, const int error); 00483 00488 void fetchUsernameFromSettings(); 00489 00495 void friendImageReady(User *user); 00496 00502 void gpsTriggered(bool enabled); 00503 00509 void friendsLocationsReady(QList<User *> &friendsList); 00510 00516 void locationDataParsed(const QList<Location> &result); 00517 00523 void locationItemClicked(const QList<QString> &userIDs); 00524 00531 void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound); 00532 00537 void loginActionPressed(); 00538 00544 void mapViewResized(const QSize &size); 00545 00551 void mapViewScrolled(const SceneCoordinate &coordinate); 00552 00556 void maxZoomLevelReached(); 00557 00561 void minZoomLevelReached(); 00562 00566 void newMapResolution(qreal scale); 00567 00572 void refreshUserData(); 00573 00579 void requestContactDialog(const QString &facebookId); 00580 00585 void requestReverseGeo(); 00586 00592 void reverseGeoReady(const QString &address); 00593 00599 void routeParsed(Route &route); 00600 00606 void routeTo(const GeoCoordinate &coordinates); 00607 00611 void routeToCursor(); 00612 00618 void saveUsername(const QString &username); 00619 00625 void searchForLocation(QString location); 00626 00632 void searchHistoryItemClicked(const QString &searchString); 00633 00640 void statusUpdate(const QString &status, const bool &publish); 00641 00647 void updateCredentials(const QUrl &url); 00648 00653 void clearUpdateLocationDialogData(); 00654 00658 void draggingModeTriggered(); 00659 00663 void viewZoomFinished(); 00664 00670 void userLocationReady(User *user); 00671 00675 void zoomIn(); 00676 00680 void zoomLevelChanged(int zoomLevel); 00681 00685 void zoomOut(); 00686 00687 /******************************************************************************* 00688 * DATA MEMBERS 00689 ******************************************************************************/ 00690 private: 00691 bool m_errorShown; 00692 bool m_loggedIn; 00693 bool m_refresh; 00694 00695 int m_mapCenterHorizontalShifting; 00696 int m_progressIndicatorCount; 00697 00698 QAction *m_gpsToggleAct; 00699 QAction *m_loginAct; 00700 QAction *m_toSettingsAct; 00701 00702 QLabel *m_crosshair; 00703 QLabel *m_osmLicense; 00704 00705 QList<int> m_situareTabsIndexes; 00706 QList<QDialog *> m_error_queue; 00707 QList<QDialog *> m_queue; 00708 00709 QMenu *m_viewMenu; 00710 00711 QMessageBox *m_automaticUpdateLocationDialog; 00712 00713 QString m_email; 00714 QString m_password; 00715 00716 QWebView *m_webView; 00717 00718 FriendListPanel *m_friendsListPanel; 00719 FullScreenButton *m_fullScreenButton; 00720 IndicatorButtonPanel *m_indicatorButtonPanel; 00721 LocationSearchPanel *m_locationSearchPanel; 00722 MapScale *m_mapScale; 00723 MapView *m_mapView; 00724 NetworkCookieJar *m_cookieJar; 00725 RoutingPanel *m_routingPanel; 00726 TabbedPanel *m_tabbedPanel; 00727 UserInfoPanel *m_userInfoPanel; 00728 ZoomButtonPanel *m_zoomButtonPanel; 00729 }; 00730 00731 #endif // MAINWINDOW_H