QGIS API Documentation  3.0.2-Girona (307d082)
Classes | Public Types | Public Slots | Public Member Functions | List of all members
QgsLocatorModel Class Reference

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

#include <qgslocatormodel.h>

Inheritance diagram for QgsLocatorModel:
Inheritance graph
[legend]

Public Types

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

Public Slots

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

Public Member Functions

 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
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 

Detailed Description

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.

Since
QGIS 3.0

Definition at line 42 of file qgslocatormodel.h.

Member Enumeration Documentation

◆ Role

Custom model roles.

Enumerator
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.

Definition at line 49 of file qgslocatormodel.h.

Constructor & Destructor Documentation

◆ QgsLocatorModel()

QgsLocatorModel::QgsLocatorModel ( QObject *  parent = nullptr)

Constructor for QgsLocatorModel.

Definition at line 28 of file qgslocatormodel.cpp.

Member Function Documentation

◆ addResult

void QgsLocatorModel::addResult ( const QgsLocatorResult result)
slot

Adds a new result to the model.

Definition at line 156 of file qgslocatormodel.cpp.

◆ clear()

void QgsLocatorModel::clear ( )

Resets the model and clears all existing results.

See also
deferredClear()

Definition at line 36 of file qgslocatormodel.cpp.

◆ columnCount()

int QgsLocatorModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
override

Definition at line 58 of file qgslocatormodel.cpp.

◆ data()

QVariant QgsLocatorModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
override

Definition at line 63 of file qgslocatormodel.cpp.

◆ deferredClear()

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.

See also
deferredClear()

Definition at line 47 of file qgslocatormodel.cpp.

◆ flags()

Qt::ItemFlags QgsLocatorModel::flags ( const QModelIndex &  index) const
override

Definition at line 142 of file qgslocatormodel.cpp.

◆ rowCount()

int QgsLocatorModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

Definition at line 53 of file qgslocatormodel.cpp.


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