void SearchWidget::setMarbleWidget( MarbleWidget* widget ) { if ( d->m_widget ) { return; } d->m_widget = widget; d->m_searchField->setCompletionModel( widget->model()->placemarkModel() ); connect( d->m_searchField, SIGNAL(centerOn(GeoDataCoordinates)), widget, SLOT(centerOn(GeoDataCoordinates)) ); d->m_runnerManager = new MarbleRunnerManager( widget->model()->pluginManager(), this ); d->m_runnerManager->setModel( widget->model() ); connect( d->m_runnerManager, SIGNAL(searchResultChanged(QVector<GeoDataPlacemark*>)), this, SLOT(setSearchResult(QVector<GeoDataPlacemark*>)) ); connect( d->m_runnerManager, SIGNAL(searchFinished(QString)), d->m_searchField, SLOT(disableSearchAnimation())); GeoDataTreeModel* treeModel = d->m_widget->model()->treeModel(); treeModel->addDocument( d->m_document ); d->m_branchfilter.setSourceModel( treeModel ); d->m_branchfilter.setBranchIndex( treeModel, treeModel->index( d->m_document ) ); d->m_searchResultView->setRootIndex( d->m_sortproxy.mapFromSource( d->m_branchfilter.mapFromSource( treeModel->index( d->m_document ) ) ) ); }
void SearchWidgetPrivate::clearSearch() { m_widget->model()->placemarkSelectionModel()->clear(); // clear the local document GeoDataTreeModel *treeModel = m_widget->model()->treeModel(); treeModel->removeDocument( m_document ); m_document->clear(); treeModel->addDocument( m_document ); m_branchfilter.setBranchIndex( treeModel, treeModel->index( m_document ) ); m_searchResultView->setRootIndex( m_sortproxy.mapFromSource( m_branchfilter.mapFromSource( treeModel->index( m_document ) ) ) ); // clear cached search results m_runnerManager->findPlacemarks( QString() ); }
void NavigationWidgetPrivate::setSearchResult( QVector<GeoDataPlacemark*> locations ) { if( locations.isEmpty() ) { return; } QTime t; t.start(); // fill the local document with results m_widget->model()->placemarkSelectionModel()->clear(); GeoDataTreeModel *treeModel = m_widget->model()->treeModel(); treeModel->removeDocument( m_document ); m_document->clear(); foreach (GeoDataPlacemark *placemark, locations ) { m_document->append( new GeoDataPlacemark( *placemark ) ); }
void BookmarkManagerTest::loadFile() { QFETCH( QString, relativePath ); QFETCH( bool, expected ); GeoDataTreeModel model; BookmarkManager manager( &model ); QVERIFY( model.rowCount() == 1 ); const bool fileLoaded = manager.loadFile( relativePath ); QCOMPARE( fileLoaded, expected ); QVERIFY( manager.document() != 0 ); QCOMPARE( model.rowCount(), 1 ); }
void NavigationWidget::clearSearch() { d->m_searchTerm.clear(); 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() ); }