QGIS API Documentation  3.8.0-Zanzibar (11aff65)
Public Member Functions | List of all members
QgsLocatorAutomaticModel Class Reference

A QgsLocatorModel which has is associated directly with a QgsLocator, and is automatically populated with results from locator searches. More...

#include <qgslocatormodel.h>

Inheritance diagram for QgsLocatorAutomaticModel:
Inheritance graph
[legend]

Public Member Functions

 QgsLocatorAutomaticModel (QgsLocator *locator)
 Constructor for QgsLocatorAutomaticModel, linked with the specified locator. More...
 
virtual QgsLocatorContext createContext ()
 Returns a new locator context for searches. More...
 
QgsLocatorlocator ()
 Returns a pointer to the locator utilized by this model. More...
 
void search (const QString &string)
 Enqueues a search for a specified string within the model. More...
 
- Public Member Functions inherited from QgsLocatorModel
 QgsLocatorModel (QObject *parent=nullptr)
 Constructor for QgsLocatorModel. More...
 
void clear ()
 Resets the model and clears all existing results. More...
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 
void deferredClear ()
 Resets the model and clears all existing results after a short delay, or whenever the next result is added to the model (whichever occurs first). More...
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 
QHash< int, QByteArray > roleNames () const override
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 

Additional Inherited Members

- Public Types inherited from QgsLocatorModel
enum  Role {
  ResultDataRole = Qt::UserRole + 1, ResultTypeRole, ResultFilterPriorityRole, ResultScoreRole,
  ResultFilterNameRole, ResultFilterGroupSortingRole, ResultActionsRole
}
 Custom model roles. More...
 
- Public Slots inherited from QgsLocatorModel
void addResult (const QgsLocatorResult &result)
 Adds a new result to the model. More...
 
- Static Public Attributes inherited from QgsLocatorModel
static const int NoGroup = 9999
 

Detailed Description

A QgsLocatorModel which has is associated directly with a QgsLocator, and is automatically populated with results from locator searches.

Use this QgsLocatorModel subclass when you want the connections between a QgsLocator and the model to be automatically created for you. If more flexibility in model behavior is required, use the base QgsLocatorModel class instead and setup the connections manually.

Note that this class should generally be used with a QgsLocatorProxyModel in order to ensure correct sorting of results by priority and match level.

Since
QGIS 3.0

Definition at line 136 of file qgslocatormodel.h.

Constructor & Destructor Documentation

◆ QgsLocatorAutomaticModel()

QgsLocatorAutomaticModel::QgsLocatorAutomaticModel ( QgsLocator locator)
explicit

Constructor for QgsLocatorAutomaticModel, linked with the specified locator.

The locator is used as the model's parent.

Definition at line 266 of file qgslocatormodel.cpp.

Member Function Documentation

◆ createContext()

QgsLocatorContext QgsLocatorAutomaticModel::createContext ( )
virtual

Returns a new locator context for searches.

The default implementation returns a default constructed QgsLocatorContext. Subclasses can override this method to implement custom context creation logic.

Definition at line 299 of file qgslocatormodel.cpp.

◆ locator()

QgsLocator * QgsLocatorAutomaticModel::locator ( )

Returns a pointer to the locator utilized by this model.

Definition at line 275 of file qgslocatormodel.cpp.

◆ search()

void QgsLocatorAutomaticModel::search ( const QString &  string)

Enqueues a search for a specified string within the model.

Note that the search may not begin immediately if an existing search request is still running. In this case the existing search must be completely terminated before the new search can begin. The model handles this situation automatically, and will trigger a search for the new search string as soon as possible.

Definition at line 280 of file qgslocatormodel.cpp.


The documentation for this class was generated from the following files: