Fixed bug that causes application to ask for new login even if
[situare] / src / ui / mainwindow.h
index 46f6997..dad12bf 100644 (file)
 /*
-    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;
 
+/**
+* @brief Main Window Class
+*
+* @class MainWindow mainwindow.h "src/ui/mainwindow.h"
+*/
 class MainWindow : public QMainWindow
 {
     Q_OBJECT
 
 public:
+    /**
+    * @brief Constructor
+    *
+    * @param parent Parent
+    */
     MainWindow(QWidget *parent = 0);
+
+    /**
+    * @brief Destructor
+    */
     ~MainWindow();
 
+public slots:
+    /**
+    * @brief Public slot, which initiates toListViewAct action to switch view
+    */
+    void toListView();
+
+    /**
+    * @brief Public slot, which initiates toMapViewAct action to switch view
+    */
+    void toMapView();
+
 private:
+    /**
+    * @brief Private method to create the Menu items    w.show();
+    */
     void createMenus();
+
+    /**
+    * @brief Private method to create List and Map views as a stacked widget
+    */
     void createViews();
 
-    QMenu *viewMenu;
-    QAction *toListViewAct;
-    QAction *toMapViewAct;
-    QStackedWidget *situareViews;
+    /**
+    * @brief Method used to switch active view.
+    *
+    * @param nextIndex 0 for listview, 1 for mapview
+    */
+    void switchView(int);
 
-    QLabel *infoLabel;
+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:
-    void toListView();
-    void toMapView();
-};
-
-class SituareListView : public QWidget
-{
-public:
-    SituareListView(QWidget *parent = 0);
-};
-
-class SituareMapView : public QWidget
-{
-public:
-    SituareMapView(QWidget *parent = 0);
+    /**
+    * @brief Slot to change value of m_loggedIn to true
+    */
+    void loginOK();
+
+    /**
+    * @brief Slot to check login status and exits if necessary
+    */
+    void loginScreenClosed();
 };
 
 #endif // MAINWINDOW_H