<file>res/images/list_item_top.png</file>
<file>res/images/show_position.png</file>
<file>res/images/show_position_s.png</file>
+ <file>res/dummy/nmealog.txt</file>
</qresource>
</RCC>
#include "engine.h"
#include "ui/mainwindow.h"
+#include "gps/gpsposition.h"
SituareEngine::SituareEngine(QMainWindow *parent)
: QObject(parent)
m_facebookAuthenticator = new FacebookAuthentication();
+ m_gps = new GPSPosition(this);
+
connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
m_situareService, SLOT(credentialsReady(FacebookCredentials)));
connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
connect(m_ui, SIGNAL(refreshUserData()),
this, SLOT(refreshUserData()));
- m_facebookAuthenticator->start();
+ connect(m_gps, SIGNAL(timeout()), m_ui, SLOT(gpsTimeout()));
+ connect(m_gps, SIGNAL(error(QString)), m_ui, SLOT(gpsError(QString)));
+ connect(m_ui, SIGNAL(enableGPS(bool)), this, SLOT(enableGPS(bool)));
+ connect(m_gps, SIGNAL(position(QPointF)),
+ m_ui, SIGNAL(positionReceived(QPointF)));
+
+ m_facebookAuthenticator->start();
}
SituareEngine::~SituareEngine()
m_facebookAuthenticator->close();
m_ui->show();
m_situareService->fetchLocations(); // request user locations
+ enableGPS(true);
}
void SituareEngine::requestAddress()
emit userLocationReady(user);
emit friendsLocationsReady(friendsList);
}
+
+void SituareEngine::enableGPS(bool enabled)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (enabled)
+ m_gps->start();
+ else
+ m_gps->stop();
+}
Kaj Wallin - kaj.wallin@ixonos.com
Henri Lampela - henri.lampela@ixonos.com
+ Jussi Laitinen - jussi.laitinen@ixonos.com
Situare is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
#include "situareservice/situareservice.h"
#include "ui/mainwindow.h"
+class GPSPosition;
+
/**
* @brief Engine class for Situare Application
*
void userDataChanged(User *user, QList<User *> &friendsList);
/**
+ * @brief Slot for gps enabling.
+ *
+ * @parma enabled true if gps should be enabled, false otherwise
+ */
+ void enableGPS(bool enabled);
+
+ /**
* @brief Slot to intercept signal when user has cancelled login process
*
*/
* DATA MEMBERS
******************************************************************************/
private:
- MainWindow *m_ui; ///< Instance of the MainWindow UI
FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
+ GPSPosition *m_gps; ///< Instance of the gps position
+ MainWindow *m_ui; ///< Instance of the MainWindow UI
SituareService *m_situareService; ///< Instance of the situare server communication service
};
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Jussi Laitinen - jussi.laitinen@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+#include <QGeoPositionInfoSource>
+#include <QNmeaPositionInfoSource>
+#include <QFile>
+#include <QDir>
+#include <QApplication>
+#include <QDebug>
+
+#include "gpsposition.h"
+
+GPSPosition::GPSPosition(QObject *parent)
+ : QObject(parent),
+ m_running(false),
+ m_updateInterval(DEFAULT_UPDATE_INTERVAL)
+{
+ m_gpsSource = QGeoPositionInfoSource::createDefaultSource(this);
+
+ if (!m_gpsSource) {
+ QNmeaPositionInfoSource *nmeaSource = new QNmeaPositionInfoSource(
+ QNmeaPositionInfoSource::SimulationMode, this);
+ QFile *logFile = new QFile(":/res/dummy/nmealog.txt", this);
+ nmeaSource->setDevice(logFile);
+ m_gpsSource = nmeaSource;
+
+ emit error(tr("Could not start GPS. Using NMEA data source."));
+ }
+
+ m_gpsSource->setUpdateInterval(m_updateInterval);
+
+ connect(m_gpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)),
+ this, SLOT(positionUpdated(QGeoPositionInfo)));
+ connect(m_gpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
+}
+
+GPSPosition::~GPSPosition()
+{
+ stop();
+}
+
+void GPSPosition::start()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (m_gpsSource && !isRunning()) {
+ m_gpsSource->startUpdates();
+ m_running = true;
+ }
+}
+
+void GPSPosition::stop()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (m_gpsSource && isRunning()) {
+ m_gpsSource->stopUpdates();
+ m_running = false;
+ }
+}
+
+bool GPSPosition::isRunning()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ return m_running;
+}
+
+void GPSPosition::update()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ emit m_gpsSource->requestUpdate(DEFAULT_UPDATE_INTERVAL);
+}
+
+void GPSPosition::positionUpdated(QGeoPositionInfo positionInfo)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ emit position(QPointF(positionInfo.coordinate().longitude(),
+ positionInfo.coordinate().latitude()));
+}
+
+void GPSPosition::updateTimeout()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ emit timeout();
+}
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Jussi Laitinen - jussi.laitinen@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+#ifndef GPSPOSITION_H
+#define GPSPOSITION_H
+
+#include <QGeoPositionInfoSource>
+#include <QPointF>
+
+QTM_USE_NAMESPACE
+
+/**
+* @brief GPSPosition class use GPS to receive location information.
+*
+* @class GPSPosition engine.h "gps/gpsposition.h"
+*/
+class GPSPosition : public QObject
+{
+ Q_OBJECT
+
+public:
+ /**
+ * @brief Start GPS.
+ */
+ GPSPosition(QObject *parent = 0);
+ ~GPSPosition();
+
+/******************************************************************************
+* MEMBER FUNCTIONS AND SLOTS
+******************************************************************************/
+public:
+ /**
+ * @brief Checks if GPS is running.
+ *
+ * @return true if GPS running, false otherwise
+ */
+ bool isRunning();
+
+ /**
+ * @brief Start GPS.
+ */
+ void start();
+
+ /**
+ * @brief Stop GPS.
+ */
+ void stop();
+
+ /**
+ * @brief Request GPS update.
+ */
+ void update();
+
+private slots:
+
+ /**
+ * @brief Slot for received position update.
+ *
+ * @param positionInfo Geo position info.
+ */
+ void positionUpdated(QGeoPositionInfo positionInfo);
+
+ /**
+ * @brief Slot for update timeout.
+ *
+ * Called when request timeout occurs.
+ */
+ void updateTimeout();
+
+/******************************************************************************
+* SIGNALS
+******************************************************************************/
+signals:
+ /**
+ * @brief Signal for position information.
+ *
+ * @param latLonCoordinate latitude and longitude values
+ */
+ void position(QPointF latLonCoordinate);
+
+ /**
+ * @brief Signal for timeout.
+ */
+ void timeout();
+
+ /**
+ * @brief Signal for error.
+ *
+ * @param message error message
+ */
+ void error(const QString &message);
+
+private:
+ QGeoPositionInfoSource *m_gpsSource; ///< GPS position info source
+ bool m_running; ///< GPS is running
+ int m_updateInterval; ///< GPS update interval
+};
+
+const int DEFAULT_UPDATE_INTERVAL = 5000; ///< Default update interval
+
+#endif // GPSPOSITION_H
#include "mapengine.h"
#include "maptile.h"
+#include "gps/gpsposition.h"
+
MapEngine::MapEngine(QObject *parent)
: QObject(parent)
, m_centerTile(QPoint(UNDEFINED, UNDEFINED))
ui/panelsidebar.cpp \
ui/panelsliderbar.cpp \
map/friendgroupitem.cpp \
- map/frienditemshandler.cpp
+ map/frienditemshandler.cpp \
+ gps/gpsposition.cpp
HEADERS += ui/mainwindow.h \
ui/mapviewscreen.h \
ui/listviewscreen.h \
ui/panelsidebar.h \
ui/panelsliderbar.h \
map/friendgroupitem.h \
- map/frienditemshandler.h
+ map/frienditemshandler.h \
+ gps/gpsposition.h
QT += network \
webkit
+CONFIG += mobility
+
+MOBILITY = location
+
DEFINES += QT_NO_DEBUG_OUTPUT
!maemo5 {
*/
#include <QtGui>
+
+#ifdef Q_WS_MAEMO_5
+#include <QtMaemo5/QMaemo5InformationBox>
+#endif // Q_WS_MAEMO_5
+
#include "mainwindow.h"
#include "listviewscreen.h"
#include "mapviewscreen.h"
connect(m_listViewScreen, SIGNAL(updateFriendsData()),
this, SIGNAL(refreshUserData()));
+ connect(this, SIGNAL(enableAutoCentering(bool)),
+ m_mapViewScreen, SLOT(enableAutoCentering(bool)));
+ connect(this, SIGNAL(positionReceived(QPointF)),
+ m_mapViewScreen, SLOT(positionReceived(QPointF)));
+
this->toggleProgressIndicator(true);
+
+ //Debug, use settings instead
+ autoCenteringToggled(true);
}
MainWindow::~MainWindow()
m_toSettingsAct = new QAction(tr("Settings"), this);
m_toSettingsAct->setObjectName(tr("Settings"));
connect(m_toSettingsAct, SIGNAL(triggered()), this, SLOT(openSettingsDialog()));
+ m_gpsToggleAct = new QAction(tr("GPS enabled"), this);
+ m_gpsToggleAct->setCheckable(true);
+ m_gpsToggleAct->setChecked(true);
+ connect(m_gpsToggleAct, SIGNAL(toggled(bool)), this, SLOT(gpsActionToggled(bool)));
+ m_autoCenteringAct = new QAction(tr("Auto centering enabled"), this);
+ m_autoCenteringAct->setCheckable(true);
+ m_autoCenteringAct->setChecked(true);
+ connect(m_autoCenteringAct, SIGNAL(toggled(bool)), this, SLOT(autoCenteringToggled(bool)));
m_viewMenu = menuBar()->addMenu(tr("View"));
m_viewMenu->addAction(m_toListViewAct);
m_viewMenu->addAction(m_toMapViewAct);
m_viewMenu->addAction(m_toSettingsAct);
+ m_viewMenu->addAction(m_gpsToggleAct);
+ m_viewMenu->addAction(m_autoCenteringAct);
m_viewMenu->setObjectName(tr("View Menu"));
}
SettingsDialog *dialog = new SettingsDialog(this);
dialog->show();
}
+
+void MainWindow::gpsActionToggled(bool checked)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (checked) {
+ emit enableGPS(true);
+ m_gpsToggleAct->setText(tr("GPS enabled"));
+ showMaemoInformationBox(tr("GPS enabled"));
+ m_autoCenteringAct->setEnabled(true);
+ }
+ else {
+ emit enableGPS(false);
+ m_gpsToggleAct->setText(tr("GPS disabled"));
+ showMaemoInformationBox(tr("GPS disabled"));
+ m_autoCenteringAct->setEnabled(false);
+ }
+}
+
+void MainWindow::gpsTimeout()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ showMaemoInformationBox(tr("GPS timeout"));
+}
+
+void MainWindow::gpsError(const QString &message)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ showMaemoInformationBox(message);
+}
+
+void MainWindow::autoCenteringToggled(bool checked)
+{
+ qDebug() << __PRETTY_FUNCTION__ << " " << checked;
+
+ if (checked) {
+ emit enableAutoCentering(true);
+ m_autoCenteringAct->setText(tr("Auto centering enabled"));
+ showMaemoInformationBox(tr("Auto centering enabled"));
+ }
+ else {
+ emit enableAutoCentering(false);
+ m_autoCenteringAct->setText(tr("Auto centering disabled"));
+ showMaemoInformationBox(tr("Auto centering disabled"));
+ }
+}
+
+void MainWindow::showMaemoInformationBox(const QString &message)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+#ifdef Q_WS_MAEMO_5
+ QMaemo5InformationBox::information(this, message,
+ QMaemo5InformationBox::DefaultTimeout);
+#endif // Q_WS_MAEMO_5
+}
*/
void switchView(int);
+ void showMaemoInformationBox(const QString &message);
+
private slots:
/**
* @brief Private slot, which starts UpdateLocationDialog
*/
void openLocationUpdateDialog();
+ /**
+ * @brief Slot for gps enabling.
+ *
+ * @param checked true if button state is checked, false otherwise
+ */
+ void gpsActionToggled(bool checked);
+
+ /**
+ * @brief Slot for gps timeout.
+ *
+ * Called when request timeout occurs.
+ */
+ void gpsTimeout();
+
+ /**
+ * @brief Slot for gps error.
+ *
+ * @param message error message
+ */
+ void gpsError(const QString &message);
+
+ /**
+ * @brief Slot for auto centering enabling.
+ *
+ * @param checked true if button state is checked, false otherwise
+ */
+ void autoCenteringToggled(bool checked);
+
/*******************************************************************************
* SIGNALS
******************************************************************************/
*/
void refreshUserData();
+ /**
+ * @brief Signal for gps position.
+ *
+ * @param position longitude and latitude values
+ */
+ void positionReceived(QPointF position);
+
+ /**
+ * @brief Signal for gps enabling.
+ *
+ * @param enabled true if gps should be enabled
+ */
+ void enableGPS(bool enabled);
+
+ /**
+ * @brief Signal for map auto centering
+ *
+ * @param enabled true if map should auto center to gps location
+ */
+ void enableAutoCentering(bool enabled);
+
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
UpdateLocationDialog *m_locationDialog; ///< Message dialog
MapViewScreen *m_mapViewScreen; ///< Instance of the map view
QStackedWidget *m_situareViews; ///< Stacked widget that hold both view widgets
+ QAction *m_autoCenteringAct; ///< Action to auto center map using gps position
+ QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
QAction *m_toListViewAct; ///< Action to trigger switch to list view
QAction *m_toMapViewAct; ///< Action to trigger switch to map view
QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
#include "panelsidebar.h"
MapViewScreen::MapViewScreen(QWidget *parent)
- : QWidget(parent)
+ : QWidget(parent),
+ m_autoCenteringEnabled(false)
{
MapView *mapView = new MapView(this);
mapEngine = new MapEngine(this);
osmLicense->move(width - osmLicense->fontMetrics().width(OSM_LICENSE) - PANEL_PEEK_AMOUNT,
height - osmLicense->fontMetrics().height());
}
+
+void MapViewScreen::positionReceived(QPointF position)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (m_autoCenteringEnabled)
+ mapEngine->setViewLocation(position);
+}
+
+void MapViewScreen::enableAutoCentering(bool enabled)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_autoCenteringEnabled = enabled;
+}
******************************************************************************/
private slots:
+
+ /**
+ * @brief Slot for enabling auto centering.
+ *
+ * @param enabled true if map should center to GPS position, false otherwise
+ */
+ void enableAutoCentering(bool enabled);
+
/**
* @brief Slot for drawing the Open Street Map license text
*
*/
void drawOsmLicense(int width, int height);
+ /**
+ * @brief Slot for GPS position.
+ *
+ * @param position latitude and longitude values
+ */
+ void positionReceived(QPointF position);
+
/*******************************************************************************
* SIGNALS
******************************************************************************/
******************************************************************************/
private:
+ bool m_autoCenteringEnabled; ///< Enable
FriendListPanel *friendsListPanel; ///< Instance of friends list panel
MapEngine *mapEngine; ///< MapEngine
QLabel *osmLicense; ///< Label for Open Street Map license