QGIS API Documentation
3.18.1-Zürich (202f1bf7e5)
|
List Model holding features of specific layer. More...
#include <qgsquickfeatureslistmodel.h>
Public Types | |
enum | modelRoles { FeatureTitle = Qt::UserRole + 1 , FeatureId , Feature , Description , KeyColumn , FoundPair } |
Roles for FeaturesListModel. More... | |
Signals | |
void | currentFeatureChanged (QgsFeature feature) |
Signal emitted when current feature has changed. More... | |
void | featuresCountChanged (int featuresCount) |
featuresCountChanged Signal emitted when features are reloaded or layer is changed More... | |
void | featuresLimitChanged (int featuresLimit) |
Signal emitted when maximum number of features that can be loaded changes. More... | |
void | searchExpressionChanged (QString searchExpression) |
Signal emitted when search expression has changed. More... | |
Public Member Functions | |
QgsQuickFeaturesListModel (QObject *parent=nullptr) | |
Create features list model. More... | |
~QgsQuickFeaturesListModel () override | |
Q_INVOKABLE QVariant | attributeFromValue (const int role, const QVariant &value, const int requestedRole) const |
attributeFromValue finds feature with role and value, returns value for requested role More... | |
Q_INVOKABLE QVariant | convertMultivalueFormat (const QVariant &multivalue, const int requestedRole=Qt::DisplayRole) |
convertMultivalueFormat converts postgres string like string to an array of variants with requested role. More... | |
QgsFeature | currentFeature () const |
Gets current feature property. More... | |
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
Q_INVOKABLE QgsQuickFeatureLayerPair | featureLayerPair (const int &featureId) |
Function to get QgsQuickFeatureLayerPair by feature id. More... | |
int | featuresCount () const |
Returns number of features in layer, not number of loaded features. More... | |
int | featuresLimit () const |
Returns maximum amount of features that can be queried from layer. More... | |
Q_INVOKABLE void | populateFromLayer (QgsVectorLayer *layer) |
populateFromLayer populates model with features from layer More... | |
Q_ENUM (modelRoles) | |
Q_INVOKABLE void | reloadFeatures () |
reloadFeatures reloads features from current layer More... | |
QHash< int, QByteArray > | roleNames () const override |
int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
Q_INVOKABLE int | rowFromAttribute (const int role, const QVariant &value) const |
rowFromAttribute finds feature with requested role and value, returns its row More... | |
QString | searchExpression () const |
Returns search expression. More... | |
void | setCurrentFeature (QgsFeature feature) |
Sets current feature property. More... | |
void | setFeatureTitleField (const QString &attribute) |
setFeatureTitleField Sets name of attribute that will be used for FeatureTitle and Qt::DisplayRole More... | |
void | setFilterExpression (const QString &filterExpression) |
setFilterExpression Sets filter expression for current layer that will be used when querying for data More... | |
void | setKeyField (const QString &attribute) |
Sets name of attribute used as "key" in value relation. More... | |
void | setSearchExpression (const QString &searchExpression) |
setSearchExpression Sets search expression, upon setting also reloads features from current layer with new expression More... | |
Q_INVOKABLE void | setupValueRelation (const QVariantMap &config) |
setupValueRelation populates model with value relation data from config More... | |
Properties | |
QgsFeature | currentFeature |
Feature that has opened feature form. More... | |
int | featuresCount |
Read only property holding true number of features in layer - not only requested features Changing search expression does not result in changing this number. More... | |
int | featuresLimit |
Property limiting maximum number of features queried from layer Read only property. More... | |
QString | searchExpression |
Search expression represents a filter used when querying for data in current layer. More... | |
List Model holding features of specific layer.
Model allows searching by any string or number attribute.
Definition at line 35 of file qgsquickfeatureslistmodel.h.
Roles for FeaturesListModel.
Definition at line 66 of file qgsquickfeatureslistmodel.h.
|
explicit |
Create features list model.
Definition at line 20 of file qgsquickfeatureslistmodel.cpp.
|
overridedefault |
QVariant QgsQuickFeaturesListModel::attributeFromValue | ( | const int | role, |
const QVariant & | value, | ||
const int | requestedRole | ||
) | const |
attributeFromValue finds feature with role and value, returns value for requested role
role | role to find from modelRoles |
value | value to find |
requestedRole | a role whose value is returned |
Definition at line 333 of file qgsquickfeatureslistmodel.cpp.
QVariant QgsQuickFeaturesListModel::convertMultivalueFormat | ( | const QVariant & | multivalue, |
const int | requestedRole = Qt::DisplayRole |
||
) |
convertMultivalueFormat converts postgres string like string to an array of variants with requested role.
Array {1,2,3} with requested role FeatureId results in list of QVariant ints [1, 2, 3]
multivalue | string to convert |
requestedRole | role to convert keys from string, default value is Qt::DisplayRole |
Definition at line 347 of file qgsquickfeatureslistmodel.cpp.
QgsFeature QgsQuickFeaturesListModel::currentFeature | ( | ) | const |
Gets current feature property.
Definition at line 310 of file qgsquickfeatureslistmodel.cpp.
|
signal |
Signal emitted when current feature has changed.
|
override |
Definition at line 60 of file qgsquickfeatureslistmodel.cpp.
QgsQuickFeatureLayerPair QgsQuickFeaturesListModel::featureLayerPair | ( | const int & | featureId | ) |
Function to get QgsQuickFeatureLayerPair by feature id.
Definition at line 362 of file qgsquickfeatureslistmodel.cpp.
int QgsQuickFeaturesListModel::featuresCount | ( | ) | const |
Returns number of features in layer, not number of loaded features.
Definition at line 265 of file qgsquickfeatureslistmodel.cpp.
|
signal |
featuresCountChanged Signal emitted when features are reloaded or layer is changed
featuresCount | number of features in layer, not number of loaded features |
int QgsQuickFeaturesListModel::featuresLimit | ( | ) | const |
Returns maximum amount of features that can be queried from layer.
Definition at line 315 of file qgsquickfeatureslistmodel.cpp.
|
signal |
Signal emitted when maximum number of features that can be loaded changes.
void QgsQuickFeaturesListModel::populateFromLayer | ( | QgsVectorLayer * | layer | ) |
populateFromLayer populates model with features from layer
layer | to be used |
Definition at line 228 of file qgsquickfeatureslistmodel.cpp.
QgsQuickFeaturesListModel::Q_ENUM | ( | modelRoles | ) |
void QgsQuickFeaturesListModel::reloadFeatures | ( | ) |
reloadFeatures reloads features from current layer
Definition at line 237 of file qgsquickfeatureslistmodel.cpp.
|
override |
Definition at line 253 of file qgsquickfeatureslistmodel.cpp.
|
override |
Definition at line 28 of file qgsquickfeatureslistmodel.cpp.
int QgsQuickFeaturesListModel::rowFromAttribute | ( | const int | role, |
const QVariant & | value | ||
) | const |
rowFromAttribute finds feature with requested role and value, returns its row
role | to find from modelRoles |
value | to find |
Definition at line 320 of file qgsquickfeatureslistmodel.cpp.
QString QgsQuickFeaturesListModel::searchExpression | ( | ) | const |
Returns search expression.
Definition at line 272 of file qgsquickfeatureslistmodel.cpp.
|
signal |
Signal emitted when search expression has changed.
void QgsQuickFeaturesListModel::setCurrentFeature | ( | QgsFeature | feature | ) |
Sets current feature property.
Definition at line 300 of file qgsquickfeatureslistmodel.cpp.
void QgsQuickFeaturesListModel::setFeatureTitleField | ( | const QString & | attribute | ) |
setFeatureTitleField Sets name of attribute that will be used for FeatureTitle and Qt::DisplayRole
attribute | Name of attribute to use. If empty, displayExpression will be used. |
Definition at line 285 of file qgsquickfeatureslistmodel.cpp.
void QgsQuickFeaturesListModel::setFilterExpression | ( | const QString & | filterExpression | ) |
setFilterExpression Sets filter expression for current layer that will be used when querying for data
filterExpression | to be set |
Definition at line 295 of file qgsquickfeatureslistmodel.cpp.
void QgsQuickFeaturesListModel::setKeyField | ( | const QString & | attribute | ) |
Sets name of attribute used as "key" in value relation.
Definition at line 290 of file qgsquickfeatureslistmodel.cpp.
void QgsQuickFeaturesListModel::setSearchExpression | ( | const QString & | searchExpression | ) |
setSearchExpression Sets search expression, upon setting also reloads features from current layer with new expression
searchExpression | QString to set, empty string represents no filter |
Definition at line 277 of file qgsquickfeatureslistmodel.cpp.
void QgsQuickFeaturesListModel::setupValueRelation | ( | const QVariantMap & | config | ) |
setupValueRelation populates model with value relation data from config
config | to be used |
Definition at line 204 of file qgsquickfeatureslistmodel.cpp.
|
readwrite |
Feature that has opened feature form.
This property needs to be set before opening feature form to be able to evaulate filter expressions that contain form scope.
Definition at line 1 of file qgsquickfeatureslistmodel.h.
|
read |
Read only property holding true number of features in layer - not only requested features Changing search expression does not result in changing this number.
Definition at line 1 of file qgsquickfeatureslistmodel.h.
|
read |
Property limiting maximum number of features queried from layer Read only property.
Definition at line 1 of file qgsquickfeatureslistmodel.h.
|
readwrite |
Search expression represents a filter used when querying for data in current layer.
Changing this property results in reloading features from current layer with new search expression.
Definition at line 1 of file qgsquickfeatureslistmodel.h.