[Marble-commits] KDE/kdeedu/marble/src/lib

Dennis Nienhüser earthwings at gentoo.org
Sat Nov 13 12:20:38 CET 2010


SVN commit 1196401 by nienhueser:

Other routing items (source, destination, via points) are more confusing than useful when selecting routing targets, so disable them in the dialog invoked by RoutingInputWidgets.

 M  +26 -3     GoToDialog.cpp  
 M  +7 -0      GoToDialog.h  
 M  +1 -0      routing/RoutingInputWidget.cpp  


--- trunk/KDE/kdeedu/marble/src/lib/GoToDialog.cpp #1196400:1196401
@@ -38,6 +38,8 @@
 
     virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
 
+    void setShowRoutingItems( bool show );
+
 private:
     QVariant currentLocationData ( int role ) const;
 
@@ -54,6 +56,8 @@
     QVector<GeoDataPlacemark*> m_bookmarks;
 
     bool m_hasCurrentLocation;
+
+    bool m_showRoutingItems;
 };
 
 class GoToDialogPrivate
@@ -65,6 +69,8 @@
 
     GeoDataLookAt m_lookAt;
 
+    TargetModel* m_targetModel;
+
     GoToDialogPrivate( GoToDialog* parent, MarbleWidget* marbleWidget );
 
     void saveSelection( const QModelIndex &index );
@@ -72,7 +78,8 @@
 
 TargetModel::TargetModel( MarbleWidget* marbleWidget, QObject * parent ) :
     QAbstractListModel( parent ),
-    m_marbleWidget( marbleWidget ), m_hasCurrentLocation( false )
+    m_marbleWidget( marbleWidget ), m_hasCurrentLocation( false ),
+    m_showRoutingItems( true )
 {
     BookmarkManager* manager = marbleWidget->model()->bookmarkManager();
     foreach( GeoDataFolder * folder, manager->folders() ) {
@@ -91,6 +98,10 @@
 
 QVector<GeoDataPlacemark> TargetModel::viaPoints() const
 {
+    if ( !m_showRoutingItems ) {
+        return QVector<GeoDataPlacemark>();
+    }
+
     RouteRequest* request = m_marbleWidget->model()->routingManager()->routeRequest();
     QVector<GeoDataPlacemark> result;
     for ( int i = 0; i < request->size(); ++i ) {
@@ -223,8 +234,14 @@
     return QVariant();
 }
 
+void TargetModel::setShowRoutingItems( bool show )
+{
+    m_showRoutingItems = show;
+    reset();
+}
+
 GoToDialogPrivate::GoToDialogPrivate( GoToDialog* parent, MarbleWidget* marbleWidget ) :
-    m_parent( parent), m_marbleWidget( marbleWidget )
+    m_parent( parent), m_marbleWidget( marbleWidget ), m_targetModel( 0 )
 {
     // nothing to do
 }
@@ -241,7 +258,8 @@
 {
     setupUi( this );
 
-    bookmarkListView->setModel( new TargetModel( marbleWidget ) );
+    d->m_targetModel = new TargetModel( marbleWidget, this );
+    bookmarkListView->setModel( d->m_targetModel );
     connect( bookmarkListView, SIGNAL( activated( QModelIndex ) ),
              this, SLOT( saveSelection ( QModelIndex ) ) );
 }
@@ -256,6 +274,11 @@
     return d->m_lookAt;
 }
 
+void GoToDialog::setShowRoutingItems( bool show )
+{
+    d->m_targetModel->setShowRoutingItems( show );
 }
 
+}
+
 #include "GoToDialog.moc"
--- trunk/KDE/kdeedu/marble/src/lib/GoToDialog.h #1196400:1196401
@@ -40,6 +40,13 @@
 
     ~GoToDialog();
 
+    /** Toggle whether routing items (source, destination and via points) are visible */
+    void setShowRoutingItems( bool show );
+
+    /**
+      * Returns the position of the item selected by the user, or a default
+      * constructed GeoDataLookAt if the dialog was cancelled by the user
+      */
     GeoDataLookAt lookAt() const;
 
     Q_PRIVATE_SLOT( d, void saveSelection( const QModelIndex &index ) )
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingInputWidget.cpp #1196400:1196401
@@ -466,6 +466,7 @@
 {
     QPointer<GoToDialog> dialog = new GoToDialog( d->m_marbleWidget, this );
     dialog->setWindowTitle( tr( "Choose Placemark" ) );
+    dialog->setShowRoutingItems( false );
     if ( dialog->exec() == QDialog::Accepted ) {
         GeoDataLookAt lookAt = dialog->lookAt();
         setTargetPosition( lookAt.coordinates() );


More information about the Marble-commits mailing list