#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__;
- 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)));
}
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"));
-/*
- FBAuth = new FacebookAuthentication(this);
- FBAuth->show();
- FBAuth->start();
-
- connect(FBAuth, SIGNAL(credentialsReady()), this, SLOT(loginOK()));
- connect(FBAuth, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
-*/
+ 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()
{
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;
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__ << loggedIn;
- if (loggedIn) {
- //this->show();
- return;
- }
- else {
- this->close();
- }
+ qDebug() << __PRETTY_FUNCTION__;
+
+ emit requestReverseGeo();
+ m_locationDialog->exec();
}
-void MainWindow::loginOK()
+void MainWindow::openSettingsDialog()
{
- qDebug() << __PRETTY_FUNCTION__ << loggedIn;
- loggedIn = true;
+ qDebug() << __PRETTY_FUNCTION__;
+ SettingsDialog *dialog = new SettingsDialog(this);
+ dialog->show();
}
+
+