void GpsController::getGps()
{
- if ( q->currentLocation() != 0 ) {
- emit locationChanged( q->currentLocation() );
+ Location *location;
+
+ if ( q->useFakeLocation() ) {
+ location = q->fakeLocation();
+ } else {
+ location = q->liveLocation();
}
+
+ emit locationChanged( location );
}
void GpsController::useLiveGps()
{
q->setUseFakeLocation( false );
- q->setCurrentLocation( new Location( "livegps" ) );
q->startGps();
+ emit locationChanged( q->liveLocation() );
}
-void GpsController::useFakeGps( Location *fakeLocation )
+void GpsController::useFakeGps( const QString &fakeLocationLabel )
{
- qDebug() << "using fake gps (" << fakeLocation->label() << ")";
- q->stopGps();
- q->setUseFakeLocation( true );
- q->setCurrentLocation( fakeLocation );
- emit locationChanged( q->currentLocation() );
+ qDebug() << "using fake gps (" << fakeLocationLabel << ")";
+
+ q->setFakeLocationLabel( fakeLocationLabel );
+ Location *fakeLocation = q->fakeLocation();
+
+ if ( fakeLocation == 0 ) {
+ qDebug() << "invalid fake location label; cannot use fake location";
+ } else {
+ q->stopGps();
+ q->setUseFakeLocation( true );
+ emit locationChanged( fakeLocation );
+ }
}