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 );
533 const QModelIndex childIndex =
index( i, 0,
parent );
534 if ( hasChildren( childIndex ) )
578 if ( !
index.isValid() )
579 return Qt::NoItemFlags;
581 Qt::ItemFlags
flags = Qt::ItemIsEnabled;
586 flags =
flags | Qt::ItemIsDragEnabled | Qt::ItemIsSelectable;
595 return orientation == Qt::Horizontal && role == Qt::DisplayRole ? tr(
"Available Widgets" ) : QVariant {};
611 for (
int i = 0; i < fields.
size(); ++i )
615 itemData.setShowLabel(
true );
619 auto item = std::make_unique< QgsAttributesFormItem >();
628 itemFields->addChild( std::move( item ) );
631 mRootItem->addChild( std::move( itemFields ) );
637 const QList<QgsRelation> relations =
mProject->relationManager()->referencedRelations(
mLayer );
643 if ( polymorphicRelation.
isValid() )
645 name = u
"%1 (%2)"_s.arg( relation.name(), polymorphicRelation.
name() );
649 name = relation.name();
654 auto itemRelation = std::make_unique< QgsAttributesFormItem >();
657 itemRelation->setData(
ItemIdRole, relation.id() );
660 itemRelations->addChild( std::move( itemRelation ) );
663 mRootItem->addChild( std::move( itemRelations ) );
668 mRootItem->addChild( std::move( itemActions ) );
669 populateActionItems(
mLayer->actions()->actions() );
679 itemOtherWidgets->addChild( std::move( itemQml ) );
685 itemOtherWidgets->addChild( std::move( itemHtml ) );
691 itemOtherWidgets->addChild( std::move( itemText ) );
697 itemOtherWidgets->addChild( std::move( itemSpacer ) );
699 mRootItem->addChild( std::move( itemOtherWidgets ) );
709 beginRemoveRows( actionsIndex, 0, itemActions->
childCount() );
714 for (
const auto &action : std::as_const( actions ) )
716 if ( action.isValid() && action.runable() && ( action.actionScopes().contains( u
"Feature"_s ) || action.actionScopes().contains( u
"Layer"_s ) ) )
724 beginInsertRows( actionsIndex, 0, count - 1 );
725 populateActionItems( actions );
730void QgsAttributesAvailableWidgetsModel::populateActionItems(
const QList<QgsAction> actions )
735 for (
const auto &action : std::as_const( actions ) )
737 if ( action.isValid() && action.runable() && ( action.actionScopes().contains( u
"Feature"_s ) || action.actionScopes().contains( u
"Layer"_s ) ) )
739 const QString actionTitle { action.shortTitle().isEmpty() ? action.name() : action.shortTitle() };
741 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
744 auto itemAction = std::make_unique< QgsAttributesFormItem >();
745 itemAction->setData(
ItemIdRole, action.id().toString() );
751 itemActions->
addChild( std::move( itemAction ) );
758 if ( !
index.isValid() )
767 bool invalidRelation =
false;
775 case Qt::DisplayRole:
785 case Qt::ToolTipRole:
790 if ( !cfg.mAlias.isEmpty() )
791 return tr(
"%1 (%2)" ).arg( item->
name(), cfg.mAlias );
799 return tr(
"Invalid relation" );
805 case Qt::DecorationRole:
808 case Qt::BackgroundRole:
811 return QBrush( QColor( 140, 140, 140, 50 ) );
816 case Qt::ForegroundRole:
822 return QBrush( QColor( Qt::lightGray ) );
828 return QBrush( QColor( 255, 0, 0 ) );
840 QFont font = QFont();
841 font.setItalic(
true );
854 return item->
data( role );
863 return Qt::CopyAction;
868 return QStringList() << u
"application/x-qgsattributesformavailablewidgetsrelement"_s;
873 if ( indexes.count() == 0 )
877 if ( types.isEmpty() )
880 QMimeData *
data =
new QMimeData();
881 const QString format = types.at( 0 );
883 QDataStream stream( &encoded, QIODevice::WriteOnly );
886 QModelIndexList sortedIndexes = indexes;
888 std::sort( sortedIndexes.begin(), sortedIndexes.end(), [
this](
const QModelIndex &a,
const QModelIndex &b ) { return indexLessThan( a, b ); } );
890 for (
const QModelIndex &
index : std::as_const( sortedIndexes ) )
892 if (
index.isValid() )
898 stream << itemId << itemType << itemName;
902 data->setData( format, encoded );
913 return createIndex( row, 0, item );
915 return QModelIndex();
925 return createIndex( row, 0, item );
927 return QModelIndex();
937 return createIndex( row, 0, item );
939 return QModelIndex();
945 return QModelIndex();
949 return QModelIndex();
952 return item ? createIndex( item->
row(), 0, item ) : QModelIndex();
963 return orientation == Qt::Horizontal && role == Qt::DisplayRole ? tr(
"Form Layout" ) : QVariant {};
968 if ( !
index.isValid() )
969 return Qt::ItemIsDropEnabled;
971 Qt::ItemFlags
flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
975 flags |= Qt::ItemIsDropEnabled;
988 const auto editorElements =
mLayer->editFormConfig().tabs();
991 loadAttributeEditorElementItem( editorElement,
mRootItem.get() );
1006 auto editorItem = std::make_unique< QgsAttributesFormItem >();
1008 switch ( editorElement->
type() )
1012 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
1013 setCommonProperties( itemData );
1020 setFieldItemDataFromLayer( editorItem.get() );
1027 const QgsAttributeEditorAction *actionEditor =
static_cast<const QgsAttributeEditorAction *
>( editorElement );
1028 const QgsAction action { actionEditor->
action(
mLayer ) };
1031 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
1032 setCommonProperties( itemData );
1034 editorItem->setData(
ItemIdRole, action.
id().toString() );
1049 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
1050 setCommonProperties( itemData );
1052 const QgsAttributeEditorRelation *relationEditor =
static_cast<const QgsAttributeEditorRelation *
>( editorElement );
1053 QgsAttributesFormData::RelationEditorConfiguration relationEditorConfig;
1058 relationEditorConfig.
label = relationEditor->
label();
1061 QgsRelation relation = relationEditor->
relation();
1062 if ( relation.
id().isEmpty() )
1066 relation =
mProject->relationManager()->relation( editorElement->
name() );
1081 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
1082 setCommonProperties( itemData );
1088 const QgsAttributeEditorContainer *container =
static_cast<const QgsAttributeEditorContainer *
>( editorElement );
1101 const QList<QgsAttributeEditorElement *> children = container->
children();
1102 for ( QgsAttributeEditorElement *childElement : children )
1104 loadAttributeEditorElementItem( childElement, editorItem.get() );
1111 const QgsAttributeEditorQmlElement *qmlElementEditor =
static_cast<const QgsAttributeEditorQmlElement *
>( editorElement );
1112 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
1113 setCommonProperties( itemData );
1115 QgsAttributesFormData::QmlElementEditorConfiguration qmlEdConfig;
1128 const QgsAttributeEditorHtmlElement *htmlElementEditor =
static_cast<const QgsAttributeEditorHtmlElement *
>( editorElement );
1129 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
1130 setCommonProperties( itemData );
1132 QgsAttributesFormData::HtmlElementEditorConfiguration htmlEdConfig;
1145 const QgsAttributeEditorTextElement *textElementEditor =
static_cast<const QgsAttributeEditorTextElement *
>( editorElement );
1146 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
1147 setCommonProperties( itemData );
1149 QgsAttributesFormData::TextElementEditorConfiguration textEdConfig;
1150 textEdConfig.
text = textElementEditor->
text();
1162 const QgsAttributeEditorSpacerElement *spacerElementEditor =
static_cast<const QgsAttributeEditorSpacerElement *
>( editorElement );
1163 QgsAttributesFormData::AttributeFormItemData itemData = QgsAttributesFormData::AttributeFormItemData();
1164 setCommonProperties( itemData );
1167 QgsAttributesFormData::SpacerElementEditorConfiguration spacerEdConfig;
1180 QgsDebugError( u
"Not loading invalid attribute editor type..."_s );
1185 if ( position >= 0 && position < parent->childCount() )
1187 parent->insertChild( position, std::move( editorItem ) );
1191 parent->addChild( std::move( editorItem ) );
1197 if ( !
index.isValid() )
1210 const int fieldIndex =
mLayer->fields().indexOf( item->
name() );
1211 const bool invalidField = fieldIndex == -1;
1215 bool invalidRelation =
false;
1223 case Qt::DisplayRole:
1229 if ( item->
id().isEmpty() )
1231 return tr(
"Invalid relation" );
1237 return item->
name();
1243 case Qt::ToolTipRole:
1249 return tr(
"Invalid field" );
1253 return item->
name();
1259 if ( !item->
id().isEmpty() )
1262 return tr(
"Invalid relation" );
1269 case Qt::DecorationRole:
1270 return item->
icon();
1272 case Qt::BackgroundRole:
1275 return QBrush( QColor( 140, 140, 140, 50 ) );
1280 case Qt::ForegroundRole:
1286 return QBrush( QColor( 255, 0, 0 ) );
1290 return QBrush( QColor( Qt::lightGray ) );
1296 if ( invalidRelation )
1298 return QBrush( QColor( 255, 0, 0 ) );
1302 return QBrush( QColor( Qt::lightGray ) );
1315 QFont font = QFont();
1316 font.setItalic(
true );
1325 QFont font = QFont();
1326 font.setItalic(
true );
1339 return item->
data( role );
1356 beginRemoveRows(
parent, row, row + count - 1 );
1357 for (
int r = 0; r < count; ++r )
1365 beginRemoveRows(
parent, row, row );
1376 return Qt::CopyAction | Qt::MoveAction;
1381 return Qt::DropAction::CopyAction | Qt::DropAction::MoveAction;
1386 return QStringList() << u
"application/x-qgsattributesformlayoutelement"_s << u
"application/x-qgsattributesformavailablewidgetsrelement"_s;
1389QModelIndexList QgsAttributesFormLayoutModel::curateIndexesForMimeData(
const QModelIndexList &indexes )
const
1391 QModelIndexList containerList;
1392 for (
const auto index : indexes )
1397 containerList <<
index;
1401 if ( containerList.size() == 0 )
1404 QModelIndexList curatedIndexes;
1407 for (
const auto index : indexes )
1410 bool redundantChild =
false;
1412 while (
parent.isValid() )
1414 if ( containerList.contains(
parent ) )
1416 redundantChild =
true;
1423 if ( !redundantChild )
1424 curatedIndexes <<
index;
1427 return curatedIndexes;
1432 if ( indexes.count() == 0 )
1436 QModelIndexList curatedIndexes;
1437 if ( indexes.count() > 1 )
1439 curatedIndexes = curateIndexesForMimeData( indexes );
1443 curatedIndexes = indexes;
1447 if ( types.isEmpty() )
1450 QMimeData *
data =
new QMimeData();
1451 const QString format = types.at( 0 );
1453 QDataStream stream( &encoded, QIODevice::WriteOnly );
1456 std::sort( curatedIndexes.begin(), curatedIndexes.end(), [
this](
const QModelIndex &a,
const QModelIndex &b ) { return indexLessThan( a, b ); } );
1460 mDraggedLayoutIndexes.clear();
1461 for (
const QModelIndex &
index : std::as_const( curatedIndexes ) )
1462 mDraggedLayoutIndexes << QPersistentModelIndex(
index );
1464 for (
const QModelIndex &
index : std::as_const( curatedIndexes ) )
1466 if (
index.isValid() )
1470 QDomElement rootElem = doc.createElement( u
"form_layout_mime"_s );
1473 rootElem.appendChild( editorElem );
1475 doc.appendChild( rootElem );
1476 stream << doc.toString( -1 );
1480 data->setData( format, encoded );
1487 bool isDropSuccessful =
false;
1493 if ( action == Qt::IgnoreAction )
1495 isDropSuccessful =
true;
1497 else if (
data->hasFormat( u
"application/x-qgsattributesformavailablewidgetsrelement"_s ) )
1499 Q_ASSERT( action == Qt::CopyAction );
1500 QByteArray itemData =
data->data( u
"application/x-qgsattributesformavailablewidgetsrelement"_s );
1501 QDataStream stream( &itemData, QIODevice::ReadOnly );
1502 QModelIndexList addedIndexes;
1504 while ( !stream.atEnd() )
1509 stream >> itemId >> itemTypeInt >> itemName;
1514 isDropSuccessful =
true;
1520 if ( !addedIndexes.isEmpty() )
1523 else if (
data->hasFormat( u
"application/x-qgsattributesformlayoutelement"_s ) )
1525 Q_ASSERT( action == Qt::MoveAction );
1527 const QList< QPersistentModelIndex > draggedIndexes = mDraggedLayoutIndexes;
1528 mDraggedLayoutIndexes.clear();
1530 if ( draggedIndexes.isEmpty() )
1533 for (
const QPersistentModelIndex &source : draggedIndexes )
1535 if ( !source.isValid() )
1542 const QPersistentModelIndex persistentParent(
parent );
1543 QMetaObject::invokeMethod(
this, [
this, draggedIndexes, persistentParent, row]() { performInternalMove( draggedIndexes, persistentParent, row ); }, Qt::QueuedConnection );
1545 isDropSuccessful =
true;
1548 return isDropSuccessful;
1551void QgsAttributesFormLayoutModel::performInternalMove(
const QList< QPersistentModelIndex > &draggedIndexes,
const QModelIndex &parent,
int row )
1553 for (
const QPersistentModelIndex &source : draggedIndexes )
1555 if ( !source.isValid() )
1564 QList< QgsAttributesFormItem * > draggedItems;
1565 draggedItems.reserve( draggedIndexes.size() );
1566 for (
const QPersistentModelIndex &source : draggedIndexes )
1570 const auto isSelfOrAncestorOf = [](
const QgsAttributesFormItem *ancestor, QgsAttributesFormItem *item ) {
1571 for ( QgsAttributesFormItem *walk = item; walk; walk = walk->parent() )
1573 if ( walk == ancestor )
1587 QList< QgsAttributesFormItem * > movedItems;
1588 for ( QgsAttributesFormItem *item : std::as_const( draggedItems ) )
1590 QgsAttributesFormItem *sourceParentItem = item->parent();
1591 if ( !sourceParentItem )
1594 const int sourceRow = item->row();
1595 const int destRow = row + rows;
1598 if ( sourceParentItem == destParentItem && ( destRow == sourceRow || destRow == sourceRow + 1 ) )
1606 if ( isSelfOrAncestorOf( item, destParentItem ) )
1609 std::unique_ptr< QgsAttributesFormItem > movedItem = sourceParentItem->
takeChild( sourceRow );
1611 int insertPosition = destRow;
1612 if ( sourceParentItem == destParentItem && sourceRow < destRow )
1613 insertPosition = destRow - 1;
1614 insertPosition = std::clamp( insertPosition, 0, destParentItem->
childCount() );
1616 destParentItem->
insertChild( insertPosition, std::move( movedItem ) );
1620 if ( sourceParentItem == destParentItem && sourceRow < row )
1628 if ( !movedItems.isEmpty() )
1630 QModelIndexList indexes;
1631 indexes.reserve( movedItems.size() );
1632 for ( QgsAttributesFormItem *item : std::as_const( movedItems ) )
1633 indexes << createIndex( item->row(), 0, item );
1640 for (
int i = 0; i <
parent->childCount(); i++ )
1642 QgsAttributesFormItem *child =
parent->child( i );
1652 updateFieldConfigForFieldItemsRecursive( child, fieldName, config );
1659 updateFieldConfigForFieldItemsRecursive(
mRootItem.get(), fieldName, config );
1662void QgsAttributesFormLayoutModel::updateAliasForFieldItemsRecursive(
QgsAttributesFormItem *parent,
const QString &fieldName,
const QString &fieldAlias )
1664 for (
int i = 0; i <
parent->childCount(); i++ )
1670 const QModelIndex
index = createIndex( child->
row(), 0, child );
1676 updateAliasForFieldItemsRecursive( child, fieldName, fieldAlias );
1683 updateAliasForFieldItemsRecursive(
mRootItem.get(), fieldName, fieldAlias );
1686QList< QgsAddAttributeFormContainerDialog::ContainerPair > QgsAttributesFormLayoutModel::recursiveListOfContainers(
QgsAttributesFormItem *parent )
const
1688 QList< QgsAddAttributeFormContainerDialog::ContainerPair > containerList;
1689 for (
int i = 0; i <
parent->childCount(); i++ )
1699 containerList.append( recursiveListOfContainers( child ) );
1703 return containerList;
1715 switch ( indexType )
1719 const int fieldIndex =
mLayer->fields().lookupField( indexName );
1752 bool isTopLevel = !
index.parent().isValid();
1764 QModelIndex childIndex;
1772 widgetDef = container;
1780 widgetDef = element;
1788 widgetDef = element;
1796 widgetDef = element;
1804 widgetDef = element;
1826 return recursiveListOfContainers(
mRootItem.get() );
1843 parentItem->
addChild( std::move( containerItem ) );
1851 if ( fieldIndex == -1 )
1866 beginInsertRows(
parent, row, row );
1867 auto item = std::make_unique< QgsAttributesFormItem >();
1876 setFieldItemDataFromLayer( item.get() );
1889 : QSortFilterProxyModel( parent )
1895 QSortFilterProxyModel::setSourceModel( mModel );
1920 if ( mFilterText.isEmpty() )
1923 QModelIndex sourceIndex = sourceModel()->index( sourceRow, 0, sourceParent );
1924 if ( !sourceIndex.isValid() )
1933 QModelIndex parent = sourceIndex.
parent();
1934 while ( parent.isValid() )
1940 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.
QDomElement toDomElement(QDomDocument &doc) const
Gets the XML Dom element to save this 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.