Fixed bug that causes application to ask for new login even if
[situare] / src / ui / mainwindow.h
index ae4a600..dad12bf 100644 (file)
@@ -1,38 +1,41 @@
 /*
-    Situare - A location system for Facebook
-    Copyright (C) 2010  Ixonos Plc. Authors:
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
 
-       Henri Lampela - henri.lampela@ixonos.com
-       Kaj Wallin - kaj.wallin@ixonos.com
+      Henri Lampela - henri.lampela@ixonos.com
+      Kaj Wallin - kaj.wallin@ixonos.com
 
-    Situare is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License
-    version 2 as published by the Free Software Foundation.
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
 
-    Situare is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
 
-    You should have received a copy of the GNU General Public License
-    along with Situare; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
-    USA.
- */
 
 #ifndef MAINWINDOW_H
 #define MAINWINDOW_H
 
 #include <QtGui/QMainWindow>
 #include <QWidget>
+#include <QDebug>
+#include "facebookservice/facebookauthentication.h"
+#include "situareservice/situareservice.h"
+#include <QNetworkAccessManager>
 
-class QMenu;
-class QAction;
-class QStackedWidget;
 class QLabel;
+class QStackedWidget;
 
 /**
-* @Main Window Class
+* @brief Main Window Class
 *
 * @class MainWindow mainwindow.h "src/ui/mainwindow.h"
 */
@@ -41,86 +44,67 @@ class MainWindow : public QMainWindow
     Q_OBJECT
 
 public:
+    /**
+    * @brief Constructor
+    *
+    * @param parent Parent
+    */
     MainWindow(QWidget *parent = 0);
-    ~MainWindow();
 
-private:
     /**
-    * @brief Private method to create the Menu items
-    *
-    * @fn createMenus
+    * @brief Destructor
     */
-    void createMenus();
+    ~MainWindow();
+
+public slots:
     /**
-    * @brief Private method to create List and Map views as a stacked widget
-    *
-    * @fn createViews
+    * @brief Public slot, which initiates toListViewAct action to switch view
     */
-    void createViews();
+    void toListView();
 
-    QMenu *viewMenu;
     /**
-    * @brief Action item for changing view to List View
-    *
-    * @var toListViewAct
+    * @brief Public slot, which initiates toMapViewAct action to switch view
     */
-    QAction *toListViewAct;
+    void toMapView();
+
+private:
     /**
-    * @brief Action item for changing view to Map View
-    *
-    * @var toMapViewAct
+    * @brief Private method to create the Menu items    w.show();
     */
-    QAction *toMapViewAct;
+    void createMenus();
+
     /**
-    * @brief Widget Stack object for the List and Map Views
-    *
-    * @var situareViews
+    * @brief Private method to create List and Map views as a stacked widget
     */
-    QStackedWidget *situareViews;
+    void createViews();
 
     /**
-    * @brief DUMMY LABEL, REMOVE WHEN BOTH VIEWS ARE COMPLETE
+    * @brief Method used to switch active view.
     *
-    * @var infoLabel
-    * @todo REMOVE THIS
+    * @param nextIndex 0 for listview, 1 for mapview
     */
-    QLabel *infoLabel;
+    void switchView(int);
+
+private:
+    FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
+    QNetworkAccessManager *m_networkManager; ///< NetworkManager that is passed on to SituareService
+    SituareService *m_situareService; ///< Instance of the situare server communication service
+    bool m_loggedIn; ///< Boolean value to indicate whether login has been successfull or not
+    QStackedWidget *m_situareViews; ///< Stacked widget that hold both view widgets
+    QAction *m_toListViewAct; ///< Action to trigger switch to list view
+    QAction *m_toMapViewAct; ///< Action to trigger switch to map view
+    QMenu *m_viewMenu; ///< Object that hold the view menu items
 
 private slots:
     /**
-    * @brief Private slot, which initiates toListViewAct action
-    *
-    * @fn toListView
+    * @brief Slot to change value of m_loggedIn to true
     */
-    void toListView();
+    void loginOK();
+
     /**
-    * @brief Private slots, which initiates toMapViewAct action
-    *
-    * @fn toMapView
+    * @brief Slot to check login status and exits if necessary
     */
-    void toMapView();
-};
-
-/**
-* @brief List View class. Used for displaying List of friends
-*
-* @class SituareListView mainwindow.h "src/ui/mainwindow.h"
-*/
-class SituareListView : public QWidget
-{
-public:
-    SituareListView(QWidget *parent = 0);
-};
-
-/**
-* @brief Map View class. Used to display Map
-*
-* @class SituareMapView mainwindow.h "src/ui/mainwindow.h"
-*/
-class SituareMapView : public QWidget
-{
-public:
-    SituareMapView(QWidget *parent = 0);
+    void loginScreenClosed();
 };
 
 #endif // MAINWINDOW_H