19#include "moc_qgsattributesformproperties.cpp"
20#include "qgsattributetypedialog.h"
21#include "qgsattributeformcontaineredit.h"
22#include "qgsattributewidgetedit.h"
58 QGridLayout *availableWidgetsWidgetLayout =
new QGridLayout;
61 availableWidgetsWidgetLayout->setContentsMargins( 0, 0, 0, 0 );
62 mAvailableWidgetsWidget->setLayout( availableWidgetsWidgetLayout );
69 QGridLayout *formLayoutWidgetLayout =
new QGridLayout;
71 mFormLayoutWidget->setLayout( formLayoutWidgetLayout );
73 formLayoutWidgetLayout->setContentsMargins( 0, 0, 0, 0 );
78 connect(
mAvailableWidgetsView->selectionModel(), &QItemSelectionModel::selectionChanged,
this, &QgsAttributesFormProperties::onAttributeSelectionChanged );
79 connect(
mFormLayoutView->selectionModel(), &QItemSelectionModel::selectionChanged,
this, &QgsAttributesFormProperties::onFormLayoutSelectionChanged );
81 connect(
mAvailableWidgetsView, &QWidget::customContextMenuRequested,
this, &QgsAttributesFormProperties::onContextMenuRequested );
83 connect( mAddContainerButton, &QAbstractButton::clicked,
this, &QgsAttributesFormProperties::addContainer );
84 connect( mRemoveLayoutItemButton, &QAbstractButton::clicked,
this, &QgsAttributesFormProperties::removeTabOrGroupButton );
85 connect( mInvertSelectionButton, &QAbstractButton::clicked,
this, &QgsAttributesFormProperties::onInvertSelectionButtonClicked );
86 connect( mShowAliasesButton, &QAbstractButton::toggled,
this, &QgsAttributesFormProperties::toggleShowAliases );
87 connect( mEditorLayoutComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsAttributesFormProperties::mEditorLayoutComboBox_currentIndexChanged );
88 connect( pbnSelectEditForm, &QToolButton::clicked,
this, &QgsAttributesFormProperties::pbnSelectEditForm_clicked );
89 connect( mTbInitCode, &QPushButton::clicked,
this, &QgsAttributesFormProperties::mTbInitCode_clicked );
98 mAvailableWidgetsContextMenu =
new QMenu(
this );
99 mActionCopyWidgetConfiguration =
new QAction( tr(
"Copy widget configuration" ),
this );
100 mActionPasteWidgetConfiguration =
new QAction( tr(
"Paste widget configuration" ),
this );
102 connect( mActionCopyWidgetConfiguration, &QAction::triggered,
this, &QgsAttributesFormProperties::copyWidgetConfiguration );
103 connect( mActionPasteWidgetConfiguration, &QAction::triggered,
this, &QgsAttributesFormProperties::pasteWidgetConfiguration );
105 mAvailableWidgetsContextMenu->addAction( mActionCopyWidgetConfiguration );
106 mAvailableWidgetsContextMenu->addAction( mActionPasteWidgetConfiguration );
109 mMessageBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
110 gridLayout->addWidget( mMessageBar, 0, 0 );
140 mFormLayoutView->setSelectionBehavior( QAbstractItemView::SelectRows );
141 mFormLayoutView->setSelectionMode( QAbstractItemView::SelectionMode::ExtendedSelection );
143 mFormLayoutView->setDragDropMode( QAbstractItemView::DragDropMode::DragDrop );
183 mEditorLayoutComboBox->setCurrentIndex( mEditorLayoutComboBox->findData( QVariant::fromValue(
mLayer->
editFormConfig().
layout() ) ) );
185 mEditorLayoutComboBox_currentIndexChanged( mEditorLayoutComboBox->currentIndex() );
188 mEditFormLineEdit->setText( cfg.
uiForm() );
200 if ( mInitCode.isEmpty() )
202 mInitCode.append( tr(
"# -*- coding: utf-8 -*-\n\"\"\"\n"
203 "QGIS forms can have a Python function that is called when the form is\n"
206 "Use this function to add extra logic to your forms.\n"
208 "Enter the name of the function in the \"Python Init function\"\n"
210 "An example follows:\n"
212 "from qgis.PyQt.QtWidgets import QWidget\n\n"
213 "def my_form_open(dialog, layer, feature):\n"
214 " geom = feature.geometry()\n"
215 " control = dialog.findChild(QWidget, \"MyLineEdit\")\n" ) );
219void QgsAttributesFormProperties::loadAttributeTypeDialog()
230 if ( fieldIndex < 0 )
235 loadAttributeTypeDialogFromConfiguration( cfg );
241 mAttributeTypeFrame->layout()->setContentsMargins( 0, 0, 0, 0 );
283void QgsAttributesFormProperties::storeAttributeTypeDialog()
344 QModelIndex index = mAvailableWidgetsModel->
fieldModelIndex( fieldName );
345 if ( index.isValid() )
355void QgsAttributesFormProperties::storeAttributeWidgetEdit()
363 QModelIndex index =
mFormLayoutView->selectionModel()->selectedRows().at( 0 );
364 storeAttributeWidgetEdit( index );
367void QgsAttributesFormProperties::storeAttributeWidgetEdit(
const QModelIndex &index )
372 if ( !index.isValid() )
381 itemData.setRelationEditorConfiguration( config );
387void QgsAttributesFormProperties::loadAttributeWidgetEdit()
392 const QModelIndex currentIndex =
mFormLayoutView->selectionModel()->selectedRows().at( 0 );
399 mAttributeTypeFrame->layout()->setContentsMargins( 0, 0, 0, 0 );
403void QgsAttributesFormProperties::loadInfoWidget(
const QString &infoText )
406 mAttributeTypeFrame->layout()->setContentsMargins( 0, 0, 0, 0 );
410void QgsAttributesFormProperties::storeAttributeContainerEdit()
418 const QModelIndex currentIndex =
mFormLayoutView->selectionModel()->selectedRows().at( 0 );
419 storeAttributeContainerEdit( currentIndex );
422void QgsAttributesFormProperties::storeAttributeContainerEdit(
const QModelIndex &index )
427 if ( !index.isValid() )
431 QString containerName;
438void QgsAttributesFormProperties::loadAttributeContainerEdit()
443 const QModelIndex currentIndex =
mFormLayoutView->selectionModel()->selectedRows().at( 0 );
451 mAttributeTypeFrame->layout()->setContentsMargins( 0, 0, 0, 0 );
455void QgsAttributesFormProperties::onAttributeSelectionChanged(
const QItemSelection &,
const QItemSelection & )
457 disconnect(
mFormLayoutView->selectionModel(), &QItemSelectionModel::selectionChanged,
this, &QgsAttributesFormProperties::onFormLayoutSelectionChanged );
460 if (
mFormLayoutView->selectionModel()->selectedRows( 0 ).count() == 1 )
468 connect(
mFormLayoutView->selectionModel(), &QItemSelectionModel::selectionChanged,
this, &QgsAttributesFormProperties::onFormLayoutSelectionChanged );
471void QgsAttributesFormProperties::onFormLayoutSelectionChanged(
const QItemSelection &,
const QItemSelection &deselected )
474 disconnect(
mAvailableWidgetsView->selectionModel(), &QItemSelectionModel::selectionChanged,
this, &QgsAttributesFormProperties::onAttributeSelectionChanged );
476 if ( deselected.indexes().count() == 1 )
478 index = deselected.indexes().at( 0 );
480 else if ( deselected.indexes().count() == 0 &&
mFormLayoutView->selectionModel()->selectedIndexes().count() == 2 )
487 connect(
mAvailableWidgetsView->selectionModel(), &QItemSelectionModel::selectionChanged,
this, &QgsAttributesFormProperties::onAttributeSelectionChanged );
496 storeAttributeWidgetEdit( deselectedFormLayoutIndex );
497 storeAttributeContainerEdit( deselectedFormLayoutIndex );
501 storeAttributeTypeDialog();
504 clearAttributeTypeFrame();
506 if ( emitter->selectionModel()->selectedRows( 0 ).count() != 1 )
508 receiver->clearSelection();
512 const QModelIndex index = emitter->selectionModel()->selectedRows().at( 0 );
521 loadAttributeWidgetEdit();
525 loadInfoWidget( tr(
"This configuration is available in the Drag and Drop Designer" ) );
534 loadAttributeWidgetEdit();
536 loadAttributeTypeDialog();
541 receiver->clearSelection();
542 loadAttributeContainerEdit();
549 loadInfoWidget( action.html() );
559 loadInfoWidget( tr(
"This configuration is available with double-click in the Drag and Drop Designer" ) );
563 loadInfoWidget( tr(
"This configuration is available with double-click in the Form Layout panel" ) );
565 receiver->clearSelection();
570 receiver->clearSelection();
577void QgsAttributesFormProperties::clearAttributeTypeFrame()
605void QgsAttributesFormProperties::onInvertSelectionButtonClicked(
bool checked )
608 for (
int i = 0; i < mFormLayoutModel->
rowCount(); ++i )
610 QModelIndex index = mFormLayoutModel->
index( i, 0 );
611 mFormLayoutView->selectionModel()->select( index, QItemSelectionModel::Toggle );
615void QgsAttributesFormProperties::toggleShowAliases(
bool checked )
622void QgsAttributesFormProperties::addContainer()
624 QList<QgsAddAttributeFormContainerDialog::ContainerPair> existingContainerList = mFormLayoutModel->
listOfContainers();
626 QModelIndex currentItem;
628 currentItem =
mFormLayoutView->selectionModel()->selectedRows().at( 0 );
632 if ( !dialog.exec() )
635 const QString name = dialog.name();
636 QModelIndex parentContainerItem = dialog.parentContainerItem();
638 mFormLayoutModel->
addContainer( parentContainerItem, name, dialog.columnCount(), dialog.containerType() );
639 if ( parentContainerItem.isValid() )
643void QgsAttributesFormProperties::removeTabOrGroupButton()
649 const QModelIndexList items =
mFormLayoutView->selectionModel()->selectedRows();
653 const QModelIndex item = items.at( 0 );
654 mFormLayoutModel->
removeRow( item.row(), item.parent() );
658void QgsAttributesFormProperties::mEditorLayoutComboBox_currentIndexChanged(
int )
662 if ( selection.count() > 0 )
676 mFormLayoutWidget->setVisible(
false );
677 mUiFileFrame->setVisible(
false );
678 mAddContainerButton->setVisible(
false );
679 mRemoveLayoutItemButton->setVisible(
false );
680 mInvertSelectionButton->setVisible(
false );
684 mFormLayoutWidget->setVisible(
true );
685 mUiFileFrame->setVisible(
false );
686 mAddContainerButton->setVisible(
true );
687 mRemoveLayoutItemButton->setVisible(
true );
688 mInvertSelectionButton->setVisible(
true );
693 mFormLayoutWidget->setVisible(
false );
694 mUiFileFrame->setVisible(
true );
695 mAddContainerButton->setVisible(
false );
696 mRemoveLayoutItemButton->setVisible(
false );
697 mInvertSelectionButton->setVisible(
false );
702 if ( selection.count() > 0 )
708void QgsAttributesFormProperties::mTbInitCode_clicked()
717 if ( !attributesFormInitCode.exec() )
720 mInitCodeSource = attributesFormInitCode.
codeSource();
721 mInitCode = attributesFormInitCode.
initCode();
726void QgsAttributesFormProperties::pbnSelectEditForm_clicked()
729 const QString lastUsedDir = myQSettings.
value( QStringLiteral(
"style/lastUIDir" ), QDir::homePath() ).toString();
730 const QString uifilename = QFileDialog::getOpenFileName(
this, tr(
"Select edit form" ), lastUsedDir, tr(
"UI file" ) +
" (*.ui)" );
732 if ( uifilename.isNull() )
735 const QFileInfo fi( uifilename );
736 myQSettings.
setValue( QStringLiteral(
"style/lastUIDir" ), fi.path() );
737 mEditFormLineEdit->setText( uifilename );
742 storeAttributeWidgetEdit();
743 storeAttributeContainerEdit();
744 storeAttributeTypeDialog();
754 const QModelIndex fieldContainer = mAvailableWidgetsModel->
fieldContainer();
757 for (
int i = 0; i < mAvailableWidgetsModel->
rowCount( fieldContainer ); i++ )
759 index = mAvailableWidgetsModel->
index( i, 0, fieldContainer );
816 for (
int t = 0; t < mFormLayoutModel->
rowCount(); t++ )
818 QModelIndex index = mFormLayoutModel->
index( t, 0 );
821 editFormConfig.
addTab( editorElement );
824 editFormConfig.
setUiForm( mEditFormLineEdit->text() );
836 const QModelIndex relationContainer = mAvailableWidgetsModel->
relationContainer();
838 for (
int i = 0; i < mAvailableWidgetsModel->
rowCount( relationContainer ); i++ )
840 const QModelIndex relationIndex = mAvailableWidgetsModel->
index( i, 0, relationContainer );
847 if ( layoutIndex.isValid() )
866 : QTreeView( parent )
877 if ( index.isValid() )
880 selectionModel()->setCurrentIndex( index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
884 selectionModel()->clearSelection();
909 mModel = qobject_cast<QgsAttributesAvailableWidgetsModel *>( model );
913 QTreeView::setModel( mModel );
925 connect(
this, &QTreeView::doubleClicked,
this, &QgsAttributesFormLayoutView::onItemDoubleClicked );
930 mModel = qobject_cast<QgsAttributesFormLayoutModel *>( model );
934 QTreeView::setModel( mModel );
945void QgsAttributesFormLayoutView::handleExternalDroppedItem( QModelIndex &index )
947 selectionModel()->setCurrentIndex( index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
956 onItemDoubleClicked( index );
960void QgsAttributesFormLayoutView::handleInternalDroppedItem( QModelIndex &index )
962 selectionModel()->clearCurrentIndex();
966 expandRecursively( index );
972 const QMimeData *data =
event->mimeData();
974 if ( data->hasFormat( QStringLiteral(
"application/x-qgsattributesformavailablewidgetsrelement" ) )
975 || data->hasFormat( QStringLiteral(
"application/x-qgsattributesformlayoutelement" ) ) )
978 if ( event->source() ==
this )
980 event->setDropAction( Qt::MoveAction );
988 QTreeView::dragEnterEvent( event );
997 const QMimeData *data =
event->mimeData();
999 if ( data->hasFormat( QStringLiteral(
"application/x-qgsattributesformavailablewidgetsrelement" ) )
1000 || data->hasFormat( QStringLiteral(
"application/x-qgsattributesformlayoutelement" ) ) )
1003 if ( event->source() ==
this )
1005 event->setDropAction( Qt::MoveAction );
1013 QTreeView::dragMoveEvent( event );
1018 if ( !( event->mimeData()->hasFormat( QStringLiteral(
"application/x-qgsattributesformavailablewidgetsrelement" ) )
1019 || event->mimeData()->hasFormat( QStringLiteral(
"application/x-qgsattributesformlayoutelement" ) ) ) )
1022 if ( event->source() ==
this )
1024 event->setDropAction( Qt::MoveAction );
1027 QTreeView::dropEvent( event );
1030void QgsAttributesFormLayoutView::onItemDoubleClicked(
const QModelIndex &index )
1036 QGroupBox *baseData =
new QGroupBox( tr(
"Base configuration" ) );
1038 QFormLayout *baseLayout =
new QFormLayout();
1039 baseData->setLayout( baseLayout );
1040 QCheckBox *showLabelCheckbox =
new QCheckBox( QStringLiteral(
"Show label" ) );
1041 showLabelCheckbox->setChecked( itemData.
showLabel() );
1042 baseLayout->addRow( showLabelCheckbox );
1043 QWidget *baseWidget =
new QWidget();
1044 baseWidget->setLayout( baseLayout );
1058 dlg.setObjectName(
"QML Form Configuration Widget" );
1060 dlg.setWindowTitle( tr(
"Configure QML Widget" ) );
1062 QVBoxLayout *mainLayout =
new QVBoxLayout( &dlg );
1063 QSplitter *qmlSplitter =
new QSplitter();
1064 QWidget *qmlConfigWiget =
new QWidget();
1065 QVBoxLayout *layout =
new QVBoxLayout( qmlConfigWiget );
1066 layout->setContentsMargins( 0, 0, 0, 0 );
1067 mainLayout->addWidget( qmlSplitter );
1068 qmlSplitter->addWidget( qmlConfigWiget );
1069 layout->addWidget( baseWidget );
1071 QLineEdit *title =
new QLineEdit( itemName );
1090 QComboBox *qmlObjectTemplate =
new QComboBox();
1091 qmlObjectTemplate->addItem( tr(
"Free Text…" ) );
1092 qmlObjectTemplate->addItem( tr(
"Rectangle" ) );
1093 qmlObjectTemplate->addItem( tr(
"Pie Chart" ) );
1094 qmlObjectTemplate->addItem( tr(
"Bar Chart" ) );
1095 connect( qmlObjectTemplate, qOverload<int>( &QComboBox::activated ), qmlCode, [=](
int index ) {
1101 qmlCode->
setText( QString() );
1106 qmlCode->
setText( QStringLiteral(
"import QtQuick 2.0\n"
1111 " color: \"steelblue\"\n"
1112 " Text{ text: \"A rectangle\" }\n"
1118 qmlCode->
setText( QStringLiteral(
"import QtQuick 2.0\n"
1119 "import QtCharts 2.0\n"
1127 " PieSlice { label: \"First slice\"; value: 25 }\n"
1128 " PieSlice { label: \"Second slice\"; value: 45 }\n"
1129 " PieSlice { label: \"Third slice\"; value: 30 }\n"
1136 qmlCode->
setText( QStringLiteral(
"import QtQuick 2.0\n"
1137 "import QtCharts 2.0\n"
1140 " title: \"Bar series\"\n"
1143 " legend.alignment: Qt.AlignBottom\n"
1144 " antialiasing: true\n"
1153 " axisY: valueAxisY\n"
1154 " axisX: BarCategoryAxis { categories: [\"2007\", \"2008\", \"2009\", \"2010\", \"2011\", \"2012\" ] }\n"
1155 " BarSet { label: \"Bob\"; values: [2, 2, 3, 4, 5, 6] }\n"
1156 " BarSet { label: \"Susan\"; values: [5, 1, 2, 4, 1, 7] }\n"
1157 " BarSet { label: \"James\"; values: [3, 5, 8, 13, 5, 8] }\n"
1169 expressionWidget->registerExpressionContextGenerator(
this );
1170 expressionWidget->setLayer(
mLayer );
1171 QToolButton *addFieldButton =
new QToolButton();
1174 QToolButton *editExpressionButton =
new QToolButton();
1176 editExpressionButton->setToolTip( tr(
"Insert/Edit Expression" ) );
1178 connect( addFieldButton, &QAbstractButton::clicked,
this, [=] {
1179 QString expression = expressionWidget->expression().trimmed().replace(
'"', QLatin1String(
"\\\"" ) );
1180 if ( !expression.isEmpty() )
1181 qmlCode->
insertText( QStringLiteral(
"expression.evaluate(\"%1\")" ).arg( expression ) );
1184 connect( editExpressionButton, &QAbstractButton::clicked,
this, [=] {
1186 expression.replace( QLatin1String(
"\\\"" ), QLatin1String(
"\"" ) );
1190 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
1191 if ( exprDlg.exec() == QDialog::Accepted && !exprDlg.expressionText().trimmed().isEmpty() )
1193 QString expression = exprDlg.expressionText().trimmed().replace(
'"', QLatin1String(
"\\\"" ) );
1194 if ( !expression.isEmpty() )
1195 qmlCode->
insertText( QStringLiteral(
"expression.evaluate(\"%1\")" ).arg( expression ) );
1199 layout->addWidget(
new QLabel( tr(
"Title" ) ) );
1200 layout->addWidget( title );
1201 QGroupBox *qmlCodeBox =
new QGroupBox( tr(
"QML Code" ) );
1202 qmlCodeBox->setLayout(
new QVBoxLayout );
1203 qmlCodeBox->layout()->addWidget( qmlObjectTemplate );
1204 QWidget *expressionWidgetBox =
new QWidget();
1205 qmlCodeBox->layout()->addWidget( expressionWidgetBox );
1206 expressionWidgetBox->setLayout(
new QHBoxLayout );
1207 expressionWidgetBox->layout()->setContentsMargins( 0, 0, 0, 0 );
1208 expressionWidgetBox->layout()->addWidget( expressionWidget );
1209 expressionWidgetBox->layout()->addWidget( addFieldButton );
1210 expressionWidgetBox->layout()->addWidget( editExpressionButton );
1211 expressionWidgetBox->layout()->addWidget( editExpressionButton );
1212 layout->addWidget( qmlCodeBox );
1213 layout->addWidget( qmlCode );
1215 qmlPreviewBox->setMinimumWidth( 200 );
1216 qmlPreviewBox->setWidget( qmlWrapper->
widget() );
1219 qmlSplitter->addWidget( qmlPreviewBox );
1220 qmlSplitter->setChildrenCollapsible(
false );
1221 qmlSplitter->setHandleWidth( 6 );
1222 qmlSplitter->setSizes( QList<int>() << 1 << 1 );
1224 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help );
1226 connect( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
1227 connect( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
1228 connect( buttonBox, &QDialogButtonBox::helpRequested, &dlg, [=] {
1229 QgsHelp::openHelp( QStringLiteral(
"working_with_vector/vector_properties.html#other-widgets" ) );
1232 mainLayout->addWidget( buttonBox );
1237 qmlEdCfg.
qmlCode = qmlCode->text();
1239 itemData.
setShowLabel( showLabelCheckbox->isChecked() );
1250 dlg.setObjectName(
"HTML Form Configuration Widget" );
1252 dlg.setWindowTitle( tr(
"Configure HTML Widget" ) );
1254 QVBoxLayout *mainLayout =
new QVBoxLayout( &dlg );
1255 QSplitter *htmlSplitter =
new QSplitter();
1256 QWidget *htmlConfigWiget =
new QWidget();
1257 QVBoxLayout *layout =
new QVBoxLayout( htmlConfigWiget );
1258 layout->setContentsMargins( 0, 0, 0, 0 );
1259 mainLayout->addWidget( htmlSplitter );
1260 htmlSplitter->addWidget( htmlConfigWiget );
1261 htmlSplitter->setChildrenCollapsible(
false );
1262 htmlSplitter->setHandleWidth( 6 );
1263 htmlSplitter->setSizes( QList<int>() << 1 << 1 );
1264 layout->addWidget( baseWidget );
1266 QLineEdit *title =
new QLineEdit( itemName );
1270 htmlCode->setSizePolicy( QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Expanding );
1278 connect( htmlCode, &QgsCodeEditorHTML::textChanged,
this, [=] {
1286 expressionWidget->registerExpressionContextGenerator(
this );
1287 expressionWidget->setLayer(
mLayer );
1288 QToolButton *addFieldButton =
new QToolButton();
1291 QToolButton *editExpressionButton =
new QToolButton();
1293 editExpressionButton->setToolTip( tr(
"Insert/Edit Expression" ) );
1295 connect( addFieldButton, &QAbstractButton::clicked,
this, [=] {
1296 QString expression = expressionWidget->expression().trimmed().replace(
'"', QLatin1String(
"\\\"" ) );
1297 if ( !expression.isEmpty() )
1298 htmlCode->
insertText( QStringLiteral(
"<script>document.write(expression.evaluate(\"%1\"));</script>" ).arg( expression ) );
1301 connect( editExpressionButton, &QAbstractButton::clicked,
this, [=] {
1303 expression.replace( QLatin1String(
"\\\"" ), QLatin1String(
"\"" ) );
1307 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
1308 if ( exprDlg.exec() == QDialog::Accepted && !exprDlg.expressionText().trimmed().isEmpty() )
1310 QString expression = exprDlg.expressionText().trimmed().replace(
'"', QLatin1String(
"\\\"" ) );
1311 if ( !expression.isEmpty() )
1312 htmlCode->
insertText( QStringLiteral(
"<script>document.write(expression.evaluate(\"%1\"));</script>" ).arg( expression ) );
1316 layout->addWidget(
new QLabel( tr(
"Title" ) ) );
1317 layout->addWidget( title );
1318 QGroupBox *expressionWidgetBox =
new QGroupBox( tr(
"HTML Code" ) );
1319 layout->addWidget( expressionWidgetBox );
1320 expressionWidgetBox->setLayout(
new QHBoxLayout );
1321 expressionWidgetBox->layout()->addWidget( expressionWidget );
1322 expressionWidgetBox->layout()->addWidget( addFieldButton );
1323 expressionWidgetBox->layout()->addWidget( editExpressionButton );
1324 layout->addWidget( htmlCode );
1326 htmlPreviewBox->setLayout(
new QGridLayout );
1327 htmlPreviewBox->setMinimumWidth( 200 );
1328 htmlPreviewBox->layout()->addWidget( htmlWrapper->
widget() );
1330 emit htmlCode->textChanged();
1331 htmlSplitter->addWidget( htmlPreviewBox );
1332 htmlSplitter->setChildrenCollapsible(
false );
1333 htmlSplitter->setHandleWidth( 6 );
1334 htmlSplitter->setSizes( QList<int>() << 1 << 1 );
1336 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help );
1338 connect( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
1339 connect( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
1340 connect( buttonBox, &QDialogButtonBox::helpRequested, &dlg, [=] {
1341 QgsHelp::openHelp( QStringLiteral(
"working_with_vector/vector_properties.html#other-widgets" ) );
1344 mainLayout->addWidget( buttonBox );
1349 htmlEdCfg.
htmlCode = htmlCode->text();
1351 itemData.
setShowLabel( showLabelCheckbox->isChecked() );
1362 dlg.setObjectName(
"Text Form Configuration Widget" );
1364 dlg.setWindowTitle( tr(
"Configure Text Widget" ) );
1366 QVBoxLayout *mainLayout =
new QVBoxLayout( &dlg );
1367 QSplitter *textSplitter =
new QSplitter();
1368 QWidget *textConfigWiget =
new QWidget();
1369 QVBoxLayout *layout =
new QVBoxLayout( textConfigWiget );
1370 layout->setContentsMargins( 0, 0, 0, 0 );
1371 mainLayout->addWidget( textSplitter );
1372 textSplitter->addWidget( textConfigWiget );
1373 layout->addWidget( baseWidget );
1375 QLineEdit *title =
new QLineEdit( itemName );
1378 text->setSizePolicy( QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Expanding );
1386 connect( text, &QgsCodeEditorExpression::textChanged,
this, [=] {
1387 textWrapper->
setText( text->text() );
1394 expressionWidget->registerExpressionContextGenerator(
this );
1395 expressionWidget->setLayer(
mLayer );
1396 QToolButton *addFieldButton =
new QToolButton();
1399 QToolButton *editExpressionButton =
new QToolButton();
1401 editExpressionButton->setToolTip( tr(
"Insert/Edit Expression" ) );
1403 connect( addFieldButton, &QAbstractButton::clicked,
this, [=] {
1404 QString expression = expressionWidget->expression().trimmed();
1405 if ( !expression.isEmpty() )
1406 text->
insertText( QStringLiteral(
"[%%1%]" ).arg( expression ) );
1408 connect( editExpressionButton, &QAbstractButton::clicked,
this, [=] {
1414 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
1415 if ( exprDlg.exec() == QDialog::Accepted && !exprDlg.expressionText().trimmed().isEmpty() )
1417 QString expression = exprDlg.expressionText().trimmed();
1418 if ( !expression.isEmpty() )
1419 text->
insertText( QStringLiteral(
"[%%1%]" ).arg( expression ) );
1423 layout->addWidget(
new QLabel( tr(
"Title" ) ) );
1424 layout->addWidget( title );
1425 QGroupBox *expressionWidgetBox =
new QGroupBox( tr(
"Text" ) );
1426 layout->addWidget( expressionWidgetBox );
1427 expressionWidgetBox->setLayout(
new QHBoxLayout );
1428 expressionWidgetBox->layout()->addWidget( expressionWidget );
1429 expressionWidgetBox->layout()->addWidget( addFieldButton );
1430 expressionWidgetBox->layout()->addWidget( editExpressionButton );
1431 layout->addWidget( text );
1433 textPreviewBox->setLayout(
new QGridLayout );
1434 textPreviewBox->setMinimumWidth( 200 );
1435 textPreviewBox->layout()->addWidget( textWrapper->
widget() );
1437 emit text->textChanged();
1438 textSplitter->addWidget( textPreviewBox );
1439 textSplitter->setChildrenCollapsible(
false );
1440 textSplitter->setHandleWidth( 6 );
1441 textSplitter->setSizes( QList<int>() << 1 << 1 );
1443 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help );
1445 connect( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
1446 connect( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
1447 connect( buttonBox, &QDialogButtonBox::helpRequested, &dlg, [=] {
1448 QgsHelp::openHelp( QStringLiteral(
"working_with_vector/vector_properties.html#other-widgets" ) );
1451 mainLayout->addWidget( buttonBox );
1456 textEdCfg.
text = text->text();
1458 itemData.
setShowLabel( showLabelCheckbox->isChecked() );
1469 dlg.setObjectName(
"Spacer Form Configuration Widget" );
1471 dlg.setWindowTitle( tr(
"Configure Spacer Widget" ) );
1473 QVBoxLayout *mainLayout =
new QVBoxLayout();
1474 mainLayout->addWidget(
new QLabel( tr(
"Title" ) ) );
1475 QLineEdit *title =
new QLineEdit( itemName );
1476 mainLayout->addWidget( title );
1478 QHBoxLayout *cbLayout =
new QHBoxLayout();
1479 mainLayout->addLayout( cbLayout );
1480 dlg.setLayout( mainLayout );
1481 QCheckBox *cb =
new QCheckBox { &dlg };
1483 cbLayout->addWidget(
new QLabel( tr(
"Draw horizontal line" ), &dlg ) );
1484 cbLayout->addWidget( cb );
1486 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help );
1488 connect( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
1489 connect( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
1490 connect( buttonBox, &QDialogButtonBox::helpRequested, &dlg, [=] {
1491 QgsHelp::openHelp( QStringLiteral(
"working_with_vector/vector_properties.html#other-widgets" ) );
1494 mainLayout->addWidget( buttonBox );
1499 spacerEdCfg.
drawLine = cb->isChecked();
1513void QgsAttributesFormProperties::updatedFields()
1516 QMap<QString, QgsAttributesFormData::FieldConfig> fieldConfigs;
1518 const QModelIndex fieldContainerBefore = mAvailableWidgetsModel->
fieldContainer();
1521 for (
int i = 0; i < mAvailableWidgetsModel->
rowCount( fieldContainerBefore ); i++ )
1523 index = mAvailableWidgetsModel->
index( i, 0, fieldContainerBefore );
1526 fieldConfigs[fieldName] = config;
1531 const QModelIndex fieldContainerAfter = mAvailableWidgetsModel->
fieldContainer();
1533 for (
int i = 0; i < mAvailableWidgetsModel->
rowCount( fieldContainerAfter ); i++ )
1535 index = mAvailableWidgetsModel->
index( i, 0, fieldContainerAfter );
1538 if ( fieldConfigs.contains( fieldName ) )
1546void QgsAttributesFormProperties::onContextMenuRequested( QPoint point )
1557 const QClipboard *clipboard = QApplication::clipboard();
1558 const QMimeData *mimeData = clipboard->mimeData();
1562 const bool pasteEnabled = mimeData->hasFormat( QStringLiteral(
"application/x-qgsattributetabledesignerelementclipboard" ) );
1563 mActionPasteWidgetConfiguration->setEnabled( pasteEnabled );
1564 mAvailableWidgetsContextMenu->popup( globalPos );
1568void QgsAttributesFormProperties::copyWidgetConfiguration()
1582 if ( fieldIndex < 0 )
1589 QDomElement documentElement = doc.createElement( QStringLiteral(
"FormWidgetClipboard" ) );
1590 documentElement.setAttribute( QStringLiteral(
"name" ), field.
name() );
1595 QDomElement editWidgetElement = doc.createElement( QStringLiteral(
"editWidget" ) );
1596 documentElement.appendChild( editWidgetElement );
1597 editWidgetElement.setAttribute( QStringLiteral(
"type" ), widgetSetup.
type() );
1598 QDomElement editWidgetConfigElement = doc.createElement( QStringLiteral(
"config" ) );
1601 editWidgetElement.appendChild( editWidgetConfigElement );
1604 QDomElement splitPolicyElement = doc.createElement( QStringLiteral(
"splitPolicy" ) );
1606 documentElement.appendChild( splitPolicyElement );
1609 QDomElement duplicatePolicyElement = doc.createElement( QStringLiteral(
"duplicatePolicy" ) );
1611 documentElement.appendChild( duplicatePolicyElement );
1614 QDomElement mergePolicyElement = doc.createElement( QStringLiteral(
"mergePolicy" ) );
1616 documentElement.appendChild( mergePolicyElement );
1619 QDomElement defaultElem = doc.createElement( QStringLiteral(
"default" ) );
1622 documentElement.appendChild( defaultElem );
1625 QDomElement constraintElem = doc.createElement( QStringLiteral(
"constraint" ) );
1630 documentElement.appendChild( constraintElem );
1633 QDomElement constraintExpressionElem = doc.createElement( QStringLiteral(
"constraintExpression" ) );
1636 documentElement.appendChild( constraintExpressionElem );
1641 QDomElement widgetGeneralSettingsElem = doc.createElement( QStringLiteral(
"widgetGeneralSettings" ) );
1642 widgetGeneralSettingsElem.setAttribute( QStringLiteral(
"editable" ),
mAttributeTypeDialog->fieldEditable() );
1643 widgetGeneralSettingsElem.setAttribute( QStringLiteral(
"reuse_last_values" ),
mAttributeTypeDialog->labelOnTop() );
1644 widgetGeneralSettingsElem.setAttribute( QStringLiteral(
"label_on_top" ),
mAttributeTypeDialog->reuseLastValues() );
1645 documentElement.appendChild( widgetGeneralSettingsElem );
1655 const QModelIndex indexLayout =
mFormLayoutView->selectionModel()->selectedRows().at( 0 );
1658 QDomElement displayElement = doc.createElement( QStringLiteral(
"widgetDisplay" ) );
1659 displayElement.setAttribute( QStringLiteral(
"showLabel" ), layoutData.showLabel() );
1660 displayElement.setAttribute( QStringLiteral(
"horizontalStretch" ), layoutData.horizontalStretch() );
1661 displayElement.setAttribute( QStringLiteral(
"verticalStretch" ), layoutData.verticalStretch() );
1662 displayElement.appendChild( layoutData.labelStyle().writeXml( doc ) );
1663 documentElement.appendChild( displayElement );
1666 doc.appendChild( documentElement );
1668 QMimeData *mimeData =
new QMimeData;
1669 mimeData->setData( QStringLiteral(
"application/x-qgsattributetabledesignerelementclipboard" ), doc.toByteArray() );
1670 QClipboard *clipboard = QApplication::clipboard();
1671 clipboard->setMimeData( mimeData );
1674void QgsAttributesFormProperties::pasteWidgetConfiguration()
1684 if ( fieldIndex < 0 )
1691 QClipboard *clipboard = QApplication::clipboard();
1692 const QMimeData *mimeData = clipboard->mimeData();
1696 if ( doc.setContent( mimeData->data( QStringLiteral(
"application/x-qgsattributetabledesignerelementclipboard" ) ) ) )
1698 QDomElement docElem = doc.documentElement();
1699 if ( docElem.tagName() != QLatin1String(
"FormWidgetClipboard" ) )
1708 const QDomElement fieldWidgetElement = docElem.firstChildElement( QStringLiteral(
"editWidget" ) );
1709 if ( !fieldWidgetElement.isNull() )
1711 const QString widgetType = fieldWidgetElement.attribute( QStringLiteral(
"type" ) );
1717 const QDomElement configElement = fieldWidgetElement.firstChildElement( QStringLiteral(
"config" ) );
1718 if ( !configElement.isNull() )
1720 const QDomElement optionsElem = configElement.childNodes().at( 0 ).toElement();
1724 if ( widgetType == QStringLiteral(
"ValueRelation" ) )
1726 optionsMap[QStringLiteral(
"Value" )] = context.
projectTranslator()->
translate( QStringLiteral(
"project:layers:%1:fields:%2:valuerelationvalue" ).arg(
mLayer->
id(), fieldName ), optionsMap[QStringLiteral(
"Value" )].toString() );
1728 if ( widgetType == QStringLiteral(
"ValueMap" ) )
1730 if ( optionsMap[QStringLiteral(
"map" )].canConvert<QList<QVariant>>() )
1732 QList<QVariant> translatedValueList;
1733 const QList<QVariant> valueList = optionsMap[QStringLiteral(
"map" )].toList();
1734 for (
int i = 0, row = 0; i < valueList.count(); i++, row++ )
1736 QMap<QString, QVariant> translatedValueMap;
1737 QString translatedKey = context.
projectTranslator()->
translate( QStringLiteral(
"project:layers:%1:fields:%2:valuemapdescriptions" ).arg(
mLayer->
id(), fieldName ), valueList[i].toMap().constBegin().key() );
1738 translatedValueMap.insert( translatedKey, valueList[i].toMap().constBegin().value() );
1739 translatedValueList.append( translatedValueMap );
1741 optionsMap.insert( QStringLiteral(
"map" ), translatedValueList );
1750 mMessageBar->
pushMessage( QString(), tr(
"Unable to paste widget configuration. The target field (%1) does not support the %2 widget type." ).arg( fieldName, widgetType ),
Qgis::MessageLevel::Warning );
1755 const QDomElement splitPolicyElement = docElem.firstChildElement( QStringLiteral(
"splitPolicy" ) );
1756 if ( !splitPolicyElement.isNull() )
1763 const QDomElement duplicatePolicyElement = docElem.firstChildElement( QStringLiteral(
"duplicatePolicy" ) );
1764 if ( !duplicatePolicyElement.isNull() )
1771 const QDomElement mergePolicyElement = docElem.firstChildElement( QStringLiteral(
"mergePolicy" ) );
1772 if ( !mergePolicyElement.isNull() )
1779 const QDomElement defaultElement = docElem.firstChildElement( QStringLiteral(
"default" ) );
1780 if ( !defaultElement.isNull() )
1782 mAttributeTypeDialog->setDefaultValueExpression( defaultElement.attribute( QStringLiteral(
"expression" ) ) );
1783 mAttributeTypeDialog->setApplyDefaultValueOnUpdate( defaultElement.attribute( QStringLiteral(
"applyOnUpdate" ) ).toInt() );
1789 const QDomElement constraintElement = docElem.firstChildElement( QStringLiteral(
"constraint" ) );
1790 if ( !constraintElement.isNull() )
1792 const int intConstraints = constraintElement.attribute( QStringLiteral(
"constraints" ), QStringLiteral(
"0" ) ).toInt();
1818 const int uniqueStrength = constraintElement.attribute( QStringLiteral(
"unique_strength" ), QStringLiteral(
"1" ) ).toInt();
1819 const int notNullStrength = constraintElement.attribute( QStringLiteral(
"notnull_strength" ), QStringLiteral(
"1" ) ).toInt();
1820 const int expStrength = constraintElement.attribute( QStringLiteral(
"exp_strength" ), QStringLiteral(
"1" ) ).toInt();
1831 const QDomElement constraintExpressionElement = docElem.firstChildElement( QStringLiteral(
"constraintExpression" ) );
1832 if ( !constraintExpressionElement.isNull() )
1834 QString expression = constraintExpressionElement.attribute( QStringLiteral(
"exp" ), QString() );
1835 QString description = constraintExpressionElement.attribute( QStringLiteral(
"desc" ), QString() );
1841 const QDomElement widgetGeneralSettingsElement = docElem.firstChildElement( QStringLiteral(
"widgetGeneralSettings" ) );
1842 if ( !widgetGeneralSettingsElement.isNull() )
1844 const int editable = widgetGeneralSettingsElement.attribute( QStringLiteral(
"editable" ), QStringLiteral(
"0" ) ).toInt();
1845 const int reuse = widgetGeneralSettingsElement.attribute( QStringLiteral(
"reuse_last_values" ), QStringLiteral(
"0" ) ).toInt();
1846 const int labelOnTop = widgetGeneralSettingsElement.attribute( QStringLiteral(
"label_on_top" ), QStringLiteral(
"0" ) ).toInt();
1853 loadAttributeTypeDialogFromConfiguration( config );
1858 const QDomElement displayElement = docElem.firstChildElement( QStringLiteral(
"widgetDisplay" ) );
1859 if ( !displayElement.isNull() )
1861 const int showLabel = displayElement.attribute( QStringLiteral(
"showLabel" ), QStringLiteral(
"0" ) ).toInt();
1862 const int horizontalStretch = displayElement.attribute( QStringLiteral(
"horizontalStretch" ), QStringLiteral(
"0" ) ).toInt();
1863 const int verticalStretch = displayElement.attribute( QStringLiteral(
"verticalStretch" ), QStringLiteral(
"0" ) ).toInt();
1865 style.
readXml( displayElement );
AttributeFormSuppression
Available form types for layout of the attribute form editor.
@ On
Always suppress feature form.
@ Default
Use the application-wide setting.
@ Off
Never suppress feature form.
AttributeFormLayout
Available form types for layout of the attribute form editor.
@ DragAndDrop
"Drag and drop" layout. Needs to be configured.
@ AutoGenerated
Autogenerate a simple tabular layout for the form.
@ UiFile
Load a .ui file for the layout. Needs to be configured.
FieldDomainMergePolicy
Merge policy for field domains.
@ DefaultValue
Use default field value.
@ Warning
Warning message.
FieldDomainSplitPolicy
Split policy for field domains.
@ Duplicate
Duplicate original value.
FieldDuplicatePolicy
Duplicate policy for fields.
@ Duplicate
Duplicate original value.
QgsAction action(QUuid id) const
Gets an action by its id.
Utility class that encapsulates an action based on vector attributes.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
An abstract base class for any elements of a drag and drop form.
A HTML editor based on QScintilla2.
A text editor based on QScintilla2.
void setText(const QString &text) override
void setEditingTimeoutInterval(int timeout)
Sets the timeout (in milliseconds) threshold for the editingTimeout() signal to be emitted after an e...
void insertText(const QString &text)
Insert text at cursor position, or replace any selected text if user has made a selection.
void editingTimeout()
Emitted when either:
Provides a container for managing client side default values for fields.
A generic dialog for building expression strings.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static QgsExpressionContextScope * formScope(const QgsFeature &formFeature=QgsFeature(), const QString &formMode=QString())
Creates a new scope which contains functions and variables from the current attribute form/table form...
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void appendScopes(const QList< QgsExpressionContextScope * > &scopes)
Appends a list of scopes to the end of the context.
static QString findAndSelectActiveExpression(QgsCodeEditor *editor, const QString &pattern=QString())
Find the expression under the cursor in the given editor and select it.
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Stores information about constraints which may be present on a field.
ConstraintStrength
Strength of constraints.
@ ConstraintStrengthHard
Constraint must be honored before feature can be accepted.
void setConstraintStrength(Constraint constraint, ConstraintStrength strength)
Sets the strength of a constraint.
void setConstraintExpression(const QString &expression, const QString &description=QString())
Set the constraint expression for the field.
@ ConstraintOriginProvider
Constraint was set at data provider.
@ ConstraintOriginLayer
Constraint was set by layer.
ConstraintStrength constraintStrength(Constraint constraint) const
Returns the strength of a field constraint, or ConstraintStrengthNotSet if the constraint is not pres...
ConstraintOrigin constraintOrigin(Constraint constraint) const
Returns the origin of a field constraint, or ConstraintOriginNotSet if the constraint is not present ...
QString constraintExpression() const
Returns the constraint expression for the field, if set.
@ ConstraintNotNull
Field may not be null.
@ ConstraintUnique
Field must have a unique value.
@ ConstraintExpression
Field has an expression constraint set. See constraintExpression().
void removeConstraint(Constraint constraint)
Removes a constraint from the field.
QString constraintDescription() const
Returns the descriptive name for the constraint expression.
void setConstraint(Constraint constraint, ConstraintOrigin origin=ConstraintOriginLayer)
Sets a constraint on the field.
QFlags< Constraint > Constraints
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
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
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).
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
static QgsEditorWidgetRegistry * editorWidgetRegistry()
Returns the global editor widget registry, used for managing all known edit widget factories.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
A bar for displaying non-blocking messages to the user.
void pushMessage(const QString &text, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=-1)
A convenience method for pushing a message with the specified text to the bar.
virtual QString translate(const QString &context, const QString &sourceText, const char *disambiguation=nullptr, int n=-1) const =0
Translates a string using the Qt QTranslator mechanism.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
static QgsProject * instance()
Returns the QgsProject singleton instance.
int count() const
Returns the number of properties contained within the collection.
A container for the context for various read/write operations on objects.
const QgsProjectTranslator * projectTranslator() const
Returns the project translator.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
bool setValue(const T &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
A boolean settings entry.
static const QgsSettingsEntryBool * settingsDigitizingDisableEnterAttributeValuesDialog
Settings entry digitizing disable enter attribute values dialog.
Stores settings for use within QGIS.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Wraps a label widget to display text.
void setText(const QString &text)
Sets the text code to htmlCode.
void reinitWidget()
Clears the content and makes new initialization.
void setFeature(const QgsFeature &feature) override
Represents a vector layer which manages a vector based dataset.
QgsDefaultValue defaultValueDefinition(int index) const
Returns the definition of the expression used when calculating the default value for a field.
void setFieldConstraint(int index, QgsFieldConstraints::Constraint constraint, QgsFieldConstraints::ConstraintStrength strength=QgsFieldConstraints::ConstraintStrengthHard)
Sets a constraint for a specified field index.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
void removeFieldConstraint(int index, QgsFieldConstraints::Constraint constraint)
Removes a constraint for a specified field index.
void setFieldMergePolicy(int index, Qgis::FieldDomainMergePolicy policy)
Sets a merge policy for the field with the specified index.
void setDefaultValueDefinition(int index, const QgsDefaultValue &definition)
Sets the definition of the expression to use when calculating the default value for a field.
void setEditFormConfig(const QgsEditFormConfig &editFormConfig)
Sets the editFormConfig (configuration) of the form used to represent this vector layer.
void setEditorWidgetSetup(int index, const QgsEditorWidgetSetup &setup)
Sets the editor widget setup for the field at the specified index.
void setConstraintExpression(int index, const QString &expression, const QString &description=QString())
Sets the constraint expression for the specified field index.
void setFieldDuplicatePolicy(int index, Qgis::FieldDuplicatePolicy policy)
Sets a duplicate policy for the field with the specified index.
QgsActionManager * actions()
Returns all layer actions defined on this layer.
void setFieldAlias(int index, const QString &aliasString)
Sets an alias (a display name) for attributes to display in dialogs.
void updatedFields()
Emitted whenever the fields available from this layer have been changed.
QgsEditFormConfig editFormConfig
void setFieldSplitPolicy(int index, Qgis::FieldDomainSplitPolicy policy)
Sets a split policy for the field with the specified index.
static QDomElement writeVariant(const QVariant &value, QDomDocument &doc)
Write a QVariant to a QDomElement.
static QVariant readVariant(const QDomElement &element)
Read a QVariant from a QDomElement.
T qgsEnumKeyToValue(const QString &key, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given key of an enum.
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
The TabStyle struct defines color and font overrides for form fields, tabs and groups labels.
void readXml(const QDomNode &node)
Reads configuration from node.