minor changes
[marble:akssps011s-marble.git] / src / plugins / render / routing / RoutingPlugin.cpp
1 //
2 // This file is part of the Marble Desktop Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2010      Siddharth Srivastava <akssps011@gmail.com>
9 //
10
11 #include "RoutingPlugin.h"
12
13 #include "ui_RoutingWidgetSmall.h"
14 #include "ui_RoutingInformationWidget.h"
15 #include "ui_RoutingInformationWidgetSmall.h"
16
17 #include "WidgetGraphicsItem.h"
18 #include "MarbleGraphicsGridLayout.h"
19 #include "MarbleWidget.h"
20 #include "MarbleMap.h"
21 #include "MarbleModel.h"
22 #include "routing/AdjustNavigation.h"
23 #include "routing/RoutingManager.h"
24 #include "routing/RoutingModel.h"
25 #include "gps/PositionTracking.h"
26 #include "ViewportParams.h"
27 #include "MarbleDataFacade.h"
28 #include "GeoDataCoordinates.h"
29
30 #include <QtGui/QWidget>
31 #include <QtCore/QRect>
32 #include <QtGui/QToolButton>
33 #include <QtGui/QFont>
34 #include <QtGui/QActionGroup>
35 #include <QtGui/QPixmap>
36
37 using namespace Marble;
38
39 const int defaultMinZoom = 900;
40 const int defaultMaxZoom = 2400;
41 int const thresholdTime = 3;  //in minutes
42
43 RoutingPlugin::RoutingPlugin( const QPointF &point )
44         : AbstractFloatItem( point ),
45           m_marbleWidget( 0 ),
46           m_widgetItem( 0 ),
47           m_widgetItemRouting( 0 ),
48           m_profiles( MarbleGlobal::getInstance()->profiles() ),
49           m_routingModel( 0 ),
50           m_adjustNavigation( 0 ),
51           m_navigationMenu( 0 ),
52           m_alwaysRecenterAction( 0 ),
53           m_whenRequiredAction( 0 ),
54           m_autoZoomAction( 0 ),
55           m_disableRecenterAction( 0 ),
56           m_remainingTime( 0 ),
57           m_remainingDistance( 0 ),
58           m_currentSpeed( 0 ),
59           m_alwaysRecenter( false ),
60           m_recenterWhenRequired( false ),
61           m_routingWidgetSmall( 0 ),
62           m_routingInformationWidget( 0 ),
63           m_routingInformationWidgetSmall( 0 )
64 {
65     setEnabled( true );
66     //plugin is visible by default on small screen devices
67     setVisible( MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen );
68
69     if( m_profiles & MarbleGlobal::SmallScreen ) {
70          setFrame( FrameGraphicsItem::RectFrame );
71     }
72     else {
73         setFrame( FrameGraphicsItem::RoundedRectFrame );
74     }
75
76     setPadding( 0 );
77 }
78
79 RoutingPlugin::~RoutingPlugin()
80 {
81     delete m_routingWidgetSmall;
82     delete m_routingInformationWidgetSmall;
83     delete m_routingInformationWidget;
84 }
85
86 QStringList RoutingPlugin::backendTypes() const
87 {
88     return QStringList( "routing" );
89 }
90
91 QString RoutingPlugin::name() const
92 {
93     return tr( "Routing" );
94 }
95
96 QString RoutingPlugin::guiString() const
97 {
98     return tr( "&Routing" );
99 }
100
101 QString RoutingPlugin::nameId() const
102 {
103     return QString("routing");
104 }
105
106 QString RoutingPlugin::description() const
107 {
108     return tr( "Routing information and navigation controls" );
109 }
110
111 QIcon RoutingPlugin::icon() const
112 {
113     return QIcon();
114 }
115
116 void RoutingPlugin::initialize()
117 {
118     QWidget *widget = new QWidget( 0 );
119     QWidget *widgetSmall = new QWidget( 0 );
120
121     if( m_profiles & MarbleGlobal::SmallScreen ) {
122         m_routingWidgetSmall = new Ui::RoutingWidgetSmall;
123         m_routingWidgetSmall->setupUi( widget );
124         m_routingInformationWidgetSmall = new Ui::RoutingInformationWidgetSmall;
125         m_routingInformationWidgetSmall->setupUi( widgetSmall );
126
127         m_widgetItem = new WidgetGraphicsItem( this );
128         m_widgetItem->setWidget( widget );
129         m_widgetItemRouting = new WidgetGraphicsItem( this );
130         m_widgetItemRouting->setWidget( widgetSmall );
131         m_widgetItemRouting->setVisible( false );
132         createNavigationMenu();
133     }
134     else {
135         m_routingInformationWidget = new Ui::RoutingInformationWidget;
136         m_routingInformationWidget->setupUi( widget );
137
138         m_widgetItem = new WidgetGraphicsItem( this );
139         m_widgetItem->setWidget( widget );
140     }
141
142     MarbleGraphicsGridLayout *layout = new MarbleGraphicsGridLayout( 1, 1 );
143     layout->addItem( m_widgetItem, 0, 0 );
144     setLayout( layout );
145 }
146
147 bool RoutingPlugin::isInitialized() const
148 {
149     return m_widgetItem;
150 }
151
152 bool RoutingPlugin::eventFilter( QObject *object, QEvent *e )
153 {
154     if ( !enabled() || !visible() ) {
155         return false;
156     }
157
158     MarbleWidget *widget = dynamic_cast<MarbleWidget*> (object);
159
160     if ( !widget ) {
161        return AbstractFloatItem::eventFilter( object, e );
162     }
163
164     if ( m_marbleWidget != widget ) {
165         m_marbleWidget = widget;
166         m_adjustNavigation = m_marbleWidget->map()->model()->routingManager()->adjustNavigation();
167         m_routingModel = m_marbleWidget->map()->model()->routingManager()->routingModel();
168
169         if( m_profiles & MarbleGlobal::SmallScreen ) {
170
171             // disconnect signals
172             disconnect( m_marbleWidget->model()->positionTracking(), SIGNAL( statusChanged( PositionProviderStatus ) ),
173                          this, SLOT( setNavigationMenu( PositionProviderStatus ) ) );
174             disconnect( m_marbleWidget->model()->positionTracking(), SIGNAL( positionProviderPluginChanged( PositionProviderPlugin* ) ),
175                                     this, SLOT( setNavigationMenuDisabled( PositionProviderPlugin* ) ) );
176             disconnect( m_routingWidgetSmall->navigationButton, SIGNAL( clicked( bool ) ),
177                          this, SLOT( showNavigationMenu() ) );
178
179             disconnect( m_alwaysRecenterAction, SIGNAL( triggered() ), this, SLOT( setAlwaysRecenter() ) );
180             disconnect( m_whenRequiredAction, SIGNAL( triggered() ), this, SLOT( setRecenterWhenRequired() ) );
181             disconnect( m_disableRecenterAction, SIGNAL( triggered() ), this, SLOT( setRecenteringDisabled() ) );
182             disconnect( m_autoZoomAction, SIGNAL( triggered() ), this, SLOT( setAutoZoom() ) );
183
184             disconnect( m_routingWidgetSmall->routingButton, SIGNAL( clicked( bool ) ),
185                      this, SLOT( showRoutingItem( bool ) ) );
186             disconnect( m_routingWidgetSmall->zoomInButton, SIGNAL( clicked() ),
187                      m_marbleWidget, SLOT( zoomIn() ) );
188             disconnect( m_routingWidgetSmall->zoomOutButton, SIGNAL( clicked() ),
189                      m_marbleWidget, SLOT( zoomOut() ) );
190             disconnect( m_marbleWidget, SIGNAL( themeChanged( QString ) ),
191                      this, SLOT( selectTheme( QString ) ) );
192
193             disconnect( m_adjustNavigation, SIGNAL( recenterModeChanged( int ) ),
194                      this, SLOT( setRecenterMenu( int ) ) );
195             disconnect( m_adjustNavigation, SIGNAL( autoZoomToggled( bool ) ),
196                      this, SLOT( setAutoZoomMenu( bool ) ) );
197
198
199             connect( m_marbleWidget->model()->positionTracking(), SIGNAL( statusChanged( PositionProviderStatus ) ),
200                         this, SLOT( setNavigationMenu( PositionProviderStatus ) ) );
201             connect( m_marbleWidget->model()->positionTracking(), SIGNAL( positionProviderPluginChanged( PositionProviderPlugin* ) ),
202                                    this, SLOT( setNavigationMenuDisabled( PositionProviderPlugin* ) ) );
203             connect( m_routingWidgetSmall->navigationButton, SIGNAL( clicked( bool ) ),
204                         this, SLOT( showNavigationMenu() ) );
205
206             connect( m_alwaysRecenterAction, SIGNAL( triggered() ), this, SLOT( setAlwaysRecenter() ) );
207             connect( m_whenRequiredAction, SIGNAL( triggered() ), this, SLOT( setRecenterWhenRequired() ) );
208             connect( m_disableRecenterAction, SIGNAL( triggered() ), this, SLOT( setRecenteringDisabled() ) );
209             connect( m_autoZoomAction, SIGNAL( triggered() ), this, SLOT( setAutoZoom() ) );
210
211             connect( m_routingWidgetSmall->routingButton, SIGNAL( clicked( bool ) ),
212                     this, SLOT( showRoutingItem( bool ) ) );
213             connect( m_routingWidgetSmall->zoomInButton, SIGNAL( clicked() ),
214                     m_marbleWidget, SLOT( zoomIn() ) );
215             connect( m_routingWidgetSmall->zoomOutButton, SIGNAL( clicked() ),
216                     m_marbleWidget, SLOT( zoomOut() ) );
217             connect( m_marbleWidget, SIGNAL( themeChanged( QString ) ),
218                     this, SLOT( selectTheme( QString ) ) );
219
220             // connect statements below set the navigation menu if the action(re-center, autozoom) are
221             // performed from CurrentLocation UI
222             connect( m_adjustNavigation, SIGNAL( recenterModeChanged( int ) ),
223                     this, SLOT( setRecenterMenu( int ) ) );
224             connect( m_adjustNavigation, SIGNAL( autoZoomToggled( bool ) ),
225                     this, SLOT( setAutoZoomMenu( bool ) ) );
226
227             updateButtons( m_marbleWidget->map()->zoom() );
228         }
229         else {
230             disconnect( m_routingModel, SIGNAL( nextInstruction( qint32, qreal ) ),
231                     this, SLOT( setDestinationInformation( qint32, qreal ) ) );
232             connect( m_routingModel, SIGNAL( nextInstruction( qint32, qreal ) ),
233                     this, SLOT( setDestinationInformation( qint32, qreal ) ), Qt::UniqueConnection );
234
235             PositionTracking *tracking = m_marbleWidget->map()->model()->positionTracking();
236             disconnect( tracking, SIGNAL( gpsLocation( GeoDataCoordinates, qreal ) ),
237                      this, SLOT( setCurrentLocation( GeoDataCoordinates, qreal ) ) );
238             connect( tracking, SIGNAL( gpsLocation( GeoDataCoordinates, qreal ) ),
239                      this, SLOT( setCurrentLocation( GeoDataCoordinates, qreal ) ) );
240         }
241     }
242     return AbstractFloatItem::eventFilter( object, e );
243 }
244
245 void RoutingPlugin::showNavigationMenu()
246 {
247     QPointF floatItemPosition = positivePosition();
248     floatItemPosition += m_routingWidgetSmall->navigationButton->mapToParent( QPoint( 0, 0 ) );
249     floatItemPosition.ry() += m_routingWidgetSmall->navigationButton->height();
250     m_navigationMenu->exec( m_marbleWidget->mapToGlobal( floatItemPosition.toPoint() ) );
251 }
252
253 void RoutingPlugin::createNavigationMenu()
254 {
255     QObject *object = this;
256
257     m_disableRecenterAction = new QAction( object );
258     m_disableRecenterAction->setText( tr( "Auto Center Disabled" ) );
259     m_disableRecenterAction->setToolTip( tr( "Disable Auto Centering" ) );
260     m_disableRecenterAction->setCheckable( true );
261     m_disableRecenterAction->setChecked( true );
262
263     m_alwaysRecenterAction = new QAction( object );
264     m_alwaysRecenterAction->setText( tr( "Keep At Center" ) );
265     m_alwaysRecenterAction->setToolTip( tr( "Always keep the gps location at the center of the map" ) );
266     m_alwaysRecenterAction->setCheckable( true );
267
268     m_whenRequiredAction = new QAction( object );
269     m_whenRequiredAction->setText( tr( "Auto Center When Required" ) );
270     m_whenRequiredAction->setToolTip( tr( "Re-center when required" ) );
271     m_whenRequiredAction->setCheckable( true );
272
273     m_autoZoomAction = new QAction( object );
274     m_autoZoomAction->setText( tr( "Auto Zoom" ) );
275     m_autoZoomAction->setToolTip( tr( "Auto Zoom to appropriate zoom level" ) );
276     m_autoZoomAction->setCheckable( true );
277
278     QActionGroup *recenterGroup = new QActionGroup( object );
279     recenterGroup->addAction( m_disableRecenterAction );
280     recenterGroup->addAction( m_alwaysRecenterAction );
281     recenterGroup->addAction( m_whenRequiredAction );
282
283     QList<QAction*> recenterMenu = recenterGroup->actions();
284     m_navigationMenu = new QMenu();
285     m_navigationMenu->addActions( recenterMenu );
286     m_navigationMenu->addSeparator();
287     m_navigationMenu->addAction( m_autoZoomAction );
288     m_navigationMenu->setEnabled( false );
289 }
290
291 void RoutingPlugin::setAlwaysRecenter()
292 {
293     if( !m_marbleWidget ) {
294         return;
295     }
296
297     if( m_recenterWhenRequired ) {
298         m_adjustNavigation->setRecenter( Disabled );
299         m_recenterWhenRequired = false;
300     }
301
302     m_alwaysRecenter = true;
303
304     if( m_alwaysRecenterAction->isChecked() ) {
305         m_adjustNavigation->setRecenter( AlwaysRecenter );
306     }
307 }
308
309 void RoutingPlugin::setRecenterWhenRequired()
310 {
311     if( !m_marbleWidget ) {
312         return;
313     }
314
315     if( m_alwaysRecenter ) {
316         m_adjustNavigation->setRecenter( Disabled );
317         m_alwaysRecenter = false;
318     }
319
320     m_recenterWhenRequired = true;
321
322     if( m_whenRequiredAction->isChecked() ) {
323         m_adjustNavigation->setRecenter( RecenterOnBorder );
324     }
325 }
326
327 void RoutingPlugin::setAutoZoom()
328 {
329     if( !m_marbleWidget ) {
330         return;
331     }
332
333     if( m_autoZoomAction->isChecked() ) {
334         m_adjustNavigation->setAutoZoom( true );
335     }
336     else {
337         m_adjustNavigation->setAutoZoom( false );
338         m_autoZoomAction->setChecked( false );
339     }
340 }
341
342 //similar to updateButtons(int value) in navigation plugin
343 void RoutingPlugin::updateButtons( int zoomValue )
344 {
345     int minZoom = defaultMinZoom;
346     int maxZoom = defaultMaxZoom;
347     QToolButton *zoomInButton = 0;
348     QToolButton *zoomOutButton = 0;
349
350     if ( m_marbleWidget ) {
351         minZoom = m_marbleWidget->map()->minimumZoom();
352         maxZoom = m_marbleWidget->map()->maximumZoom();
353     }
354
355     zoomInButton = m_routingWidgetSmall->zoomInButton;
356     zoomOutButton = m_routingWidgetSmall->zoomOutButton;
357
358     if ( zoomValue <= minZoom ) {
359         zoomInButton->setEnabled( true );
360         zoomOutButton->setEnabled( false );
361     } else if ( zoomValue >= maxZoom ) {
362         zoomInButton->setEnabled( false );
363         zoomOutButton->setEnabled( true );
364     } else {
365         zoomInButton->setEnabled( true );
366         zoomOutButton->setEnabled( true );
367     }
368
369     if ( m_marbleWidget )
370     {
371         // Trigger a repaint of the float item. Otherwise button state updates
372         // are delayed
373         QRectF floatItemRect = QRectF( positivePosition(), size() ).toRect();
374         QRegion dirtyRegion( floatItemRect.toRect() );
375
376         m_marbleWidget->setAttribute( Qt::WA_NoSystemBackground, false );
377
378         update();
379
380         m_marbleWidget->setAttribute( Qt::WA_NoSystemBackground,
381                                       m_marbleWidget->map()->mapCoversViewport() );
382     }
383 }
384
385 void RoutingPlugin::selectTheme( const QString &theme )
386 {
387     Q_UNUSED( theme );
388
389     if ( m_marbleWidget ) {
390             updateButtons( m_marbleWidget->map()->zoom() );
391     }
392 }
393
394 void RoutingPlugin::showRoutingItem( bool show )
395 {
396     if( !m_marbleWidget ) {
397         return;
398     }
399
400     PositionTracking *tracking = m_marbleWidget->map()->model()->positionTracking();
401
402     if( show ) {
403         MarbleGraphicsGridLayout *gridLayout = new MarbleGraphicsGridLayout( 2, 1 );
404         gridLayout->addItem( m_widgetItemRouting, 0, 0 );
405         gridLayout->addItem( m_widgetItem, 1, 0 );
406         setLayout( gridLayout );
407         m_widgetItemRouting->setVisible( show );
408         m_marbleWidget->repaint();
409         connect( m_routingModel, SIGNAL( nextInstruction( qint32, qreal ) ),
410                 this, SLOT( setDestinationInformation( qint32, qreal ) ), Qt::UniqueConnection );
411         connect( tracking, SIGNAL( gpsLocation( GeoDataCoordinates, qreal ) ),
412                  this, SLOT( setCurrentLocation( GeoDataCoordinates, qreal ) ) );
413     }
414     else {
415         MarbleGraphicsGridLayout *gridLayout = new MarbleGraphicsGridLayout( 1, 1 );
416         gridLayout->addItem( m_widgetItem, 0 , 0 );
417         setLayout( gridLayout );
418         m_widgetItemRouting->setVisible( show );
419         m_marbleWidget->repaint();
420         disconnect( m_routingModel, SIGNAL( nextInstruction( qint32, qreal ) ),
421                 this, SLOT( setDestinationInformation( qint32, qreal ) ) );
422         disconnect( tracking, SIGNAL( gpsLocation( GeoDataCoordinates, qreal ) ),
423                  this, SLOT( setCurrentLocation( GeoDataCoordinates, qreal ) ) );
424     }
425 }
426
427 void RoutingPlugin::setDestinationInformation( qint32 remainingTime, qreal remainingDistance )
428 {
429     m_remainingTime = remainingTime;
430     m_remainingDistance = remainingDistance;
431 }
432
433 void RoutingPlugin::setCurrentLocation( GeoDataCoordinates position, qreal speed )
434 {
435     m_currentPosition = position;
436     m_currentSpeed = speed;
437     bool hasRoute = m_routingModel->rowCount() != 0;
438     if ( hasRoute ) {
439         updateRoutingItem();
440     }
441 }
442
443 void RoutingPlugin::updateRoutingItem()
444 {
445     qreal instructionLength = m_routingModel->currentInstructionLength();
446     qreal remainingInstructionDistance = m_routingModel->nextInstructionDistance();
447     qint32 remainingTimeMinutes =  qint32( m_remainingTime * SEC2MIN ) % 60;
448     qint32 remainingTimeHours =  qint32( m_remainingTime * SEC2HOUR );
449     qint32 remainingInstructionTime = 0;
450
451     //This icon represents that the gps device is now close to the instruction point(turn)
452     QPixmap instructionIconNear( ":/icons/instruction-near.png" );
453     // This icon represents the next instruction point on the route
454     QPixmap instructionIconNext( ":/icons/instruction-next.png" );
455
456     if( !m_currentSpeed ) {
457         remainingInstructionTime = qint32( ( remainingInstructionDistance / m_currentSpeed ) / 60 ) % 60;
458     }
459
460     if( m_profiles & MarbleGlobal::SmallScreen ) {
461        m_routingInformationWidgetSmall->remainingTimeLabel->setAlignment( Qt::AlignCenter );
462
463        if( remainingTimeHours ) {
464            m_routingInformationWidgetSmall->remainingTimeLabel->setText( QString::number( remainingTimeHours ) % " hr " %
465                                                                          QString::number( remainingTimeMinutes ) % " min " );
466        }
467        else if( remainingTimeMinutes ) {
468            m_routingInformationWidgetSmall->remainingTimeLabel->setText( tr( "%n minutes", "", remainingTimeMinutes ) );
469        }
470        else {
471            m_routingInformationWidgetSmall->remainingTimeLabel->setText( "Less than a minute." );
472        }
473
474        if( remainingTimeMinutes < thresholdTime ) {
475            m_routingInformationWidgetSmall->instructionIconLabel->setPixmap( instructionIconNear );
476        }
477        else {
478            m_routingInformationWidgetSmall->instructionIconLabel->setPixmap( instructionIconNext );
479        }
480
481        updateInstructionLabel( m_routingInformationWidgetSmall->distanceAndInstructionLabel );
482
483        if( !m_routingModel->deviatedFromRoute() && remainingInstructionDistance != 0 ) {
484            m_routingInformationWidgetSmall->distanceCoveredProgressBar->setRange( 0, qRound( instructionLength ) );
485            m_routingInformationWidgetSmall->distanceCoveredProgressBar->setValue( qRound ( instructionLength - remainingInstructionDistance ) );
486         }
487
488         if ( remainingInstructionDistance == 0 && remainingInstructionTime == 0 ) {
489             m_routingInformationWidgetSmall->distanceCoveredProgressBar->setValue( qRound( instructionLength ) );
490         }
491
492     }
493     else {
494         m_routingInformationWidget->remainingTimeLabel->setAlignment( Qt::AlignCenter );
495
496         if( remainingTimeHours ) {
497             m_routingInformationWidget->remainingTimeLabel->setText( tr( "%n hours", "",  remainingTimeHours) % tr( " %n minutes", "", remainingTimeMinutes ) );
498         }
499         else if ( remainingTimeMinutes ) {
500             m_routingInformationWidget->remainingTimeLabel->setText( tr( "%n minutes", "", remainingTimeMinutes ) );
501         }
502         else {
503             m_routingInformationWidget->remainingTimeLabel->setText( "Less than a minute." );
504         }
505
506         if( remainingTimeMinutes < thresholdTime ) {
507             m_routingInformationWidget->instructionIconLabel->setPixmap( instructionIconNear );
508         }
509         else {
510             m_routingInformationWidget->instructionIconLabel->setPixmap( instructionIconNext );
511         }
512
513         updateInstructionLabel( m_routingInformationWidget->distanceAndInstructionLabel );
514
515         if( !m_routingModel->deviatedFromRoute() && remainingInstructionDistance !=0 ) {
516             m_routingInformationWidget->distanceCoveredProgressBar->setRange( 0, qRound( instructionLength ) );
517             m_routingInformationWidget->distanceCoveredProgressBar->setValue( qRound ( instructionLength - remainingInstructionDistance ) );
518         }
519
520         if (  remainingInstructionDistance == 0 && remainingInstructionTime == 0 ) {
521             m_routingInformationWidget->distanceCoveredProgressBar->setValue( qRound( instructionLength ) );
522         }
523     }
524 }
525
526 void RoutingPlugin::updateInstructionLabel( QLabel *label )
527 {
528     if( m_routingModel->remainingTime() < thresholdTime && !m_routingModel->instructionText().isEmpty() ) {
529         QLabel *instructionLabel = label;
530         instructionLabel->setAlignment( Qt::AlignCenter );
531         instructionLabel->setText( m_routingModel->instructionText() );
532     }
533     else {
534         QLabel *nextInstructionDistanceLabel = label;
535         nextInstructionDistanceLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
536
537         qreal instructionDistance = m_routingModel->nextInstructionDistance();
538
539         QString indicatorText = m_routingModel->instructionText().isEmpty() ? "<b>Destination: </b>" : "<b>Next Turn at: </b>";
540
541         if( m_remainingDistance ) {
542             if( instructionDistance < 1000 ) {
543                 nextInstructionDistanceLabel->setText( indicatorText % QString::number( int( instructionDistance ) ) % " Meters " );
544             }
545             else {
546                 nextInstructionDistanceLabel->setText( indicatorText % QString::number( instructionDistance * METER2KM , 'f', 1 ) % " KM " );
547             }
548         }
549         else {
550             nextInstructionDistanceLabel->setText( "Arrived at Destination" );
551         }
552     }
553 }
554
555 void RoutingPlugin::setRecenterMenu( int centerMode )
556 {
557     if( centerMode == AlwaysRecenter ) {
558         m_alwaysRecenterAction->setChecked( true );
559     }
560     else if ( centerMode == RecenterOnBorder ) {
561         m_whenRequiredAction->setChecked( true );
562     }
563     else {
564         m_disableRecenterAction->setChecked( true );
565     }
566 }
567
568 void RoutingPlugin::setAutoZoomMenu( bool autoZoom )
569 {
570     m_autoZoomAction->setChecked( autoZoom );
571 }
572
573 void RoutingPlugin::setRecenteringDisabled()
574 {
575     m_adjustNavigation->setRecenter( Disabled );
576 }
577
578 void RoutingPlugin::setNavigationMenu( PositionProviderStatus status )
579 {
580     if( status == PositionProviderStatusAvailable ) {
581         m_navigationMenu->setEnabled( true );
582     }
583     else {
584         m_navigationMenu->setEnabled( false );
585     }
586 }
587
588 void RoutingPlugin::setNavigationMenuDisabled( PositionProviderPlugin *activePlugin )
589 {
590     if( !activePlugin ) {
591         m_navigationMenu->setEnabled( false );
592     }
593 }
594
595 Q_EXPORT_PLUGIN2( RoutingPlugin, Marble::RoutingPlugin )
596
597 #include "RoutingPlugin.moc"