QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
QgsFeatureListModel Class Reference

A proxy model for feature lists. More...

#include <qgsfeaturelistmodel.h>

Inheritance diagram for QgsFeatureListModel:

Classes

struct  FeatureInfo

Public Types

enum  Role { FeatureInfoRole = 0x1000 , FeatureRole , FeatureWithGeometryRole }

Public Slots

Q_DECL_DEPRECATED void onBeginInsertRows (const QModelIndex &parent, int first, int last)
 Does nothing except for calling beginInsertRows().
Q_DECL_DEPRECATED void onBeginRemoveRows (const QModelIndex &parent, int first, int last)
 Does nothing except for calling beginRemoveRows().
Q_DECL_DEPRECATED void onEndInsertRows (const QModelIndex &parent, int first, int last)
 Does nothing except for calling endInsertRows().
Q_DECL_DEPRECATED void onEndRemoveRows (const QModelIndex &parent, int first, int last)
 Does nothing except for calling endRemoveRows().

Public Member Functions

 QgsFeatureListModel (QgsAttributeTableFilterModel *sourceModel, QObject *parent=nullptr)
 Constructor for QgsFeatureListModel.
int columnCount (const QModelIndex &parent=QModelIndex()) const override
QVariant data (const QModelIndex &index, int role) const override
QString displayExpression () const
bool featureByIndex (const QModelIndex &index, QgsFeature &feat)
QModelIndex fidToIdx (QgsFeatureId fid) const
 Returns the model index corresponding to a feature ID.
QModelIndex fidToIndex (QgsFeatureId fid) override
QModelIndexList fidToIndexList (QgsFeatureId fid)
Qt::ItemFlags flags (const QModelIndex &index) const override
QgsFeatureId idxToFid (const QModelIndex &index) const
 Returns the feature ID corresponding to an index from the model.
bool injectNull ()
 Returns the current state of null value injection.
QgsVectorLayerCachelayerCache ()
 Returns the vector layer cache which is being used to populate the model.
virtual QModelIndex mapFromMaster (const QModelIndex &sourceIndex) const
QModelIndex mapFromSource (const QModelIndex &sourceIndex) const override
virtual QItemSelection mapSelectionFromMaster (const QItemSelection &selection) const
virtual QItemSelection mapSelectionToMaster (const QItemSelection &selection) const
virtual QModelIndex mapToMaster (const QModelIndex &proxyIndex) const
QModelIndex mapToSource (const QModelIndex &proxyIndex) const override
QgsAttributeTableModelmasterModel ()
QModelIndex parent (const QModelIndex &child) const override
QString parserErrorString ()
 Returns a detailed message about errors while parsing a QgsExpression.
int rowCount (const QModelIndex &parent=QModelIndex()) const override
bool setDisplayExpression (const QString &expression)
 Sets the display expression.
void setInjectNull (bool injectNull)
 If true is specified, a NULL value will be injected.
void setSortByDisplayExpression (bool sortByDisplayExpression, Qt::SortOrder order=Qt::AscendingOrder)
 Sort this model by its display expression.
virtual void setSourceModel (QgsAttributeTableFilterModel *sourceModel)
bool sortByDisplayExpression () const
 Sort this model by its display expression.
Public Member Functions inherited from QgsFeatureModel
virtual ~QgsFeatureModel ()=default

Detailed Description

A proxy model for feature lists.

Definition at line 41 of file qgsfeaturelistmodel.h.

Member Enumeration Documentation

◆ Role

Enumerator
FeatureInfoRole 
FeatureRole 

Feature with all attributes and no geometry.

FeatureWithGeometryRole 

Feature with all attributes and geometry,.

Since
QGIS 3.42

Definition at line 58 of file qgsfeaturelistmodel.h.

Constructor & Destructor Documentation

◆ QgsFeatureListModel()

QgsFeatureListModel::QgsFeatureListModel ( QgsAttributeTableFilterModel * sourceModel,
QObject * parent = nullptr )
explicit

Constructor for QgsFeatureListModel.

Definition at line 30 of file qgsfeaturelistmodel.cpp.

Member Function Documentation

◆ columnCount()

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

Definition at line 415 of file qgsfeaturelistmodel.cpp.

◆ data()

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

Definition at line 64 of file qgsfeaturelistmodel.cpp.

◆ displayExpression()

QString QgsFeatureListModel::displayExpression ( ) const

Definition at line 251 of file qgsfeaturelistmodel.cpp.

◆ featureByIndex()

bool QgsFeatureListModel::featureByIndex ( const QModelIndex & index,
QgsFeature & feat )

Definition at line 256 of file qgsfeaturelistmodel.cpp.

◆ fidToIdx()

QModelIndex QgsFeatureListModel::fidToIdx ( QgsFeatureId fid) const

Returns the model index corresponding to a feature ID.

See also
idxToFid()

Definition at line 59 of file qgsfeaturelistmodel.cpp.

◆ fidToIndex()

QModelIndex QgsFeatureListModel::fidToIndex ( QgsFeatureId fid)
overridevirtual

Implements QgsFeatureModel.

Definition at line 430 of file qgsfeaturelistmodel.cpp.

◆ fidToIndexList()

QModelIndexList QgsFeatureListModel::fidToIndexList ( QgsFeatureId fid)

Definition at line 435 of file qgsfeaturelistmodel.cpp.

◆ flags()

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

Definition at line 186 of file qgsfeaturelistmodel.cpp.

◆ idxToFid()

