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_facebookAuthenticator = new FacebookAuthentication(this);
42 connect(m_facebookAuthenticator, SIGNAL(credentialsReady()), this, SLOT(loginOK()));
43 connect(m_facebookAuthenticator, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
44 m_facebookAuthenticator->start();
46 m_networkManager = new QNetworkAccessManager;
47 m_situareService = new SituareService(this,m_networkManager);
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_situareViews = new QStackedWidget;
77 m_situareViews->addWidget(new ListViewScreen);
78 m_situareViews->addWidget(new MapViewScreen);
81 void MainWindow::toListView()
83 qDebug() << __PRETTY_FUNCTION__;
87 void MainWindow::toMapView()
89 qDebug() << __PRETTY_FUNCTION__;
93 void MainWindow::switchView(int nextIndex)
95 qDebug() << __PRETTY_FUNCTION__ << ":" << nextIndex;
96 if (nextIndex < 0 || nextIndex > 1) {
97 qDebug() << "Illegal parameter value in MainWindow::switchView";
100 m_situareViews->setCurrentIndex(nextIndex);
101 switch (m_situareViews->currentIndex()) {
103 setWindowTitle(tr("List view"));
106 setWindowTitle(tr("Map view"));
109 qDebug() << "Illegal switch value in MainWindow::switchView";
114 void MainWindow::loginScreenClosed()
116 qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
126 void MainWindow::loginOK()
128 qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
130 m_facebookAuthenticator->close();