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

Thibaut Gridel tgridel at free.fr
Fri Aug 13 19:33:16 CEST 2010


SVN commit 1163314 by tgridel:

MarbleControlBox: center on selected placemark

 M  +20 -4     MarbleControlBox.cpp  
 M  +1 -0      MarbleControlBox.h  


--- trunk/KDE/kdeedu/marble/src/lib/MarbleControlBox.cpp #1163313:1163314
@@ -77,6 +77,7 @@
 
     QStandardItemModel     *m_mapThemeModel;
     QSortFilterProxyModel  *m_sortproxy;
+    QSortFilterProxyModel  *m_treeSortProxy;
     MapThemeSortFilterProxyModel *m_mapSortProxy;
 
     MarbleRunnerManager  *m_runnerManager;
@@ -282,11 +283,13 @@
              widget->fileViewModel(),       SLOT( saveFile() ) );
     connect( d->m_fileViewUi.m_closeButton, SIGNAL( clicked() ) ,
              widget->fileViewModel(),    SLOT( closeFile() ) );
-    QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(this);
-    sortModel->setSourceModel( widget->model()->treeModel() );
-    sortModel->setDynamicSortFilter( true );
-    d->m_fileViewUi.m_treeView->setModel( sortModel );
+    d->m_treeSortProxy = new QSortFilterProxyModel(this);
+    d->m_treeSortProxy->setSourceModel( widget->model()->treeModel() );
+    d->m_treeSortProxy->setDynamicSortFilter( true );
+    d->m_fileViewUi.m_treeView->setModel( d->m_treeSortProxy );
     d->m_fileViewUi.m_treeView->setSortingEnabled( true );
+    connect( d->m_fileViewUi.m_treeView, SIGNAL(activated(QModelIndex)),
+            this, SLOT(mapCenterOnTreeViewModel(QModelIndex)) );
 
     d->m_legendWidget->setMarbleWidget( widget );
 
@@ -598,6 +601,19 @@
     emit centerOn( d->m_sortproxy->mapToSource( index ), true );
 }
 
+void MarbleControlBox::mapCenterOnTreeViewModel( const QModelIndex &index )
+{
+    if (!index.isValid()) {
+        return;
+    }
+    GeoDataObject *object = static_cast<GeoDataObject*>(d->m_treeSortProxy->mapToSource(index).internalPointer());
+    if (dynamic_cast<GeoDataPlacemark*>(object))
+    {
+        GeoDataCoordinates coord = (dynamic_cast<GeoDataPlacemark*>(object))->coordinate();
+        d->m_widget->centerOn( coord, true );
+    }
+}
+
 void MarbleControlBox::adjustForAnimation()
 {
     // TODO: use signals here as well
--- trunk/KDE/kdeedu/marble/src/lib/MarbleControlBox.h #1163313:1163314
@@ -233,6 +233,7 @@
 
     void updateButtons( int );
     void mapCenterOnSignal( const QModelIndex & );
+    void mapCenterOnTreeViewModel( const QModelIndex & );
 
     void adjustForAnimation();
     void adjustForStill();


More information about the Marble-commits mailing list