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)),
48 m_locationDialog, SLOT(setAddress(QString)));
49 connect(m_locationDialog, SIGNAL(statusUpdate(QString,bool)), this,
50 SIGNAL(statusUpdate(QString,bool)));
52 connect(this, SIGNAL(userLocationReady(User*)),
53 m_mapViewScreen, SIGNAL(userLocationReady(User*)));
54 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
55 m_mapViewScreen, SIGNAL(friendsLocationsReady(QList<User*>&)));
57 connect(this, SIGNAL(userLocationReady(User*)),
58 m_listViewScreen, SLOT(userDataReceived(User*)));
59 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
60 m_listViewScreen, SLOT(friendInfoReceived(QList<User*>&)));
61 connect(m_listViewScreen, SIGNAL(updateFriendsData()),
62 this, SIGNAL(refreshUserData()));
64 this->toggleProgressIndicator(true);
67 MainWindow::~MainWindow()
69 qDebug() << __PRETTY_FUNCTION__;
70 delete m_toListViewAct;
71 delete m_toMapViewAct;
72 delete m_toSettingsAct;
73 delete m_situareViews;
76 void MainWindow::toggleProgressIndicator(bool value)
78 qDebug() << __PRETTY_FUNCTION__;
80 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, value);
83 #endif // Q_WS_MAEMO_5
86 void MainWindow::createMenus()
88 qDebug() << __PRETTY_FUNCTION__;
89 m_toListViewAct = new QAction(tr("List"), this);
90 m_toListViewAct->setObjectName(tr("List"));
91 connect(m_toListViewAct, SIGNAL(triggered()), this, SLOT(toListView()));
92 m_toMapViewAct = new QAction(tr("Map"), this);
93 m_toMapViewAct->setObjectName(tr("Map"));
94 connect(m_toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
95 m_toSettingsAct = new QAction(tr("Settings"), this);
96 m_toSettingsAct->setObjectName(tr("Settings"));
97 connect(m_toSettingsAct, SIGNAL(triggered()), this, SLOT(openSettingsDialog()));
98 m_viewMenu = menuBar()->addMenu(tr("View"));
99 m_viewMenu->addAction(m_toListViewAct);
100 m_viewMenu->addAction(m_toMapViewAct);
101 m_viewMenu->addAction(m_toSettingsAct);
102 m_viewMenu->setObjectName(tr("View Menu"));
105 void MainWindow::createViews()
107 qDebug() << __PRETTY_FUNCTION__;
108 m_listViewScreen = new ListViewScreen(this);
109 m_mapViewScreen = new MapViewScreen(this);
111 m_situareViews = new QStackedWidget;
112 m_situareViews->addWidget(m_listViewScreen);
113 m_situareViews->addWidget(m_mapViewScreen);
116 void MainWindow::toListView()
118 qDebug() << __PRETTY_FUNCTION__;
122 void MainWindow::toMapView()
124 qDebug() << __PRETTY_FUNCTION__;
128 void MainWindow::switchView(int nextIndex)
130 qDebug() << __PRETTY_FUNCTION__ << ":" << nextIndex;
131 if (nextIndex < 0 || nextIndex > 1) {
132 qDebug() << "Illegal parameter value in MainWindow::switchView";
135 m_situareViews->setCurrentIndex(nextIndex);
136 switch (m_situareViews->currentIndex()) {
138 setWindowTitle(tr("List view"));
141 setWindowTitle(tr("Map view"));
144 qDebug() << "Illegal switch value in MainWindow::switchView";
149 void MainWindow::openLocationUpdateDialog()
151 qDebug() << __PRETTY_FUNCTION__;
153 emit requestReverseGeo();
154 m_locationDialog->exec();
157 void MainWindow::openSettingsDialog()
159 qDebug() << __PRETTY_FUNCTION__;
160 SettingsDialog *dialog = new SettingsDialog(this);