Moved location update logic to new class called UpdateLocation.
[situare] / src / ui / mainwindow.h
index 5c2776f..ea5683a 100644 (file)
 #define MAINWINDOW_H
 
 #include <QtGui/QMainWindow>
+#include <QSslError>
 #include <QUrl>
 
 #include "network/networkcookiejar.h"
 
+class QDialog;
 class QGraphicsScene;
 class QLabel;
 class QMessageBox;
@@ -39,25 +41,25 @@ class QNetworkReply;
 class QToolButton;
 class QWebView;
 
-class FacebookAuthentication;
-class FullScreenButton;
 class FriendListPanel;
-class IndicatorButtonPanel;
+class FullScreenButton;
 class GeoCoordinate;
+class IndicatorButtonPanel;
+class Location;
+class LocationSearchPanel;
 class MapScale;
 class MapScene;
 class MapView;
 class Route;
 class RoutingPanel;
-class TabbedPanel;
-class SettingsDialog;
 class SceneCoordinate;
+class SettingsDialog;
 class SituareService;
 class TabbedPanel;
+class UpdateLocation;
 class User;
 class UserInfoPanel;
 class ZoomButtonPanel;
-class Location;
 
 /**
  * @brief Main Window Class
@@ -93,10 +95,11 @@ private:
  ******************************************************************************/
 public:
     /**
-     * @brief Clears cookie jar
-     *
-     */
-    void clearCookieJar();
+      * @brief Build and show login dialog with login browser
+      *
+      * @param browser Login browser instance
+      */
+    void buildLoginDialog(QWebView *browser);
 
     /**
      * @brief
@@ -106,13 +109,6 @@ 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();
@@ -147,20 +143,8 @@ public:
      */
     void showEnableAutomaticUpdateLocationDialog(const QString &text);
 
-    /**
-     * @brief Gets the username from member variable for saving purposes
-     *
-     * @return QString Username
-     */
-    const QString username();
-
 public slots:
     /**
-     * @brief Build direction indicator button panel and connect signals
-     */
-    void buildIndicatorButtonPanel();
-
-    /**
      * @brief Builds information box with message.
      *
      * @param message Information message
@@ -169,14 +153,9 @@ public slots:
     void buildInformationBox(const QString &message, bool modal=false);
 
     /**
-     * @brief Slot for failed login
-     */
-    void loginFailed();
-
-    /**
-     * @brief Slot to intercept signal when login with cookies is requested
-     */
-    void loginUsingCookies();
+      * @brief Hides and deletes login dialog
+      */
+    void destroyLoginDialog();
 
     /**
      * @brief Public slot, which open settings dialog
@@ -191,22 +170,12 @@ public slots:
     void setCrosshairVisibility(bool visible);
 
     /**
-     * @brief Sets username to member variable for login dialog
-     *
-     * @param username Username to be set
-     */
-    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
-     */
-    void startLoginProcess();
+    * @brief Shows contact dialog.
+    *
+    * Shows contact dialog with contact's information.
+    * @param guid globally unique ID of a contact
+    */
+    void showContactDialog(const QString &guid);
 
     /**
      * @brief Toggle progress indicator.
@@ -216,10 +185,11 @@ public slots:
     void toggleProgressIndicator(bool state);
 
     /**
-     * @brief Shows / hides Situare related UI items
+     * @brief Shows / hides Situare related UI items based on login state
      *
+     * @param loggedIn Is the user currently logged in
      */
-    void updateItemVisibility();
+    void updateItemVisibility(bool loggedIn);
 
 private:
     /**
@@ -238,6 +208,17 @@ private:
     void buildFullScreenButton();
 
     /**
+     * @brief Build direction indicator button panel and connect signals
+     */
+    void buildIndicatorButtonPanel();
+
+
+    /**
+     * @brief Build location search panel and connect signals
+     */
+    void buildLocationSearchPanel();
+
+    /**
      * @brief Build map and connect slots
      */
     void buildMap();
@@ -268,11 +249,6 @@ private:
     void buildUserInfoPanel();
 
     /**
-     * @brief Build webview and connect slots
-     */
-    void buildWebView();
-
-    /**
      * @brief Build zoom button panel and connect slots
      */
     void buildZoomButtonPanel();
@@ -360,18 +336,6 @@ 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
-     */
-    void loadDone(bool done);
-
-    /**
     * @brief Called when map center point horizontal shifting is changed
     *
     * @param shifting New shifting value
@@ -384,14 +348,19 @@ private slots:
     void moveCrosshair();
 
     /**
-     * @brief Slot to save cookies to settings
+     * @brief Slot for settings dialog accepted.
      */
-    void saveCookies();
+    void settingsDialogAccepted();
 
     /**
-     * @brief Slot for settings dialog accepted.
+     * @brief Show update location dialog
      */
-    void settingsDialogAccepted();
+    void showUpdateLocationDialog();
+
+    /**
+     * @brief Ignore SSL error from the reply
+     */
+    void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
 
     /**
      * @brief Start location search (open search dialog)
@@ -403,13 +372,6 @@ private slots:
      */
     void toggleFullScreen();
 
-    /**
-     * @brief Slot to intercept signal from webview's networkaccessmanager
-     *
-     * @param reply Network reply (contains errors)
-     */
-    void webViewRequestFinished(QNetworkReply* reply);
-
 /*******************************************************************************
  * SIGNALS
  ******************************************************************************/
@@ -422,12 +384,6 @@ signals:
     void autoCenteringTriggered(bool enabled);
 
     /**
-     * @brief Signal that indicates when user has cancelled login process
-     *
-     */
-    void cancelLoginProcess();
-
-    /**
      * @brief Signal for centering to coordinates.
      *
      * @param coordinates geo coordinates to center to.
@@ -442,6 +398,11 @@ signals:
     void centerToSceneCoordinates(const SceneCoordinate &coordinate);
 
     /**
+    * @brief Emitted when route is cleared
+    */
+    void clearRoute();
+
+    /**
     * @brief Signal when direction and distance from current map center point to current GPS
     *        location is changed
     *
@@ -468,12 +429,6 @@ signals:
     void error(const int context, const int error);
 
     /**
-     * @brief Signal for requesting username from settings
-     *
-     */
-    void fetchUsernameFromSettings();
-
-    /**
      * @brief Signals when friend's profile image is ready
      *
      * @param user Friend
@@ -517,6 +472,14 @@ signals:
     void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
 
     /**
+    * @brief Send location update
+    *
+    * @param status Status message
+    * @param publish Publish on Facebook?
+    */
+    void locationUpdate(const QString &status, bool publish);
+
+    /**
      * @brief Signals when Login/Logout action is pressed
      *
      */
@@ -558,6 +521,13 @@ signals:
     void refreshUserData();
 
     /**
+    * @brief Requests contact dialog.
+    *
+    * @param facebookId contact's facebookId
+    */
+    void requestContactDialog(const QString &facebookId);
+
+    /**
      * @brief Signal for requesting reverseGeo from SituareEngine
      *
      */
@@ -585,11 +555,9 @@ signals:
     void routeTo(const GeoCoordinate &coordinates);
 
     /**
-     * @brief Signal to save username to settings
-     *
-     * @param username Username
-     */
-    void saveUsername(const QString &username);
+    * @brief Request routing to current cursor position
+    */
+    void routeToCursor();
 
     /**
      * @brief Signal for location search
@@ -599,25 +567,11 @@ signals:
     void searchForLocation(QString location);
 
     /**
-     * @brief Signal for requestLocationUpdate from SituareEngine
-     *
-     * @param status Status message
-     * @param publish Publish on Facebook
-     */
-    void statusUpdate(const QString &status, const bool &publish);
-
-    /**
-     * @brief Signals when webview's urlChanged signal is emitted
-     *
-     * @param url New url
-     */
-    void updateCredentials(const QUrl &url);
-
-    /**
-     * @brief Signals when updateLocationDialog's data must be cleared
-     *
-     */
-    void clearUpdateLocationDialogData();
+    * @brief Signal is emitted when search history item is clicked.
+    *
+    * @param searchString search string used
+    */
+    void searchHistoryItemClicked(const QString &searchString);
 
     /**
     * @brief Dragging mode triggered.
@@ -630,6 +584,11 @@ signals:
     void viewZoomFinished();
 
     /**
+    * @brief Signals when updateLocation request finished successfully
+    */
+    void updateWasSuccessful();
+
+    /**
      * @brief Signal for use location ready.
      *
      * @param user User object
@@ -666,9 +625,12 @@ private:
     QAction *m_loginAct;                    ///< Action to Login/Logout
     QAction *m_toSettingsAct;               ///< Action to trigger switch to settings dialog
 
+    QDialog *m_loginDialog;                 ///< Login dialog
+
     QLabel *m_crosshair;                    ///< Label for center point crosshair
     QLabel *m_osmLicense;                   ///< Label for Open Street Map license
 
+    QList<int> m_situareTabsIndexes;        ///< List of Situare tab indexes
     QList<QDialog *> m_error_queue;         ///< QList type error dialog queue
     QList<QDialog *> m_queue;               ///< QList type dialog queue
 
@@ -676,19 +638,15 @@ private:
 
     QMessageBox *m_automaticUpdateLocationDialog;   ///< Automatic update location dialog
 
-    QString m_email;                        ///< Placeholder for email
-    QString m_password;                     ///< Placeholder for password
-
-    QWebView *m_webView;                    ///< Shows facebook login page
-
     FriendListPanel *m_friendsListPanel;    ///< Instance of friends list panel
     FullScreenButton *m_fullScreenButton;   ///< Instance of the fullscreen toggle button
-    IndicatorButtonPanel *m_indicatorButtonPanel;     ///< Instance of direction indicator button
+    IndicatorButtonPanel *m_indicatorButtonPanel;   ///< Instance of direction indicator button
+    LocationSearchPanel *m_locationSearchPanel;     ///< Location search panel
     MapScale *m_mapScale;                   ///< Instance of the map scale
     MapView *m_mapView;                     ///< Instance of the map view
-    NetworkCookieJar *m_cookieJar;          ///< Placeholder for QNetworkCookies
     RoutingPanel *m_routingPanel;           ///< Instance of routing panel
     TabbedPanel *m_tabbedPanel;             ///< Widget for tabbed panels
+    UpdateLocation *m_updateLocationController;     ///< Controller for update location dialog
     UserInfoPanel *m_userInfoPanel;         ///< Instance of the user information panel
     ZoomButtonPanel *m_zoomButtonPanel;     ///< Instance of zoom button panel
 };