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,
23 #include <QGraphicsScene>
24 #include <QGraphicsView>
25 #include <QGraphicsWidget>
26 #include <QtGui/QVBoxLayout>
27 #include <QGraphicsProxyWidget>
29 #include "mainwindow.h"
30 #include "listviewscreen.h"
31 #include "mapviewscreen.h"
32 #include "facebookservice/facebookauthentication.h"
33 #include "situareservice/situareservice.h"
35 MainWindow::MainWindow(QWidget *parent)
38 qDebug() << __PRETTY_FUNCTION__;
41 setCentralWidget(m_situareViews);
43 setWindowTitle(tr("List view"));
46 m_facebookAuthenticator = new FacebookAuthentication(this);
47 connect(m_facebookAuthenticator, SIGNAL(credentialsReady()), this, SLOT(loginOK()));
48 connect(m_facebookAuthenticator, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
49 m_facebookAuthenticator->start();
51 m_networkManager = new QNetworkAccessManager;
52 m_situareService = new SituareService(this,m_networkManager);
55 MainWindow::~MainWindow()
57 qDebug() << __PRETTY_FUNCTION__;
58 delete m_toListViewAct;
59 delete m_toMapViewAct;
60 delete m_situareViews;
63 void MainWindow::createMenus()
65 qDebug() << __PRETTY_FUNCTION__;
66 m_toListViewAct = new QAction(tr("List"), this);
67 m_toListViewAct->setObjectName(tr("List"));
68 connect(m_toListViewAct, SIGNAL(triggered()), this, SLOT(toListView()));
69 m_toMapViewAct = new QAction(tr("Map"), this);
70 m_toMapViewAct->setObjectName(tr("Map"));
71 connect(m_toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
72 m_viewMenu = menuBar()->addMenu(tr("View"));
73 m_viewMenu->addAction(m_toListViewAct);
74 m_viewMenu->addAction(m_toMapViewAct);
75 m_viewMenu->setObjectName(tr("View Menu"));
78 void MainWindow::createViews()
80 qDebug() << __PRETTY_FUNCTION__;
81 m_situareViews = new QStackedWidget;
82 m_situareViews->addWidget(new ListViewScreen);
83 m_situareViews->addWidget(new MapViewScreen);
87 void MainWindow::toListView()
89 qDebug() << __PRETTY_FUNCTION__;
93 void MainWindow::toMapView()
95 qDebug() << __PRETTY_FUNCTION__;
99 void MainWindow::switchView(int nextIndex)
101 qDebug() << __PRETTY_FUNCTION__ << ":" << nextIndex;
102 if (nextIndex < 0 || nextIndex > 1) {
103 qDebug() << "Illegal parameter value in MainWindow::switchView";
106 m_situareViews->setCurrentIndex(nextIndex);
107 switch (m_situareViews->currentIndex()) {
109 setWindowTitle(tr("List view"));
112 setWindowTitle(tr("Map view"));
115 qDebug() << "Illegal switch value in MainWindow::switchView";
120 void MainWindow::loginScreenClosed()
122 qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
132 void MainWindow::loginOK()
134 qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
136 m_facebookAuthenticator->close();