QgsFeatureId QgsFeatureListModel::idxToFid ( const QModelIndex & index) const

Returns the feature ID corresponding to an index from the model.

See also
fidToIdx()

Definition at line 54 of file qgsfeaturelistmodel.cpp.

◆ injectNull()

bool QgsFeatureListModel::injectNull ( )

Returns the current state of null value injection.

Returns
If a NULL value is added

Definition at line 211 of file qgsfeaturelistmodel.cpp.

◆ layerCache()

QgsVectorLayerCache * QgsFeatureListModel::layerCache ( )

Returns the vector layer cache which is being used to populate the model.

Definition at line 49 of file qgsfeaturelistmodel.cpp.

◆ mapFromMaster()

QModelIndex QgsFeatureListModel::mapFromMaster ( const QModelIndex & sourceIndex) const
virtual

Definition at line 338 of file qgsfeaturelistmodel.cpp.

◆ mapFromSource()

QModelIndex QgsFeatureListModel::mapFromSource ( const QModelIndex & sourceIndex) const
override

Definition at line 392 of file qgsfeaturelistmodel.cpp.

◆ mapSelectionFromMaster()

QItemSelection QgsFeatureListModel::mapSelectionFromMaster ( const QItemSelection & selection) const
virtual

Definition at line 359 of file qgsfeaturelistmodel.cpp.

◆ mapSelectionToMaster()

QItemSelection QgsFeatureListModel::mapSelectionToMaster ( const QItemSelection & selection) const
virtual

Definition at line 364 of file qgsfeaturelistmodel.cpp.

◆ mapToMaster()

QModelIndex QgsFeatureListModel::mapToMaster ( const QModelIndex & proxyIndex) const
virtual

Definition at line 318 of file qgsfeaturelistmodel.cpp.

◆ mapToSource()

QModelIndex QgsFeatureListModel::mapToSource ( const QModelIndex & proxyIndex) const
override

Definition at line 371 of file qgsfeaturelistmodel.cpp.

◆ masterModel()

QgsAttributeTableModel * QgsFeatureListModel::masterModel ( )

Definition at line 216 of file qgsfeaturelistmodel.cpp.

◆ onBeginInsertRows

void QgsFeatureListModel::onBeginInsertRows ( const QModelIndex & parent,
int first,
int last )
slot

Does nothing except for calling beginInsertRows().

Deprecated
QGIS 3.40. Use beginInsertRows() instead.

Definition at line 274 of file qgsfeaturelistmodel.cpp.

◆ onBeginRemoveRows

void QgsFeatureListModel::onBeginRemoveRows ( const QModelIndex & parent,
int first,
int last )
slot

Does nothing except for calling beginRemoveRows().

Deprecated
QGIS 3.40. Use beginRemoveRows() instead.

Definition at line 261 of file qgsfeaturelistmodel.cpp.

◆ onEndInsertRows

void QgsFeatureListModel::onEndInsertRows ( const QModelIndex & parent,
int first,
int last )
slot

Does nothing except for calling endInsertRows().

Deprecated
QGIS 3.40. Use endInsertRows() instead.

Definition at line 279 of file qgsfeaturelistmodel.cpp.

◆ onEndRemoveRows

void QgsFeatureListModel::onEndRemoveRows ( const QModelIndex & parent,
int first,
int last )
slot

Does nothing except for calling endRemoveRows().

Deprecated
QGIS 3.40. Use endRemoveRows() instead.

Definition at line 266 of file qgsfeaturelistmodel.cpp.

◆ parent()

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

Definition at line 409 of file qgsfeaturelistmodel.cpp.

◆ parserErrorString()

QString QgsFeatureListModel::parserErrorString ( )

Returns a detailed message about errors while parsing a QgsExpression.

Returns
A message containing information about the parser error.

Definition at line 246 of file qgsfeaturelistmodel.cpp.

◆ rowCount()

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

Definition at line 421 of file qgsfeaturelistmodel.cpp.

◆ setDisplayExpression()

bool QgsFeatureListModel::setDisplayExpression ( const QString & expression)

Sets the display expression.

Parameters
expressionA QgsExpression compatible string.
Returns
true if the expression could be set, false if there was a parse error. If it fails, the old expression will still be applied. Call parserErrorString() for a meaningful error message.

Definition at line 221 of file qgsfeaturelistmodel.cpp.

◆ setInjectNull()

void QgsFeatureListModel::setInjectNull ( bool injectNull)

If true is specified, a NULL value will be injected.

Parameters
injectNullstate of null value injection
Note
If set to true, the sort by display expression cannot be used

Definition at line 198 of file qgsfeaturelistmodel.cpp.

◆ setSortByDisplayExpression()

void QgsFeatureListModel::setSortByDisplayExpression ( bool sortByDisplayExpression,
Qt::SortOrder order = Qt::AscendingOrder )

Sort this model by its display expression.

Note
Not compatible with injectNull, if sorting by display expression is enabled, injectNull will automatically turned off.
Since
QGIS 3.2

Definition at line 298 of file qgsfeaturelistmodel.cpp.

◆ setSourceModel()

void QgsFeatureListModel::setSourceModel ( QgsAttributeTableFilterModel * sourceModel)
virtual

Definition at line 36 of file qgsfeaturelistmodel.cpp.

◆ sortByDisplayExpression()

bool QgsFeatureListModel::sortByDisplayExpression ( ) const

Sort this model by its display expression.

Since
QGIS 3.2

Definition at line 293 of file qgsfeaturelistmodel.cpp.


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