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 Sami Rämö - sami.ramo@ixonos.com 00008 00009 Situare is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License 00011 version 2 as published by the Free Software Foundation. 00012 00013 Situare is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with Situare; if not, write to the Free Software 00020 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00021 USA. 00022 */ 00023 00024 #ifndef MAINWINDOW_H 00025 #define MAINWINDOW_H 00026 00027 #include <QtGui/QMainWindow> 00028 #include <QUrl> 00029 00030 #include "network/networkcookiejar.h" 00031 #include "panelsidebar.h" 00032 00033 class QGraphicsScene; 00034 class QLabel; 00035 class QWebView; 00036 class QNetworkReply; 00037 00038 class FacebookAuthentication; 00039 class FriendListPanel; 00040 class MapScale; 00041 class MapScene; 00042 class MapView; 00043 class SituareService; 00044 class User; 00045 class UserInfoPanel; 00046 class ZoomButtonPanel; 00047 class SettingsDialog; 00048 class QToolButton; 00049 class QMessageBox; 00050 00054 class MainWindow : public QMainWindow 00055 { 00056 Q_OBJECT 00057 00058 public: 00064 MainWindow(QWidget *parent = 0); 00065 00070 ~MainWindow(); 00071 00072 /******************************************************************************* 00073 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS 00074 ******************************************************************************/ 00075 private: 00079 void keyPressEvent(QKeyEvent* event); 00080 00081 /******************************************************************************* 00082 * MEMBER FUNCTIONS AND SLOTS 00083 ******************************************************************************/ 00084 public: 00091 void buildInformationBox(const QString &message, bool modal=false); 00092 00097 void clearCookieJar(); 00098 00104 void loggedIn(bool logged); 00105 00109 void requestAutomaticLocationUpdateSettings(); 00110 00111 00117 void setAutoCenteringButtonEnabled(bool enabled); 00118 00126 void setGPSButtonEnabled(bool enabled); 00127 00133 void setMapViewScene(QGraphicsScene *scene); 00134 00140 void showEnableAutomaticUpdateLocationDialog(const QString &text); 00141 00147 const QString username(); 00148 00149 public slots: 00154 void loginFailed(); 00155 00160 void loginUsingCookies(); 00161 00165 void openSettingsDialog(); 00166 00172 void setUsername(const QString &username); 00173 00179 void startLoginProcess(); 00180 00186 void toggleProgressIndicator(bool state); 00187 00193 void updateItemVisibility(bool show); 00194 00195 private: 00199 void buildFullScreenButton(); 00200 00204 void buildFriendListPanel(); 00205 00209 void buildManualLocationCrosshair(); 00210 00214 void buildMap(); 00215 00219 void buildMapScale(); 00220 00224 void buildOsmLicense(); 00225 00229 void buildUserInfoPanel(); 00230 00235 void buildWebView(); 00236 00240 void buildZoomButtonPanel(); 00241 00245 void createMenus(); 00246 00252 void grabZoomKeys(bool grab); 00253 00259 void queueDialog(QDialog *dialog); 00260 00266 void setOwnLocationCrosshairVisibility(bool visible); 00267 00272 void showErrorInformationBox(); 00273 00279 void showInformationBox(); 00280 00281 private slots: 00287 void automaticUpdateDialogFinished(int result); 00288 00294 void dialogFinished(int status); 00295 00301 void drawFullScreenButton(const QSize &size); 00302 00308 void drawMapScale(const QSize &size); 00309 00315 void drawOsmLicense(const QSize &size); 00316 00322 void drawOwnLocationCrosshair(const QSize &size); 00323 00329 void errorDialogFinished(int status); 00330 00336 void gpsTimeout(); 00337 00342 void loadCookies(); 00343 00349 void loadDone(bool done); 00350 00355 void saveCookies(); 00356 00362 void setViewPortSize(const QSize &size); 00363 00367 void toggleFullScreen(); 00368 00374 void webViewRequestFinished(QNetworkReply* reply); 00375 00376 /******************************************************************************* 00377 * SIGNALS 00378 ******************************************************************************/ 00379 signals: 00385 void autoCenteringTriggered(bool enabled); 00386 00391 void cancelLoginProcess(); 00392 00398 void centerToSceneCoordinates(QPoint sceneCoordinate); 00399 00406 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs); 00407 00412 void fetchUsernameFromSettings(); 00413 00419 void findUser(const QPointF &coordinates); 00420 00426 void gpsTriggered(bool enabled); 00427 00433 void findFriend(const QPointF &coordinates); 00434 00440 void friendsLocationsReady(QList<User *> &friendsList); 00441 00447 void locationItemClicked(const QList<QString> &userIDs); 00448 00453 void loginActionPressed(); 00454 00460 void mapViewResized(const QSize &size); 00461 00467 void mapViewScrolled(QPoint sceneCoordinate); 00468 00472 void maxZoomLevelReached(); 00473 00479 void messageSendingFailed(const QString &error); 00480 00484 void minZoomLevelReached(); 00485 00491 void notificateUpdateFailing(const QString &message); 00492 00496 void newMapResolution(qreal scale); 00497 00502 void refreshUserData(); 00503 00508 void requestReverseGeo(); 00509 00515 void reverseGeoReady(const QString &address); 00516 00522 void saveUsername(const QString &username); 00523 00530 void statusUpdate(const QString &status, const bool &publish); 00531 00537 void updateCredentials(const QUrl &url); 00538 00543 void updateWasSuccessful(); 00544 00548 void viewZoomFinished(); 00549 00555 void userLocationReady(User *user); 00556 00560 void zoomIn(); 00561 00565 void zoomLevelChanged(int zoomLevel); 00566 00570 void zoomOut(); 00571 00572 /******************************************************************************* 00573 * DATA MEMBERS 00574 ******************************************************************************/ 00575 private: 00576 bool m_drawOwnLocationCrosshair; 00577 bool m_errorShown; 00578 bool m_loggedIn; 00579 bool m_refresh; 00580 00581 int m_viewPortHeight; 00582 int m_viewPortWidth; 00583 00584 QAction *m_autoCenteringAct; 00585 QAction *m_gpsToggleAct; 00586 QAction *m_loginAct; 00587 QAction *m_toSettingsAct; 00588 00589 QLabel *m_osmLicense; 00590 QLabel *m_ownLocationCrosshair; 00591 00592 QList<QDialog *> m_error_queue; 00593 QList<QDialog *> m_queue; 00594 00595 QMenu *m_viewMenu; 00596 00597 QMessageBox *m_automaticUpdateLocationDialog; 00598 00599 QString m_email; 00600 QString m_password; 00601 00602 QToolButton *m_fullScreenButton; 00603 00604 QWebView *m_webView; 00605 00606 FriendListPanel *m_friendsListPanel; 00607 MapScale *m_mapScale; 00608 MapView *m_mapView; 00609 NetworkCookieJar *m_cookieJar; 00610 PanelSideBar *m_userPanelSidebar; 00611 PanelSideBar *m_friendsListPanelSidebar; 00612 UserInfoPanel *m_userPanel; 00613 ZoomButtonPanel *m_zoomButtonPanel; 00614 00615 SettingsDialog *m_settingsDialog; 00616 }; 00617 00618 #endif // MAINWINDOW_H