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_facebookAuthenticator = new FacebookAuthentication(this);
43 //connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)), this, SLOT(loginOK()));
44 //connect(m_facebookAuthenticator, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
45 // m_facebookAuthenticator->start();
47 m_locationDialog = new UpdateLocationDialog(this);
48 connect(m_listViewScreen->m_personalInfo,SIGNAL(launchMessageUpdate()),
49 this,SLOT(openLocationUpdateDialog()));
51 connect(this, SIGNAL(reverseGeoReady(QString)), m_locationDialog, SLOT(setAddress(QString)));
52 connect(m_locationDialog, SIGNAL(statusUpdate(QString,bool)), this,
53 SIGNAL(statusUpdate(QString,bool)));
55 connect(this, SIGNAL(userLocationReady(User*)),
56 m_mapViewScreen, SLOT(userLocationReady(User*)));
57 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
58 m_mapViewScreen, SLOT(friendsLocationsReady(QList<User*>&)));
61 MainWindow::~MainWindow()
63 qDebug() << __PRETTY_FUNCTION__;
64 delete m_toListViewAct;
65 delete m_toMapViewAct;
66 delete m_toSettingsAct;
67 delete m_situareViews;
70 void MainWindow::createMenus()
72 qDebug() << __PRETTY_FUNCTION__;
73 m_toListViewAct = new QAction(tr("List"), this);
74 m_toListViewAct->setObjectName(tr("List"));
75 connect(m_toListViewAct, SIGNAL(triggered()), this, SLOT(toListView()));
76 m_toMapViewAct = new QAction(tr("Map"), this);
77 m_toMapViewAct->setObjectName(tr("Map"));
78 connect(m_toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
79 m_toSettingsAct = new QAction(tr("Settings"), this);
80 m_toSettingsAct->setObjectName(tr("Settings"));
81 connect(m_toSettingsAct, SIGNAL(triggered()), this, SLOT(openSettingsDialog()));
82 m_viewMenu = menuBar()->addMenu(tr("View"));
83 m_viewMenu->addAction(m_toListViewAct);
84 m_viewMenu->addAction(m_toMapViewAct);
85 m_viewMenu->addAction(m_toSettingsAct);
86 m_viewMenu->setObjectName(tr("View Menu"));
89 void MainWindow::createViews()
91 qDebug() << __PRETTY_FUNCTION__;
92 m_listViewScreen = new ListViewScreen(this);
93 m_mapViewScreen = new MapViewScreen(this);
95 m_situareViews = new QStackedWidget;
96 m_situareViews->addWidget(m_listViewScreen);
97 m_situareViews->addWidget(m_mapViewScreen);
100 void MainWindow::toListView()
102 qDebug() << __PRETTY_FUNCTION__;
106 void MainWindow::toMapView()
108 qDebug() << __PRETTY_FUNCTION__;
112 void MainWindow::switchView(int nextIndex)
114 qDebug() << __PRETTY_FUNCTION__ << ":" << nextIndex;
115 if (nextIndex < 0 || nextIndex > 1) {
116 qDebug() << "Illegal parameter value in MainWindow::switchView";
119 m_situareViews->setCurrentIndex(nextIndex);
120 switch (m_situareViews->currentIndex()) {
122 setWindowTitle(tr("List view"));
125 setWindowTitle(tr("Map view"));
128 qDebug() << "Illegal switch value in MainWindow::switchView";
133 void MainWindow::openLocationUpdateDialog()
135 qDebug() << __PRETTY_FUNCTION__;
137 emit requestReverseGeo();
138 m_locationDialog->exec();
141 void MainWindow::openSettingsDialog()
143 qDebug() << __PRETTY_FUNCTION__;
144 SettingsDialog *dialog = new SettingsDialog(this);
148 void MainWindow::loginScreenClosed()
150 qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
160 void MainWindow::loginOK()
162 qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
164 //m_facebookAuthenticator->close();
167 //void MainWindow::userLocationReady(User &user)
169 // emit userLocationReady(user);
172 //void MainWindow::friendsLocationsReady(QList<User *>friendsList)
174 // emit friendsLocationsReady(friendsList);