/*
- Situare - A location system for Facebook
- Copyright (C) 2010 Ixonos Plc. Authors:
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
- Henri Lampela - henri.lampela@ixonos.com
- Kaj Wallin - kaj.wallin@ixonos.com
+ Henri Lampela - henri.lampela@ixonos.com
+ Kaj Wallin - kaj.wallin@ixonos.com
- Situare is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
- Situare is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with Situare; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- USA.
- */
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
#include <QtGui>
#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)
{
- QWidget *widget = new QWidget;
- setCentralWidget(widget);
-// createViews();
+ qDebug() << __PRETTY_FUNCTION__;
- QVBoxLayout *mainleiska = new QVBoxLayout;
- infoLabel = new QLabel(tr("This is the beginning"),this);
- mainleiska->addWidget(infoLabel);
-
- widget->setLayout(mainleiska);
- this->setWindowTitle(tr("Situare"));
+ createViews();
+ setCentralWidget(m_situareViews);
createMenus();
-
+ setWindowTitle(tr("List view"));
+ 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 m_toListViewAct;
+ delete m_toMapViewAct;
+ delete m_toSettingsAct;
+ delete m_situareViews;
}
void MainWindow::createMenus()
{
- 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);
+ qDebug() << __PRETTY_FUNCTION__;
+ 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__;
+ 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()
{
- infoLabel->setText(tr("List view invoked"));
+ qDebug() << __PRETTY_FUNCTION__;
+ switchView(0);
}
void MainWindow::toMapView()
{
- infoLabel->setText(tr("Map view invoked"));
+ qDebug() << __PRETTY_FUNCTION__;
+ switchView(1);
}
-void MainWindow::createViews()
+void MainWindow::switchView(int nextIndex)
{
- situareViews = new QStackedWidget(this);
- situareViews->addWidget(new SituareListView(this));
- situareViews->addWidget(new SituareMapView(this));
+ qDebug() << __PRETTY_FUNCTION__ << ":" << nextIndex;
+ if (nextIndex < 0 || nextIndex > 1) {
+ qDebug() << "Illegal parameter value in MainWindow::switchView";
+ return;
+ }
+ m_situareViews->setCurrentIndex(nextIndex);
+ switch (m_situareViews->currentIndex()) {
+ case 0:
+ setWindowTitle(tr("List view"));
+ break;
+ case 1:
+ setWindowTitle(tr("Map view"));
+ break;
+ default:
+ qDebug() << "Illegal switch value in MainWindow::switchView";
+ break;
+ }
}
-SituareListView::SituareListView(QWidget *parent)
- : QWidget(parent)
+void MainWindow::openLocationUpdateDialog()
{
- QPushButton *listViewButton = new QPushButton(tr("This is listview"));
- QHBoxLayout *listViewLayout = new QHBoxLayout;
- listViewLayout->addWidget(listViewButton);
- setLayout(listViewLayout);
+ qDebug() << __PRETTY_FUNCTION__;
+
+ emit requestReverseGeo();
+ m_locationDialog->exec();
}
-SituareMapView::SituareMapView(QWidget *parent)
- : QWidget(parent)
+void MainWindow::openSettingsDialog()
{
- QPushButton *mapViewButton = new QPushButton(tr("THIS IS MAPVIEW !!"));
- QHBoxLayout *mapViewLayout = new QHBoxLayout;
- mapViewLayout->addWidget(mapViewButton);
- setLayout(mapViewLayout);
+ qDebug() << __PRETTY_FUNCTION__;
+ SettingsDialog *dialog = new SettingsDialog(this);
+ dialog->show();
}
+