Added missing comments to engine.h, liblocationwrapper.h, mainwindow.h
[situare] / src / ui / mainwindow.h
index 2657415..90b08dd 100644 (file)
 #include <QtGui/QMainWindow>
 #include <QUrl>
 
+#include "network/networkcookiejar.h"
 #include "panelsidebar.h"
 
 class QGraphicsScene;
 class QLabel;
 class QWebView;
+class QNetworkReply;
 
 class FacebookAuthentication;
 class FriendListPanel;
-class LoginDialog;
+class MapScale;
 class MapScene;
 class MapView;
 class SituareService;
@@ -43,6 +45,8 @@ class User;
 class UserInfoPanel;
 class ZoomButtonPanel;
 class SettingsDialog;
+class QToolButton;
+class QMessageBox;
 
 /**
 * @brief Main Window Class
@@ -77,7 +81,21 @@ private:
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
-public:    
+public:
+    /**
+    * @brief Builds information box with message.
+    *
+    * @param message Information message
+    * @param modal Modal = true, non-modal false
+    */
+    void buildInformationBox(const QString &message, bool modal=false);
+
+    /**
+    * @brief Clears cookie jar
+    *
+    */
+    void clearCookieJar();
+
     /**
     * @brief
     *
@@ -86,6 +104,12 @@ public:
     void loggedIn(bool logged);
 
     /**
+    * @brief Requests automatic location update settings.
+    */
+    void requestAutomaticLocationUpdateSettings();
+
+
+    /**
     * @brief Enable / disable auto centering button.
     *
     * @param enabled true if shoud be enabled, false otherwise
@@ -109,11 +133,11 @@ public:
     void setMapViewScene(QGraphicsScene *scene);
 
     /**
-    * @brief Show Maemo information box with message.
+    * Shows dialog with enable automatic location update question.
     *
-    * @brief message information message
+    * @param text text to show in dialog
     */
-    void showMaemoInformationBox(const QString &message);
+    void showEnableAutomaticUpdateLocationDialog(const QString &text);
 
     /**
     * @brief Gets the username from member variable for saving purposes
@@ -124,18 +148,16 @@ public:
 
 public slots:
     /**
-    * @brief Slot to intercept signal when user has pressed connect button from loginDialog
+    * @brief Slot to intercept signal when login has failed (loginFailure signal)
     *
-    * @param email E-mail
-    * @param password Password
     */
-    void loginDialogDone(const QString &email, const QString &password);
+    void loginFailed();
 
     /**
-    * @brief Slot to intercept signal when login has failed (loginFailure signal)
+    * @brief Slot to intercept signal when login with cookies is requested
     *
     */
-    void loginFailed();
+    void loginUsingCookies();
 
     /**
     * @brief Public slot, which open settings dialog
@@ -150,19 +172,11 @@ public slots:
     void setUsername(const QString &username);
 
     /**
-    * @brief
-    *
-    * @param show
-    */
-    void showPanels(bool show);
-
-    /**
     * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
     *        doesn't exist yet
     *
-    * @param url Login page url
     */
-    void startLoginProcess(const QUrl &url);
+    void startLoginProcess();
 
     /**
     * @brief Toggle progress indicator.
@@ -171,8 +185,20 @@ public slots:
     */
     void toggleProgressIndicator(bool state);
 
+    /**
+    * @brief Shows / hides Situare related UI items
+    *
+    * @param show
+    */
+    void updateItemVisibility(bool show);
+
 private:
     /**
+      * @brief Build fullscreen toggle button and connect slots
+      */
+    void buildFullScreenButton();
+
+    /**
       * @brief Build friend list panel and connect slots
       */
     void buildFriendListPanel();
@@ -188,6 +214,11 @@ private:
     void buildMap();
 
     /**
+     * @brief Build map scale and connect slots
+     */
+    void buildMapScale();
+
+    /**
       * @brief Build OSM license and connect slots
       */
     void buildOsmLicense();
@@ -198,6 +229,12 @@ private:
     void buildUserInfoPanel();
 
     /**
+    * @brief Build webview and connect slots
+    *
+    */
+    void buildWebView();
+
+    /**
       * @brief Build zoom button panel and connect slots
       */
     void buildZoomButtonPanel();
@@ -215,14 +252,62 @@ private:
     void grabZoomKeys(bool grab);
 
     /**
+    * @brief Queues dialog/information box
+    *
+    * @param dialog Dialog to be added into queue
+    */
+    void queueDialog(QDialog *dialog);
+
+    /**
       * @brief Set own location crosshair visibility
       *
       * @param visible
       */
     void setOwnLocationCrosshairVisibility(bool visible);
 
+    /**
+    * @brief Shows queued error information box
+    *
+    */
+    void showErrorInformationBox();
+
+    /**
+    * @brief Shows queued information box
+    *
+    * @fn showInformationBox
+    */
+    void showInformationBox();
+
 private slots:
     /**
+    * @brief Slot for automatic update dialog finished.
+    *
+    * @result result code
+    */
+    void automaticUpdateDialogFinished(int result);
+
+    /**
+    * @brief Slot to intercept signal when dialog/information note is processed
+    *
+    * @param status Status of the dialog
+    */
+    void dialogFinished(int status);
+
+    /**
+    * @brief Slot for drawing the fullscreen toggle button
+    *
+    * @param size Size of the screen
+    */
+    void drawFullScreenButton(const QSize &size);
+
+    /**
+    * @brief Slot for drawing the map distance scale
+    *
+    * @param size Size of the screen
+    */
+    void drawMapScale(const QSize &size);
+
+    /**
     * @brief Slot for drawing the Open Street Map license text
     *
     * @param size Size of the screen
@@ -232,17 +317,16 @@ private slots:
     /**
     * @brief Slot for drawing the own location crosshair
     *
-    * @param width Width of the viewport
-    * @param height Height of the viewport
+    * @param size Size of the screen
     */
