33 #include <QSortFilterProxyModel>
35 using namespace Marble;
37 #include "ui_NavigationWidget.h"
42 class NavigationWidgetPrivate
45 NavigationWidgetPrivate();
47 void updateButtons(
int );
51 void adjustForAnimation();
52 void adjustForStill();
65 Ui::NavigationWidget m_navigationUi;
74 NavigationWidgetPrivate::NavigationWidgetPrivate()
75 : m_widget( 0 ), m_sortproxy( 0 ), m_runnerManager( 0 ),
78 m_document->setName(
"Search Results" );
84 d( new NavigationWidgetPrivate() )
86 d->m_searchTerm.clear();
89 d->m_navigationUi.setupUi(
this );
90 d->m_navigationUi.m_splitter->setStretchFactor( 0, 1 );
91 d->m_navigationUi.m_splitter->setStretchFactor( 1, 2 );
92 d->m_navigationUi.locationListView->setVisible(
false );
95 d->m_navigationUi.locationListView->setModel( d->m_sortproxy );
96 connect( d->m_navigationUi.goHomeButton, SIGNAL(clicked()),
98 connect( d->m_navigationUi.zoomSlider, SIGNAL(valueChanged(
int)),
100 connect( d->m_navigationUi.zoomInButton, SIGNAL(clicked()),
102 connect( d->m_navigationUi.zoomOutButton, SIGNAL(clicked()),
105 connect( d->m_navigationUi.zoomSlider, SIGNAL(valueChanged(
int)),
106 this, SLOT(updateButtons(
int)) );
108 connect( d->m_navigationUi.moveLeftButton, SIGNAL(clicked()),
110 connect( d->m_navigationUi.moveRightButton, SIGNAL(clicked()),
112 connect( d->m_navigationUi.moveUpButton, SIGNAL(clicked()),
114 connect( d->m_navigationUi.moveDownButton, SIGNAL(clicked()),
120 connect( d->m_navigationUi.zoomSlider, SIGNAL(sliderPressed()),
121 this, SLOT(adjustForAnimation()) );
122 connect( d->m_navigationUi.zoomSlider, SIGNAL(sliderReleased()),
123 this, SLOT(adjustForStill()) );
140 d->m_widget = widget;
141 treeModel = d->m_widget->model()->treeModel();
144 d->m_branchfilter.setSourceModel( treeModel );
145 d->m_branchfilter.setBranchIndex( treeModel, treeModel->
index( d->m_document ) );
147 d->m_sortproxy->sort( 0, Qt::AscendingOrder );
148 d->m_sortproxy->setDynamicSortFilter(
true );
149 d->m_sortproxy->setSourceModel( &d->m_branchfilter );
150 d->m_navigationUi.locationListView->setRootIndex(
151 d->m_sortproxy->mapFromSource(
152 d->m_branchfilter.mapFromSource( treeModel->
index( d->m_document ) ) ) );
174 d->m_searchTerm = searchTerm;
179 d->m_navigationUi.locationListView->setVisible(
true );
181 d->m_runnerManager->findPlacemarks( d->m_searchTerm, d->m_widget->viewport()->viewLatLonAltBox() );
183 d->m_runnerManager->findPlacemarks( d->m_searchTerm );
199 d->m_navigationUi.zoomSlider->blockSignals(
true );
201 d->m_navigationUi.zoomSlider->setValue( zoom );
203 d->updateButtons( zoom );
205 d->m_navigationUi.zoomSlider->blockSignals(
false );
210 d->m_searchTerm.clear();
212 d->m_navigationUi.locationListView->setVisible(
false );
213 d->m_widget->model()->placemarkSelectionModel()->clear();
218 d->m_document->clear();
220 d->m_branchfilter.setBranchIndex( treeModel, treeModel->
index( d->m_document ) );
221 d->m_navigationUi.locationListView->setRootIndex(
222 d->m_sortproxy->mapFromSource(
223 d->m_branchfilter.mapFromSource( treeModel->
index( d->m_document ) ) ) );
226 d->m_runnerManager->findPlacemarks(
QString() );
239 m_widget->model()->placemarkSelectionModel()->clear();
247 m_branchfilter.setBranchIndex( treeModel, treeModel->
index( m_document ) );
248 m_navigationUi.locationListView->setRootIndex(
249 m_sortproxy->mapFromSource(
250 m_branchfilter.mapFromSource( treeModel->
index( m_document ) ) ) );
251 m_widget->centerOn( m_document->latLonAltBox() );
252 mDebug() <<
"NavigationWidget (searchResults): Time elapsed:"<< t.
elapsed() <<
" ms";
260 d->m_navigationUi.zoomSlider->setMinimum( d->m_widget->minimumZoom() );
261 d->m_navigationUi.zoomSlider->setMaximum( d->m_widget->maximumZoom() );
262 d->updateButtons( d->m_navigationUi.zoomSlider->value() );
266 void NavigationWidgetPrivate::updateButtons(
int zoom )
268 if ( zoom <= m_navigationUi.zoomSlider->minimum() ) {
269 m_navigationUi.zoomInButton->setEnabled(
true );
270 m_navigationUi.zoomOutButton->setEnabled(
false );
271 }
else if ( zoom >= m_navigationUi.zoomSlider->maximum() ) {
272 m_navigationUi.zoomInButton->setEnabled(
false );
273 m_navigationUi.zoomOutButton->setEnabled(
true );
275 m_navigationUi.zoomInButton->setEnabled(
true );
276 m_navigationUi.zoomOutButton->setEnabled(
true );
280 void NavigationWidgetPrivate::mapCenterOnSignal(
const QModelIndex &index )
289 m_widget->centerOn( *placemark,
true );
290 m_widget->model()->placemarkSelectionModel()->select( index, QItemSelectionModel::ClearAndSelect );
294 void NavigationWidgetPrivate::adjustForAnimation()
302 void NavigationWidgetPrivate::adjustForStill()
306 m_widget->setViewContext(
Still );
314 if ( smallScreen ||
height() < 390 ) {
315 if ( !d->m_navigationUi.zoomSlider->isHidden() ) {
317 d->m_navigationUi.zoomSlider->hide();
318 d->m_navigationUi.m_pSpacerFrame->setSizePolicy( QSizePolicy::Preferred,
319 QSizePolicy::Expanding );
323 if ( d->m_navigationUi.zoomSlider->isHidden() ) {
325 d->m_navigationUi.zoomSlider->show();
326 d->m_navigationUi.m_pSpacerFrame->setSizePolicy( QSizePolicy::Preferred,
327 QSizePolicy::Fixed );
335 #include "NavigationWidget.moc"
SearchMode
Search mode: Global (worldwide) versus area (local, regional) search.
A container for Features, Styles and in the future Schemas.
The representation of GeoData in a model This class represents all available data given by kml-data f...
This file contains the headers for MarbleModel.
A base class for all geodata objects.
Search a certain region of a planet (e.g. visible region)
The pointer to a specific object.
int addDocument(GeoDataDocument *document)
animated view (e.g. while rotating the globe)
void removeDocument(int index)
virtual QVariant data(const QModelIndex &index, int role) const =0
This file contains the headers for ViewportParams.
static MarbleGlobal * getInstance()
const QAbstractItemModel * model() const
Profiles profiles() const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
a class representing a point of interest on the map
QDebug mDebug()
a function to replace qDebug() in Marble library code