Preliminary merge. Integration is brancehd from fresh master.
[situare] / src / ui / mainwindow.cpp
index 073639e..e7137cc 100644 (file)
 #include "mainwindow.h"
 #include "listviewscreen.h"
 #include "mapviewscreen.h"
+#include "settingsdialog.h"
+#include "facebookservice/facebookauthentication.h"
+#include "situareservice/situareservice.h"
 
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
-    loggedIn = false;
+
     createViews();
-    setCentralWidget(situareViews);
+    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)));
+    connect(this, SIGNAL(userLocationReady(User*)),
+            m_mapViewScreen, SLOT(userLocationReady(User*)));
+    connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
+            m_mapViewScreen, SLOT(friendsLocationsReady(QList<User*>&)));
 }
 
 MainWindow::~MainWindow()
 {
     qDebug() << __PRETTY_FUNCTION__;
-    delete toListViewAct;
-    delete toMapViewAct;
-    delete situareViews;
+    delete m_toListViewAct;
+    delete m_toMapViewAct;
+    delete m_toSettingsAct;
+    delete m_situareViews;
 }
 
 void MainWindow::createMenus()
 {
     qDebug() << __PRETTY_FUNCTION__;
-    toListViewAct = new QAction(tr("List"), this);
-    toListViewAct->setObjectName(tr("List"));
-    connect(toListViewAct, SIGNAL(triggered()), this, SLOT(toListView()));
-    toMapViewAct = new QAction(tr("Map"), this);
-    toMapViewAct->setObjectName(tr("Map"));
-    connect(toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
-    viewMenu = menuBar()->addMenu(tr("View"));
-    viewMenu->addAction(toListViewAct);
-    viewMenu->addAction(toMapViewAct);
-    viewMenu->setObjectName(tr("View Menu"));
-//    QList<QAction*> actionit = viewMenu->actions();
-//    qDebug() << "AKTIONIT" << actionit;
-
-/*
-    testClose1Act = new QAction(tr("login fail"),this);
-    connect(testClose1Act, SIGNAL(triggered()), this, SLOT(testClose1()));
-    testClose2Act = new QAction(tr("login ok"), this);
-    connect(testClose2Act, SIGNAL(triggered()), this, SLOT(testClose2()));
-    viewMenu->addAction(testClose1Act);
-    viewMenu->addAction(testClose2Act);
-*/
+    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_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"));
 }
 
 void MainWindow::createViews()
 {
     qDebug() << __PRETTY_FUNCTION__;
-    situareViews = new QStackedWidget;
-    situareViews->addWidget(new ListViewScreen);
-    situareViews->addWidget(new MapViewScreen);
+    m_listViewScreen = new ListViewScreen(this);
+    m_mapViewScreen = new MapViewScreen(this);
+
+    m_situareViews = new QStackedWidget;
+    m_situareViews->addWidget(m_listViewScreen);
+    m_situareViews->addWidget(m_mapViewScreen);
 }
 
 void MainWindow::toListView()
@@ -98,11 +107,11 @@ 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;
     }
-    situareViews->setCurrentIndex(nextIndex);
-    switch (situareViews->currentIndex()) {
+    m_situareViews->setCurrentIndex(nextIndex);
+    switch (m_situareViews->currentIndex()) {
         case 0:
             setWindowTitle(tr("List view"));
             break;
@@ -110,23 +119,23 @@ 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::testClose1()
+void MainWindow::openLocationUpdateDialog()
 {
-    qDebug() << tr("Login window closed with FAIL");
-    this->loggedIn = false;
-    emit testLoginClosed();
+    qDebug() << __PRETTY_FUNCTION__;
+
+    emit requestReverseGeo();
+    m_locationDialog->exec();
 }
 
-void MainWindow::testClose2()
+void MainWindow::openSettingsDialog()
 {
-    qDebug() << tr("Login window closed with OK");
-    this->loggedIn = true;
-    emit testLoginClosed();
+    qDebug() << __PRETTY_FUNCTION__;
+    SettingsDialog *dialog = new SettingsDialog(this);
+    dialog->show();
 }
-*/
+