QGIS API Documentation 3.43.0-Master (56aa1fd18d7)
Public Slots | Signals | Public Member Functions | List of all members
QgsAttributesFormLayoutModel Class Reference

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

#include <qgsattributesformmodel.h>

Inheritance diagram for QgsAttributesFormLayoutModel:
Inheritance graph
[legend]

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.
 

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
 
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.
 
- 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
 
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

- 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
bool indexLessThan (const QModelIndex &a, const QModelIndex &b) const
 Auxiliary function to sort indexes, returning true if index a is less than index b.
 
QgsAttributesFormItemitemForIndex (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 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 719 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 856 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 1635 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 1512 of file qgsattributesformmodel.cpp.

◆ data()

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

Definition at line 1094 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 1394 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 867 of file qgsattributesformmodel.cpp.

◆ headerData()

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

Definition at line 861 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 1654 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 1630 of file qgsattributesformmodel.cpp.

◆ mimeData()

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

Definition at line 1344 of file qgsattributesformmodel.cpp.

◆ mimeTypes()

QStringList QgsAttributesFormLayoutModel::mimeTypes ( ) const
override

Definition at line 1298 of file qgsattributesformmodel.cpp.

◆ populate

void QgsAttributesFormLayoutModel::populate ( )
overrideslot

Definition at line 881 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 1279 of file qgsattributesformmodel.cpp.

◆ removeRows()

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

Definition at line 1262 of file qgsattributesformmodel.cpp.

◆ setData()

bool QgsAttributesFormLayoutModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)
override

Definition at line 1245 of file qgsattributesformmodel.cpp.

◆ supportedDragActions()

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

Definition at line 1288 of file qgsattributesformmodel.cpp.

◆ supportedDropActions()

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

Definition at line 1293 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 1487 of file qgsattributesformmodel.cpp.


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