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
7 Jussi Laitinen jussi.laitinen@ixonos.com
9 Situare is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 version 2 as published by the Free Software Foundation.
13 Situare is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Situare; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
25 #include "mainwindow.h"
26 #include "listviewscreen.h"
27 #include "mapviewscreen.h"
28 #include "settingsdialog.h"
29 #include "facebookservice/facebookauthentication.h"
30 #include "situareservice/situareservice.h"
32 MainWindow::MainWindow(QWidget *parent)
35 qDebug() << __PRETTY_FUNCTION__;
38 setCentralWidget(m_situareViews);
40 setWindowTitle(tr("List view"));
43 m_locationDialog = new UpdateLocationDialog(this);
44 connect(m_listViewScreen,SIGNAL(launchUpdateDialog()),
45 this,SLOT(openLocationUpdateDialog()));
47 connect(this, SIGNAL(reverseGeoReady(QString)), m_locationDialog, SLOT(setAddress(QString)));
48 connect(m_locationDialog, SIGNAL(statusUpdate(QString,bool)), this,
49 SIGNAL(statusUpdate(QString,bool)));
51 connect(this, SIGNAL(userLocationReady(User*)),
52 m_mapViewScreen, SIGNAL(userLocationReady(User*)));
53 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
54 m_mapViewScreen, SIGNAL(friendsLocationsReady(QList<User*>&)));
56 connect(this, SIGNAL(userLocationReady(User*)), m_listViewScreen,
57 SLOT(userDataReceived(User*)));
58 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)), m_listViewScreen,
59 SLOT(friendInfoReceived(QList<User*>&)));
60 connect(m_listViewScreen, SIGNAL(updateFriendsData()),
61 this, SIGNAL(refreshUserData()));
63 this->toggleProgressIndicator(true);
66 MainWindow::~MainWindow()
68 qDebug() << __PRETTY_FUNCTION__;
69 delete m_toListViewAct;
70 delete m_toMapViewAct;
71 delete m_toSettingsAct;
72 delete m_situareViews;
75 void MainWindow::toggleProgressIndicator(bool value)
77 qDebug() << __PRETTY_FUNCTION__;
79 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, value);
82 #endif // Q_WS_MAEMO_5
85 void MainWindow::createMenus()
87 qDebug() << __PRETTY_FUNCTION__;
88 m_toListViewAct = new QAction(tr("List"), this);
89 m_toListViewAct->setObjectName(tr("List"));
90 connect(m_toListViewAct, SIGNAL(triggered()), this, SLOT(toListView()));
91 m_toMapViewAct = new QAction(tr("Map"), this);
92 m_toMapViewAct->setObjectName(tr("Map"));
93 connect(m_toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
94 m_toSettingsAct = new QAction(tr("Settings"), this);
95 m_toSettingsAct->setObjectName(tr("Settings"));
96 connect(m_toSettingsAct, SIGNAL(triggered()), this, SLOT(openSettingsDialog()));
97 m_viewMenu = menuBar()->addMenu(tr("View"));
98 m_viewMenu->addAction(m_toListViewAct);
99 m_viewMenu->addAction(m_toMapViewAct);
100 m_viewMenu->addAction(m_toSettingsAct);
101 m_viewMenu->setObjectName(tr("View Menu"));
104 void MainWindow::createViews()
106 qDebug() << __PRETTY_FUNCTION__;
107 m_listViewScreen = new ListViewScreen(this);
108 m_mapViewScreen = new MapViewScreen(this);
110 m_situareViews = new QStackedWidget;
111 m_situareViews->addWidget(m_listViewScreen);
112 m_situareViews->addWidget(m_mapViewScreen);
115 void MainWindow::toListView()
117 qDebug() << __PRETTY_FUNCTION__;
121 void MainWindow::toMapView()
123 qDebug() << __PRETTY_FUNCTION__;
127 void MainWindow::switchView(int nextIndex)
129 qDebug() << __PRETTY_FUNCTION__ << ":" << nextIndex;
130 if (nextIndex < 0 || nextIndex > 1) {
131 qDebug() << "Illegal parameter value in MainWindow::switchView";
134 m_situareViews->setCurrentIndex(nextIndex);
135 switch (m_situareViews->currentIndex()) {
137 setWindowTitle(tr("List view"));
140 setWindowTitle(tr("Map view"));
143 qDebug() << "Illegal switch value in MainWindow::switchView";
148 void MainWindow::openLocationUpdateDialog()
150 qDebug() << __PRETTY_FUNCTION__;
152 emit requestReverseGeo();
153 m_locationDialog->exec();
156 void MainWindow::openSettingsDialog()
158 qDebug() << __PRETTY_FUNCTION__;
159 SettingsDialog *dialog = new SettingsDialog(this);