Preliminary merge. Integration is brancehd from fresh master.
[situare] / src / ui / mainwindow.cpp
index 1560569..e7137cc 100644 (file)
@@ -32,20 +32,24 @@ MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
-    m_loggedIn = false;
+
     createViews();
     setCentralWidget(m_situareViews);
     createMenus();
     setWindowTitle(tr("List view"));
     this->hide();
 
-    m_facebookAuthenticator = new FacebookAuthentication(this);
-    connect(m_facebookAuthenticator, SIGNAL(credentialsReady()), this, SLOT(loginOK()));
-    connect(m_facebookAuthenticator, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
-    m_facebookAuthenticator->start();
-
-    m_networkManager = new QNetworkAccessManager;
-    m_situareService = new SituareService(this,m_networkManager);
+    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()
@@ -79,9 +83,12 @@ void MainWindow::createMenus()
 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()
@@ -117,28 +124,18 @@ void MainWindow::switchView(int nextIndex)
     }
 }
 
-void MainWindow::openSettingsDialog()
+void MainWindow::openLocationUpdateDialog()
 {
     qDebug() << __PRETTY_FUNCTION__;
-    SettingsDialog *dialog = new SettingsDialog(this);
-    dialog->show();
-}
 
-void MainWindow::loginScreenClosed()
-{
-    qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
-    if (m_loggedIn) {
-        this->show();
-        return;
-    }
-    else {
-        this->close();
-    }
+    emit requestReverseGeo();
+    m_locationDialog->exec();
 }
 
-void MainWindow::loginOK()
+void MainWindow::openSettingsDialog()
 {
-    qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
-    m_loggedIn = true;
-    m_facebookAuthenticator->close();
+    qDebug() << __PRETTY_FUNCTION__;
+    SettingsDialog *dialog = new SettingsDialog(this);
+    dialog->show();
 }
+