QGIS API Documentation  3.23.0-Master (eb871beae0)
Public Types | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Properties | Friends | List of all members
QgsFeaturePickerModelBase Class Referenceabstract

Provides a list of features based on filter conditions. More...

#include <qgsfeaturepickermodelbase.h>

Inheritance diagram for QgsFeaturePickerModelBase:
Inheritance graph
[legend]

Public Types

enum  Role {
  IdentifierValueRole = Qt::UserRole , IdentifierValuesRole , ValueRole , FeatureRole ,
  FeatureIdRole
}
 Extra roles that can be used to fetch data from this model. More...
 

Signals

void allowNullChanged ()
 Add a NULL entry to the list. More...
 
void beginUpdate ()
 Notification that the model is about to be changed because a job was completed. More...
 
void currentFeatureChanged ()
 Emitted when the current feature in the model has changed This emitted both when the extra value changes and when the extra value status changes. More...
 
void displayExpressionChanged ()
 The display expression will be used for. More...
 
void endUpdate ()
 Notification that the model change is finished. More...
 
void extraIdentifierValueChanged ()
 Allows specifying one value that does not need to match the filter criteria but will still be available in the model. More...
 
void extraIdentifierValueIndexChanged (int index)
 The index at which the extra identifier value is available within the model. More...
 
void extraValueDoesNotExistChanged ()
 Flag indicating that the extraIdentifierValue does not exist in the data. More...
 
void fetchGeometryChanged ()
 Emitted when the fetching of the geometry changes. More...
 
void fetchLimitChanged ()
 Emitted when the fetching limit for the feature request changes. More...
 
void filterExpressionChanged ()
 An additional filter expression to apply, next to the filterValue. More...
 
void filterJobCompleted ()
 Indicates that a filter job has been completed and new data may be available. More...
 
void filterValueChanged ()
 This value will be used to filter the features available from this model. More...
 
void isLoadingChanged ()
 Indicator if the model is currently performing any feature iteration in the background. More...
 
void sourceLayerChanged ()
 The source layer from which features will be fetched. More...
 

Public Member Functions

 QgsFeaturePickerModelBase (QObject *parent=nullptr)
 Create a new QgsFeaturePickerModelBase, optionally specifying a parent. More...
 
 ~QgsFeaturePickerModelBase () override
 
bool allowNull () const
 Add a NULL entry to the list. More...
 
int columnCount (const QModelIndex &parent) const override
 
QVariant data (const QModelIndex &index, int role) const override
 
QString displayExpression () const
 The display expression will be used for. More...
 
int extraIdentifierValueIndex () const
 The index at which the extra identifier value is available within the model. More...
 
bool extraValueDoesNotExist () const
 Flag indicating that the extraIdentifierValue does not exist in the data. More...
 
bool fetchGeometry () const
 Returns if the geometry is fetched. More...
 
int fetchLimit () const
 Returns the feature request fetch limit. More...
 
QString filterExpression () const
 An additional filter expression to apply, next to the filterValue. More...
 
QString filterValue () const
 This value will be used to filter the features available from this model. More...
 
QModelIndex index (int row, int column, const QModelIndex &parent) const override
 
bool isLoading () const
 Indicator if the model is currently performing any feature iteration in the background. More...
 
QModelIndex parent (const QModelIndex &child) const override
 
int rowCount (const QModelIndex &parent) const override
 
void setAllowNull (bool allowNull)
 Add a NULL entry to the list. More...
 
void setDisplayExpression (const QString &displayExpression)
 The display expression will be used for. More...
 
virtual void setExtraIdentifierValueToNull ()=0
 Allows specifying one value that does not need to match the filter criteria but will still be available in the model as NULL value(s). More...
 
void setFetchGeometry (bool fetchGeometry)
 Defines if the geometry will be fetched. More...
 
void setFetchLimit (int fetchLimit)
 Defines the feature request fetch limit If set to 0, no limit is applied when fetching. More...
 
void setFilterExpression (const QString &filterExpression)
 An additional filter expression to apply, next to the filterValue. More...
 
void setFilterValue (const QString &filterValue)
 This value will be used to filter the features available from this model. More...
 
void setSourceLayer (QgsVectorLayer *sourceLayer)
 The source layer from which features will be fetched. More...
 
QgsVectorLayersourceLayer () const
 The source layer from which features will be fetched. More...
 

Protected Member Functions

virtual bool compareEntries (const QgsFeatureExpressionValuesGatherer::Entry &a, const QgsFeatureExpressionValuesGatherer::Entry &b) const =0
 Returns true if the 2 entries refers to the same feature. More...
 
virtual QgsFeatureExpressionValuesGatherer::Entry createEntry (const QVariant &identifier) const =0
 Creates an entry with just the identifier so the feature can be retrieved in a next iteration. More...
 
virtual QgsFeatureExpressionValuesGatherer * createValuesGatherer (const QgsFeatureRequest &request) const =0
 Creates the value gatherer. More...
 
virtual QVariant entryIdentifier (const QgsFeatureExpressionValuesGatherer::Entry &entry) const =0
 Returns the identifier of the given entry. More...
 
QVariant extraIdentifierValue () const
 Allows specifying one value that does not need to match the filter criteria but will still be available in the model. More...
 
virtual bool identifierIsNull (const QVariant &identifier) const =0
 Returns true if the entry is null The identifier can be either the feature ID or the list of identifier fields. More...
 
virtual QVariant nullIdentifier () const =0
 Returns a null identifier. More...
 
virtual QSet< QString > requestedAttributes () const
 Returns the attributes to be fetched in the request. More...
 
virtual void requestToReloadCurrentFeature (QgsFeatureRequest &request)=0
 Update the request to match the current feature to be reloaded. More...
 
void setExtraIdentifierValue (const QVariant &extraIdentifierValue)
 Allows specifying one value that does not need to match the filter criteria but will still be available in the model. More...
 
void setExtraIdentifierValueUnguarded (const QVariant &identifierValue)
 This will set the identifier value to be set in the model even if it doesn't exist currently in the data. More...
 

Protected Attributes

QVector< QgsFeatureExpressionValuesGatherer::Entry > mEntries
 
QVariant mExtraIdentifierValue
 The current identifier value. More...
 
int mExtraValueIndex = -1
 The current index. More...
 

Properties

bool allowNull
 
QString displayExpression
 
int extraIdentifierValueIndex
 
bool fetchGeometry
 
int fetchLimit
 
QString filterExpression
 
QString filterValue
 
QgsVectorLayersourceLayer
 

Friends

class TestQgsFeatureListComboBox
 

Detailed Description

Provides a list of features based on filter conditions.

Features are fetched asynchronously.

Since
QGIS 3.14

Definition at line 32 of file qgsfeaturepickermodelbase.h.

Member Enumeration Documentation

◆ Role

Extra roles that can be used to fetch data from this model.

Enumerator
IdentifierValueRole 
Deprecated:
Use IdentifierValuesRole instead
IdentifierValuesRole 

Used to retrieve the identifierValues (primary keys) of a feature.

ValueRole 

Used to retrieve the displayExpression of a feature.

FeatureRole 

Used to retrieve the feature, it might be incomplete if the request doesn't fetch all attributes or geometry.

FeatureIdRole 

Used to retrieve the id of a feature.

Definition at line 50 of file qgsfeaturepickermodelbase.h.

Constructor & Destructor Documentation

◆ QgsFeaturePickerModelBase()

QgsFeaturePickerModelBase::QgsFeaturePickerModelBase ( QObject *  parent = nullptr)
explicit

Create a new QgsFeaturePickerModelBase, optionally specifying a parent.

Definition at line 25 of file qgsfeaturepickermodelbase.cpp.

◆ ~QgsFeaturePickerModelBase()

QgsFeaturePickerModelBase::~QgsFeaturePickerModelBase ( )
override

Definition at line 39 of file qgsfeaturepickermodelbase.cpp.

Member Function Documentation

◆ allowNull()

bool QgsFeaturePickerModelBase::allowNull ( ) const

Add a NULL entry to the list.

Definition at line 566 of file qgsfeaturepickermodelbase.cpp.

◆ allowNullChanged

void QgsFeaturePickerModelBase::allowNullChanged ( )
signal

Add a NULL entry to the list.

◆ beginUpdate

void QgsFeaturePickerModelBase::beginUpdate ( )
signal

Notification that the model is about to be changed because a job was completed.

◆ columnCount()

int QgsFeaturePickerModelBase::columnCount ( const QModelIndex &  parent) const
inlineoverride

