/*
- 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
+ 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.
- */
-
-#include <QPushButton>
-#include <QVBoxLayout>
+ 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 "mapfetcher.h"
+#include "listviewscreen.h"
+#include "mapviewscreen.h"
+#include "settingsdialog.h"
+#include "facebookservice/facebookauthentication.h"
+#include "situareservice/situareservice.h"
MainWindow::MainWindow(QWidget *parent)
- : QWidget(parent)
+ : QMainWindow(parent)
{
- this->setWindowTitle(tr("Situare"));
+ qDebug() << __PRETTY_FUNCTION__;
- QNetworkAccessManager *manager = new QNetworkAccessManager(this);
- mapFetcher = new MapFetcher(this, manager);
+ createViews();
+ setCentralWidget(m_situareViews);
+ createMenus();
+ setWindowTitle(tr("List view"));
+ this->hide();
- connect(mapFetcher, SIGNAL(mapImageReceived(QUrl,QPixmap)), this, SLOT(imageReceived(QUrl,QPixmap)));
+ m_locationDialog = new UpdateLocationDialog(this);
+ connect(m_listViewScreen->m_personalInfo,SIGNAL(launchMessageUpdate()),
+ this,SLOT(openLocationUpdateDialog()));
- QPushButton *button = new QPushButton("Fetch");
- QLabel *label = new QLabel(this);
- connect(button, SIGNAL(clicked()), this, SLOT(debug()));
+ connect(this, SIGNAL(reverseGeoReady(QString)), m_locationDialog, SLOT(setAddress(QString)));
+ connect(m_locationDialog, SIGNAL(statusUpdate(QString,bool)), this,
+ SIGNAL(statusUpdate(QString,bool)));
+}
- QWidget *widget = new QWidget(this);
- QVBoxLayout *vbox = new QVBoxLayout;
- vbox->addWidget(button);
- vbox->addWidget(label);
- widget->setLayout(vbox);
- this->setLayout(vbox);
+MainWindow::~MainWindow()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ delete m_toListViewAct;
+ delete m_toMapViewAct;
+ delete m_toSettingsAct;
+ delete m_situareViews;
}
-void MainWindow::imageReceived(const QUrl &url, const QPixmap &image)
+void MainWindow::createMenus()
{
qDebug() << __PRETTY_FUNCTION__;
- QLabel *label = new QLabel();
- label->setPixmap(image);
- label->show();
+ 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::debug()
+void MainWindow::createViews()
{
qDebug() << __PRETTY_FUNCTION__;
- for (int i = 0; i < 2; ++i)
- for (int j = 0; j < 2; ++j)
- mapFetcher->fetchMapImage(QUrl(QString("http://tile.openstreetmap.org/mapnik/13/467%1/213%2.png")
- .arg(i).arg(j)));
+ m_listViewScreen = new ListViewScreen(this);
+ m_mapViewScreen = new MapViewScreen(this);
+
+ m_situareViews = new QStackedWidget;
+ m_situareViews->addWidget(m_listViewScreen);
+ m_situareViews->addWidget(m_mapViewScreen);
}
-MainWindow::~MainWindow()
+void MainWindow::toListView()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ switchView(0);
+}
+
+void MainWindow::toMapView()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ switchView(1);
+}
+
+void MainWindow::switchView(int nextIndex)
{
+ 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;
+ }
+}
+
+void MainWindow::openLocationUpdateDialog()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ emit requestReverseGeo();
+ m_locationDialog->exec();
}
+
+void MainWindow::openSettingsDialog()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ SettingsDialog *dialog = new SettingsDialog(this);
+ dialog->show();
+}
+
+