Merge branch 'master' into cookies_refactored
[situare] / src / ui / mainwindow.h
index 1650ce8..05c98eb 100644 (file)
@@ -4,6 +4,7 @@
 
       Henri Lampela - henri.lampela@ixonos.com
       Kaj Wallin - kaj.wallin@ixonos.com
+      Sami Rämö - sami.ramo@ixonos.com
 
    Situare is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    USA.
 */
 
-
 #ifndef MAINWINDOW_H
 #define MAINWINDOW_H
 
 #include <QtGui/QMainWindow>
-#include <QWidget>
-#include <QtWebKit>
-#include <QDebug>
-#include <QObject>
-#include <QNetworkAccessManager>
-#include "facebookservice/facebookauthentication.h"
-#include "situareservice/situareservice.h"
+#include <QUrl>
 
-#include "updatelocation/updatelocationdialog.h"
-#include "ui/logindialog.h"
+#include "networkcookiejar.h"
+#include "panelsidebar.h"
 
+class QGraphicsScene;
 class QLabel;
+class QWebView;
 
+class FacebookAuthentication;
 class FriendListPanel;
+class LoginDialog;
 class MapScene;
 class MapView;
+class SituareService;
+class User;
 class UserInfoPanel;
 class ZoomButtonPanel;
 
 /**
 * @brief Main Window Class
-*
-* @class MainWindow mainwindow.h "src/ui/mainwindow.h"
 */
 class MainWindow : public QMainWindow
 {
@@ -79,21 +77,25 @@ private:
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
-public:
+public:    
     /**
-    * @brief Enable / disable auto centering.
+    * @brief
     *
-    * Connect required actions to autoCenteringToggled() signal.
+    * @param logged
+    */
+    void loggedIn(bool logged);
+
+    /**
+    * @brief Enable / disable auto centering button.
     *
     * @param enabled true if shoud be enabled, false otherwise
     */
     void setAutoCenteringButtonEnabled(bool enabled);
 
     /**
-    * @brief Enable / disable GPS.
+    * @brief Enable / disable GPS button.
     *
-    * Does show message for user and show / hide auto centering menu action.
-    * Connect required actions to gpsToggled() signal.
+    * Does set visibilities for manual location cursor and auto centering menu button.
     *
     * @param enabled true if enabled, false otherwise
     */
@@ -113,6 +115,13 @@ public:
     */
     void showMaemoInformationBox(const QString &message);
 
+    /**
+    * @brief Gets the username from member variable for saving purposes
+    *
+    * @return QString Username
+    */
+    const QString username();
+
 public slots:
     /**
     * @brief Slot to intercept signal when user has pressed connect button from loginDialog
@@ -129,11 +138,29 @@ public slots:
     void loginFailed();
 
     /**
+    * @brief Slot to intercept signal when login with cookies is requested
+    *
+    */
+    void loginUsingCookies();
+
+    /**
     * @brief Public slot, which open settings dialog
     */
     void openSettingsDialog();
 
-    //////////////////////
+    /**
+    * @brief Sets username to member variable for login dialog
+    *
+    * @param username Username to be set
+    */
+    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
@@ -151,20 +178,62 @@ public slots:
     void toggleProgressIndicator(bool state);
 
 private:
-
+    /**
+      * @brief Build friend list panel and connect slots
+      */
     void buildFriendListPanel();
 
+    /**
+    * @brief Build login dialog and connect slots
+    *
+    */
+    void buildLoginDialog();
+
+    /**
+      * @brief Build manual location setting cross hair and connect slots
+      */
     void buildManualLocationCrosshair();
 
+    /**
+      * @brief Build map and connect slots
+      */
     void buildMap();
 
+    /**
+      * @brief Build OSM license and connect slots
+      */
     void buildOsmLicense();
 
+    /**
+      * @brief Build user info panel and connect slots
+      */
     void buildUserInfoPanel();
 
+    /**
+    * @brief Build webview and connect slots
+    *
+    */
+    void buildWebView();
+
+    /**
+      * @brief Build zoom button panel and connect slots
+      */
     void buildZoomButtonPanel();
 
     /**
+    * @brief Clears cookie jar
+    *
+    */
+    void clearCookieJar();
+
+    /**
+    * @brief connect/disconnect webview signals
+    *
+    * @param connectSignals true = connect, false = disconnect
+    */
+    void connectWebViewSignals(bool connectSignals);
+
+    /**
     * @brief Private method to create the Menu items
     */
     void createMenus();
@@ -177,22 +246,19 @@ private:
     void grabZoomKeys(bool grab);
 
     /**
-    * @brief Set own location crosshair visibility
-    *
-    * @param visibility
-    */
+      * @brief Set own location crosshair visibility
+      *
+      * @param visible
+      */
     void setOwnLocationCrosshairVisibility(bool visible);
 
 private slots:
-//    void autoCenteringToggledActions(bool enabled);
-
     /**
     * @brief Slot for drawing the Open Street Map license text
     *
-    * @param width Width of the viewport
-    * @param height Height of the viewport
+    * @param size Size of the screen
     */
-    void drawOsmLicense(int width, int height);
+    void drawOsmLicense(const QSize &size);
 
     /**
     * @brief Slot for drawing the own location crosshair
@@ -216,7 +282,11 @@ private slots:
     */
     void gpsTimeout();
 
-//    void gpsToggledActions(bool enabled);
+    /**
+    * @brief Slot to load cookies from settings
+    *
+    */
+    void loadCookies();
 
     /**
     * @brief Slot to intercept signal when webview has finished loading webpage
@@ -226,6 +296,12 @@ 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
@@ -238,31 +314,37 @@ private slots:
  ******************************************************************************/
 signals:
     /**
+    * @brief Automatic centering setting changed by user
+    *
+    * @param enabled True if automatic centering is enabled, otherwise false
+    */
+    void autoCenteringTriggered(bool enabled);
+
+    /**
     * @brief Signal that indicates when user has cancelled login process
     *
     */
     void cancelLoginProcess();
 
     /**
-    * @brief Automatic centering setting changed
+    * @brief View should be centered to new location
     *
-    * @param enabled True if automatic centering is enabled, otherwise false
+    * @param sceneCoordinate Scene coordinates of the new center point
     */
-    void autoCenteringToggled(bool enabled);
+    void centerToSceneCoordinates(QPoint sceneCoordinate);
 
     /**
-    * @brief Automatic centering setting changed by user
+    * @brief Signal for requesting username from settings
     *
-    * @param enabled True if automatic centering is enabled, otherwise false
     */
-    void autoCenteringTriggered(bool enabled);
+    void fetchUsernameFromSettings();
 
     /**
-    * @brief View should be centered to new location
+    * @brief Signal for finding user.
     *
-    * @param sceneCoordinate Scene coordinates of the new center point
+    * @param coordinates user geo coordinates
     */
-    void centerToSceneCoordinates(QPoint sceneCoordinate);
+    void findUser(const QPointF &coordinates);
 
     /**
     * @brief GPS setting changed
@@ -271,13 +353,6 @@ signals:
     */
     void gpsTriggered(bool enabled);
 
-//     /**
-//    * @brief Signal for auto centering enabling.
-//    *
-//    * @param enabled if auto centering should be enabled
-//    */
-//    void enableAutoCentering(bool enabled);
-
     /**
     * @brief Signal for finding friend.
     *
@@ -293,16 +368,40 @@ signals:
     void friendsLocationsReady(QList<User *> &friendsList);
 
     /**
+    * @brief Signal is emitted when location item is clicked.
+    *
+    * @param userIDs list of friends user IDs in the group
+    */
+    void locationItemClicked(const QList<QString> &userIDs);
+
+    /**
+    * @brief Signals when Login/Logout action is pressed
+    *
+    */
+    void loginActionPressed();
+
+    /**
     * @brief MapView has been resized
     *
     * @param size view size
     */
     void mapViewResized(const QSize &size);
 
+    /**
+      * @brief Forwarding signal from MapView to MapEngine
+      *
+      * @param sceneCoordinate
+      */
     void mapViewScrolled(QPoint sceneCoordinate);
 
+    /**
+      * @brief Forwarding signal from MapEngine to MapView
+      */
     void maxZoomLevelReached();
 
+    /**
+      * @brief Forwarding signal from MapEngine to MapView
+      */
     void minZoomLevelReached();
 
     /**
@@ -312,11 +411,6 @@ signals:
     void refreshUserData();
 
     /**
-    * @brief Signal from SituareEngine to MapEngine is travelling here
-    */
-    void requestOwnLocation();
-
-    /**
     * @brief Signal for requesting reverseGeo from SituareEngine
     *
     */
@@ -345,13 +439,6 @@ signals:
     void updateCredentials(const QUrl &url);
 
     /**
-    * @brief Map view port content update
-    *
-    * @param viewArea visible area of map scene
-    */
-    void updateMapViewContent(QRect viewArea);
-
-    /**
     * @brief MapView has finished zooming
     */
     void viewZoomFinished();
@@ -368,6 +455,9 @@ signals:
     */
     void zoomIn();
 
+    /**
+      * @brief Forwarding signal from MapEngine to MapView
+      */
     void zoomLevelChanged(int zoomLevel);
 
     /**
@@ -381,6 +471,7 @@ signals:
 private:
 
     bool m_drawOwnLocationCrosshair;        ///< Flag for making ownLocationCrosshair visible or not
+    bool m_loggedIn;                        ///< Indicates login state
     bool m_refresh;                         ///< Indicates when webpage is refreshed
 
     int m_viewPortHeight;                   ///< Height of view port
@@ -388,6 +479,7 @@ private:
 
     QAction *m_autoCenteringAct;            ///< Action to auto center map using gps position
     QAction *m_gpsToggleAct;                ///< Action to trigger gps toggle
+    QAction *m_loginAct;                    ///< Action to Login/Logout
     QAction *m_toSettingsAct;               ///< Action to trigger switch to settings dialog
 
     QLabel *m_osmLicense;                   ///< Label for Open Street Map license
@@ -398,14 +490,14 @@ private:
     QString m_email;                        ///< Placeholder for email
     QString m_password;                     ///< Placeholder for password
 
-    QUrl m_loginUrl;                        ///< Placeholder for login page url
-
     QWebView *m_webView;                    ///< Shows facebook login page
 
     FriendListPanel *m_friendsListPanel;    ///< Instance of friends list panel
     LoginDialog *m_loginDialog;             ///< Login dialog
     MapView *m_mapView;                     ///< Instance of the map view
-    UpdateLocationDialog *m_locationDialog; ///< Message dialog
+    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
 };