-    void drawOwnLocationCrosshair(int width, int height);
+    void drawOwnLocationCrosshair(const QSize &size);
 
     /**
-    * @brief Slot for gps error.
+    * @brief Slot to intercept signal when error dialog/information note is processed
     *
-    * @param message error message
+    * @param status Status of the dialog
     */
-    void gpsError(const QString &message);
+    void errorDialogFinished(int status);
 
     /**
     * @brief Slot for gps timeout.
@@ -252,6 +336,12 @@ private slots:
     void gpsTimeout();
 
     /**
+    * @brief Slot to load cookies from settings
+    *
+    */
+    void loadCookies();
+
+    /**
     * @brief Slot to intercept signal when webview has finished loading webpage
     *
     * @param done Status of the loading
@@ -259,12 +349,29 @@ private slots:
     void loadDone(bool done);
 
     /**
+    * @brief Slot to save cookies to settings
+    *
+    */
+    void saveCookies();
+
+    /**
     * @brief Set correnct view port size to datamembers
     *
-    * @param width Width of the viewport
-    * @param height Height of the viewport
+    * @param size Size of the screen
+    */
+    void setViewPortSize(const QSize &size);
+
+    /**
+    * @brief Toggle between fullscreen and normal window mode
     */
-    void setViewPortSize(const int width, const int height);
+    void toggleFullScreen();
+
+    /**
+    * @brief Slot to intercept signal from webview's networkaccessmanager
+    *
+    * @param reply Network reply (contains errors)
+    */
+    void webViewRequestFinished(QNetworkReply* reply);
 
 /*******************************************************************************
  * SIGNALS
@@ -305,6 +412,13 @@ signals:
     void fetchUsernameFromSettings();
 
     /**
+    * @brief Signal for finding user.
+    *
+    * @param coordinates user geo coordinates
+    */
+    void findUser(const QPointF &coordinates);
+
+    /**
     * @brief GPS setting changed
     *
     * @param enabled True if GPS is enabled, otherwise false
@@ -358,11 +472,30 @@ signals:
     void maxZoomLevelReached();
 
     /**
+    * @brief Signal that informs that user's message/location failed to update on Situare server
+    *        This signal is originally sended from SituareService with name error
+    *        Signal is renamed on MainWindow
+    */
+    void messageSendingFailed(const QString &error);
+
+    /**
       * @brief Forwarding signal from MapEngine to MapView
       */
     void minZoomLevelReached();
 
     /**
+    * @brief Signal that used to inform user that his message/location update tp Situare server
+    *        was failed.
+    *        This signal is originally sended from UserInfo
+    */
+    void notificateUpdateFailing(const QString &message);
+
+    /**
+     * @brief Forwarding signal from MapEngine to MapScale
+     */
+    void newMapResolution(qreal scale);
+
+    /**
     * @brief Signal for refreshing user data.
     *
     */
@@ -382,6 +515,13 @@ signals:
     void reverseGeoReady(const QString &address);
 
     /**
+    * @brief Signal to save username to settings
+    *
+    * @param username Username
+    */
+    void saveUsername(const QString &username);
+
+    /**
     * @brief Signal for requestLocationUpdate from SituareEngine
     *
     * @param status Status message
@@ -397,6 +537,12 @@ signals:
     void updateCredentials(const QUrl &url);
 
     /**
+    * @brief Signals when updateLocation request finished successfully
+    *
+    */
+    void updateWasSuccessful();
+
+    /**
     * @brief MapView has finished zooming
     */
     void viewZoomFinished();
@@ -427,8 +573,8 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 private:
-
     bool m_drawOwnLocationCrosshair;        ///< Flag for making ownLocationCrosshair visible or not
+    bool m_errorShown;                      ///< Indicates if error dialog/note is shown
     bool m_loggedIn;                        ///< Indicates login state
     bool m_refresh;                         ///< Indicates when webpage is refreshed
 
@@ -443,18 +589,24 @@ private:
     QLabel *m_osmLicense;                   ///< Label for Open Street Map license
     QLabel *m_ownLocationCrosshair;         ///< Label that show ownLocationCrosshair
 
+    QList<QDialog *> m_error_queue;         ///< QList type error dialog queue
+    QList<QDialog *> m_queue;               ///< QList type dialog queue
+
     QMenu *m_viewMenu;                      ///< Object that hold the view menu items
 
+    QMessageBox *m_automaticUpdateLocationDialog;   ///< Automatic update location dialog
+
     QString m_email;                        ///< Placeholder for email
     QString m_password;                     ///< Placeholder for password
 
-    QUrl m_loginUrl;                        ///< Placeholder for login page url
+    QToolButton *m_fullScreenButton;        ///< Instance of the fullscreen toggle button
 
     QWebView *m_webView;                    ///< Shows facebook login page
 
     FriendListPanel *m_friendsListPanel;    ///< Instance of friends list panel
-    LoginDialog *m_loginDialog;             ///< Login dialog
+    MapScale *m_mapScale;                   ///< Instance of the map scale
     MapView *m_mapView;                     ///< Instance of the map view
+    NetworkCookieJar *m_cookieJar;          ///< Placeholder for QNetworkCookies
     PanelSideBar *m_userPanelSidebar;       ///< User panel side bar
     PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
     UserInfoPanel *m_userPanel;             ///< Instance of the user information panel