Class FeatureModel
Inherits the following classes: QAbstractListModel
Classes
| Type | Name |
|---|---|
| struct | RememberValues keeping the information what attributes are remembered and the last edited feature |
Public Types
| Type | Name |
|---|---|
| enum | FeatureRoles |
| enum | ModelModes |
Public Slots
| Type | Name |
|---|---|
| slot void | removeLayer (QObject * layer) |
Public Properties
| Type | Name |
|---|---|
| property AppExpressionContextScopesGenerator * | appExpressionContextScopesGenerator |
| property bool | attributeEditingLocked |
| property bool | batchMode |
| property QgsVectorLayer * | currentLayer |
| property QgsFeature | feature |
| property bool | featureAdditionLocked |
| property bool | featureDeletionLocked |
| property QList< QgsFeature > | features |
| property Geometry * | geometry |
| property bool | geometryEditingLocked |
| property QgsFeature | linkedParentFeature |
| property QgsRelation | linkedRelation |
| property QString | linkedRelationOrderingField |
| property FeatureModel::ModelModes | modelMode |
| property QgsProject * | project |
| property SnappingResult | topSnappingResult |
| property VertexModel * | vertexModel |
Public Signals
| Type | Name |
|---|---|
| signal void | appExpressionContextScopesGeneratorChanged |
| signal void | attributeEditingLockedChanged |
| signal void | batchModeChanged |
| signal void | currentLayerChanged |
| signal void | featureAdditionLockedChanged |
| signal void | featureChanged Emitted when the model's single feature has been changed. |
| signal void | featureDeletionLockedChanged |
| signal void | featureUpdated Emitted when the model's feature has been saved (i.e. updated) but not changed as a result. |
| signal void | featuresChanged Emitted when the model's multi features list has been changed. |
| signal void | geometryChanged |
| signal void | geometryEditingLockedChanged |
| signal void | linkedParentFeatureChanged |
| signal void | linkedRelationChanged |
| signal void | linkedRelationOrderingFieldChanged |
| signal void | modelModeChanged |
| signal void | projectChanged |
| signal void | topSnappingResultChanged |
| signal void | vertexModelChanged |
| signal void | warning (const QString & text) |
Public Functions
| Type | Name |
|---|---|
| FeatureModel (QObject * parent=nullptr) |
|
| AppExpressionContextScopesGenerator * | appExpressionContextScopesGenerator () const |
| Q_INVOKABLE void | applyGeometry (bool fromVertexModel=false) |
| Q_INVOKABLE void | applyGeometryToVertexModel () Apply the feature geometry to a vertex model if present. |
| bool | attributeEditingLocked () const |
| bool | batchMode () const |
| Q_INVOKABLE bool | create () |
| QgsExpressionContext | createExpressionContext () const |
| QVariant | data (const QModelIndex & index, int role) override const |
| Q_INVOKABLE bool | deleteFeature () |
| QgsFeature | feature () const |
| bool | featureAdditionLocked () const |
| bool | featureDeletionLocked () const |
| QList< QgsFeature > | features () const |
| Geometry * | geometry () Returns the geometry object that will drive the feature geometry. |
| bool | geometryEditingLocked () const |
| QgsVectorLayer * | layer () const |
| QgsFeature | linkedParentFeature () const |
| QgsRelation | linkedRelation () const |
| QString | linkedRelationOrderingField () const |
| ModelModes | modelMode () const |
| bool | positionLocked () const |
| QgsProject * | project () const Returns the current project from which the digitizing logs will be sought. |
| Q_INVOKABLE void | refresh () |
| QVector< bool > | rememberedAttributes () const |
| Q_INVOKABLE void | reset () |
| Q_INVOKABLE void | resetAttributes (bool partialReset=false) |
| Q_INVOKABLE void | resetFeature () |
| Q_INVOKABLE void | resetFeatureId () |
| QHash< int, QByteArray > | roleNames () override const |
| int | rowCount (const QModelIndex & parent) override const |
| Q_INVOKABLE bool | save () |
| void | setAppExpressionContextScopesGenerator (AppExpressionContextScopesGenerator * generator) |
| void | setBatchMode (bool batchMode) |
| void | setCurrentLayer (QgsVectorLayer * layer) |
| bool | setData (const QModelIndex & index, const QVariant & value, int role=Qt::EditRole) override |
| void | setFeature (const QgsFeature & feature) |
| void | setFeatures (const QList< QgsFeature > & features) |
| void | setGeometry (Geometry * geometry) Sets the geometry object that will drive the feature geometry. |
| void | setLinkedParentFeature (const QgsFeature & feature) |
| void | setLinkedRelation (const QgsRelation & relation) |
| void | setLinkedRelationOrderingField (const QString & orderingField) |
| void | setModelMode (const ModelModes mode) |
| void | setPositionLocked (bool positionLocked) |
| void | setProject (QgsProject * project) Sets the project used to find the digitizing logs layer. |
| void | setTopSnappingResult (const SnappingResult & topSnappingResult) |
| void | setVertexModel (VertexModel * model) Sets the vertex model is used to highlight vertices on the map. |
| Q_INVOKABLE bool | suppressFeatureForm () const |
| SnappingResult | topSnappingResult () const |
| Q_INVOKABLE bool | updateAttributesFromFeature (const QgsFeature & feature) |
| Q_INVOKABLE void | updateRubberband () const Update the linked geometry rubber band to match the feature's geometry. |
| VertexModel * | vertexModel () Returns the vertex model is used to highlight vertices on the map. |
Public Types Documentation
enum FeatureRoles
enum FeatureModel::FeatureRoles {
AttributeName = Qt::UserRole + 1,
AttributeValue,
Field,
RememberAttribute,
LinkedAttribute,
AttributeAllowEdit
};
enum ModelModes
enum FeatureModel::ModelModes {
SingleFeatureModel = 1,
MultiFeatureModel
};
Public Properties Documentation
property appExpressionContextScopesGenerator [1/2]
AppExpressionContextScopesGenerator * FeatureModel::appExpressionContextScopesGenerator;
property attributeEditingLocked [1/2]
bool FeatureModel::attributeEditingLocked;
property batchMode [1/2]
bool FeatureModel::batchMode;
property currentLayer
QgsVectorLayer * FeatureModel::currentLayer;
property feature [1/2]
QgsFeature FeatureModel::feature;
property featureAdditionLocked [1/2]
bool FeatureModel::featureAdditionLocked;
property featureDeletionLocked [1/2]
bool FeatureModel::featureDeletionLocked;
property features [1/2]
QList<QgsFeature> FeatureModel::features;
property geometry [1/2]
Geometry * FeatureModel::geometry;
property geometryEditingLocked [1/2]
bool FeatureModel::geometryEditingLocked;
property linkedParentFeature [1/2]
QgsFeature FeatureModel::linkedParentFeature;
property linkedRelation [1/2]
QgsRelation FeatureModel::linkedRelation;
property linkedRelationOrderingField [1/2]
QString FeatureModel::linkedRelationOrderingField;
property modelMode [1/2]
FeatureModel::ModelModes FeatureModel::modelMode;
property project [1/2]
QgsProject * FeatureModel::project;
property topSnappingResult [1/2]
SnappingResult FeatureModel::topSnappingResult;
property vertexModel [1/2]
VertexModel * FeatureModel::vertexModel;
Public Slots Documentation
slot removeLayer
void FeatureModel::removeLayer;
Public Signals Documentation
signal appExpressionContextScopesGeneratorChanged
void FeatureModel::appExpressionContextScopesGeneratorChanged;
signal attributeEditingLockedChanged
void FeatureModel::attributeEditingLockedChanged;
signal batchModeChanged
void FeatureModel::batchModeChanged;
signal currentLayerChanged
void FeatureModel::currentLayerChanged;
signal featureAdditionLockedChanged
void FeatureModel::featureAdditionLockedChanged;
signal featureChanged
Emitted when the model's single feature has been changed.
void FeatureModel::featureChanged;
signal featureDeletionLockedChanged
void FeatureModel::featureDeletionLockedChanged;
signal featureUpdated
Emitted when the model's feature has been saved (i.e. updated) but not changed as a result.
void FeatureModel::featureUpdated;
signal featuresChanged
Emitted when the model's multi features list has been changed.
void FeatureModel::featuresChanged;
signal geometryChanged
void FeatureModel::geometryChanged;
signal geometryEditingLockedChanged
void FeatureModel::geometryEditingLockedChanged;
signal linkedParentFeatureChanged
void FeatureModel::linkedParentFeatureChanged;
signal linkedRelationChanged
void FeatureModel::linkedRelationChanged;
signal linkedRelationOrderingFieldChanged
void FeatureModel::linkedRelationOrderingFieldChanged;
signal modelModeChanged
void FeatureModel::modelModeChanged;
signal projectChanged
void FeatureModel::projectChanged;
signal topSnappingResultChanged
void FeatureModel::topSnappingResultChanged;
signal vertexModelChanged
void FeatureModel::vertexModelChanged;
signal warning
void FeatureModel::warning;
Public Functions Documentation
function FeatureModel
explicit FeatureModel::FeatureModel (
QObject * parent=nullptr
)
function appExpressionContextScopesGenerator [2/2]
AppExpressionContextScopesGenerator * FeatureModel::appExpressionContextScopesGenerator () const
Returns the application expression context scopes generator object
function applyGeometry
Q_INVOKABLE void FeatureModel::applyGeometry (
bool fromVertexModel=false
)
Apply the geometry object or vertex model object's geometry to the feature geometry.
Parameters:
fromVertexModelset to TRUE to use the vertex model
function applyGeometryToVertexModel
Apply the feature geometry to a vertex model if present.
Q_INVOKABLE void FeatureModel::applyGeometryToVertexModel ()
function attributeEditingLocked [2/2]
inline bool FeatureModel::attributeEditingLocked () const
function batchMode [2/2]
inline bool FeatureModel::batchMode () const
Returns TRUE if the feature model is in batch mode. When enabled, the vector layer will remain in editing mode until batch mode is disabled.
function create
Q_INVOKABLE bool FeatureModel::create ()
Will create this feature as a new feature on the data source.
function createExpressionContext
QgsExpressionContext FeatureModel::createExpressionContext () const
function data
QVariant FeatureModel::data (
const QModelIndex & index,
int role
) override const
function deleteFeature
Q_INVOKABLE bool FeatureModel::deleteFeature ()
Deletes the current feature from the data source.
function feature [2/2]
QgsFeature FeatureModel::feature () const
Return the feature wrapped in a QVariant for passing it around in QML
function featureAdditionLocked [2/2]
inline bool FeatureModel::featureAdditionLocked () const
function featureDeletionLocked [2/2]
inline bool FeatureModel::featureDeletionLocked () const
function features [2/2]
QList< QgsFeature > FeatureModel::features () const
Return the features list for passing it around in QML
function geometry [2/2]
Returns the geometry object that will drive the feature geometry.
Geometry * FeatureModel::geometry ()
function geometryEditingLocked [2/2]
inline bool FeatureModel::geometryEditingLocked () const
function layer
QgsVectorLayer * FeatureModel::layer () const
function linkedParentFeature [2/2]
QgsFeature FeatureModel::linkedParentFeature () const
A linked feature is a parent feature of a relation passing it's pk(s) to the created child features fk(s)
Returns:
the parent feature linked to this feature
See also: setLinkedParentFeature
function linkedRelation [2/2]
QgsRelation FeatureModel::linkedRelation () const
The relation connecting this feature to the parent, over which this feature has been loaded (e.g. over relation editor widget)
Returns:
the relation connecting the parent
See also: setLinkedRelation
function linkedRelationOrderingField [2/2]
QString FeatureModel::linkedRelationOrderingField () const
Returns the field name used for ordering in ordered relations. Empty string if not available.
See also: setLinkedRelationOrderingField
function modelMode [2/2]
ModelModes FeatureModel::modelMode () const
function positionLocked
bool FeatureModel::positionLocked () const
Returns whether the position is locked to the GNSS
function project [2/2]
Returns the current project from which the digitizing logs will be sought.
inline QgsProject * FeatureModel::project () const
function refresh
Q_INVOKABLE void FeatureModel::refresh ()
Will refresh the feature values and geometry from the data source.
function rememberedAttributes
QVector< bool > FeatureModel::rememberedAttributes () const
function reset
Q_INVOKABLE void FeatureModel::reset ()
Will reset the feature to the original values and dismiss any buffered edits.
function resetAttributes
Q_INVOKABLE void FeatureModel::resetAttributes (
bool partialReset=false
)
Resets the attribute values of the current feature
Parameters:
partialResetwhen set to TRUE, only attributes with default or remembered values will be reset
function resetFeature
Q_INVOKABLE void FeatureModel::resetFeature ()
function resetFeatureId
Q_INVOKABLE void FeatureModel::resetFeatureId ()
function roleNames
QHash< int, QByteArray > FeatureModel::roleNames () override const
function rowCount
int FeatureModel::rowCount (
const QModelIndex & parent
) override const
function save
Q_INVOKABLE bool FeatureModel::save ()
Will commit the edit buffer of this layer. May change in the future to only commit the changes buffered in this model.
Returns:
Success of the operation
function setAppExpressionContextScopesGenerator
void FeatureModel::setAppExpressionContextScopesGenerator (
AppExpressionContextScopesGenerator * generator
)
Sets the application expression context scopes generator object
function setBatchMode
void FeatureModel::setBatchMode (
bool batchMode
)
Toggles the feature model batch mode. When enabled, the vector layer will remain in editing mode until batch mode is disabled.
function setCurrentLayer
void FeatureModel::setCurrentLayer (
QgsVectorLayer * layer
)
function setData
bool FeatureModel::setData (
const QModelIndex & index,
const QVariant & value,
int role=Qt::EditRole
) override
function setFeature
void FeatureModel::setFeature (
const QgsFeature & feature
)
function setFeatures
void FeatureModel::setFeatures (
const QList< QgsFeature > & features
)
function setGeometry
Sets the geometry object that will drive the feature geometry.
void FeatureModel::setGeometry (
Geometry * geometry
)
function setLinkedParentFeature
void FeatureModel::setLinkedParentFeature (
const QgsFeature & feature
)
A linked feature is a parent feature of a relation passing it's pk(s) to the created child features fk(s) The fk fields are evaluated over the linked relation.
Parameters:
feature
See also: linkedParentFeature
function setLinkedRelation
void FeatureModel::setLinkedRelation (
const QgsRelation & relation
)
The relation connecting this feature to the parent, over which this feature has been loaded (e.g. over relation editor widget) The relation is userd to evaluate the parents pk(s) and the childs fk(s)
Parameters:
relation
See also: linkedRelation
function setLinkedRelationOrderingField
void FeatureModel::setLinkedRelationOrderingField (
const QString & orderingField
)
Sets the field name used for ordering in ordered relations. Empty string if not available.
See also: linkedRelationOrderingField
function setModelMode
void FeatureModel::setModelMode (
const ModelModes mode
)
function setPositionLocked
void FeatureModel::setPositionLocked (
bool positionLocked
)
Sets whether the position is locked to the GNSS
function setProject
Sets the project used to find the digitizing logs layer.
void FeatureModel::setProject (
QgsProject * project
)
function setTopSnappingResult
void FeatureModel::setTopSnappingResult (
const SnappingResult & topSnappingResult
)
Sets the top snapping result of the coordinate locator
Parameters:
topSnappingResultthe top snapping result object
function setVertexModel
Sets the vertex model is used to highlight vertices on the map.
void FeatureModel::setVertexModel (
VertexModel * model
)
function suppressFeatureForm
Q_INVOKABLE bool FeatureModel::suppressFeatureForm () const
Returns whether the feature form should be suppressed when adding new features.
function topSnappingResult [2/2]
SnappingResult FeatureModel::topSnappingResult () const
Returns the top snapping result of the coordinate locator
function updateAttributesFromFeature
Q_INVOKABLE bool FeatureModel::updateAttributesFromFeature (
const QgsFeature & feature
)
Update attributes to match that of a given feature
Parameters:
featurefeature from which attributes will be taken
Returns:
TRUE if one or more attribute was updated
function updateRubberband
Update the linked geometry rubber band to match the feature's geometry.
Q_INVOKABLE void FeatureModel::updateRubberband () const
function vertexModel [2/2]
Returns the vertex model is used to highlight vertices on the map.
VertexModel * FeatureModel::vertexModel ()
The documentation for this class was generated from the following file src/core/featuremodel.h