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 "settingsdialog.h"
28 #include "facebookservice/facebookauthentication.h"
29 #include "situareservice/situareservice.h"
31 MainWindow::MainWindow(QWidget *parent)
34 qDebug() << __PRETTY_FUNCTION__;
37 setCentralWidget(m_situareViews);
39 setWindowTitle(tr("List view"));
42 m_locationDialog = new UpdateLocationDialog(this);
43 connect(m_listViewScreen->m_personalInfo,SIGNAL(launchMessageUpdate()),
44 this,SLOT(openLocationUpdateDialog()));
46 connect(this, SIGNAL(reverseGeoReady(QString)), m_locationDialog, SLOT(setAddress(QString)));
47 connect(m_locationDialog, SIGNAL(statusUpdate(QString,bool)), this,
48 SIGNAL(statusUpdate(QString,bool)));
51 MainWindow::~MainWindow()
53 qDebug() << __PRETTY_FUNCTION__;
54 delete m_toListViewAct;
55 delete m_toMapViewAct;
56 delete m_toSettingsAct;
57 delete m_situareViews;
60 void MainWindow::createMenus()
62 qDebug() << __PRETTY_FUNCTION__;
63 m_toListViewAct = new QAction(tr("List"), this);
64 m_toListViewAct->setObjectName(tr("List"));
65 connect(m_toListViewAct, SIGNAL(triggered()), this, SLOT(toListView()));
66 m_toMapViewAct = new QAction(tr("Map"), this);
67 m_toMapViewAct->setObjectName(tr("Map"));
68 connect(m_toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
69 m_toSettingsAct = new QAction(tr("Settings"), this);
70 m_toSettingsAct->setObjectName(tr("Settings"));
71 connect(m_toSettingsAct, SIGNAL(triggered()), this, SLOT(openSettingsDialog()));
72 m_viewMenu = menuBar()->addMenu(tr("View"));
73 m_viewMenu->addAction(m_toListViewAct);
74 m_viewMenu->addAction(m_toMapViewAct);
75 m_viewMenu->addAction(m_toSettingsAct);
76 m_viewMenu->setObjectName(tr("View Menu"));
79 void MainWindow::createViews()
81 qDebug() << __PRETTY_FUNCTION__;
82 m_listViewScreen = new ListViewScreen(this);
83 m_mapViewScreen = new MapViewScreen(this);
85 m_situareViews = new QStackedWidget;
86 m_situareViews->addWidget(m_listViewScreen);
87 m_situareViews->addWidget(m_mapViewScreen);
90 void MainWindow::toListView()
92 qDebug() << __PRETTY_FUNCTION__;
96 void MainWindow::toMapView()
98 qDebug() << __PRETTY_FUNCTION__;
102 void MainWindow::switchView(int nextIndex)
104 qDebug() << __PRETTY_FUNCTION__ << ":" << nextIndex;
105 if (nextIndex < 0 || nextIndex > 1) {
106 qDebug() << "Illegal parameter value in MainWindow::switchView";
109 m_situareViews->setCurrentIndex(nextIndex);
110 switch (m_situareViews->currentIndex()) {
112 setWindowTitle(tr("List view"));
115 setWindowTitle(tr("Map view"));
118 qDebug() << "Illegal switch value in MainWindow::switchView";
123 void MainWindow::openLocationUpdateDialog()
125 qDebug() << __PRETTY_FUNCTION__;
127 emit requestReverseGeo();
128 m_locationDialog->exec();
131 void MainWindow::openSettingsDialog()
133 qDebug() << __PRETTY_FUNCTION__;
134 SettingsDialog *dialog = new SettingsDialog(this);