QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
QgsAttributesFormLayoutModel Class Reference

Manages form layouts when configuring attributes forms via drag and drop designer. More...

#include <qgsattributesformmodel.h>

Inheritance diagram for QgsAttributesFormLayoutModel:

Public Slots

void populate () override
Public Slots inherited from QgsAttributesFormModel
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.
Signals inherited from QgsAttributesFormModel
void fieldConfigDataChanged (QgsAttributesFormItem *item)
 Notifies other objects that the field config data has changed in the item.

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.
QgsAttributeEditorElementcreateAttributeEditorWidget (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::ContainerPairlistOfContainers () 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
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.
void updateFieldConfigForFieldItems (const QString &fieldName, const QgsAttributesFormData::FieldConfig &config)
 Updates the field config of all matching fields in the model.
Public Member Functions inherited from QgsAttributesFormModel
 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
QgsAttributesFormItemitemForIndex (const QModelIndex &index) const
 Returns the underlying item that corresponds to the given index.
QModelIndex parent (const QModelIndex &index) const override
QgsAttributesFormItemrootItem () 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.

Additional Inherited Members

Public Types inherited from QgsAttributesFormModel
enum  ItemRoles {
  ItemDataRole = Qt::UserRole , ItemFieldConfigRole , ItemNameRole , ItemIdRole ,
  ItemTypeRole , ItemDisplayRole
}
 Custom model roles. More...
Protected Member Functions inherited from QgsAttributesFormModel
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 inherited from QgsAttributesFormModel
QgsVectorLayermLayer
QgsProjectmProject
std::unique_ptr< QgsAttributesFormItemmRootItem
bool mShowAliases = false

Detailed Description

Manages form layouts when configuring attributes forms via drag and drop designer.

Warning
Not part of stable API and may change in future QGIS releases.
Since
QGIS 3.44

Definition at line 772 of file qgsattributesformmodel.h.

Constructor & Destructor Documentation

◆ QgsAttributesFormLayoutModel()

QgsAttributesFormLayoutModel::QgsAttributesFormLayoutModel ( QgsVectorLayer * layer,
QgsProject * project,
QObject * parent = nullptr )
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 911 of file qgsattributesformmodel.cpp.

Member Function Documentation

◆ addContainer()

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 1707 of file qgsattributesformmodel.cpp.

◆ createAttributeEditorWidget()

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 1584 of file qgsattributesformmodel.cpp.

◆ data()

QVariant QgsAttributesFormLayoutModel::data ( const QModelIndex & index,
int role = Qt::DisplayRole ) const
override

Definition at line 1159 of file qgsattributesformmodel.cpp.

◆ dropMimeData()

bool QgsAttributesFormLayoutModel::dropMimeData ( const QMimeData * data,
Qt::DropAction action,
int row,
int column,
const QModelIndex & parent )
override

Definition at line 1442 of file qgsattributesformmodel.cpp.

◆ externalItemDropped

void QgsAttributesFormLayoutModel::externalItemDropped ( QModelIndex & index)
signal

Informs that items were inserted (via drop) in the model from another model.

◆ flags()

Qt::ItemFlags QgsAttributesFormLayoutModel::flags ( const QModelIndex & index) const
override

Definition at line 922 of file qgsattributesformmodel.cpp.

◆ headerData()

QVariant QgsAttributesFormLayoutModel::headerData ( int section,
Qt::Orientation orientation,
int role = Qt::DisplayRole ) const
override

Definition at line 916 of file qgsattributesformmodel.cpp.

◆ insertChild()

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 1726 of file qgsattributesformmodel.cpp.

◆ internalItemDropped

void QgsAttributesFormLayoutModel::internalItemDropped ( QModelIndex & index)
signal

Informs that items were moved (via drop) in the model from the same model.

◆ listOfContainers()

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 1702 of file qgsattributesformmodel.cpp.

◆ mimeData()

QMimeData * QgsAttributesFormLayoutModel::mimeData ( const QModelIndexList & indexes) const
override

Definition at line 1392 of file qgsattributesformmodel.cpp.

◆ mimeTypes()

QStringList QgsAttributesFormLayoutModel::mimeTypes ( ) const
override

Definition at line 1346 of file qgsattributesformmodel.cpp.

◆ populate

void QgsAttributesFormLayoutModel::populate ( )
overrideslot

Definition at line 936 of file qgsattributesformmodel.cpp.

◆ removeRow()

bool QgsAttributesFormLayoutModel::removeRow ( int row,
const QModelIndex & parent = QModelIndex() )

Removes the index located at row within the given parent.

Definition at line 1327 of file qgsattributesformmodel.cpp.

◆ removeRows()

bool QgsAttributesFormLayoutModel::removeRows ( int row,
int count,
const QModelIndex & parent = QModelIndex() )
override

Definition at line 1310 of file qgsattributesformmodel.cpp.

◆ supportedDragActions()

Qt::DropActions QgsAttributesFormLayoutModel::supportedDragActions ( ) const
override

Definition at line 1336 of file qgsattributesformmodel.cpp.

◆ supportedDropActions()

Qt::DropActions QgsAttributesFormLayoutModel::supportedDropActions ( ) const
override

Definition at line 1341 of file qgsattributesformmodel.cpp.

◆ updateAliasForFieldItems()

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.

Parameters
fieldNameName of the field to search.
fieldAliasAlias to be set to matching fields.

Definition at line 1559 of file qgsattributesformmodel.cpp.

◆ updateFieldConfigForFieldItems()

void QgsAttributesFormLayoutModel::updateFieldConfigForFieldItems ( const QString & fieldName,
const QgsAttributesFormData::FieldConfig & config )

Updates the field config of all matching fields in the model.

Parameters
fieldNameName of the field to search.
configField config to be set to matching fields.
Since
QGIS 4.0

Definition at line 1535 of file qgsattributesformmodel.cpp.


The documentation for this class was generated from the following files: