[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [marble] src/lib: Clear search results when switching theme
From: Rene Kuettner <rene () bitkanal ! net>
Date: 2012-11-09 10:17:28
Message-ID: 20121109101728.8EAD3A60C4 () git ! kde ! org
[Download RAW message or body]
Git commit 9e56c69245c51ae1f65dfd2bc8382f86bd8a6ce9 by Rene Kuettner.
Committed on 09/11/2012 at 11:03.
Pushed by renek into branch 'master'.
Clear search results when switching theme
REVIEW: 107182
Search results and the search result cache are now cleared when switching
celestial bodies. This avoids confusion with search results belonging to
another planet.
M +5 -0 src/lib/MapViewWidget.cpp
M +1 -0 src/lib/MapViewWidget.h
M +2 -0 src/lib/MarbleControlBox.cpp
M +29 -18 src/lib/NavigationWidget.cpp
M +5 -0 src/lib/NavigationWidget.h
http://commits.kde.org/marble/9e56c69245c51ae1f65dfd2bc8382f86bd8a6ce9
diff --git a/src/lib/MapViewWidget.cpp b/src/lib/MapViewWidget.cpp
index aa68b6e..994707b 100644
--- a/src/lib/MapViewWidget.cpp
+++ b/src/lib/MapViewWidget.cpp
@@ -279,6 +279,7 @@ void MapViewWidget::Private::setCelestialBody( int comboIndex )
bool foundMapTheme = false;
QString currentMapThemeId = m_widget->mapThemeId();
+ QString oldPlanetId = m_widget->model()->planetId();
int row = m_mapSortProxy.rowCount();
@@ -297,6 +298,10 @@ void MapViewWidget::Private::setCelestialBody( int comboIndex )
emit q->mapThemeIdChanged( m_mapSortProxy.data( index ).toString() );
}
+ if( oldPlanetId != m_widget->model()->planetId() ) {
+ emit q->celestialBodyChanged( m_widget->model()->planetId() );
+ }
+
updateMapThemeView();
}
diff --git a/src/lib/MapViewWidget.h b/src/lib/MapViewWidget.h
index 0fb4812..b292a35 100644
--- a/src/lib/MapViewWidget.h
+++ b/src/lib/MapViewWidget.h
@@ -63,6 +63,7 @@ class MARBLE_EXPORT MapViewWidget : public QWidget
Q_PRIVATE_SLOT( d, void toggleFavorite() )
Q_SIGNALS:
+ void celestialBodyChanged( const QString& );
void mapThemeIdChanged( const QString& );
void projectionChanged( Projection );
void showMapWizard();
diff --git a/src/lib/MarbleControlBox.cpp b/src/lib/MarbleControlBox.cpp
index 098f780..07449dd 100644
--- a/src/lib/MarbleControlBox.cpp
+++ b/src/lib/MarbleControlBox.cpp
@@ -102,6 +102,8 @@ MarbleControlBox::MarbleControlBox(QWidget *parent)
connect( d->m_mapViewWidget, SIGNAL( showMapWizard() ), this, SIGNAL( \
showMapWizard() ) );
connect( d->m_mapViewWidget, SIGNAL( showUploadDialog() ), this, SIGNAL( \
showUploadDialog() ) ); + connect( d->m_mapViewWidget, SIGNAL( \
celestialBodyChanged( const QString& ) ), + d->m_navigationWidget, SLOT( \
clearSearch() ) );
connect( d->m_navigationWidget, SIGNAL( searchFinished() ), this, SIGNAL( \
searchFinished() ) ); }
diff --git a/src/lib/NavigationWidget.cpp b/src/lib/NavigationWidget.cpp
index d56e0b8..67a0730 100644
--- a/src/lib/NavigationWidget.cpp
+++ b/src/lib/NavigationWidget.cpp
@@ -173,26 +173,16 @@ void NavigationWidget::setMarbleWidget( MarbleWidget *widget )
void NavigationWidget::search(const QString &searchTerm, SearchMode searchMode )
{
d->m_searchTerm = searchTerm;
- d->m_navigationUi.locationListView->setVisible( !searchTerm.isEmpty() );
- if ( !searchTerm.isEmpty() ) {
- if ( searchMode == AreaSearch ) {
- d->m_runnerManager->findPlacemarks( d->m_searchTerm, \
d->m_widget->viewport()->viewLatLonAltBox() );
- } else {
- d->m_runnerManager->findPlacemarks( d->m_searchTerm );
- }
+ if( searchTerm.isEmpty() ) {
+ clearSearch();
} else {
- d->m_widget->model()->placemarkSelectionModel()->clear();
-
- // clear the local document
- GeoDataTreeModel *treeModel = d->m_widget->model()->treeModel();
- treeModel->removeDocument( d->m_document );
- d->m_document->clear();
- treeModel->addDocument( d->m_document );
- d->m_branchfilter.setBranchIndex( treeModel, treeModel->index( d->m_document \
) );
- d->m_navigationUi.locationListView->setRootIndex(
- d->m_sortproxy->mapFromSource(
- d->m_branchfilter.mapFromSource( treeModel->index( \
d->m_document ) ) ) ); + d->m_navigationUi.locationListView->setVisible( true \
); + //if ( searchMode == AreaSearch ) {
+ // d->m_runnerManager->findPlacemarks( d->m_searchTerm, \
d->m_widget->viewport()->viewLatLonAltBox() ); + //} else {
+ d->m_runnerManager->findPlacemarks( d->m_searchTerm );
+ //}
}
}
@@ -216,6 +206,27 @@ void NavigationWidget::changeZoom( int zoom )
d->m_navigationUi.zoomSlider->blockSignals( false );
}
+void NavigationWidget::clearSearch()
+{
+ d->m_searchTerm = QString();
+
+ d->m_navigationUi.locationListView->setVisible( false );
+ d->m_widget->model()->placemarkSelectionModel()->clear();
+
+ // clear the local document
+ GeoDataTreeModel *treeModel = d->m_widget->model()->treeModel();
+ treeModel->removeDocument( d->m_document );
+ d->m_document->clear();
+ treeModel->addDocument( d->m_document );
+ d->m_branchfilter.setBranchIndex( treeModel, treeModel->index( d->m_document ) \
); + d->m_navigationUi.locationListView->setRootIndex(
+ d->m_sortproxy->mapFromSource(
+ d->m_branchfilter.mapFromSource( treeModel->index( d->m_document ) ) \
) ); +
+ // clear cached search results
+ d->m_runnerManager->findPlacemarks( QString() );
+}
+
void NavigationWidgetPrivate::setSearchResult( QVector<GeoDataPlacemark*> locations \
) {
if( locations.isEmpty() ) {
diff --git a/src/lib/NavigationWidget.h b/src/lib/NavigationWidget.h
index 8a8ec88..b176eb5 100644
--- a/src/lib/NavigationWidget.h
+++ b/src/lib/NavigationWidget.h
@@ -100,6 +100,11 @@ class MARBLE_EXPORT NavigationWidget : public QWidget
*/
void changeZoom( int zoom );
+ /**
+ * @brief Clear all previous search results
+ */
+ void clearSearch();
+
protected:
/**
* @brief Reimplementation of the resizeEvent() of the widget.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic