QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
Classes | Public Types | Public Slots | Public Member Functions | Static Public Attributes | 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 class  CustomRole : int {
  ResultData = Qt::UserRole + 1 , ResultType , ResultFilterPriority , ResultScore ,
  ResultFilterName , ResultFilterGroupSorting , ResultFilterGroupTitle , ResultFilterGroupScore ,
  ResultActions
}
 Custom model roles. More...
 

Public Slots

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

Public Member Functions

 QgsLocatorModel (QObject *parent=nullptr)
 Constructor for QgsLocatorModel.
 
void clear ()
 Resets the model and clears all existing results.
 
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).
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 
QHash< int, QByteArray > roleNames () const override
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 

Static Public Attributes

static const int NoGroup = -1
 
static const int UnorderedGroup = 0
 

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.

Definition at line 41 of file qgslocatormodel.h.

Member Enumeration Documentation

◆ CustomRole

enum class QgsLocatorModel::CustomRole : int
strong

Custom model roles.

Custom model roles.

Note
Prior to QGIS 3.36 this was available as QgsLocatorModel::Role
Since
QGIS 3.36
Enumerator
ResultData 

QgsLocatorResult data.

ResultType 

Result type.

ResultFilterPriority 

Result priority, used by QgsLocatorProxyModel for sorting roles.

ResultScore 

Result match score, used by QgsLocatorProxyModel for sorting roles.

ResultFilterName 

Associated filter name which created the result.

ResultFilterGroupSorting 

Custom value for sorting.

Deprecated:
QGIS 3.40. No longer used.
ResultFilterGroupTitle 

Group title.

ResultFilterGroupScore 

Group score.

ResultActions 

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

Definition at line 59 of file qgslocatormodel.h.

Constructor & Destructor Documentation

◆ QgsLocatorModel()

QgsLocatorModel::QgsLocatorModel ( QObject *  parent = nullptr)

Constructor for QgsLocatorModel.

Definition at line 31 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 212 of file qgslocatormodel.cpp.

◆ clear()

void QgsLocatorModel::clear ( )

Resets the model and clears all existing results.

See also
deferredClear()

Definition at line 39 of file qgslocatormodel.cpp.

◆ columnCount()

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

Definition at line 62 of file qgslocatormodel.cpp.

◆ data()

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

Definition at line 67 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 51 of file qgslocatormodel.cpp.

◆ flags()

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

Definition at line 182 of file qgslocatormodel.cpp.

◆ roleNames()

QHash< int, QByteArray > QgsLocatorModel::roleNames ( ) const
override

Definition at line 196 of file qgslocatormodel.cpp.

◆ rowCount()

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

Definition at line 57 of file qgslocatormodel.cpp.

Member Data Documentation

◆ NoGroup

const int QgsLocatorModel::NoGroup = -1
static

Definition at line 47 of file qgslocatormodel.h.

◆ UnorderedGroup

const int QgsLocatorModel::UnorderedGroup = 0
static

Definition at line 48 of file qgslocatormodel.h.


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