SituareEngine::SituareEngine(QMainWindow *parent)
: QObject(parent),
m_autoCenteringEnabled(false),
- m_gpsEnabled(false)
+ m_gpsEnabled(false),
+ m_latestLocation()
{
qDebug() << __PRETTY_FUNCTION__;
m_ui = new MainWindow;
enableGPS(gpsEnabled.toBool());
enableAutoCentering(autoCenteringEnabled.toBool());
-connect(this, SIGNAL(requestOwnLocation()),
+ connect(this, SIGNAL(requestOwnLocation()),
m_ui, SIGNAL(requestOwnLocation()));
connect(m_ui, SIGNAL(ownLocation(QPointF)),
this, SLOT(receiveOwnLocation(QPointF)));
{
qDebug() << __PRETTY_FUNCTION__;
- QPointF coordinates;
-
- if (m_gpsEnabled)
- coordinates = m_gps->lastPosition();
- else
- coordinates = QPointF(0, 0); //Manual position from map
-
- m_situareService->reverseGeo(coordinates);
+ if (m_gpsEnabled) {
+ m_latestLocation = m_gps->lastPosition();
+ m_situareService->reverseGeo(m_latestLocation);
+ }
+ else {
+ emit requestOwnLocation();
+ m_situareService->reverseGeo(m_latestLocation);
+ }
}
void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
m_ui->toggleProgressIndicator(true);
- QPointF coordinates;
-
- if (m_gpsEnabled)
- coordinates = m_gps->lastPosition();
- else
- coordinates = QPointF(0, 0); //Manual position from map
-
- m_situareService->updateLocation(coordinates, status, publish);
+ if (m_gpsEnabled) {
+ m_latestLocation = m_gps->lastPosition();
+ m_situareService->updateLocation(m_latestLocation, status, publish);
+ }
+ else {
+ emit requestOwnLocation();
+ m_situareService->updateLocation(m_latestLocation, status, publish);
+ }
}
void SituareEngine::updateWasSuccessful()
{
qWarning() << __PRETTY_FUNCTION__;
qWarning() << ownLocation.x() << " " << ownLocation.y();
+ m_latestLocation = ownLocation;
}
GPSPositionInterface *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
+ QPointF m_latestLocation; ///< Placeholder for user's latest asked location
};
#endif // ENGINE_H
setCentralWidget(m_mapViewScreen);
createMenus();
setWindowTitle(tr("Situare"));
- show();
+ show();
m_locationDialog = new UpdateLocationDialog(this);
connect(this, SIGNAL(zoomOutKeyPressed()),
m_mapViewScreen, SIGNAL(zoomOutKeyPressed()));
-connect(this, SIGNAL(requestOwnLocation()),
+ connect(this, SIGNAL(requestOwnLocation()),
m_mapViewScreen, SIGNAL(requestOwnLocation()));
connect(m_mapViewScreen, SIGNAL(ownLocation(QPointF)),
this, SIGNAL(ownLocation(QPointF)));
m_gpsToggleAct->setChecked(true);
connect(m_gpsToggleAct, SIGNAL(toggled(bool)),
this, SLOT(gpsToggled(bool)));
-connect(m_gpsToggleAct, SIGNAL(toggled(bool)),
- m_mapViewScreen, SLOT(setOwnLocationCrosshairVisibility(bool)));
+ connect(m_gpsToggleAct, SIGNAL(toggled(bool)),
+ m_mapViewScreen, SLOT(setOwnLocationCrosshairVisibility(bool)));
m_autoCenteringAct = new QAction(tr("Auto centering"), this);
m_autoCenteringAct->setCheckable(true);
m_autoCenteringAct->setChecked(true);
connect(m_autoCenteringAct, SIGNAL(toggled(bool)),
this, SLOT(autoCenteringToggled(bool)));
- m_viewMenu = menuBar()->addMenu(tr("Main"));
+ m_viewMenu = menuBar()->addMenu(tr("Main"));
m_viewMenu->addAction(m_toSettingsAct);
- m_viewMenu->addAction(m_gpsToggleAct);
+ m_viewMenu->addAction(m_gpsToggleAct);
m_viewMenu->addAction(m_autoCenteringAct);
m_viewMenu->setObjectName(tr("Menu"));
}