2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Henri Lampela - henri.lampela@ixonos.com
6 Kaj Wallin - kaj.wallin@ixonos.com
8 Situare is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
12 Situare is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Situare; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24 #include "mainwindow.h"
25 #include "listviewscreen.h"
26 #include "mapviewscreen.h"
27 #include "facebookservice/facebookauthentication.h"
28 #include "situareservice/situareservice.h"
30 MainWindow::MainWindow(QWidget *parent)
33 qDebug() << __PRETTY_FUNCTION__;
36 setCentralWidget(m_situareViews);
38 setWindowTitle(tr("List view"));
41 m_locationDialog = new UpdateLocationDialog(this);
42 connect(m_listViewScreen->m_personalInfo,SIGNAL(launchMessageUpdate()),
43 this,SLOT(openLocationUpdateDialog()));
45 connect(this, SIGNAL(reverseGeoReady(QString)), m_locationDialog, SLOT(setAddress(QString)));
46 connect(m_locationDialog, SIGNAL(statusUpdate(QString,bool)), this,
47 SIGNAL(statusUpdate(QString,bool)));
50 MainWindow::~MainWindow()
52 qDebug() << __PRETTY_FUNCTION__;
53 delete m_toListViewAct;
54 delete m_toMapViewAct;
55 delete m_situareViews;
58 void MainWindow::createMenus()
60 qDebug() << __PRETTY_FUNCTION__;
61 m_toListViewAct = new QAction(tr("List"), this);
62 m_toListViewAct->setObjectName(tr("List"));
63 connect(m_toListViewAct, SIGNAL(triggered()), this, SLOT(toListView()));
64 m_toMapViewAct = new QAction(tr("Map"), this);
65 m_toMapViewAct->setObjectName(tr("Map"));
66 connect(m_toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
67 m_viewMenu = menuBar()->addMenu(tr("View"));
68 m_viewMenu->addAction(m_toListViewAct);
69 m_viewMenu->addAction(m_toMapViewAct);
70 m_viewMenu->setObjectName(tr("View Menu"));
73 void MainWindow::createViews()
75 qDebug() << __PRETTY_FUNCTION__;
76 m_listViewScreen = new ListViewScreen(this);
77 m_mapViewScreen = new MapViewScreen(this);
79 m_situareViews = new QStackedWidget;
80 m_situareViews->addWidget(m_listViewScreen);
81 m_situareViews->addWidget(m_mapViewScreen);
84 void MainWindow::toListView()
86 qDebug() << __PRETTY_FUNCTION__;
90 void MainWindow::toMapView()
92 qDebug() << __PRETTY_FUNCTION__;
96 void MainWindow::switchView(int nextIndex)
98 qDebug() << __PRETTY_FUNCTION__ << ":" << nextIndex;
99 if (nextIndex < 0 || nextIndex > 1) {
100 qDebug() << "Illegal parameter value in MainWindow::switchView";
103 m_situareViews->setCurrentIndex(nextIndex);
104 switch (m_situareViews->currentIndex()) {
106 setWindowTitle(tr("List view"));
109 setWindowTitle(tr("Map view"));
112 qDebug() << "Illegal switch value in MainWindow::switchView";
116 void MainWindow::openLocationUpdateDialog()
118 qDebug() << __PRETTY_FUNCTION__;
120 emit requestReverseGeo();
121 m_locationDialog->exec();