QGIS API Documentation 3.43.0-Master (5250e42f050)
|
Manages form layouts when configuring attributes forms via drag and drop designer. More...
#include <qgsattributesformmodel.h>
Public Slots | |
void | populate () override |
![]() | |
virtual void | populate ()=0 |
Populates the model with initial data read from the layer. | |
Signals | |
void | externalItemDropped (QModelIndex &index) |
Informs that items were inserted (via drop) in the model from another model. | |
void | internalItemDropped (QModelIndex &index) |
Informs that items were moved (via drop) in the model from the same model. | |
Public Member Functions | |
QgsAttributesFormLayoutModel (QgsVectorLayer *layer, QgsProject *project, QObject *parent=nullptr) | |
Constructor for QgsAttributesFormLayoutModel, with the given parent. | |
void | addContainer (QModelIndex &parent, const QString &name, int columnCount, Qgis::AttributeEditorContainerType type) |
Adds a new container to parent. | |
QgsAttributeEditorElement * | createAttributeEditorWidget (const QModelIndex &index, QgsAttributeEditorElement *parent) const |
Creates a new attribute editor element based on the definition stored in a form layout model index. | |
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override |
Qt::ItemFlags | flags (const QModelIndex &index) const override |
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override |
void | insertChild (const QModelIndex &parent, int row, const QString &itemId, QgsAttributesFormData::AttributesFormItemType itemType, const QString &itemName) |
Inserts a new child to parent model index at the given row position. | |
QList< QgsAddAttributeFormContainerDialog::ContainerPair > | listOfContainers () const |
Returns a list of containers stored in the model, structured as pairs (name, container model index). | |
QMimeData * | mimeData (const QModelIndexList &indexes) const override |
QStringList | mimeTypes () const override |
bool | removeRow (int row, const QModelIndex &parent=QModelIndex()) |
Removes the index located at row within the given parent. | |
bool | removeRows (int row, int count, const QModelIndex &parent=QModelIndex()) override |
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override |
Qt::DropActions | supportedDragActions () const override |
Qt::DropActions | supportedDropActions () const override |
void | updateAliasForFieldItems (const QString &fieldName, const QString &fieldAlias) |
Updates the aliases of all matching fields in the model. | |
![]() | |
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. | |
Additional Inherited Members | |
![]() | |
enum | ItemRoles { ItemDataRole = Qt::UserRole , ItemFieldConfigRole , ItemNameRole , ItemIdRole , ItemTypeRole , ItemDisplayRole } |
Custom model roles. More... | |
![]() | |
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. | |
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. | |
![]() | |
QgsVectorLayer * | mLayer |
QgsProject * | mProject |
std::unique_ptr< QgsAttributesFormItem > | mRootItem |
bool | mShowAliases = false |
Manages form layouts when configuring attributes forms via drag and drop designer.
Definition at line 731 of file qgsattributesformmodel.h.
|
explicit |
Constructor for QgsAttributesFormLayoutModel, with the given parent.
The given layer is the data source to populate the model. The given project is used to extract information about relations.
Definition at line 870 of file qgsattributesformmodel.cpp.
void QgsAttributesFormLayoutModel::addContainer | ( | QModelIndex & | parent, |
const QString & | name, | ||
int | columnCount, | ||
Qgis::AttributeEditorContainerType | type | ||
) |
Adds a new container to parent.
If no parent is set then the container will be forced to be a tab widget.
Definition at line 1649 of file qgsattributesformmodel.cpp.
QgsAttributeEditorElement * QgsAttributesFormLayoutModel::createAttributeEditorWidget | ( | const QModelIndex & | index, |
QgsAttributeEditorElement * | parent | ||
) | const |
Creates a new attribute editor element based on the definition stored in a form layout model index.
Definition at line 1526 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 1108 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 1408 of file qgsattributesformmodel.cpp.
|
signal |
Informs that items were inserted (via drop) in the model from another model.
|
override |
Definition at line 881 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 875 of file qgsattributesformmodel.cpp.
void QgsAttributesFormLayoutModel::insertChild | ( | const QModelIndex & | parent, |
int | row, | ||
const QString & | itemId, | ||
QgsAttributesFormData::AttributesFormItemType | itemType, | ||
const QString & | itemName | ||
) |
Inserts a new child to parent model index at the given row position.
The child is constructed from the given itemId, itemType and itemName.
Definition at line 1668 of file qgsattributesformmodel.cpp.
|
signal |
Informs that items were moved (via drop) in the model from the same model.
QList< QgsAddAttributeFormContainerDialog::ContainerPair > QgsAttributesFormLayoutModel::listOfContainers | ( | ) | const |
Returns a list of containers stored in the model, structured as pairs (name, container model index).
Definition at line 1644 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 1358 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 1312 of file qgsattributesformmodel.cpp.
|
overrideslot |
Definition at line 895 of file qgsattributesformmodel.cpp.
bool QgsAttributesFormLayoutModel::removeRow | ( | int | row, |
const QModelIndex & | parent = QModelIndex() |
||
) |
Removes the index located at row within the given parent.
Definition at line 1293 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 1276 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 1259 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 1302 of file qgsattributesformmodel.cpp.
|
override |
Definition at line 1307 of file qgsattributesformmodel.cpp.
void QgsAttributesFormLayoutModel::updateAliasForFieldItems | ( | const QString & | fieldName, |
const QString & | fieldAlias | ||
) |
Updates the aliases of all matching fields in the model.
Required because a field might appear several times in the form layout.
fieldName | Name of the field to search |
fieldAlias | Alias to be set to matching fields |
Definition at line 1501 of file qgsattributesformmodel.cpp.