Added engine to master
[situare] / src / ui / mainwindow.cpp
index 7fe402f..c67b106 100644 (file)
 #include "mainwindow.h"
 #include "listviewscreen.h"
 #include "mapviewscreen.h"
-//#include "facebookservice/facebookauthentication.h"
+#include "settingsdialog.h"
+#include "facebookservice/facebookauthentication.h"
+#include "situareservice/situareservice.h"
 
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
-    m_loggedIn = false;
+
     createViews();
     setCentralWidget(m_situareViews);
     createMenus();
     setWindowTitle(tr("List view"));
-    //this->show();
-/*
-    connect(this,SIGNAL(testLoginClosed()), this, SLOT(loginScreenClosed()));
-*/
+    this->hide();
+
+    m_locationDialog = new UpdateLocationDialog(this);
+    connect(m_listViewScreen->m_personalInfo,SIGNAL(launchMessageUpdate()),
+            this,SLOT(openLocationUpdateDialog()));
+
+    connect(this, SIGNAL(reverseGeoReady(QString)), m_locationDialog, SLOT(setAddress(QString)));
+    connect(m_locationDialog, SIGNAL(statusUpdate(QString,bool)), this,
+            SIGNAL(statusUpdate(QString,bool)));
 }
 
 MainWindow::~MainWindow()
@@ -46,6 +53,7 @@ MainWindow::~MainWindow()
     qDebug() << __PRETTY_FUNCTION__;
     delete m_toListViewAct;
     delete m_toMapViewAct;
+    delete m_toSettingsAct;
     delete m_situareViews;
 }
 
@@ -58,31 +66,25 @@ void MainWindow::createMenus()
     m_toMapViewAct = new QAction(tr("Map"), this);
     m_toMapViewAct->setObjectName(tr("Map"));
     connect(m_toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
+    m_toSettingsAct = new QAction(tr("Settings"), this);
+    m_toSettingsAct->setObjectName(tr("Settings"));
+    connect(m_toSettingsAct, SIGNAL(triggered()), this, SLOT(openSettingsDialog()));
     m_viewMenu = menuBar()->addMenu(tr("View"));
     m_viewMenu->addAction(m_toListViewAct);
     m_viewMenu->addAction(m_toMapViewAct);
+    m_viewMenu->addAction(m_toSettingsAct);
     m_viewMenu->setObjectName(tr("View Menu"));
-
-    m_openUpdateDialog = new QAction(tr("D_Update"), this);
-    connect(m_openUpdateDialog, SIGNAL(triggered()), this, SLOT(openUpdateDialog()));
-    m_viewMenu->addAction(m_openUpdateDialog);
-    this->show();
-/*
-    FBAuth = new FacebookAuthentication(this);
-    FBAuth->show();
-    FBAuth->start();
-
-    connect(FBAuth, SIGNAL(credentialsReady()), this, SLOT(loginOK()));
-    connect(FBAuth, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
-*/
 }
 
 void MainWindow::createViews()
 {
     qDebug() << __PRETTY_FUNCTION__;
+    m_listViewScreen = new ListViewScreen(this);
+    m_mapViewScreen = new MapViewScreen(this);
+
     m_situareViews = new QStackedWidget;
-    m_situareViews->addWidget(new ListViewScreen);
-    m_situareViews->addWidget(new MapViewScreen);
+    m_situareViews->addWidget(m_listViewScreen);
+    m_situareViews->addWidget(m_mapViewScreen);
 }
 
 void MainWindow::toListView()
@@ -101,7 +103,7 @@ void MainWindow::switchView(int nextIndex)
 {
     qDebug() << __PRETTY_FUNCTION__ << ":" << nextIndex;
     if (nextIndex < 0 || nextIndex > 1) {
-        qDebug() << tr("Illegal parameter value in MainWindow::switchView");
+        qDebug() << "Illegal parameter value in MainWindow::switchView";
         return;
     }
     m_situareViews->setCurrentIndex(nextIndex);
@@ -113,31 +115,24 @@ void MainWindow::switchView(int nextIndex)
             setWindowTitle(tr("Map view"));
             break;
         default:
-            qDebug() << tr("Illegal switch value in MainWindow::switchView");
+            qDebug() << "Illegal switch value in MainWindow::switchView";
             break;
     }
 }
 
-void MainWindow::loginScreenClosed()
+void MainWindow::openLocationUpdateDialog()
 {
-    qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
-    if (m_loggedIn) {
-        //this->show();
-        return;
-    }
-    else {
-        this->close();
-    }
-}
+    qDebug() << __PRETTY_FUNCTION__;
 
-void MainWindow::loginOK()
-{
-    qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
-    m_loggedIn = true;
-    //FBAuth->close();
+    emit requestReverseGeo();
+    m_locationDialog->exec();
 }
 
-void MainWindow::openUpdateDialog()
+void MainWindow::openSettingsDialog()
 {
-    qDebug() << "JIIHAA!";
+    qDebug() << __PRETTY_FUNCTION__;
+    SettingsDialog *dialog = new SettingsDialog(this);
+    dialog->show();
 }
+
+