Definition at line 108 of file qgsfeaturepickermodelbase.h.

◆ compareEntries()

virtual bool QgsFeaturePickerModelBase::compareEntries ( const QgsFeatureExpressionValuesGatherer::Entry &  a,
const QgsFeatureExpressionValuesGatherer::Entry &  b 
) const
protectedpure virtual

Returns true if the 2 entries refers to the same feature.

◆ createEntry()

virtual QgsFeatureExpressionValuesGatherer::Entry QgsFeaturePickerModelBase::createEntry ( const QVariant &  identifier) const
protectedpure virtual

Creates an entry with just the identifier so the feature can be retrieved in a next iteration.

◆ createValuesGatherer()

virtual QgsFeatureExpressionValuesGatherer* QgsFeaturePickerModelBase::createValuesGatherer ( const QgsFeatureRequest request) const
protectedpure virtual

Creates the value gatherer.

◆ currentFeatureChanged

void QgsFeaturePickerModelBase::currentFeatureChanged ( )
signal

Emitted when the current feature in the model has changed This emitted both when the extra value changes and when the extra value status changes.

It allows being notified when the feature is fetched after the extra value has been set.

Since
QGIS 3.16.5

◆ data()

QVariant QgsFeaturePickerModelBase::data ( const QModelIndex &  index,
int  role 
) const
override

Definition at line 153 of file qgsfeaturepickermodelbase.cpp.

◆ displayExpression()

QString QgsFeaturePickerModelBase::displayExpression ( ) const

The display expression will be used for.

  • displaying values in the combobox
  • filtering based on filterValue

Definition at line 69 of file qgsfeaturepickermodelbase.cpp.

◆ displayExpressionChanged

void QgsFeaturePickerModelBase::displayExpressionChanged ( )
signal

The display expression will be used for.

  • displaying values in the combobox
  • filtering based on filterValue

◆ endUpdate

void QgsFeaturePickerModelBase::endUpdate ( )
signal

Notification that the model change is finished.

Will always be emitted in sync with beginUpdate.

◆ entryIdentifier()

virtual QVariant QgsFeaturePickerModelBase::entryIdentifier ( const QgsFeatureExpressionValuesGatherer::Entry &  entry) const
protectedpure virtual

Returns the identifier of the given entry.

◆ extraIdentifierValue()

QVariant QgsFeaturePickerModelBase::extraIdentifierValue ( ) const
protected

Allows specifying one value that does not need to match the filter criteria but will still be available in the model.

Definition at line 125 of file qgsfeaturepickermodelbase.cpp.

◆ extraIdentifierValueChanged

void QgsFeaturePickerModelBase::extraIdentifierValueChanged ( )
signal

Allows specifying one value that does not need to match the filter criteria but will still be available in the model.

◆ extraIdentifierValueIndex()

int QgsFeaturePickerModelBase::extraIdentifierValueIndex ( ) const

The index at which the extra identifier value is available within the model.

Definition at line 628 of file qgsfeaturepickermodelbase.cpp.

◆ extraIdentifierValueIndexChanged

void QgsFeaturePickerModelBase::extraIdentifierValueIndexChanged ( int  index)
signal

The index at which the extra identifier value is available within the model.

◆ extraValueDoesNotExist()

bool QgsFeaturePickerModelBase::extraValueDoesNotExist ( ) const

Flag indicating that the extraIdentifierValue does not exist in the data.

Definition at line 612 of file qgsfeaturepickermodelbase.cpp.

◆ extraValueDoesNotExistChanged

void QgsFeaturePickerModelBase::extraValueDoesNotExistChanged ( )
signal

Flag indicating that the extraIdentifierValue does not exist in the data.

◆ fetchGeometry()

bool QgsFeaturePickerModelBase::fetchGeometry ( ) const

Returns if the geometry is fetched.

Definition at line 583 of file qgsfeaturepickermodelbase.cpp.

◆ fetchGeometryChanged

void QgsFeaturePickerModelBase::fetchGeometryChanged ( )
signal

Emitted when the fetching of the geometry changes.

◆ fetchLimit()

int QgsFeaturePickerModelBase::fetchLimit ( ) const

Returns the feature request fetch limit.

Definition at line 597 of file qgsfeaturepickermodelbase.cpp.

◆ fetchLimitChanged

void QgsFeaturePickerModelBase::fetchLimitChanged ( )
signal

