|
QGIS API Documentation 4.3.0-Master (9ff14a2eeba)
|
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. | |
Static Protected Member Functions | |
| static QIcon | iconForItemType (QgsAttributesFormData::AttributesFormItemType itemType) |
| Returns the icon used for items of the given itemType, both in the available widgets tree and in the form layout tree. | |
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 572 of file qgsattributesformmodel.h.
Custom model roles.
Definition at line 583 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 391 of file qgsattributesformmodel.cpp.
|
overridedefault |
|
override |
Definition at line 426 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 528 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 489 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 483 of file qgsattributesformmodel.cpp.
|
staticprotected |
Returns the icon used for items of the given itemType, both in the available widgets tree and in the form layout tree.
An invalid icon is returned for item types without a fixed icon (e.g., fields, whose icon depends on their editor widget type).
Definition at line 541 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 457 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 431 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 400 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 472 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 410 of file qgsattributesformmodel.cpp.
|
protected |
Returns a QVector of iterative positions from root item to the given item.
Definition at line 447 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 416 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 495 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 521 of file qgsattributesformmodel.cpp.
| bool QgsAttributesFormModel::showAliases | ( | ) | const |
Returns whether field aliases are preferred over field names as item text.
Definition at line 516 of file qgsattributesformmodel.cpp.
|
protected |
Definition at line 712 of file qgsattributesformmodel.h.
|
protected |
Definition at line 713 of file qgsattributesformmodel.h.
|
protected |
Definition at line 711 of file qgsattributesformmodel.h.
|
protected |
Definition at line 715 of file qgsattributesformmodel.h.