34#include "moc_qgsattributesformmodel.cpp"
36using namespace Qt::StringLiterals;
40 if ( !layer || idx < 0 || idx >= layer->
fields().
count() )
61QgsAttributesFormData::FieldConfig::operator QVariant()
63 return QVariant::fromValue<QgsAttributesFormData::FieldConfig>( *
this );
66QgsAttributesFormData::RelationEditorConfiguration::operator QVariant()
68 return QVariant::fromValue<QgsAttributesFormData::RelationEditorConfiguration>( *
this );
73 return mContainerType;
78 mContainerType = type;
103 return mVisibilityExpression;
113 return mCollapsedExpression;
123 return mRelationEditorConfiguration;
133 return mQmlElementEditorConfiguration;
144 return mHtmlElementEditorConfiguration;
154 return mSpacerElementEditorConfiguration;
164 return mBackgroundColor;
174 return mTextElementEditorConfiguration;
203 return mChildren.at(
row ).get();
210 if ( !mChildren.empty() && itemId.trimmed().isEmpty() )
214 const auto it = std::find_if( mChildren.cbegin(), mChildren.cend(), [itemType, itemId](
const std::unique_ptr< QgsAttributesFormItem > &item ) {
215 return item->type() == itemType && item->id() == itemId;
218 if ( it != mChildren.cend() )
226 if ( !mChildren.empty() && itemId.trimmed().isEmpty() )
229 for (
const auto &
child : std::as_const( mChildren ) )
231 if (
child->type() == itemType &&
child->id() == itemId )
234 if (
child->childCount() > 0 )
247 return static_cast< int >( mChildren.size() );
255 const auto it = std::find_if( mParent->mChildren.cbegin(), mParent->mChildren.cend(), [
this](
const std::unique_ptr< QgsAttributesFormItem > &item ) { return item.get() == this; } );
257 if ( it != mParent->mChildren.cend() )
259 return static_cast< int >( std::distance( mParent->mChildren.cbegin(), it ) );
270 if ( !item->mParent )
271 item->mParent =
this;
276 mChildren.push_back( std::move( item ) );
278 emit
addedChildren(
this, mChildren.size() - 1, mChildren.size() - 1 );
283 if ( position < 0 || position >
static_cast< int >( mChildren.size() ) || !item )
286 if ( !item->mParent )
287 item->mParent =
this;
292 mChildren.insert( mChildren.begin() + position, std::move( item ) );
299 if ( index >= 0 && index <
static_cast< int >( mChildren.size() ) )
300 mChildren.erase( mChildren.begin() + index );
305 if ( index < 0 || index >=
static_cast< int >( mChildren.size() ) )
308 std::unique_ptr< QgsAttributesFormItem >
child = std::move( mChildren[index] );
309 mChildren.erase( mChildren.begin() + index );
314 child->mParent =
nullptr;
337 return QVariant::fromValue( mData );
345 return QVariant::fromValue( mFieldConfigData );
362 mName = value.toString();
367 mDisplayName = value.toString();
377 mId = value.toString();
392 : QAbstractItemModel(
parent )
402 if (
index.isValid() )
423 return parentItem ? parentItem->
childCount() : 0;
436 for (
int i = 0; i < std::min( pathA.size(), pathB.size() ); i++ )
438 if ( pathA.at( i ) != pathB.at( i ) )
440 return pathA.at( i ) < pathB.at( i );
444 return pathA.size() < pathB.size();
459 if ( !hasIndex( row, column,
parent ) )
460 return QModelIndex();
464 return QModelIndex();
467 return createIndex( row, column, childItem );
469 return QModelIndex();
474 if ( !
index.isValid() )
475 return QModelIndex();
480 return ( parentItem !=
mRootItem.get() && parentItem !=
nullptr ) ? createIndex( parentItem->
row(), 0, parentItem ) : QModelIndex();
486 return item ? createIndex( item->
row(), 0, item ) : QModelIndex();
492 return item ? createIndex( item->
row(), 0, item ) : QModelIndex();
497 if ( !
index.isValid() )
501 bool result = item->
setData( role, value );
531 if ( childCount == 0 )
535 for (
int i = 0; i < childCount; i++ )
537 const QModelIndex childIndex =
index( i, 0,
parent );
538 if ( hasChildren( childIndex ) )
582 if ( !
index.isValid() )
583 return Qt::NoItemFlags;
585 Qt::ItemFlags
flags = Qt::ItemIsEnabled;
590 flags =
flags | Qt::ItemIsDragEnabled | Qt::ItemIsSelectable;
599 return orientation == Qt::Horizontal && role == Qt::DisplayRole ? tr(
"Available Widgets" ) : QVariant {};
615 for (
int i = 0; i < fields.
size(); ++i )
619 itemData.setShowLabel(
true );
623 auto item = std::make_unique< QgsAttributesFormItem >();
632 itemFields->addChild( std::move( item ) );
635 mRootItem->addChild( std::move( itemFields ) );
641 const QList<QgsRelation> relations =
mProject->relationManager()->referencedRelations(
mLayer );
647 if ( polymorphicRelation.
isValid() )
649 name = u
"%1 (%2)"_s.arg( relation.name(), polymorphicRelation.
name() );
653 name = relation.name();
658 auto itemRelation = std::make_unique< QgsAttributesFormItem >();
661 itemRelation->setData(
ItemIdRole, relation.id() );
664 itemRelations->addChild( std::move( itemRelation ) );
667 mRootItem->addChild( std::move( itemRelations ) );
672 mRootItem->addChild( std::move( itemActions ) );
673 populateActionItems(
mLayer->actions()->actions() );
683 itemOtherWidgets->addChild( std::move( itemQml ) );
689 itemOtherWidgets->addChild( std::move( itemHtml ) );
695 itemOtherWidgets->addChild( std::move( itemText ) );
701 itemOtherWidgets->addChild( std::move( itemSpacer ) );
703 mRootItem->addChild( std::move( itemOtherWidgets ) );
713 beginRemoveRows( actionsIndex, 0, itemActions->
childCount() );
718 for (
const auto &action : std::as_const( actions ) )
720 if ( action.isValid() && action.runable() && ( action.actionScopes().contains( u
"Feature"_s ) || action.actionScopes().contains( u
"Layer"_s ) ) )
728 beginInsertRows( actionsIndex, 0, count - 1 );
729 populateActionItems( actions );
734void QgsAttributesAvailableWidgetsModel::populateActionItems(
const QList<QgsAction> actions )
739 for (
const auto &action : std::as_const( actions ) )
741 if ( action.isValid() && action.runable() && ( action.actionScopes().contains( u
"Feature"_s ) || action.actionScopes().contains( u
"Layer"_s ) ) )
743 const QString actionTitle { action.shortTitle().isEmpty() ? action.name() : action.shortTitle() };
745 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
748 auto itemAction = std::make_unique< QgsAttributesFormItem >();
749 itemAction->setData(
ItemIdRole, action.id().toString() );
755 itemActions->
addChild( std::move( itemAction ) );
762 if ( !
index.isValid() )
771 bool invalidRelation =
false;
779 case Qt::DisplayRole:
789 case Qt::ToolTipRole:
794 if ( !cfg.mAlias.isEmpty() )
795 return tr(
"%1 (%2)" ).arg( item->
name(), cfg.mAlias );
803 return tr(
"Invalid relation" );
809 case Qt::DecorationRole:
812 case Qt::BackgroundRole:
815 return QBrush( QColor( 140, 140, 140, 50 ) );
820 case Qt::ForegroundRole:
826 return QBrush( QColor( Qt::lightGray ) );
832 return QBrush( QColor( 255, 0, 0 ) );
844 QFont font = QFont();
845 font.setItalic(
true );
858 return item->
data( role );
867 return Qt::CopyAction;
872 return QStringList() << u
"application/x-qgsattributesformavailablewidgetsrelement"_s;
877 if ( indexes.count() == 0 )
881 if ( types.isEmpty() )
884 QMimeData *
data =
new QMimeData();
885 const QString format = types.at( 0 );
887 QDataStream stream( &encoded, QIODevice::WriteOnly );
890 QModelIndexList sortedIndexes = indexes;
892 std::sort( sortedIndexes.begin(), sortedIndexes.end(), [
this](
const QModelIndex &a,
const QModelIndex &b ) { return indexLessThan( a, b ); } );
894 for (
const QModelIndex &
index : std::as_const( sortedIndexes ) )
896 if (
index.isValid() )
902 stream << itemId << itemType << itemName;
906 data->setData( format, encoded );
917 return createIndex( row, 0, item );
919 return QModelIndex();
929 return createIndex( row, 0, item );
931 return QModelIndex();
941 return createIndex( row, 0, item );
943 return QModelIndex();
949 return QModelIndex();
953 return QModelIndex();
956 return item ? createIndex( item->
row(), 0, item ) : QModelIndex();
967 return orientation == Qt::Horizontal && role == Qt::DisplayRole ? tr(
"Form Layout" ) : QVariant {};
972 if ( !
index.isValid() )
973 return Qt::ItemIsDropEnabled;
975 Qt::ItemFlags
flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
979 flags |= Qt::ItemIsDropEnabled;
992 const auto editorElements =
mLayer->editFormConfig().tabs();
995 loadAttributeEditorElementItem( editorElement,
mRootItem.get() );
1010 auto editorItem = std::make_unique< QgsAttributesFormItem >();
1012 switch ( editorElement->
type() )
1016 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
1017 setCommonProperties( itemData );
1024 setFieldItemDataFromLayer( editorItem.get() );
1031 const QgsAttributeEditorAction *actionEditor =
static_cast<const QgsAttributeEditorAction *
>( editorElement );
1032 const QgsAction action { actionEditor->
action(
mLayer ) };
1035 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
1036 setCommonProperties( itemData );
1038 editorItem->setData(
ItemIdRole, action.
id().toString() );
1053 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
1054 setCommonProperties( itemData );
1056 const QgsAttributeEditorRelation *relationEditor =
static_cast<const QgsAttributeEditorRelation *
>( editorElement );
1057 QgsAttributesFormData::RelationEditorConfiguration relationEditorConfig;
1062 relationEditorConfig.
label = relationEditor->
label();
1065 QgsRelation relation = relationEditor->
relation();
1066 if ( relation.
id().isEmpty() )
1070 relation =
mProject->relationManager()->relation( editorElement->
name() );
1085 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
1086 setCommonProperties( itemData );
1092 const QgsAttributeEditorContainer *container =
static_cast<const QgsAttributeEditorContainer *
>( editorElement );
1105 const QList<QgsAttributeEditorElement *> children = container->
children();
1106 for ( QgsAttributeEditorElement *childElement : children )
1108 loadAttributeEditorElementItem( childElement, editorItem.get() );
1115 const QgsAttributeEditorQmlElement *qmlElementEditor =
static_cast<const QgsAttributeEditorQmlElement *
>( editorElement );
1116 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
1117 setCommonProperties( itemData );
1119 QgsAttributesFormData::QmlElementEditorConfiguration qmlEdConfig;
1132 const QgsAttributeEditorHtmlElement *htmlElementEditor =
static_cast<const QgsAttributeEditorHtmlElement *
>( editorElement );
1133 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
1134 setCommonProperties( itemData );
1136 QgsAttributesFormData::HtmlElementEditorConfiguration htmlEdConfig;
1149 const QgsAttributeEditorTextElement *textElementEditor =
static_cast<const QgsAttributeEditorTextElement *
>( editorElement );
1150 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
1151 setCommonProperties( itemData );
1153 QgsAttributesFormData::TextElementEditorConfiguration textEdConfig;
1154 textEdConfig.
text = textElementEditor->
text();
1166 const QgsAttributeEditorSpacerElement *spacerElementEditor =
static_cast<const QgsAttributeEditorSpacerElement *
>( editorElement );
1167 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
1168 setCommonProperties( itemData );
1171 QgsAttributesFormData::SpacerElementEditorConfiguration spacerEdConfig;
1184 QgsDebugError( u
"Not loading invalid attribute editor type..."_s );
1189 if ( position >= 0 && position < parent->childCount() )
1191 parent->insertChild( position, std::move( editorItem ) );
1195 parent->addChild( std::move( editorItem ) );
1201 if ( !
index.isValid() )
1214 const int fieldIndex =
mLayer->fields().indexOf( item->
name() );
1215 const bool invalidField = fieldIndex == -1;
1219 bool invalidRelation =
false;
1227 case Qt::DisplayRole:
1233 if ( item->
id().isEmpty() )
1235 return tr(
"Invalid relation" );
1241 return item->
name();
1247 case Qt::ToolTipRole:
1253 return tr(
"Invalid field" );
1257 return item->
name();
1263 if ( !item->
id().isEmpty() )
1266 return tr(
"Invalid relation" );
1273 case Qt::DecorationRole:
1274 return item->
icon();
1276 case Qt::BackgroundRole:
1279 return QBrush( QColor( 140, 140, 140, 50 ) );
1284 case Qt::ForegroundRole:
1290 return QBrush( QColor( 255, 0, 0 ) );
1294 return QBrush( QColor( Qt::lightGray ) );
1300 if ( invalidRelation )
1302 return QBrush( QColor( 255, 0, 0 ) );
1306 return QBrush( QColor( Qt::lightGray ) );
1319 QFont font = QFont();
1320 font.setItalic(
true );
1329 QFont font = QFont();
1330 font.setItalic(
true );
1343 return item->
data( role );
1360 beginRemoveRows(
parent, row, row + count - 1 );
1361 for (
int r = 0; r < count; ++r )
1369 beginRemoveRows(
parent, row, row );
1380 return Qt::CopyAction | Qt::MoveAction;
1385 return Qt::DropAction::CopyAction | Qt::DropAction::MoveAction;
1390 return QStringList() << u
"application/x-qgsattributesformlayoutelement"_s << u
"application/x-qgsattributesformavailablewidgetsrelement"_s;
1393QModelIndexList QgsAttributesFormLayoutModel::curateIndexesForMimeData(
const QModelIndexList &indexes )
const
1395 QModelIndexList containerList;
1396 for (
const auto index : indexes )
1401 containerList <<
index;
1405 if ( containerList.size() == 0 )
1408 QModelIndexList curatedIndexes;
1411 for (
const auto index : indexes )
1414 bool redundantChild =
false;
1416 while (
parent.isValid() )
1418 if ( containerList.contains(
parent ) )
1420 redundantChild =
true;
1427 if ( !redundantChild )
1428 curatedIndexes <<
index;
1431 return curatedIndexes;
1436 if ( indexes.count() == 0 )
1440 QModelIndexList curatedIndexes;
1441 if ( indexes.count() > 1 )
1443 curatedIndexes = curateIndexesForMimeData( indexes );
1447 curatedIndexes = indexes;
1451 if ( types.isEmpty() )
1454 QMimeData *
data =
new QMimeData();
1455 const QString format = types.at( 0 );
1457 QDataStream stream( &encoded, QIODevice::WriteOnly );
1460 std::sort( curatedIndexes.begin(), curatedIndexes.end(), [
this](
const QModelIndex &a,
const QModelIndex &b ) { return indexLessThan( a, b ); } );
1464 mDraggedLayoutIndexes.clear();
1465 for (
const QModelIndex &
index : std::as_const( curatedIndexes ) )
1466 mDraggedLayoutIndexes << QPersistentModelIndex(
index );
1468 for (
const QModelIndex &
index : std::as_const( curatedIndexes ) )
1470 if (
index.isValid() )
1474 QDomElement rootElem = doc.createElement( u
"form_layout_mime"_s );
1476 QDomElement editorElem = editor->toDomElement( doc );
1477 rootElem.appendChild( editorElem );
1479 doc.appendChild( rootElem );
1480 stream << doc.toString( -1 );
1484 data->setData( format, encoded );
1491 bool isDropSuccessful =
false;
1497 if ( action == Qt::IgnoreAction )
1499 isDropSuccessful =
true;
1501 else if (
data->hasFormat( u
"application/x-qgsattributesformavailablewidgetsrelement"_s ) )
1503 Q_ASSERT( action == Qt::CopyAction );
1504 QByteArray itemData =
data->data( u
"application/x-qgsattributesformavailablewidgetsrelement"_s );
1505 QDataStream stream( &itemData, QIODevice::ReadOnly );
1506 QModelIndexList addedIndexes;
1508 while ( !stream.atEnd() )
1513 stream >> itemId >> itemTypeInt >> itemName;
1518 isDropSuccessful =
true;
1524 if ( !addedIndexes.isEmpty() )
1527 else if (
data->hasFormat( u
"application/x-qgsattributesformlayoutelement"_s ) )
1529 Q_ASSERT( action == Qt::MoveAction );
1531 const QList< QPersistentModelIndex > draggedIndexes = mDraggedLayoutIndexes;
1532 mDraggedLayoutIndexes.clear();
1534 if ( draggedIndexes.isEmpty() )
1537 for (
const QPersistentModelIndex &source : draggedIndexes )
1539 if ( !source.isValid() )
1546 const QPersistentModelIndex persistentParent(
parent );
1547 QMetaObject::invokeMethod(
this, [
this, draggedIndexes, persistentParent, row]() { performInternalMove( draggedIndexes, persistentParent, row ); }, Qt::QueuedConnection );
1549 isDropSuccessful =
true;
1552 return isDropSuccessful;
1555void QgsAttributesFormLayoutModel::performInternalMove(
const QList< QPersistentModelIndex > &draggedIndexes,
const QModelIndex &parent,
int row )
1557 for (
const QPersistentModelIndex &source : draggedIndexes )
1559 if ( !source.isValid() )
1568 QList< QgsAttributesFormItem * > draggedItems;
1569 draggedItems.reserve( draggedIndexes.size() );
1570 for (
const QPersistentModelIndex &source : draggedIndexes )
1574 const auto isSelfOrAncestorOf = [](
const QgsAttributesFormItem *ancestor, QgsAttributesFormItem *item ) {
1575 for ( QgsAttributesFormItem *walk = item; walk; walk = walk->parent() )
1577 if ( walk == ancestor )
1591 QList< QgsAttributesFormItem * > movedItems;
1592 for ( QgsAttributesFormItem *item : std::as_const( draggedItems ) )
1594 QgsAttributesFormItem *sourceParentItem = item->parent();
1595 if ( !sourceParentItem )
1598 const int sourceRow = item->row();
1599 const int destRow = row + rows;
1602 if ( sourceParentItem == destParentItem && ( destRow == sourceRow || destRow == sourceRow + 1 ) )
1610 if ( isSelfOrAncestorOf( item, destParentItem ) )
1613 std::unique_ptr< QgsAttributesFormItem > movedItem = sourceParentItem->
takeChild( sourceRow );
1615 int insertPosition = destRow;
1616 if ( sourceParentItem == destParentItem && sourceRow < destRow )
1617 insertPosition = destRow - 1;
1618 insertPosition = std::clamp( insertPosition, 0, destParentItem->
childCount() );
1620 destParentItem->
insertChild( insertPosition, std::move( movedItem ) );
1624 if ( sourceParentItem == destParentItem && sourceRow < row )
1632 if ( !movedItems.isEmpty() )
1634 QModelIndexList indexes;
1635 indexes.reserve( movedItems.size() );
1636 for ( QgsAttributesFormItem *item : std::as_const( movedItems ) )
1637 indexes << createIndex( item->row(), 0, item );
1644 for (
int i = 0; i <
parent->childCount(); i++ )
1646 QgsAttributesFormItem *child =
parent->child( i );
1656 updateFieldConfigForFieldItemsRecursive( child, fieldName, config );
1663 updateFieldConfigForFieldItemsRecursive(
mRootItem.get(), fieldName, config );
1666void QgsAttributesFormLayoutModel::updateAliasForFieldItemsRecursive(
QgsAttributesFormItem *parent,
const QString &fieldName,
const QString &fieldAlias )
1668 for (
int i = 0; i <
parent->childCount(); i++ )
1674 const QModelIndex
index = createIndex( child->
row(), 0, child );
1680 updateAliasForFieldItemsRecursive( child, fieldName, fieldAlias );
1687 updateAliasForFieldItemsRecursive(
mRootItem.get(), fieldName, fieldAlias );
1690QList< QgsAddAttributeFormContainerDialog::ContainerPair > QgsAttributesFormLayoutModel::recursiveListOfContainers(
QgsAttributesFormItem *parent )
const
1692 QList< QgsAddAttributeFormContainerDialog::ContainerPair > containerList;
1693 for (
int i = 0; i <
parent->childCount(); i++ )
1703 containerList.append( recursiveListOfContainers( child ) );
1707 return containerList;
1719 switch ( indexType )
1723 const int fieldIndex =
mLayer->fields().lookupField( indexName );
1756 bool isTopLevel = !
index.parent().isValid();
1768 QModelIndex childIndex;
1776 widgetDef = container;
1784 widgetDef = element;
1792 widgetDef = element;
1800 widgetDef = element;
1808 widgetDef = element;
1830 return recursiveListOfContainers(
mRootItem.get() );
1847 parentItem->
addChild( std::move( containerItem ) );
1855 if ( fieldIndex == -1 )
1870 beginInsertRows(
parent, row, row );
1871 auto item = std::make_unique< QgsAttributesFormItem >();
1880 setFieldItemDataFromLayer( item.get() );
1893 : QSortFilterProxyModel( parent )
1899 QSortFilterProxyModel::setSourceModel( mModel );
1924 if ( mFilterText.isEmpty() )
1927 QModelIndex sourceIndex = sourceModel()->index( sourceRow, 0, sourceParent );
1928 if ( !sourceIndex.isValid() )
1937 QModelIndex parent = sourceIndex.
parent();
1938 while ( parent.isValid() )
1944 parent = parent.parent();
AttributeEditorContainerType
Attribute editor container types.
@ Action
A layer action element.
@ QmlElement
A QML element.
@ HtmlElement
A HTML element.
@ TextElement
A text element.
@ SpacerElement
A spacer element.
Utility class that encapsulates an action based on vector attributes.
QString name() const
The name of the action. This may be a longer description.
bool isValid() const
Returns true if this action was a default constructed one.
QString shortTitle() const
The short title is used to label user interface elements like buttons.
QUuid id() const
Returns a unique id for this action.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
This element will load a layer action onto the form.
const QgsAction & action(const QgsVectorLayer *layer) const
Returns the (possibly lazy loaded) action for the given layer.
A container for attribute editors, used to group them visually in the attribute form if it is set to ...
virtual void addChildElement(QgsAttributeEditorElement *element)
Add a child element to this container.
QgsOptionalExpression visibilityExpression() const
The visibility expression is used in the attribute form to show or hide this container based on an ex...
void setColumnCount(int columnCount)
Set the number of columns in this group.
void setVisibilityExpression(const QgsOptionalExpression &visibilityExpression)
The visibility expression is used in the attribute form to show or hide this container based on an ex...
QgsOptionalExpression collapsedExpression() const
The collapsed expression is used in the attribute form to set the collapsed status of the group box c...
bool collapsed() const
For group box containers returns true if this group box is collapsed.
Qgis::AttributeEditorContainerType type() const
Returns the container type.
void setType(Qgis::AttributeEditorContainerType type)
Sets the container type.
void setCollapsedExpression(const QgsOptionalExpression &collapsedExpression)
The collapsed expression is used in the attribute form to set the collapsed status of the group box o...
QList< QgsAttributeEditorElement * > children() const
Gets a list of the children elements of this container.
QColor backgroundColor() const
Returns the background color of the container.
void setCollapsed(bool collapsed)
For group box containers sets if this group box is collapsed.
int columnCount() const
Gets the number of columns in this group.
void setBackgroundColor(const QColor &backgroundColor)
Sets the background color to backgroundColor.
An abstract base class for any elements of a drag and drop form.
void setHorizontalStretch(int stretch)
Sets the horizontal stretch factor for the element.
LabelStyle labelStyle() const
Returns the label style.
void setLabelStyle(const LabelStyle &labelStyle)
Sets the labelStyle.
Qgis::AttributeEditorType type() const
The type of this element.
int verticalStretch() const
Returns the vertical stretch factor for the element.
bool showLabel() const
Controls if this element should be labeled with a title (field, relation or groupname).
QString name() const
Returns the name of this element.
void setVerticalStretch(int stretch)
Sets the vertical stretch factor for the element.
void setShowLabel(bool showLabel)
Controls if this element should be labeled with a title (field, relation or groupname).
int horizontalStretch() const
Returns the horizontal stretch factor for the element.
This element will load a field's widget onto the form.
An attribute editor widget that will represent arbitrary HTML code.
QString htmlCode() const
The Html code that will be represented within this widget.
void setHtmlCode(const QString &htmlCode)
Sets the HTML code that will be represented within this widget to htmlCode.
An attribute editor widget that will represent arbitrary QML code.
QString qmlCode() const
The QML code that will be represented within this widget.
void setQmlCode(const QString &qmlCode)
Sets the QML code that will be represented within this widget to qmlCode.
This element will load a relation editor onto the form.
void setNmRelationId(const QVariant &nmRelationId=QVariant())
Sets nmRelationId for the relation id of the second relation involved in an N:M relation.
void setRelationWidgetTypeId(const QString &relationWidgetTypeId)
Sets the relation widget type.
const QgsRelation & relation() const
Gets the id of the relation which shall be embedded.
QVariantMap relationEditorConfiguration() const
Returns the relation editor widget configuration.
void setForceSuppressFormPopup(bool forceSuppressFormPopup)
Sets force suppress form popup status to forceSuppressFormPopup.
QVariant nmRelationId() const
Determines the relation id of the second relation involved in an N:M relation.
bool forceSuppressFormPopup() const
Determines the force suppress form popup status.
QString relationWidgetTypeId() const
Returns the current relation widget type id.
void setRelationEditorConfiguration(const QVariantMap &config)
Sets the relation editor configuration.
void setLabel(const QString &label=QString())
Sets label for this element If it's empty it takes the relation id as label.
QString label() const
Determines the label of this element.
An attribute editor widget that will represent a spacer.
void setDrawLine(bool drawLine)
Sets a flag to define if the spacer element will contain an horizontal line.
bool drawLine() const
Returns true if the spacer element will contain an horizontal line.
An attribute editor widget that will represent arbitrary text code.
void setText(const QString &text)
Sets the text that will be represented within this widget to text.
QString text() const
The Text that will be represented within this widget.
Encapsulate a field in an attribute table or data source.
Qgis::FieldDomainSplitPolicy splitPolicy() const
Returns the field's split policy, which indicates how field values should be handled during a split o...
Qgis::FieldDuplicatePolicy duplicatePolicy() const
Returns the field's duplicate policy, which indicates how field values should be handled during a dup...
QgsDefaultValue defaultValueDefinition
Qgis::FieldDomainMergePolicy mergePolicy() const
Returns the field's merge policy, which indicates how field values should be handled during a merge o...
QgsFieldConstraints constraints
Container of fields for a vector layer.
Q_INVOKABLE int indexOf(const QString &fieldName) const
Gets the field index from the field name.
QgsField field(int fieldIdx) const
Returns the field at particular index (must be in range 0..N-1).
int size() const
Returns number of items.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
QIcon iconForField(int fieldIdx, bool considerOrigin=false) const
Returns an icon corresponding to a field index, based on the field's type and source.
static QgsEditorWidgetRegistry * editorWidgetRegistry()
Returns the global editor widget registry, used for managing all known edit widget factories.
static QgsGui * instance()
Returns a pointer to the singleton instance.
An expression with an additional enabled flag.
A relation where the referenced (parent) layer is calculated based on fields from the referencing (ch...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QgsRelationManager * relationManager
static QgsProject * instance()
Returns the QgsProject singleton instance.
Q_INVOKABLE QgsRelation relation(const QString &id) const
Gets access to a relation by its id.
Represents a relationship between two vector layers.
Represents a vector layer which manages a vector based dataset.
QgsEditFormConfig editFormConfig
#define QgsDebugError(str)
The TabStyle struct defines color and font overrides for form fields, tabs and groups labels.