Emitted when the fetching limit for the feature request changes.

◆ filterExpression()

QString QgsFeaturePickerModelBase::filterExpression ( ) const

An additional filter expression to apply, next to the filterValue.

Can be used for spatial filtering etc.

Definition at line 103 of file qgsfeaturepickermodelbase.cpp.

◆ filterExpressionChanged

void QgsFeaturePickerModelBase::filterExpressionChanged ( )
signal

An additional filter expression to apply, next to the filterValue.

Can be used for spatial filtering etc.

◆ filterJobCompleted

void QgsFeaturePickerModelBase::filterJobCompleted ( )
signal

Indicates that a filter job has been completed and new data may be available.

◆ filterValue()

QString QgsFeaturePickerModelBase::filterValue ( ) const

This value will be used to filter the features available from this model.

Whenever a substring of the displayExpression of a feature matches the filter value, it will be accessible by this model.

Definition at line 86 of file qgsfeaturepickermodelbase.cpp.

◆ filterValueChanged

void QgsFeaturePickerModelBase::filterValueChanged ( )
signal

This value will be used to filter the features available from this model.

Whenever a substring of the displayExpression of a feature matches the filter value, it will be accessible by this model.

◆ identifierIsNull()

virtual bool QgsFeaturePickerModelBase::identifierIsNull ( const QVariant &  identifier) const
protectedpure virtual

Returns true if the entry is null The identifier can be either the feature ID or the list of identifier fields.

◆ index()

QModelIndex QgsFeaturePickerModelBase::index ( int  row,
int  column,
const QModelIndex &  parent 
) const
override

Definition at line 131 of file qgsfeaturepickermodelbase.cpp.

◆ isLoading()

bool QgsFeaturePickerModelBase::isLoading ( ) const

Indicator if the model is currently performing any feature iteration in the background.

Definition at line 120 of file qgsfeaturepickermodelbase.cpp.

◆ isLoadingChanged

void QgsFeaturePickerModelBase::isLoadingChanged ( )
signal

Indicator if the model is currently performing any feature iteration in the background.

◆ nullIdentifier()

virtual QVariant QgsFeaturePickerModelBase::nullIdentifier ( ) const
protectedpure virtual

Returns a null identifier.

◆ parent()

QModelIndex QgsFeaturePickerModelBase::parent ( const QModelIndex &  child) const
override

Definition at line 138 of file qgsfeaturepickermodelbase.cpp.

◆ requestedAttributes()

virtual QSet<QString> QgsFeaturePickerModelBase::requestedAttributes ( ) const
inlineprotectedvirtual

Returns the attributes to be fetched in the request.

Returns an empty set if all attributes should be fetched.

Definition at line 297 of file qgsfeaturepickermodelbase.h.

◆ requestToReloadCurrentFeature()

virtual void QgsFeaturePickerModelBase::requestToReloadCurrentFeature ( QgsFeatureRequest request)
protectedpure virtual

Update the request to match the current feature to be reloaded.

◆ rowCount()

int QgsFeaturePickerModelBase::rowCount ( const QModelIndex &  parent) const
override

Definition at line 145 of file qgsfeaturepickermodelbase.cpp.

◆ setAllowNull()

void QgsFeaturePickerModelBase::setAllowNull ( bool  allowNull)

Add a NULL entry to the list.

Definition at line 572 of file qgsfeaturepickermodelbase.cpp.

◆ setDisplayExpression()

void QgsFeaturePickerModelBase::setDisplayExpression ( const QString &  displayExpression)

The display expression will be used for.

  • displaying values in the combobox
  • filtering based on filterValue

Definition at line 75 of file qgsfeaturepickermodelbase.cpp.

◆ setExtraIdentifierValue()

void QgsFeaturePickerModelBase::setExtraIdentifierValue ( const QVariant &  extraIdentifierValue)
protected

Allows specifying one value that does not need to match the filter criteria but will still be available in the model.

Definition at line 640 of file qgsfeaturepickermodelbase.cpp.

◆ setExtraIdentifierValueToNull()

virtual void QgsFeaturePickerModelBase::setExtraIdentifierValueToNull ( )
pure virtual

Allows specifying one value that does not need to match the filter criteria but will still be available in the model as NULL value(s).

Implemented in QgsFeaturePickerModel, and QgsFeatureFilterModel.

