|
QGIS API Documentation 3.99.0-Master (d270888f95f)
|
Abstract class for tree models allowing for configuration of attributes forms. More...
#include <qgsattributesformmodel.h>

Public Types | |
| enum | ItemRoles { ItemDataRole = Qt::UserRole , ItemFieldConfigRole , ItemNameRole , ItemIdRole , ItemTypeRole , ItemDisplayRole } |
| Custom model roles. More... | |
Public Slots | |
| virtual void | populate ()=0 |
| Populates the model with initial data read from the layer. | |
Signals | |
| void | fieldConfigDataChanged (QgsAttributesFormItem *item) |
| Notifies other objects that the field config data has changed in the item. | |
Public Member Functions | |
| QgsAttributesFormModel (QgsVectorLayer *layer, QgsProject *project, QObject *parent=nullptr) | |
| Constructor for QgsAttributesFormModel, with the given parent. | |
| ~QgsAttributesFormModel () override | |
| int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
| QModelIndex | firstRecursiveMatchingModelIndex (const QgsAttributesFormData::AttributesFormItemType &itemType, const QString &itemId) const |
| Returns the first model index that matches the given itemType and itemId, recursively. | |
| QModelIndex | firstTopMatchingModelIndex (const QgsAttributesFormData::AttributesFormItemType &itemType, const QString &itemId) const |
| Returns the first top-level model index that matches the given itemType and itemId. | |
| QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const override |
| QgsAttributesFormItem * | itemForIndex (const QModelIndex &index) const |
| Returns the underlying item that corresponds to the given index. | |
| QModelIndex | parent (const QModelIndex &index) const override |
| QgsAttributesFormItem * | rootItem () const |
| Returns the root item in this model. | |
| int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
| bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override |
| void | setShowAliases (bool show) |
| Sets whether field aliases should be preferred over field names as item text. | |
| bool | showAliases () const |
| Returns whether field aliases are preferred over field names as item text. | |
Protected Member Functions | |
| void | emitDataChangedRecursively (const QModelIndex &parent=QModelIndex(), const QVector< int > &roles=QVector< int >()) |
| Emits dataChanged signal for all parent items in a model. | |
| bool | indexLessThan (const QModelIndex &a, const QModelIndex &b) const |
| Auxiliary function to sort indexes, returning true if index a is less than index b. | |
| QVector< int > | rootToLeafPath (QgsAttributesFormItem *item) const |
| Returns a QVector of iterative positions from root item to the given item. | |
Protected Attributes | |
| QgsVectorLayer * | mLayer |
| QgsProject * | mProject |
| std::unique_ptr< QgsAttributesFormItem > | mRootItem |
| bool | mShowAliases = false |
Abstract class for tree models allowing for configuration of attributes forms.
Definition at line 550 of file qgsattributesformmodel.h.
Custom model roles.
Definition at line 561 of file qgsattributesformmodel.h.
|
explicit |
Constructor for QgsAttributesFormModel, with the given parent.
The given layer and project are data sources to populate the model.
Definition at line 373 of file qgsattributesformmodel.cpp.
|
overridedefault |
|
override |
Definition at line 409 of file qgsattributesformmodel.cpp.
|
protected |
Emits dataChanged signal for all parent items in a model.
In practice, this lets views know that the whole model has changed.
| parent | Model index representing the parent item. |
| roles | List of roles that have changed in the model. |
Definition at line 513 of file qgsattributesformmodel.cpp.
|
signal |
Notifies other objects that the field config data has changed in the item.
| QModelIndex QgsAttributesFormModel::firstRecursiveMatchingModelIndex | ( | const QgsAttributesFormData::AttributesFormItemType & | itemType, |
| const QString & | itemId ) const |
Returns the first model index that matches the given itemType and itemId, recursively.
If there is no matching model index in the whole hierarchy an invalid index is returned.
Definition at line 474 of file qgsattributesformmodel.cpp.
| QModelIndex QgsAttributesFormModel::firstTopMatchingModelIndex | ( | const QgsAttributesFormData::AttributesFormItemType & | itemType, |
| const QString & | itemId ) const |
Returns the first top-level model index that matches the given itemType and itemId.
If there is no matching top-level model index an invalid index is returned.
Definition at line 468 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 440 of file qgsattributesformmodel.cpp.
|
protected |
Auxiliary function to sort indexes, returning true if index a is less than index b.
Regardless of items depth, an index nearer to the root (imagine all items in a top-down flat list) should be returned first when sorting.
For instance, index 0-19-2 (where 0 is the grandparent position and 19 the parent position) will be less than index 1-0.
Definition at line 414 of file qgsattributesformmodel.cpp.
| QgsAttributesFormItem * QgsAttributesFormModel::itemForIndex | ( | const QModelIndex & | index | ) | const |
Returns the underlying item that corresponds to the given index.
If the given index is not valid the root item is returned.
Definition at line 383 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 455 of file qgsattributesformmodel.cpp.
|
pure virtualslot |
Populates the model with initial data read from the layer.
| QgsAttributesFormItem * QgsAttributesFormModel::rootItem | ( | ) | const |
Returns the root item in this model.
Definition at line 393 of file qgsattributesformmodel.cpp.
|
protected |
Returns a QVector of iterative positions from root item to the given item.
Definition at line 430 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 399 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 480 of file qgsattributesformmodel.cpp.
| void QgsAttributesFormModel::setShowAliases | ( | bool | show | ) |
Sets whether field aliases should be preferred over field names as item text.
Definition at line 506 of file qgsattributesformmodel.cpp.
| bool QgsAttributesFormModel::showAliases | ( | ) | const |
Returns whether field aliases are preferred over field names as item text.
Definition at line 501 of file qgsattributesformmodel.cpp.
|
protected |
Definition at line 679 of file qgsattributesformmodel.h.
|
protected |
Definition at line 680 of file qgsattributesformmodel.h.
|
protected |
Definition at line 678 of file qgsattributesformmodel.h.
|
protected |
Definition at line 682 of file qgsattributesformmodel.h.