QGIS API Documentation 3.43.0-Master (56aa1fd18d7)
|
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. | |
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 |
QModelIndex | parent (const QModelIndex &index) const override |
int | rowCount (const QModelIndex &parent=QModelIndex()) const 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 | |
bool | indexLessThan (const QModelIndex &a, const QModelIndex &b) const |
Auxiliary function to sort indexes, returning true if index a is less than index b. | |
QgsAttributesFormItem * | itemForIndex (const QModelIndex &index) const |
Returns the underlying item that corresponds to the given index. | |
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 531 of file qgsattributesformmodel.h.
Custom model roles.
Definition at line 542 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 351 of file qgsattributesformmodel.cpp.
|
overridedefault |
|
override |
Definition at line 381 of file qgsattributesformmodel.cpp.
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 446 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 440 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 412 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 386 of file qgsattributesformmodel.cpp.
|
protected |
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 361 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 427 of file qgsattributesformmodel.cpp.
|
pure virtualslot |
Populates the model with initial data read from the layer.
|
protected |
Returns a QVector of iterative positions from root item to the given item.
Definition at line 402 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 371 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 457 of file qgsattributesformmodel.cpp.
bool QgsAttributesFormModel::showAliases | ( | ) | const |
Returns whether field aliases are preferred over field names as item text.
Definition at line 452 of file qgsattributesformmodel.cpp.
|
protected |
Definition at line 630 of file qgsattributesformmodel.h.
|
protected |
Definition at line 631 of file qgsattributesformmodel.h.
|
protected |
Definition at line 629 of file qgsattributesformmodel.h.
|
protected |
Definition at line 633 of file qgsattributesformmodel.h.