QgsLocatorModel class

An abstract list model for displaying the results of locator searches.

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

Derived classes

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

Public types

enum Role { ResultDataRole = Qt::UserRole + 1, ResultTypeRole, ResultFilterPriorityRole, ResultScoreRole, ResultFilterNameRole, ResultFilterGroupSortingRole, ResultActionsRole }
Custom model roles.

Constructors, destructors, conversion operators

QgsLocatorModel(QObject* parent = nullptr)
Constructor for QgsLocatorModel.

Public functions

void clear()
Resets the model and clears all existing results.
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).

Public slots

void addResult(const QgsLocatorResult& result)
Adds a new result to the model.

Enum documentation

enum QgsLocatorModel::Role

Custom model roles.

Enumerators
ResultDataRole

QgsLocatorResult data.

ResultTypeRole

Result type.

ResultFilterPriorityRole

Result priority, used by QgsLocatorProxyModel for sorting roles.

ResultScoreRole

Result match score, used by QgsLocatorProxyModel for sorting roles.

ResultFilterNameRole

Associated filter name which created the result.

ResultFilterGroupSortingRole

Group results within the same filter results.

ResultActionsRole

The actions to be shown for the given result in a context menu.

Function documentation

void QgsLocatorModel::clear()

Resets the model and clears all existing results.

void QgsLocatorModel::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).

Using deferredClear() instead of clear() can avoid the visually distracting frequent clears which may occur if the model is being updated quickly multiple times as a result of users typing in a search query.