◆ setExtraIdentifierValueUnguarded()

void QgsFeaturePickerModelBase::setExtraIdentifierValueUnguarded ( const QVariant &  identifierValue)
protected

This will set the identifier value to be set in the model even if it doesn't exist currently in the data.

Definition at line 495 of file qgsfeaturepickermodelbase.cpp.

◆ setFetchGeometry()

void QgsFeaturePickerModelBase::setFetchGeometry ( bool  fetchGeometry)

Defines if the geometry will be fetched.

Definition at line 588 of file qgsfeaturepickermodelbase.cpp.

◆ setFetchLimit()

void QgsFeaturePickerModelBase::setFetchLimit ( int  fetchLimit)

Defines the feature request fetch limit If set to 0, no limit is applied when fetching.

Definition at line 602 of file qgsfeaturepickermodelbase.cpp.

◆ setFilterExpression()

void QgsFeaturePickerModelBase::setFilterExpression ( const QString &  filterExpression)

An additional filter expression to apply, next to the filterValue.

Can be used for spatial filtering etc.

Definition at line 109 of file qgsfeaturepickermodelbase.cpp.

◆ setFilterValue()

void QgsFeaturePickerModelBase::setFilterValue ( const QString &  filterValue)

This value will be used to filter the features available from this model.

Whenever a substring of the displayExpression of a feature matches the filter value, it will be accessible by this model.

Definition at line 92 of file qgsfeaturepickermodelbase.cpp.

◆ setSourceLayer()

void QgsFeaturePickerModelBase::setSourceLayer ( QgsVectorLayer sourceLayer)

The source layer from which features will be fetched.

Definition at line 52 of file qgsfeaturepickermodelbase.cpp.

◆ sourceLayer()

QgsVectorLayer * QgsFeaturePickerModelBase::sourceLayer ( ) const

The source layer from which features will be fetched.

Definition at line 46 of file qgsfeaturepickermodelbase.cpp.

◆ sourceLayerChanged

void QgsFeaturePickerModelBase::sourceLayerChanged ( )
signal

The source layer from which features will be fetched.

Friends And Related Function Documentation

◆ TestQgsFeatureListComboBox

friend class TestQgsFeatureListComboBox
friend

Definition at line 357 of file qgsfeaturepickermodelbase.h.

Member Data Documentation

◆ mEntries

QVector<QgsFeatureExpressionValuesGatherer::Entry> QgsFeaturePickerModelBase::mEntries
protected

Definition at line 320 of file qgsfeaturepickermodelbase.h.

◆ mExtraIdentifierValue

QVariant QgsFeaturePickerModelBase::mExtraIdentifierValue
protected

The current identifier value.

Definition at line 324 of file qgsfeaturepickermodelbase.h.

◆ mExtraValueIndex

int QgsFeaturePickerModelBase::mExtraValueIndex = -1
protected

The current index.

Definition at line 327 of file qgsfeaturepickermodelbase.h.

Property Documentation

◆ allowNull

bool QgsFeaturePickerModelBase::allowNull
readwrite

Definition at line 1 of file qgsfeaturepickermodelbase.h.

◆ displayExpression

QString QgsFeaturePickerModelBase::displayExpression
readwrite

Definition at line 1 of file qgsfeaturepickermodelbase.h.

◆ extraIdentifierValueIndex

int QgsFeaturePickerModelBase::extraIdentifierValueIndex
read

Definition at line 1 of file qgsfeaturepickermodelbase.h.

◆ fetchGeometry

bool QgsFeaturePickerModelBase::fetchGeometry
readwrite

Definition at line 1 of file qgsfeaturepickermodelbase.h.

◆ fetchLimit

int QgsFeaturePickerModelBase::fetchLimit
readwrite

Definition at line 1 of file qgsfeaturepickermodelbase.h.

◆ filterExpression

QString QgsFeaturePickerModelBase::filterExpression
readwrite

Definition at line 1 of file qgsfeaturepickermodelbase.h.

◆ filterValue

QString QgsFeaturePickerModelBase::filterValue
readwrite

Definition at line 1 of file qgsfeaturepickermodelbase.h.

◆ sourceLayer

QgsVectorLayer * QgsFeaturePickerModelBase::sourceLayer
readwrite

Definition at line 1 of file qgsfeaturepickermodelbase.h.


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