Commit 0efc24be authored by Bernhard Beschow's avatar Bernhard Beschow

AlternativeRoutesModel: expose GeoDataDocument routes const'ified

parent 2a6bb562
......@@ -502,7 +502,7 @@ void Routing::openRoute( const QString &fileName )
routingManager->clearRoute();
QString target = fileName.startsWith( QLatin1String( "file://" ) ) ? fileName.mid( 7 ) : fileName;
routingManager->loadRoute( target );
Marble::GeoDataDocument* route = routingManager->alternativeRoutesModel()->currentRoute();
const Marble::GeoDataDocument *route = routingManager->alternativeRoutesModel()->currentRoute();
if ( route ) {
const Marble::GeoDataLineString* waypoints = Marble::AlternativeRoutesModel::waypoints( route );
if ( waypoints ) {
......
......@@ -329,7 +329,7 @@ QVariant AlternativeRoutesModel::data ( const QModelIndex &index, int role ) con
return result;
}
GeoDataDocument* AlternativeRoutesModel::route( int index )
const GeoDataDocument *AlternativeRoutesModel::route(int index) const
{
if ( index >= 0 && index < d->m_routes.size() ) {
return d->m_routes.at(index);
......@@ -415,9 +415,9 @@ void AlternativeRoutesModel::setCurrentRoute( int index )
}
}
GeoDataDocument * AlternativeRoutesModel::currentRoute()
const GeoDataDocument *AlternativeRoutesModel::currentRoute() const
{
GeoDataDocument* result = 0;
const GeoDataDocument *result = 0;
if ( d->m_currentIndex >= 0 && d->m_currentIndex < rowCount() ) {
result = d->m_routes[d->m_currentIndex];
}
......
......@@ -55,7 +55,7 @@ public:
/** Overload of QAbstractListModel */
QVariant data ( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
GeoDataDocument* route( int index );
const GeoDataDocument *route(int index) const;
// Model data filling
......@@ -75,7 +75,7 @@ public:
/** Remove all alternative routes from the model */
void clear();
GeoDataDocument* currentRoute();
const GeoDataDocument *currentRoute() const;
/** Returns the waypoints contained in the route as a linestring */
static const GeoDataLineString* waypoints( const GeoDataDocument* document );
......@@ -84,7 +84,7 @@ public Q_SLOTS:
void setCurrentRoute( int index );
Q_SIGNALS:
void currentRouteChanged( GeoDataDocument* newRoute );
void currentRouteChanged(const GeoDataDocument *newRoute);
void currentRouteChanged( int index );
private Q_SLOTS:
......
......@@ -243,7 +243,7 @@ void RoutingLayerPrivate::renderAlternativeRoutes( GeoPainter *painter )
painter->setPen( alternativeRoutePen );
for ( int i=0; i<m_alternativeRoutesModel->rowCount(); ++i ) {
GeoDataDocument* route = m_alternativeRoutesModel->route( i );
const GeoDataDocument *route = m_alternativeRoutesModel->route(i);
if ( route && route != m_alternativeRoutesModel->currentRoute() ) {
const GeoDataLineString* points = AlternativeRoutesModel::waypoints( route );
if ( points ) {
......@@ -645,9 +645,9 @@ RoutingLayer::RoutingLayer( MarbleWidget *widget, QWidget *parent ) :
this, SLOT(updateRouteState()) );
connect( widget, SIGNAL(visibleLatLonAltBoxChanged(GeoDataLatLonAltBox)),
this, SLOT(setViewportChanged()) );
connect( widget->model()->routingManager()->alternativeRoutesModel(), SIGNAL(currentRouteChanged(GeoDataDocument*)),
connect(widget->model()->routingManager()->alternativeRoutesModel(), SIGNAL(currentRouteChanged(const GeoDataDocument*)),
this, SLOT(setViewportChanged()) );
connect( widget->model()->routingManager()->alternativeRoutesModel(), SIGNAL(currentRouteChanged(GeoDataDocument*)),
connect(widget->model()->routingManager()->alternativeRoutesModel(), SIGNAL(currentRouteChanged(const GeoDataDocument*)),
this, SIGNAL(repaintNeeded()) );
connect( widget->model()->routingManager()->alternativeRoutesModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(showAlternativeRoutes()) );
......
......@@ -98,7 +98,7 @@ public:
void routingFinished();
void setCurrentRoute( GeoDataDocument *route );
void setCurrentRoute(const GeoDataDocument *route);
void recalculateRoute( bool deviated );
......@@ -179,7 +179,7 @@ void RoutingManagerPrivate::saveRoute(const QString &filename)
container.append( request );
}
GeoDataDocument *route = m_alternativeRoutesModel.currentRoute();
const GeoDataDocument *route = m_alternativeRoutesModel.currentRoute();
if ( route ) {
container.append( new GeoDataDocument( *route ) );
}
......@@ -265,8 +265,8 @@ RoutingManager::RoutingManager(MarbleModel *marbleModel, QObject *parent) :
this, SLOT(addRoute(GeoDataDocument*)) );
connect( &d->m_runnerManager, SIGNAL(routingFinished()),
this, SLOT(routingFinished()) );
connect( &d->m_alternativeRoutesModel, SIGNAL(currentRouteChanged(GeoDataDocument*)),
this, SLOT(setCurrentRoute(GeoDataDocument*)) );
connect(&d->m_alternativeRoutesModel, SIGNAL(currentRouteChanged(const GeoDataDocument*)),
this, SLOT(setCurrentRoute(const GeoDataDocument*)));
connect( &d->m_routingModel, SIGNAL(deviatedFromRoute(bool)),
this, SLOT(recalculateRoute(bool)) );
}
......@@ -343,7 +343,7 @@ void RoutingManagerPrivate::routingFinished()
emit q->stateChanged( m_state );
}
void RoutingManagerPrivate::setCurrentRoute( GeoDataDocument *document )
void RoutingManagerPrivate::setCurrentRoute(const GeoDataDocument *document)
{
QVector<RouteSegment> segments;
RouteSegment outline;
......
......@@ -198,7 +198,7 @@ private:
Q_PRIVATE_SLOT( d, void routingFinished() )
Q_PRIVATE_SLOT( d, void setCurrentRoute( GeoDataDocument *route ) )
Q_PRIVATE_SLOT(d, void setCurrentRoute(const GeoDataDocument *route))
Q_PRIVATE_SLOT( d, void recalculateRoute( bool deviated ) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment