Updated error handling, added error contexts. Fixed fullscreen button
[situare] / src / ui / mainwindow.h
index 2177b3e..a0829ed 100644 (file)
 class QGraphicsScene;
 class QLabel;
 class QWebView;
+class QNetworkReply;
 
 class FacebookAuthentication;
+class FullScreenButton;
 class FriendListPanel;
+class MapScale;
 class MapScene;
 class MapView;
 class SituareService;
@@ -44,6 +47,7 @@ class UserInfoPanel;
 class ZoomButtonPanel;
 class SettingsDialog;
 class QToolButton;
+class QMessageBox;
 
 /**
 * @brief Main Window Class
@@ -80,13 +84,6 @@ private:
  ******************************************************************************/
 public:
     /**
-    * @brief Sets automatic location update enabled from settings dialog.
-    *
-    * @param enabled true if enabled, false otherwise
-    */
-    void automaticLocationUpdateEnabled(bool enabled);
-
-    /**
     * @brief Clears cookie jar
     *
     */
@@ -100,6 +97,18 @@ public:
     void loggedIn(bool logged);
 
     /**
+    * @brief Gets the login state (logged in/logged out)
+    *
+    * @return bool Login state
+    */
+    bool loginState();
+
+    /**
+    * @brief Reads automatic location update settings.
+    */
+    void readAutomaticLocationUpdateSettings();
+
+    /**
     * @brief Enable / disable auto centering button.
     *
     * @param enabled true if shoud be enabled, false otherwise
@@ -125,17 +134,9 @@ public:
     /**
     * Shows dialog with enable automatic location update question.
     *
-    * @return true if accepted, false otherwise
+    * @param text text to show in dialog
     */
-    bool showEnableAutomaticUpdateLocationDialog();
-
-    /**
-    * @brief Show Maemo information box with message.
-    *
-    * @param message Information message
-    * @param modal Modal = true, non-modal false
-    */
-    void showMaemoInformationBox(const QString &message, bool modal=false);
+    void showEnableAutomaticUpdateLocationDialog(const QString &text);
 
     /**
     * @brief Gets the username from member variable for saving purposes
@@ -146,7 +147,15 @@ public:
 
 public slots:
     /**
-    * @brief Slot to intercept signal when login has failed (loginFailure signal)
+    * @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 Slot for failed login
     *
     */
     void loginFailed();
@@ -163,6 +172,13 @@ public slots:
     void openSettingsDialog();
 
     /**
+      * @brief Set own location crosshair visibility
+      *
+      * @param visible
+      */
+    void setOwnLocationCrosshairVisibility(bool visible);
+
+    /**
     * @brief Sets username to member variable for login dialog
     *
     * @param username Username to be set
@@ -170,12 +186,17 @@ public slots:
     void setUsername(const QString &username);
 
     /**
+    * @brief Method to show panels
+    *
+    */
+    void showPanels();
+
+    /**
     * @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.
@@ -187,9 +208,8 @@ public slots:
     /**
     * @brief Shows / hides Situare related UI items
     *
-    * @param show
     */
-    void updateItemVisibility(bool show);
+    void updateItemVisibility();
 
 private:
     /**
@@ -213,6 +233,11 @@ private:
     void buildMap();
 
     /**
+     * @brief Build map scale and connect slots
+     */
+    void buildMapScale();
+
+    /**
       * @brief Build OSM license and connect slots
       */
     void buildOsmLicense();
@@ -246,14 +271,41 @@ private:
     void grabZoomKeys(bool grab);
 
     /**
-      * @brief Set own location crosshair visibility
-      *
-      * @param visible
-      */
-    void setOwnLocationCrosshairVisibility(bool visible);
+    * @brief Queues dialog/information box
+    *
+    * @param dialog Dialog to be added into queue
+    */
+    void queueDialog(QDialog *dialog);
+
+    /**
+    * @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
@@ -261,6 +313,13 @@ private slots:
     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
@@ -270,10 +329,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(const QSize &size);
+
+    /**
+    * @brief Slot to intercept signal when error dialog/information note is processed
+    *
+    * @param status Status of the dialog
     */
-    void drawOwnLocationCrosshair(int width, int height);
+    void errorDialogFinished(int status);
 
     /**
     * @brief Slot for gps timeout.
@@ -302,18 +367,29 @@ private slots:
     void saveCookies();
 
     /**
+    * @brief Slot for settings dialog accepted.
+    */
+    void settingsDialogAccepted();
+
+    /**
     * @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 int width, const int height);
+    void setViewPortSize(const QSize &size);
 
     /**
     * @brief Toggle between fullscreen and normal window mode
     */
     void toggleFullScreen();
 
+    /**
+    * @brief Slot to intercept signal from webview's networkaccessmanager
+    *
+    * @param reply Network reply (contains errors)
+    */
+    void webViewRequestFinished(QNetworkReply* reply);
+
 /*******************************************************************************
  * SIGNALS
  ******************************************************************************/
@@ -344,7 +420,15 @@ signals:
     * @param enabled true if enabled, false otherwise
     * @param updateIntervalMsecs update interval in milliseconds
     */
-    void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs);
+    void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
+
+    /**
+    * @brief Signals error
+    *
+    * @param context error context
+    * @param error error code
+    */
+    void error(const int context, const int error);
 
     /**
     * @brief Signal for requesting username from settings
@@ -413,11 +497,25 @@ 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
+    *
+    * @param error error code
+    */
+    void messageSendingFailed(const int error);
+
+    /**
       * @brief Forwarding signal from MapEngine to MapView
       */
     void minZoomLevelReached();
 
     /**
+     * @brief Forwarding signal from MapEngine to MapScale
+     */
+    void newMapResolution(qreal scale);
+
+    /**
     * @brief Signal for refreshing user data.
     *
     */
@@ -459,6 +557,12 @@ signals:
     void updateCredentials(const QUrl &url);
 
     /**
+    * @brief Signals when updateLocationDialog's data must be cleared
+    *
+    */
+    void clearUpdateLocationDialogData();
+
+    /**
     * @brief MapView has finished zooming
     */
     void viewZoomFinished();
@@ -490,11 +594,11 @@ signals:
  ******************************************************************************/
 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
 
-    int m_viewPortHeight;                   ///< Height of view port
-    int m_viewPortWidth;                    ///< Width of view port
+    int m_progressIndicatorCount;           ///< Indicates the number of progress indicator calls
 
     QAction *m_autoCenteringAct;            ///< Action to auto center map using gps position
     QAction *m_gpsToggleAct;                ///< Action to trigger gps toggle
@@ -504,24 +608,30 @@ 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
+
+    QSize m_viewPortSize;                 ///< Size of the viewport
+
     QString m_email;                        ///< Placeholder for email
     QString m_password;                     ///< Placeholder for password
 
-    QToolButton *m_fullScreenButton;        ///< Instance of the fullscreen toggle button
+    FullScreenButton *m_fullScreenButton;   ///< Instance of the fullscreen toggle button
 
     QWebView *m_webView;                    ///< Shows facebook login page
 
     FriendListPanel *m_friendsListPanel;    ///< Instance of friends list panel
+    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
     ZoomButtonPanel *m_zoomButtonPanel;     ///< Instance of zoom button panel
-
-    SettingsDialog *m_settingsDialog;       ///< Settings dialog
 };
 
 #endif // MAINWINDOW_H