#include "network/networkaccessmanager.h"
#include "situareservice/situareservice.h"
#include "ui/mainwindow.h"
+#include "qmlui/geomap.h"
+#include "qmlui/rotation.h"
+#include "qmlui/loginlogic.h"
+#include <qdeclarative.h>
+#include <QDeclarativeView>
+#include <QDeclarativeContext>
+#include <QApplication>
+#include <QDesktopWidget>
#include "engine.h"
// signals connected, now it's time to show the main window
// but init the MapEngine before so starting location is set
m_mapEngine->init();
- m_ui->show();
+// m_ui->show();
+
+ // QML UI INIT
+ qmlRegisterType<GeoMap>("MapPlugin", 1, 0, "GeoMap");
- m_facebookAuthenticator->start();
+ QDeclarativeView* view = new QDeclarativeView(QApplication::desktop());
+#ifdef Q_WS_MAEMO_5
+// view.setAttribute(Qt::WA_Maemo5AutoOrientation, true);
+#endif
+ Rotation *rotation = new Rotation();
+ view->rootContext()->setContextProperty("deviceRotation", static_cast<QObject *>(rotation));
+ LoginLogic loginLogic;
+ view->rootContext()->setContextProperty("loginLogic", &loginLogic);
+ view->setSource(QUrl("qrc:/Main.qml"));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ view->show();
+
+ //m_facebookAuthenticator->start();
m_gps->setMode(GPSPosition::Default);
initializeGpsAndAutocentering();
m_mce = new MCE(this);
connect(m_mce, SIGNAL(displayOff(bool)), this, SLOT(setPowerSaving(bool)));
-
+
m_contactManager = new ContactManager(this);
m_contactManager->requestContactGuids();
}
--- /dev/null
+#include "geomap.h"
+#include <QDebug>
+#include <QGeoMapPixmapObject>
+
+using namespace QtMobility;
+
+GeoMap::GeoMap(QGraphicsItem* parent)
+ : QGraphicsGeoMap(parent),
+ source(0),
+ prevGpsLocation(0,0),
+ initialized(false)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ connect(this, SIGNAL(panned(QPoint)), this, SLOT(panned()));
+
+ setCenter(prevGpsLocation);
+
+ goToGpsLocation();
+}
+
+GeoMap::~GeoMap()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+}
+
+qreal GeoMap::angleToGpsLocation() const
+{
+ const qreal result = prevGpsLocation.isValid() ? center().azimuthTo(prevGpsLocation) : 0.0;
+ qDebug() << "QmlMap::angleToGpsLocation: " << result;
+ return result;
+}
+
+qreal GeoMap::distanceToGpsLocation() const
+{
+ const qreal result = prevGpsLocation.isValid() ? center().distanceTo(prevGpsLocation) : 0.0;
+ const int km = result * 0.001;
+ qDebug() << "QmlMap::distanceToGpsLocation: " << km;
+ return km;
+}
+
+double GeoMap::centerLatitude() const {
+ return center().latitude();
+}
+
+void GeoMap::setCenterLatitude(const double latitude) {
+ QGeoCoordinate newCenter = center();
+ newCenter.setLatitude(latitude);
+ setCenter(newCenter);
+ emit positionChanged();
+}
+
+double GeoMap::centerLongitude() const
+{
+ return center().longitude();
+}
+
+void GeoMap::setCenterLongitude(const double longitude) {
+ QGeoCoordinate newCenter = center();
+ newCenter.setLongitude(longitude);
+ setCenter(newCenter);
+ emit positionChanged();
+
+}
+
+double GeoMap::gpsLocationLatitude() const
+{
+ return prevGpsLocation.latitude();
+}
+
+double GeoMap::gpsLocationLongitude() const
+{
+ return prevGpsLocation.longitude();
+}
+
+void GeoMap::panned()
+{
+ emit positionChanged();
+}
+
+void GeoMap::goToGpsLocation()
+{
+ qDebug() << "QmlMap::goToGpsLocation";
+ if (!source)
+ source = QGeoPositionInfoSource::createDefaultSource(this);
+
+ if (source) {
+ source->requestUpdate();
+ connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
+ source->setUpdateInterval(10000);
+ source->startUpdates();
+ }
+}
+
+void GeoMap::positionUpdated(const QGeoPositionInfo& positionInfo)
+{
+ qDebug() << "QmlMap::positionUpdated: " << positionInfo.coordinate();
+ prevGpsLocation = positionInfo.coordinate();
+
+ if (!initialized) {
+ initialized = true;
+ QPixmap image(":/res/gps_position.png");
+ Q_ASSERT(!image.isNull());
+ QGeoMapPixmapObject* pixmap = new QGeoMapPixmapObject(prevGpsLocation, QPoint(-image.width()/2, -image.height()/2), image);
+ addMapObject(pixmap);
+ setCenter(prevGpsLocation);
+ emit positionChanged();
+ }
+ else {
+ qobject_cast<QGeoMapPixmapObject*>(mapObjects().at(0))->setCoordinate(prevGpsLocation);
+
+ }
+ emit gpsLocationChanged();
+}
--- /dev/null
+#ifndef GEOMAP_H
+#define GEOMAP_H
+
+#include <QGraphicsGeoMap>
+#include <QGeoPositionInfo>
+#include <QGeoPositionInfoSource>
+#include <QGeoCoordinate>
+#include <QVector3D>
+
+using namespace QtMobility;
+
+class GeoMap : public QGraphicsGeoMap
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal angleToGpsLocation READ angleToGpsLocation NOTIFY positionChanged)
+ Q_PROPERTY(qreal distanceToGpsLocation READ distanceToGpsLocation NOTIFY positionChanged)
+ Q_PROPERTY(double centerLatitude READ centerLatitude WRITE setCenterLatitude NOTIFY positionChanged)
+ Q_PROPERTY(double centerLongitude READ centerLongitude WRITE setCenterLongitude NOTIFY positionChanged)
+ Q_PROPERTY(double gpsLocationLatitude READ gpsLocationLatitude NOTIFY gpsLocationChanged)
+ Q_PROPERTY(double gpsLocationLongitude READ gpsLocationLongitude NOTIFY gpsLocationChanged)
+
+public:
+ GeoMap(QGraphicsItem* parent = 0);
+ virtual ~GeoMap();
+
+ qreal angleToGpsLocation() const;
+ qreal distanceToGpsLocation() const;
+
+ double centerLatitude() const;
+ void setCenterLatitude(const double latitude);
+ double centerLongitude() const;
+ void setCenterLongitude(const double longitude);
+ double gpsLocationLatitude() const;
+ double gpsLocationLongitude() const;
+
+signals:
+ void positionChanged();
+ void screenCenterChanged();
+ void gpsLocationChanged();
+
+public slots:
+ void goToGpsLocation();
+
+private slots:
+ void positionUpdated(const QGeoPositionInfo& positionInfo);
+ void panned();
+
+private:
+ QGeoPositionInfoSource *source;
+ QGeoCoordinate prevGpsLocation;
+ bool initialized;
+};
+
+#endif
--- /dev/null
+#include "loginlogic.h"
+#include <QDebug>
+#include <QTimer>
+#include <QDialog>
+#include <QLabel>
+#include <QApplication>
+#include <QDesktopWidget>
+#ifdef Q_WS_MAEMO_5
+#include <QtMaemo5/QMaemo5InformationBox>
+#endif
+class LoginLogicPrivate
+{
+public:
+ QString email;
+ QString password;
+
+ LoginLogicPrivate() :
+ email("janne.kiiski@gmail.com"),
+ password("mypassword")
+ {}
+};
+
+LoginLogic::LoginLogic(QObject *parent) :
+ QObject(parent), d_ptr(new LoginLogicPrivate)
+{
+}
+
+LoginLogic::~LoginLogic()
+{
+}
+
+void LoginLogic::login()
+{
+ Q_D(LoginLogic);
+ qDebug() << __PRETTY_FUNCTION__ << " user: " << d->email << " password: " << d->password;
+
+ QTimer::singleShot(5000, this, SLOT(onLoginCompleted()));
+}
+
+QString LoginLogic::email() const
+{
+ Q_D(const LoginLogic);
+ return d->email;
+}
+void LoginLogic::setEmail(const QString& email)
+{
+ Q_D(LoginLogic);
+ d->email = email;
+}
+
+QString LoginLogic::password() const
+{
+ Q_D(const LoginLogic);
+ return d->password;
+}
+
+void LoginLogic::setPassword(const QString& password)
+{
+ Q_D(LoginLogic);
+ d->password = password;
+}
+
+void LoginLogic::onLoginCompleted()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+#ifdef Q_WS_MAEMO_5
+ QMaemo5InformationBox *msgBox = new QMaemo5InformationBox(QApplication::desktop());
+
+ QString errorMessage("login completed");
+
+ if(false) {
+ msgBox->setTimeout(QMaemo5InformationBox::NoTimeout);
+ // extra line changes are needed to make error notes broader
+ errorMessage.prepend("\n");
+ errorMessage.append("\n");
+ } else {
+ msgBox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
+ }
+ QLabel *label = new QLabel(msgBox);
+ label->setAlignment(Qt::AlignCenter);
+ label->setText(errorMessage);
+ msgBox->setWidget(label);
+ msgBox->show();
+#endif
+ emit loginCompleted(rand()%2);
+}
--- /dev/null
+#ifndef LOGINLOGIC_H
+#define LOGINLOGIC_H
+
+#include <QObject>
+#include <QScopedPointer>
+
+class LoginLogicPrivate;
+
+class LoginLogic : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString email READ email WRITE setEmail NOTIFY emailChanged)
+ Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
+
+public:
+ LoginLogic(QObject *parent = 0);
+ virtual ~LoginLogic();
+
+ Q_INVOKABLE void login();
+
+ QString email() const;
+ void setEmail(const QString& email);
+ QString password() const;
+ void setPassword(const QString& password);
+
+signals:
+ void emailChanged();
+ void passwordChanged();
+
+ void loginCompleted(bool success);
+
+private slots:
+ void onLoginCompleted();
+
+private:
+ Q_DECLARE_PRIVATE(LoginLogic)
+ QScopedPointer<LoginLogicPrivate> d_ptr;
+};
+
+#endif // LOGINLOGIC_H
--- /dev/null
+<RCC>
+ <qresource prefix="/">
+ <file>res/friend_list.png</file>
+ <file>res/location_search.png</file>
+ <file>res/routing.png</file>
+ <file>res/user_info.png</file>
+ <file>PanelContents.qml</file>
+ <file>Main.qml</file>
+ <file>Button.qml</file>
+ <file>res/friends/default.gif</file>
+ <file>res/friends/henri.jpg</file>
+ <file>res/friends/jussi.jpg</file>
+ <file>res/friends/katri.jpg</file>
+ <file>res/friends/pekka.jpg</file>
+ <file>FriendsModel.qml</file>
+ <file>List.qml</file>
+ <file>Map.qml</file>
+ <file>res/gps_position.png</file>
+ <file>res/gps_position_dir.png</file>
+ <file>res/sight.png</file>
+ <file>res/zoom_in.png</file>
+ <file>res/zoom_out.png</file>
+ <file>res/ixonos_logo.png</file>
+ <file>Dialog.qml</file>
+ <file>LoginWidget.qml</file>
+ </qresource>
+</RCC>
--- /dev/null
+#include <QDebug>
+#include <QOrientationReading>
+#include <QOrientationSensor>
+
+#include "rotation.h"
+
+QTM_USE_NAMESPACE
+
+Rotation::Rotation(QObject *parent) :
+ QObject(parent)
+{
+// qDebug() << __PRETTY_FUNCTION__;
+
+ m_sensor = new QOrientationSensor(this);
+ m_sensor->start();
+ connect(m_sensor, SIGNAL(readingChanged()), this, SLOT(onReadingChanged()));
+}
+
+void Rotation::onReadingChanged()
+{
+// qDebug() << __PRETTY_FUNCTION__ << m_sensor->reading()->orientation();
+
+ switch (m_sensor->reading()->orientation()) {
+ case QOrientationReading::TopUp:
+ case QOrientationReading::TopDown:
+ m_orientation = "";
+// qDebug() << __PRETTY_FUNCTION__ << "changed to:" << m_orientation;
+ break;
+ case QOrientationReading::LeftUp:
+ case QOrientationReading::RightUp:
+ m_orientation = "potrait";
+// qDebug() << __PRETTY_FUNCTION__ << "changed to:" << m_orientation;
+ break;
+ default:
+ break;
+ }
+
+ emit orientationChanged();
+}
+
+QString Rotation::orientation()
+{
+// qDebug() << __PRETTY_FUNCTION__ << m_orientation;
+
+ return m_orientation;
+}
--- /dev/null
+#ifndef ROTATION_H
+#define ROTATION_H
+
+#include <QObject>
+
+namespace QtMobility {
+class QOrientationSensor;
+}
+using QtMobility::QOrientationSensor;
+
+class Rotation : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString orientation READ orientation NOTIFY orientationChanged)
+
+public:
+ explicit Rotation(QObject *parent = 0);
+
+ QString orientation();
+
+signals:
+ void orientationChanged();
+
+public slots:
+ void onReadingChanged();
+
+private:
+ QOrientationSensor *m_sensor;
+ QString m_orientation;
+};
+
+#endif // ROTATION_H
TEMPLATE = app
LIBS += -lqjson
RESOURCES += ../images.qrc \
- ../languages.qrc
+ ../languages.qrc \
+ qmlui/res.qrc \
+
TRANSLATIONS += ../res/languages/situare_fi.ts
SOURCES += main.cpp \
application.cpp \
ui/paneltabbar.cpp \
ui/routingpanel.cpp \
ui/routewaypointlistitem.cpp \
- ui/routewaypointlistview.cpp \
+ ui/routewaypointlistview.cpp \
ui/searchdialog.cpp \
ui/searchhistorylistitem.cpp \
ui/searchhistorylistview.cpp \
ui/zoombutton.cpp \
ui/zoombuttonpanel.cpp \
user/user.cpp \
- ui/listitemcontextbuttonbar.cpp
+ ui/listitemcontextbuttonbar.cpp \
+ qmlui/geomap.cpp \
+ qmlui/loginlogic.cpp \
+ qmlui/rotation.cpp \
+
HEADERS += application.h \
common.h \
coordinates/geocoordinate.h \
routing/location.h \
routing/route.h \
routing/routesegment.h \
- routing/routingcommon.h \
+ routing/routingcommon.h \
routing/routingservice.h \
situareservice/imagefetcher.h \
situareservice/situarecommon.h \
ui/imagebutton.h \
ui/indicatorbutton.h \
ui/indicatorbuttonpanel.h \
- ui/listcommon.h \
+ ui/listcommon.h \
ui/listview.h \
ui/listitem.h \
ui/listitemdelegate.h \
ui/zoombutton.h \
ui/zoombuttonpanel.h \
user/user.h \
- ui/listitemcontextbuttonbar.h
+ ui/listitemcontextbuttonbar.h \
+ qmlui/geomap.h \
+ qmlui/loginlogic.h \
+ qmlui/rotation.h \
+
QT += network \
- webkit
+ webkit \
+ declarative
+
DEFINES += QT_NO_DEBUG_OUTPUT
simulator {
engine/contactmanagerprivatestub.h \
engine/mceprivatestub.h
CONFIG += mobility
- MOBILITY += location
+ MOBILITY += location sensors
} else:maemo5 {
armel {
DEFINES += ARMEL
ui/ossoabookdialog.cpp
HEADERS += engine/contactmanagerprivate.h \
ui/ossoabookdialog.h
- CONFIG += mobility
- MOBILITY += contacts
} else {
SOURCES += gps/gpspositionprivatestub.cpp \
network/networkhandlerprivatestub.cpp \
HEADERS += engine/contactmanagerprivatestub.h
}
+ CONFIG += mobility
+ MOBILITY += contacts location sensors
QT += maemo5
message([QJson])