[Marble-commits] KDE/kdeedu/marble/src
Dennis Nienhüser
earthwings at gentoo.org
Mon Oct 11 20:50:59 CEST 2010
SVN commit 1184894 by nienhueser:
Add a convenience link next to the "destination reached" message to calculate the way back.
M +10 -0 lib/routing/RouteRequest.cpp
M +2 -0 lib/routing/RouteRequest.h
M +6 -0 lib/routing/RoutingManager.cpp
M +3 -0 lib/routing/RoutingManager.h
M +14 -1 plugins/render/routing/RoutingPlugin.cpp
M +3 -0 plugins/render/routing/RoutingPlugin.h
--- trunk/KDE/kdeedu/marble/src/lib/routing/RouteRequest.cpp #1184893:1184894
@@ -297,6 +297,16 @@
return visited;
}
+void RouteRequest::reverse()
+{
+ int const total = d->m_route.size();
+ int const upper = total / 2;
+ for( int i=0; i<upper; ++i ) {
+ qSwap( d->m_route[i], d->m_route[total-i-1] );
+ setVisited( i, false );
+ setVisited( total-i-1, false );
+ }
+}
} // namespace Marble
--- trunk/KDE/kdeedu/marble/src/lib/routing/RouteRequest.h #1184893:1184894
@@ -110,6 +110,8 @@
bool visited( int index ) const;
+ void reverse();
+
Q_SIGNALS:
/** The value of the n-th element was changed */
void positionChanged( int index, const GeoDataCoordinates &position );
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingManager.cpp #1184893:1184894
@@ -338,6 +338,12 @@
}
}
+void RoutingManager::reverseRoute()
+{
+ d->m_routeRequest->reverse();
+ updateRoute();
+}
+
} // namespace Marble
#include "RoutingManager.moc"
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingManager.h #1184893:1184894
@@ -72,6 +72,9 @@
*/
void retrieveRoute( RouteRequest *route );
+ /** Reverse the previously requested route, i.e. swap start and destination (and via points, if any) */
+ void reverseRoute();
+
/**
* Toggle offline mode. In offline mode, new routes cannot be downloaded
*/
--- trunk/KDE/kdeedu/marble/src/plugins/render/routing/RoutingPlugin.cpp #1184893:1184894
@@ -121,6 +121,8 @@
m_routingWidgetSmall->setupUi( widget );
m_routingInformationWidgetSmall = new Ui::RoutingInformationWidgetSmall;
m_routingInformationWidgetSmall->setupUi( widgetSmall );
+ connect( m_routingInformationWidgetSmall->distanceAndInstructionLabel, SIGNAL( linkActivated( QString ) ),
+ this, SLOT( reverseRoute() ) );
m_widgetItem = new WidgetGraphicsItem( this );
m_widgetItem->setWidget( widget );
@@ -131,6 +133,8 @@
else {
m_routingInformationWidget = new Ui::RoutingInformationWidget;
m_routingInformationWidget->setupUi( widget );
+ connect( m_routingInformationWidget->distanceAndInstructionLabel, SIGNAL( linkActivated( QString ) ),
+ this, SLOT( reverseRoute() ) );
m_widgetItem = new WidgetGraphicsItem( this );
m_widgetItem->setWidget( widget );
@@ -427,7 +431,9 @@
}
}
else {
- nextInstructionDistanceLabel->setText( "<font size=\"-1\" color=\"black\">Arrived at Destination</font>" );
+ QString content = "Arrived at Destination. <a href=\"#reverse\">Calculate the way back.</a>";
+ QString text = "<font size=\"-1\" color=\"black\">%1</font>";
+ nextInstructionDistanceLabel->setText( text.arg( content ) );
}
}
}
@@ -452,6 +458,13 @@
dataFacade()->positionTracking()->setPositionProviderPlugin( plugin );
}
+void RoutingPlugin::reverseRoute()
+{
+ if ( m_marbleWidget ) {
+ m_marbleWidget->model()->routingManager()->reverseRoute();
+ }
+}
+
Q_EXPORT_PLUGIN2( RoutingPlugin, Marble::RoutingPlugin )
#include "RoutingPlugin.moc"
--- trunk/KDE/kdeedu/marble/src/plugins/render/routing/RoutingPlugin.h #1184893:1184894
@@ -107,6 +107,9 @@
/** Activate or deactivate position tracking */
void togglePositionTracking( bool enabled );
+ /** Switch source/destination of the route and recalculate it */
+ void reverseRoute();
+
private:
/**
More information about the Marble-commits
mailing list