QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgslocatorwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgslocatorwidget.cpp
3  --------------------
4  begin : May 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "qgslocator.h"
19 #include "qgslocatormodel.h"
20 #include "qgslocatorwidget.h"
21 #include "qgslocatormodelbridge.h"
22 #include "qgsfilterlineedit.h"
23 #include "qgsmapcanvas.h"
24 #include "qgsapplication.h"
25 #include "qgslogger.h"
26 #include "qgsguiutils.h"
27 
28 #include <QLayout>
29 #include <QCompleter>
30 #include <QMenu>
31 #include <QTextLayout>
32 #include <QTextLine>
33 
35  : QWidget( parent )
36  , mModelBridge( new QgsLocatorModelBridge( this ) )
37  , mLineEdit( new QgsLocatorLineEdit( this ) )
38  , mResultsView( new QgsLocatorResultsView() )
39 {
40  mLineEdit->setShowClearButton( true );
41 #ifdef Q_OS_MACX
42  mLineEdit->setPlaceholderText( tr( "Type to locate (⌘K)" ) );
43 #else
44  mLineEdit->setPlaceholderText( tr( "Type to locate (Ctrl+K)" ) );
45 #endif
46 
47  int placeholderMinWidth = mLineEdit->fontMetrics().boundingRect( mLineEdit->placeholderText() ).width();
48  int minWidth = std::max( 200, static_cast< int >( placeholderMinWidth * 1.8 ) );
49  resize( minWidth, 30 );
50  QSizePolicy sizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
51  sizePolicy.setHorizontalStretch( 0 );
52  sizePolicy.setVerticalStretch( 0 );
53  setSizePolicy( sizePolicy );
54  setMinimumSize( QSize( minWidth, 0 ) );
55 
56  QHBoxLayout *layout = new QHBoxLayout();
57  layout->setContentsMargins( 0, 0, 0, 0 );
58  layout->addWidget( mLineEdit );
59  setLayout( layout );
60 
61  setFocusProxy( mLineEdit );
62 
63  // setup floating container widget
64  mResultsContainer = new QgsFloatingWidget( parent ? parent->window() : nullptr );
65  mResultsContainer->setAnchorWidget( mLineEdit );
66  mResultsContainer->setAnchorPoint( QgsFloatingWidget::BottomLeft );
68 
69  QHBoxLayout *containerLayout = new QHBoxLayout();
70  containerLayout->setContentsMargins( 0, 0, 0, 0 );
71  containerLayout->addWidget( mResultsView );
72  mResultsContainer->setLayout( containerLayout );
73  mResultsContainer->hide();
74 
75  mResultsView->setModel( mModelBridge->proxyModel() );
76  mResultsView->setUniformRowHeights( true );
77 
79  mResultsView->setIconSize( QSize( iconSize, iconSize ) );
80  mResultsView->recalculateSize();
81  mResultsView->setContextMenuPolicy( Qt::CustomContextMenu );
82 
83  connect( mLineEdit, &QLineEdit::textChanged, this, &QgsLocatorWidget::scheduleDelayedPopup );
84  connect( mResultsView, &QAbstractItemView::activated, this, &QgsLocatorWidget::acceptCurrentEntry );
85  connect( mResultsView, &QAbstractItemView::customContextMenuRequested, this, &QgsLocatorWidget::showContextMenu );
86 
87  connect( mModelBridge, &QgsLocatorModelBridge::resultAdded, this, &QgsLocatorWidget::resultAdded );
88  connect( mModelBridge, &QgsLocatorModelBridge::isRunningChanged, this, [ = ]() {mLineEdit->setShowSpinner( mModelBridge->isRunning() );} );
89  connect( mModelBridge, &QgsLocatorModelBridge::resultsCleared, this, [ = ]() {mHasSelectedResult = false;} );
90 
91  // have a tiny delay between typing text in line edit and showing the window
92  mPopupTimer.setInterval( 100 );
93  mPopupTimer.setSingleShot( true );
94  connect( &mPopupTimer, &QTimer::timeout, this, &QgsLocatorWidget::performSearch );
95  mFocusTimer.setInterval( 110 );
96  mFocusTimer.setSingleShot( true );
97  connect( &mFocusTimer, &QTimer::timeout, this, &QgsLocatorWidget::triggerSearchAndShowList );
98 
99  mLineEdit->installEventFilter( this );
100  mResultsContainer->installEventFilter( this );
101  mResultsView->installEventFilter( this );
102  installEventFilter( this );
103  window()->installEventFilter( this );
104 
105  mModelBridge->locator()->registerFilter( new QgsLocatorFilterFilter( this, this ) );
106 
107  mMenu = new QMenu( this );
108  QAction *menuAction = mLineEdit->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/search.svg" ) ), QLineEdit::LeadingPosition );
109  connect( menuAction, &QAction::triggered, this, [ = ]
110  {
111  mFocusTimer.stop();
112  mResultsContainer->hide();
113  mMenu->exec( QCursor::pos() );
114  } );
115  connect( mMenu, &QMenu::aboutToShow, this, &QgsLocatorWidget::configMenuAboutToShow );
116 
117 }
118 
120 {
121  return mModelBridge->locator();
122 }
123 
125 {
126  if ( mMapCanvas == canvas )
127  return;
128 
129  for ( const QMetaObject::Connection &conn : qgis::as_const( mCanvasConnections ) )
130  {
131  disconnect( conn );
132  }
133  mCanvasConnections.clear();
134 
135  mMapCanvas = canvas;
136  if ( mMapCanvas )
137  {
138  mModelBridge->updateCanvasExtent( mMapCanvas->mapSettings().visibleExtent() );
139  mModelBridge->updateCanvasCrs( mMapCanvas->mapSettings().destinationCrs() );
140  mCanvasConnections
141  << connect( mMapCanvas, &QgsMapCanvas::extentsChanged, this, [ = ]() {mModelBridge->updateCanvasExtent( mMapCanvas->mapSettings().visibleExtent() );} )
142  << connect( mMapCanvas, &QgsMapCanvas::destinationCrsChanged, this, [ = ]() {mModelBridge->updateCanvasCrs( mMapCanvas->mapSettings().destinationCrs() );} ) ;
143  }
144 }
145 
146 void QgsLocatorWidget::search( const QString &string )
147 {
148  window()->activateWindow(); // window must also be active - otherwise floating docks can steal keystrokes
149  if ( string.isEmpty() )
150  {
151  mLineEdit->setFocus();
152  mLineEdit->selectAll();
153  }
154  else
155  {
156  scheduleDelayedPopup();
157  mLineEdit->setFocus();
158  mLineEdit->setText( string );
159  performSearch();
160  }
161 }
162 
164 {
165  mModelBridge->invalidateResults();
166  mResultsContainer->hide();
167 }
168 
169 void QgsLocatorWidget::scheduleDelayedPopup()
170 {
171  mPopupTimer.start();
172 }
173 
174 void QgsLocatorWidget::resultAdded()
175 {
176  bool selectFirst = !mHasSelectedResult || mModelBridge->proxyModel()->rowCount() == 0;
177  if ( selectFirst )
178  {
179  int row = -1;
180  bool selectable = false;
181  while ( !selectable && row < mModelBridge->proxyModel()->rowCount() )
182  {
183  row++;
184  selectable = mModelBridge->proxyModel()->flags( mModelBridge->proxyModel()->index( row, 0 ) ).testFlag( Qt::ItemIsSelectable );
185  }
186  if ( selectable )
187  mResultsView->setCurrentIndex( mModelBridge->proxyModel()->index( row, 0 ) );
188  }
189 }
190 
191 void QgsLocatorWidget::showContextMenu( const QPoint &point )
192 {
193  QModelIndex index = mResultsView->indexAt( point );
194  if ( !index.isValid() )
195  return;
196 
197  const QList<QgsLocatorResult::ResultAction> actions = mResultsView->model()->data( index, QgsLocatorModel::ResultActionsRole ).value<QList<QgsLocatorResult::ResultAction>>();
198  QMenu *contextMenu = new QMenu( mResultsView );
199  for ( auto resultAction : actions )
200  {
201  QAction *menuAction = new QAction( resultAction.text, contextMenu );
202  if ( !resultAction.iconPath.isEmpty() )
203  menuAction->setIcon( QIcon( resultAction.iconPath ) );
204  connect( menuAction, &QAction::triggered, this, [ = ]() {mModelBridge->triggerResult( index, resultAction.id );} );
205  contextMenu->addAction( menuAction );
206  }
207  contextMenu->exec( mResultsView->viewport()->mapToGlobal( point ) );
208 }
209 
210 void QgsLocatorWidget::performSearch()
211 {
212  mPopupTimer.stop();
213  mModelBridge->performSearch( mLineEdit->text() );
214  showList();
215 }
216 
217 void QgsLocatorWidget::showList()
218 {
219  mResultsContainer->show();
220  mResultsContainer->raise();
221 }
222 
223 void QgsLocatorWidget::triggerSearchAndShowList()
224 {
225  if ( mModelBridge->proxyModel()->rowCount() == 0 )
226  performSearch();
227  else
228  showList();
229 }
230 
231 bool QgsLocatorWidget::eventFilter( QObject *obj, QEvent *event )
232 {
233  if ( obj == mLineEdit && event->type() == QEvent::KeyPress )
234  {
235  QKeyEvent *keyEvent = static_cast<QKeyEvent *>( event );
236  switch ( keyEvent->key() )
237  {
238  case Qt::Key_Up:
239  case Qt::Key_Down:
240  case Qt::Key_PageUp:
241  case Qt::Key_PageDown:
242  triggerSearchAndShowList();
243  mHasSelectedResult = true;
244  QgsApplication::sendEvent( mResultsView, event );
245  return true;
246  case Qt::Key_Home:
247  case Qt::Key_End:
248  if ( keyEvent->modifiers() & Qt::ControlModifier )
249  {
250  triggerSearchAndShowList();
251  mHasSelectedResult = true;
252  QgsApplication::sendEvent( mResultsView, event );
253  return true;
254  }
255  break;
256  case Qt::Key_Enter:
257  case Qt::Key_Return:
258  acceptCurrentEntry();
259  return true;
260  case Qt::Key_Escape:
261  mResultsContainer->hide();
262  return true;
263  case Qt::Key_Tab:
264  if ( !mLineEdit->performCompletion() )
265  {
266  mHasSelectedResult = true;
267  mResultsView->selectNextResult();
268  }
269  return true;
270  case Qt::Key_Backtab:
271  mHasSelectedResult = true;
272  mResultsView->selectPreviousResult();
273  return true;
274  default:
275  break;
276  }
277  }
278  else if ( obj == mResultsView && event->type() == QEvent::MouseButtonPress )
279  {
280  mHasSelectedResult = true;
281  }
282  else if ( event->type() == QEvent::FocusOut && ( obj == mLineEdit || obj == mResultsContainer || obj == mResultsView ) )
283  {
284  if ( !mLineEdit->hasFocus() && !mResultsContainer->hasFocus() && !mResultsView->hasFocus() )
285  {
286  mFocusTimer.stop();
287  mResultsContainer->hide();
288  }
289  }
290  else if ( event->type() == QEvent::FocusIn && obj == mLineEdit )
291  {
292  mFocusTimer.start();
293  }
294  else if ( obj == window() && event->type() == QEvent::Resize )
295  {
296  mResultsView->recalculateSize();
297  }
298  return QWidget::eventFilter( obj, event );
299 }
300 
301 void QgsLocatorWidget::configMenuAboutToShow()
302 {
303  mMenu->clear();
304  for ( QgsLocatorFilter *filter : mModelBridge->locator()->filters() )
305  {
306  if ( !filter->enabled() )
307  continue;
308 
309  QAction *action = new QAction( filter->displayName(), mMenu );
310  connect( action, &QAction::triggered, this, [ = ]
311  {
312  QString currentText = mLineEdit->text();
313  if ( currentText.isEmpty() )
314  currentText = tr( "<type here>" );
315  else
316  {
317  QStringList parts = currentText.split( ' ' );
318  if ( parts.count() > 1 && mModelBridge->locator()->filters( parts.at( 0 ) ).count() > 0 )
319  {
320  parts.pop_front();
321  currentText = parts.join( ' ' );
322  }
323  }
324 
325  mLineEdit->setText( filter->activePrefix() + ' ' + currentText );
326  mLineEdit->setSelection( filter->activePrefix().length() + 1, currentText.length() );
327  } );
328  mMenu->addAction( action );
329  }
330  mMenu->addSeparator();
331  QAction *configAction = new QAction( tr( "Configure…" ), mMenu );
332  connect( configAction, &QAction::triggered, this, &QgsLocatorWidget::configTriggered );
333  mMenu->addAction( configAction );
334 }
335 
336 
337 void QgsLocatorWidget::acceptCurrentEntry()
338 {
339  if ( mModelBridge->hasQueueRequested() )
340  {
341  return;
342  }
343  else
344  {
345  if ( !mResultsView->isVisible() )
346  return;
347 
348  QModelIndex index = mResultsView->currentIndex();
349  if ( !index.isValid() )
350  return;
351 
352  mResultsContainer->hide();
353  mLineEdit->clearFocus();
354  mModelBridge->triggerResult( index );
355  }
356 }
357 
359 
360 //
361 // QgsLocatorResultsView
362 //
363 
364 QgsLocatorResultsView::QgsLocatorResultsView( QWidget *parent )
365  : QTreeView( parent )
366 {
367  setRootIsDecorated( false );
368  setUniformRowHeights( true );
369  header()->hide();
370  header()->setStretchLastSection( true );
371 }
372 
373 void QgsLocatorResultsView::recalculateSize()
374 {
375  // try to show about 20 rows
376  int rowSize = 20 * itemDelegate()->sizeHint( viewOptions(), model()->index( 0, 0 ) ).height();
377 
378  // try to take up a sensible portion of window width (about half)
379  int width = std::max( 300, window()->size().width() / 2 );
380  QSize newSize( width, rowSize + frameWidth() * 2 );
381  // resize the floating widget this is contained within
382  parentWidget()->resize( newSize );
383  QTreeView::resize( newSize );
384 
385  header()->resizeSection( 0, width / 2 );
386  header()->resizeSection( 1, 0 );
387 }
388 
389 void QgsLocatorResultsView::selectNextResult()
390 {
391  int nextRow = currentIndex().row() + 1;
392  nextRow = nextRow % model()->rowCount( QModelIndex() );
393  setCurrentIndex( model()->index( nextRow, 0 ) );
394 }
395 
396 void QgsLocatorResultsView::selectPreviousResult()
397 {
398  int previousRow = currentIndex().row() - 1;
399  if ( previousRow < 0 )
400  previousRow = model()->rowCount( QModelIndex() ) - 1;
401  setCurrentIndex( model()->index( previousRow, 0 ) );
402 }
403 
404 //
405 // QgsLocatorFilterFilter
406 //
407 
408 QgsLocatorFilterFilter::QgsLocatorFilterFilter( QgsLocatorWidget *locator, QObject *parent )
409  : QgsLocatorFilter( parent )
410  , mLocator( locator )
411 {}
412 
413 QgsLocatorFilterFilter *QgsLocatorFilterFilter::clone() const
414 {
415  return new QgsLocatorFilterFilter( mLocator );
416 }
417 
418 QgsLocatorFilter::Flags QgsLocatorFilterFilter::flags() const
419 {
421 }
422 
423 void QgsLocatorFilterFilter::fetchResults( const QString &string, const QgsLocatorContext &, QgsFeedback *feedback )
424 {
425  if ( !string.isEmpty() )
426  {
427  //only shows results when nothing typed
428  return;
429  }
430 
431  for ( QgsLocatorFilter *filter : mLocator->locator()->filters() )
432  {
433  if ( feedback->isCanceled() )
434  return;
435 
436  if ( filter == this || !filter || !filter->enabled() )
437  continue;
438 
439  QgsLocatorResult result;
440  result.displayString = filter->activePrefix();
441  result.description = filter->displayName();
442  result.userData = QString( filter->activePrefix() + ' ' );
443  result.icon = QgsApplication::getThemeIcon( QStringLiteral( "/search.svg" ) );
444  emit resultFetched( result );
445  }
446 }
447 
448 void QgsLocatorFilterFilter::triggerResult( const QgsLocatorResult &result )
449 {
450  mLocator->search( result.userData.toString() );
451 }
452 
453 QgsLocatorLineEdit::QgsLocatorLineEdit( QgsLocatorWidget *locator, QWidget *parent )
454  : QgsFilterLineEdit( parent )
455  , mLocatorWidget( locator )
456 {
457  connect( mLocatorWidget->locator(), &QgsLocator::searchPrepared, this, [&] { update(); } );
458 }
459 
460 void QgsLocatorLineEdit::paintEvent( QPaintEvent *event )
461 {
462  // this adds the completion as grey text at the right of the cursor
463  // see https://stackoverflow.com/a/50425331/1548052
464  // this is possible that the completion might be badly rendered if the cursor is larger than the line edit
465  // this sounds acceptable as it is not very likely to use completion for super long texts
466  // for more details see https://stackoverflow.com/a/54218192/1548052
467 
468  QLineEdit::paintEvent( event );
469 
470  if ( !hasFocus() )
471  return;
472 
473  QString currentText = text();
474 
475  if ( currentText.length() == 0 || cursorPosition() < currentText.length() )
476  return;
477 
478  const QStringList completionList = mLocatorWidget->locator()->completionList();
479 
480  mCompletionText.clear();
481  QString completion;
482  for ( const QString &candidate : completionList )
483  {
484  if ( candidate.startsWith( currentText ) )
485  {
486  completion = candidate.right( candidate.length() - currentText.length() );
487  mCompletionText = candidate;
488  break;
489  }
490  }
491 
492  if ( completion.isEmpty() )
493  return;
494 
495  ensurePolished(); // ensure font() is up to date
496 
497  QRect cr = cursorRect();
498  QPoint pos = cr.topRight() - QPoint( cr.width() / 2, 0 );
499 
500  QTextLayout l( completion, font() );
501  l.beginLayout();
502  QTextLine line = l.createLine();
503  line.setLineWidth( width() - pos.x() );
504  line.setPosition( pos );
505  l.endLayout();
506 
507  QPainter p( this );
508  p.setPen( QPen( Qt::gray, 1 ) );
509  l.draw( &p, QPoint( 0, 0 ) );
510 }
511 
512 bool QgsLocatorLineEdit::performCompletion()
513 {
514  if ( !mCompletionText.isEmpty() )
515  {
516  setText( mCompletionText );
517  mCompletionText.clear();
518  return true;
519  }
520  else
521  return false;
522 }
523 
524 
QgsLocatorFilter
Abstract base class for filters which collect locator results.
Definition: qgslocatorfilter.h:146
QgsLocatorResult::displayString
QString displayString
String displayed for result.
Definition: qgslocatorfilter.h:65
QgsLocator
Handles the management of QgsLocatorFilter objects and async collection of search results from them.
Definition: qgslocator.h:58
QgsApplication::getThemeIcon
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
Definition: qgsapplication.cpp:626
QgsMapCanvas::destinationCrsChanged
void destinationCrsChanged()
Emitted when map CRS has changed.
qgsmapcanvas.h
QgsMapCanvas::mapSettings
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
Definition: qgsmapcanvas.cpp:391
QgsLocatorWidget::eventFilter
bool eventFilter(QObject *obj, QEvent *event) override
Definition: qgslocatorwidget.cpp:231
QgsFloatingWidget::BottomLeft
@ BottomLeft
Bottom-left of widget.
Definition: qgsfloatingwidget.h:51
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:85
qgsfilterlineedit.h
QgsFilterLineEdit
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
Definition: qgsfilterlineedit.h:40
qgslocatormodel.h
qgslocator.h
QgsLocatorWidget
A special locator widget which allows searching for matching results from a QgsLocator and presenting...
Definition: qgslocatorwidget.h:47
QgsGuiUtils::iconSize
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
Definition: qgsguiutils.cpp:250
QgsLocatorResult
Encapsulates properties of an individual matching result found by a QgsLocatorFilter.
Definition: qgslocatorfilter.h:40
qgsapplication.h
QgsLocatorModelBridge::resultAdded
void resultAdded()
Emitted when a result is added.
QgsLocatorModelBridge::proxyModel
Q_INVOKABLE QgsLocatorProxyModel * proxyModel() const
Returns the proxy model.
Definition: qgslocatormodelbridge.cpp:129
QgsLocatorModelBridge::triggerResult
void triggerResult(const QModelIndex &index, const int actionId=-1)
Triggers the result at given index and with optional actionId if an additional action was triggered.
Definition: qgslocatormodelbridge.cpp:40
QgsLocatorContext
Encapsulates the properties relating to the context of a locator search.
Definition: qgslocatorcontext.h:32
QgsLocator::searchPrepared
void searchPrepared()
Emitted when locator has prepared the search (.
QgsLocatorModelBridge
The QgsLocatorModelBridge class provides the core functionality to be used in a locator widget.
Definition: qgslocatormodelbridge.h:43
QgsLocatorWidget::invalidateResults
void invalidateResults()
Invalidates the current search results, e.g.
Definition: qgslocatorwidget.cpp:163
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsFloatingWidget::TopLeft
@ TopLeft
Top-left of widget.
Definition: qgsfloatingwidget.h:45
QgsMapCanvas::extentsChanged
void extentsChanged()
Emitted when the extents of the map change.
QgsLocatorModelBridge::invalidateResults
void invalidateResults()
This will invalidate current search results.
Definition: qgslocatormodelbridge.cpp:62
QgsLocatorModel::ResultActionsRole
@ ResultActionsRole
The actions to be shown for the given result in a context menu.
Definition: qgslocatormodel.h:59
qgslocatormodelbridge.h
QgsLocatorWidget::setMapCanvas
void setMapCanvas(QgsMapCanvas *canvas)
Sets a map canvas to associate with the widget.
Definition: qgslocatorwidget.cpp:124
QgsLocatorWidget::locator
QgsLocator * locator()
Returns a pointer to the locator utilized by this widget.
Definition: qgslocatorwidget.cpp:119
QgsFloatingWidget
A QWidget subclass for creating widgets which float outside of the normal Qt layout system.
Definition: qgsfloatingwidget.h:34
QgsLocatorModelBridge::updateCanvasCrs
void updateCanvasCrs(const QgsCoordinateReferenceSystem &crs)
Update the canvas CRS used to create search context.
Definition: qgslocatormodelbridge.cpp:73
QgsFloatingWidget::setAnchorWidget
void setAnchorWidget(QWidget *widget)
Sets the widget to "anchor" the floating widget to.
Definition: qgsfloatingwidget.cpp:36
QgsMapSettings::destinationCrs
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
Definition: qgsmapsettings.cpp:318
QgsFeedback::isCanceled
bool isCanceled() const
Tells whether the operation has been canceled already.
Definition: qgsfeedback.h:53
QgsLocatorResult::icon
QIcon icon
Icon for result.
Definition: qgslocatorfilter.h:80
QgsLocatorWidget::QgsLocatorWidget
QgsLocatorWidget(QWidget *parent SIP_TRANSFERTHIS=nullptr)
Constructor for QgsLocatorWidget.
Definition: qgslocatorwidget.cpp:34
QgsLocatorModelBridge::isRunning
bool isRunning
Definition: qgslocatormodelbridge.h:45
QgsLocatorModelBridge::updateCanvasExtent
void updateCanvasExtent(const QgsRectangle &extent)
Update the canvas extent used to create search context.
Definition: qgslocatormodelbridge.cpp:68
qgslocatorwidget.h
QgsLocatorModelBridge::hasQueueRequested
bool hasQueueRequested() const
Returns true if some text to be search is pending in the queue.
Definition: qgslocatormodelbridge.cpp:134
QgsLocatorWidget::configTriggered
void configTriggered()
Emitted when the configure option is triggered in the widget.
QgsFloatingWidget::setAnchorWidgetPoint
void setAnchorWidgetPoint(AnchorPoint point)
Returns the anchor widget's anchor point, which corresponds to the point on the anchor widget which t...
Definition: qgsfloatingwidget.cpp:76
QgsLocatorModelBridge::performSearch
Q_INVOKABLE void performSearch(const QString &text)
Perform a search.
Definition: qgslocatormodelbridge.cpp:102
QgsLocatorModelBridge::resultsCleared
void resultsCleared()
Emitted when the results are cleared.
QgsFloatingWidget::setAnchorPoint
void setAnchorPoint(AnchorPoint point)
Sets the floating widget's anchor point, which corresponds to the point on the widget which should re...
Definition: qgsfloatingwidget.cpp:66
QgsLocatorModelBridge::locator
QgsLocator * locator() const
Returns the locator.
Definition: qgslocatormodelbridge.cpp:124
QgsLocator::registerFilter
void registerFilter(QgsLocatorFilter *filter)
Registers a filter within the locator.
Definition: qgslocator.cpp:91
qgslogger.h
qgsguiutils.h
QgsLocatorWidget::search
void search(const QString &string)
Triggers the locator widget to focus, open and start searching for a specified string.
Definition: qgslocatorwidget.cpp:146
QgsGuiUtils::scaleIconSize
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
Definition: qgsguiutils.cpp:245
QgsMapSettings::visibleExtent
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes takes output image size into accou...
Definition: qgsmapsettings.cpp:371
QgsLocatorResult::description
QString description
Descriptive text for result.
Definition: qgslocatorfilter.h:70
QgsLocatorFilter::FlagFast
@ FlagFast
Filter finds results quickly and can be safely run in the main thread.
Definition: qgslocatorfilter.h:165
QgsLocator::filters
QList< QgsLocatorFilter * > filters(const QString &prefix=QString())
Returns the list of filters registered in the locator.
Definition: qgslocator.cpp:54
QgsLocatorModelBridge::isRunningChanged
void isRunningChanged()
Emitted when the running status changes.
QgsLocatorResult::userData
QVariant userData
Custom reference or other data set by the filter.
Definition: qgslocatorfilter.h:75