#include "mainwindow.h"
#include "listviewscreen.h"
#include "mapviewscreen.h"
- //#include "facebookservice/facebookauthentication.h"
++#include "facebookservice/facebookauthentication.h"
++#include "situareservice/situareservice.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
qDebug() << __PRETTY_FUNCTION__;
+ m_loggedIn = false;
createViews();
- setCentralWidget(situareViews);
+ setCentralWidget(m_situareViews);
createMenus();
- setWindowTitle(tr("View"));
+ setWindowTitle(tr("List view"));
- this->show();
++ this->hide();
+
- /*
+ FBAuth = new FacebookAuthentication(this);
+ FBAuth->show();
+ FBAuth->start();
+
++ m_networkManager = new QNetworkAccessManager;
++ m_situareService = new SituareService(this,m_networkManager);
++
+ connect(FBAuth, SIGNAL(credentialsReady()), this, SLOT(loginOK()));
+ connect(FBAuth, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
- */
- /*
- connect(this,SIGNAL(testLoginClosed()), this, SLOT(loginScreenClosed()));
- */
}
MainWindow::~MainWindow()
void MainWindow::createMenus()
{
qDebug() << __PRETTY_FUNCTION__;
- toListViewAct = new QAction(tr("List"), this);
- connect(toListViewAct, SIGNAL(triggered()), this, SLOT(toListView()));
- toMapViewAct = new QAction(tr("Map"), this);
- connect(toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
- viewMenu = menuBar()->addMenu(tr("View"));
- viewMenu->addAction(toListViewAct);
- viewMenu->addAction(toMapViewAct);
+ m_toListViewAct = new QAction(tr("List"), this);
+ m_toListViewAct->setObjectName(tr("List"));
+ connect(m_toListViewAct, SIGNAL(triggered()), this, SLOT(toListView()));
+ m_toMapViewAct = new QAction(tr("Map"), this);
+ m_toMapViewAct->setObjectName(tr("Map"));
+ connect(m_toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
+ m_viewMenu = menuBar()->addMenu(tr("View"));
+ m_viewMenu->addAction(m_toListViewAct);
+ m_viewMenu->addAction(m_toMapViewAct);
+ m_viewMenu->setObjectName(tr("View Menu"));
-
}
void MainWindow::createViews()
}
}
-int MainWindow::getViewIndex()
+void MainWindow::loginScreenClosed()
+{
+ qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
+ if (m_loggedIn) {
- //this->show();
++ this->show();
+ return;
+ }
+ else {
+ this->close();
+ }
+}
+
+void MainWindow::loginOK()
{
- return situareViews->currentIndex();
+ qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
+ m_loggedIn = true;
- //FBAuth->close();
++ FBAuth->close();
}
#include <QtGui/QMainWindow>
#include <QWidget>
#include <QDebug>
- //#include "facebookservice/facebookauthentication.h"
++#include "facebookservice/facebookauthentication.h"
++#include "situareservice/situareservice.h"
++#include <QNetworkAccessManager>
class QLabel;
class QStackedWidget;
Q_OBJECT
public:
- MainWindow(QWidget *parent = 0);
- ~MainWindow();
-
/**
- * @brief Public method to get current index of the view. Used for Unit testing
+ * @brief Constructor
*
- * @fn getViewIndex
+ * @param parent Parent
*/
- int getViewIndex();
+ MainWindow(QWidget *parent = 0);
-private:
/**
- * @brief Private method to create List and Map views as a stacked widget
- *
- * @fn createViews
+ * @brief Destructor
*/
- void createViews();
+ ~MainWindow();
+
+public slots:
/**
- * @brief Widget Stack object for the List and Map Views
- *
- * @var situareViews
+ * @brief Public slot, which initiates toListViewAct action to switch view
*/
- QStackedWidget *situareViews;
+ void toListView();
/**
- * @brief Private method to create the Menu items
- *
- * @fn createMenus
+ * @brief Public slot, which initiates toMapViewAct action to switch view
*/
- void createMenus();
- QMenu *viewMenu;
+ void toMapView();
+private:
/**
- * @brief Private method to create the Menu items
- * @brief Action item for changing view to List View
- *
- * @var toListViewAct
++ * @brief Private method to create the Menu items w.show();
*/
- QAction *toListViewAct;
+ void createMenus();
+
/**
- * @brief Action item for changing view to Map View
- *
- * @var toMapViewAct
+ * @brief Private method to create List and Map views as a stacked widget
*/
- QAction *toMapViewAct;
+ void createViews();
/**
* @brief Method used to switch active view.
*/
void switchView(int);
-public slots:
+private:
++ FacebookAuthentication *FBAuth;
++ QNetworkAccessManager *m_networkManager;
++ SituareService *m_situareService;
+ 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
+
- QAction *m_openUpdateDialog; ///< DUMMY item used to launch location update dialog
+private slots:
/**
- * @brief Public slot, which initiates toListViewAct action to switch view
- *
- * @fn toListView
+ * @brief Slot to change value of m_loggedIn to true
*/
- void toListView();
+ void loginOK();
+
/**
- * @brief Public slot, which initiates toMapViewAct action to switch view
- *
- * @fn toMapView
+ * @brief Slot to check login status and exits if necessary
*/
- void toMapView();
+ void loginScreenClosed();
-
- /**
- * @brief DUMMY slot to open update location dialog
- */
- void openUpdateDialog();
};
#endif // MAINWINDOW_H