Drop search and routing results on planet change (QWidget tools only)

Summary:
A more complete solution could perhaps cache the results per planet.
So when switching back to a planet, the last search & routing results
could be used again.

Test Plan:
Switching between differet themes for the same planet keeps current
search & routing results. Switching planet drops the results.

Reviewers: rahn, nienhueser, #marble

Reviewed By: nienhueser, #marble

Differential Revision: https://phabricator.kde.org/D2087
parent bb33e328
......@@ -35,12 +35,14 @@ public:
BranchFilterProxyModel m_branchfilter;
QSortFilterProxyModel m_sortproxy;
GeoDataDocument *m_document;
QString m_planetId;
SearchWidgetPrivate();
void setSearchResult( const QVector<GeoDataPlacemark*>& );
void search( const QString &searchTerm, SearchMode searchMode );
void clearSearch();
void centerMapOn( const QModelIndex &index );
void handlePlanetChange();
};
SearchWidgetPrivate::SearchWidgetPrivate() :
......@@ -122,6 +124,10 @@ void SearchWidget::setMarbleWidget( MarbleWidget* widget )
d->m_widget = widget;
d->m_planetId = widget->model()->planetId();
connect( widget->model(), SIGNAL(themeChanged(QString)),
this, SLOT(handlePlanetChange()) );
d->m_searchField->setCompletionModel( widget->model()->placemarkModel() );
connect( d->m_searchField, SIGNAL(centerOn(GeoDataCoordinates)),
widget, SLOT(centerOn(GeoDataCoordinates)) );
......@@ -188,6 +194,18 @@ void SearchWidgetPrivate::centerMapOn( const QModelIndex &index )
}
}
void SearchWidgetPrivate::handlePlanetChange()
{
const QString newPlanetId = m_widget->model()->planetId();
if (newPlanetId == m_planetId) {
return;
}
m_planetId = newPlanetId;
clearSearch();
}
}
#include "moc_SearchWidget.cpp"
......@@ -35,6 +35,7 @@ private:
Q_PRIVATE_SLOT( d, void setSearchResult( const QVector<GeoDataPlacemark*>& ) )
Q_PRIVATE_SLOT( d, void search( const QString &searchTerm, SearchMode searchMode ) )
Q_PRIVATE_SLOT( d, void centerMapOn( const QModelIndex &index ) )
Q_PRIVATE_SLOT( d, void handlePlanetChange() )
SearchWidgetPrivate* const d;
......
......@@ -99,6 +99,7 @@ public:
int m_iconSize;
int m_collapse_width;
bool m_playing;
QString m_planetId;
QToolBar *m_toolBar;
......@@ -158,6 +159,7 @@ RoutingWidgetPrivate::RoutingWidgetPrivate( RoutingWidget *parent, MarbleWidget
m_iconSize( 16 ),
m_collapse_width( 0 ),
m_playing( false ),
m_planetId(marbleWidget->model()->planetId()),
m_toolBar( 0 ),
m_openRouteButton( 0 ),
m_saveRouteButton( 0 ),
......@@ -394,6 +396,9 @@ RoutingWidget::RoutingWidget( MarbleWidget *marbleWidget, QWidget *parent ) :
d->m_ui.directionsListView->setWindowTitle( tr( "Directions - Marble" ) );
#endif // Q_WS_MAEMO_5
}
connect( marbleWidget->model(), SIGNAL(themeChanged(QString)),
this, SLOT(handlePlanetChange()) );
}
RoutingWidget::~RoutingWidget()
......@@ -1011,6 +1016,18 @@ void RoutingWidget::seekTourToStart()
d->m_playing = false;
}
void RoutingWidget::handlePlanetChange()
{
const QString newPlanetId = d->m_widget->model()->planetId();
if (newPlanetId == d->m_planetId) {
return;
}
d->m_planetId = newPlanetId;
d->m_routingManager->clearRoute();
}
} // namespace Marble
#include "moc_RoutingWidget.cpp"
......@@ -148,6 +148,8 @@ private Q_SLOTS:
void toggleRoutePlay();
void handlePlanetChange();
protected:
bool eventFilter( QObject *o, QEvent *e );
void resizeEvent(QResizeEvent *e);
......
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