20#include "qgsattributetypedialog.h"
41#include <QPlainTextEdit>
49#include "moc_qgsattributesformview.cpp"
51using namespace Qt::StringLiterals;
60 if ( selectionModel()->selectedRows( 0 ).count() == 0 )
63 return mModel->mapToSource( selectionModel()->selectedRows( 0 ).at( 0 ) );
82 QModelIndex index =
mModel->mapFromSource( model->firstRecursiveMatchingModelIndex( itemType, itemId ) );
84 if ( index.isValid() )
88 const QModelIndexList selectedIndexes = selectionModel()->selectedRows( 0 );
89 if ( !( selectedIndexes.count() == 1 && selectedIndexes.at( 0 ) == index ) )
91 selectionModel()->setCurrentIndex( index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
96 selectionModel()->clearSelection();
102 mModel->setFilterText( text );
123 viewport()->repaint();
126 viewport()->repaint();
138 const QList<QgsAttributesFormItem *> keys =
mIndicators.keys();
150 return mModel->sourceAttributesFormModel();
160 mModel = qobject_cast<QgsAttributesFormProxyModel *>( model );
164 QTreeView::setModel(
mModel );
176 connect(
this, &QTreeView::doubleClicked,
this, &QgsAttributesFormLayoutView::onItemDoubleClicked );
181 mModel = qobject_cast<QgsAttributesFormProxyModel *>( model );
185 QTreeView::setModel(
mModel );
193void QgsAttributesFormLayoutView::selectDroppedItems(
const QModelIndexList &indexes )
195 if ( indexes.isEmpty() )
198 QItemSelection selection;
199 for (
const QModelIndex &index : indexes )
201 const QModelIndex proxyIndex =
mModel->mapFromSource( index );
202 selection.select( proxyIndex, proxyIndex );
207 selectionModel()->setCurrentIndex(
mModel->mapFromSource( indexes.constLast() ), QItemSelectionModel::NoUpdate );
208 selectionModel()->select( selection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
211void QgsAttributesFormLayoutView::handleExternalDroppedItems(
const QModelIndexList &indexes )
213 selectDroppedItems( indexes );
215 for (
const QModelIndex &index : indexes )
226 onItemDoubleClicked(
mModel->mapFromSource( index ) );
239void QgsAttributesFormLayoutView::handleInternalDroppedItems(
const QModelIndexList &indexes )
241 selectDroppedItems( indexes );
245 const int topLevelRows =
mModel->sourceModel()->rowCount( QModelIndex() );
246 for (
int row = 0; row < topLevelRows; ++row )
248 restoreExpandedState(
mModel->sourceModel()->index( row, 0, QModelIndex() ) );
250 mDraggedExpandedState.clear();
253void QgsAttributesFormLayoutView::storeExpandedState(
const QModelIndex &sourceIndex )
255 if ( !sourceIndex.isValid() )
258 if (
auto *item =
static_cast< QgsAttributesFormItem *
>( sourceIndex.internalPointer() ) )
259 mDraggedExpandedState.insert( item, isExpanded(
mModel->mapFromSource( sourceIndex ) ) );
261 const int rows =
mModel->sourceModel()->rowCount( sourceIndex );
262 for (
int row = 0; row < rows; ++row )
264 storeExpandedState(
mModel->sourceModel()->index( row, 0, sourceIndex ) );
268void QgsAttributesFormLayoutView::restoreExpandedState(
const QModelIndex &sourceIndex )
270 if ( !sourceIndex.isValid() )
274 if (
auto *item =
static_cast< QgsAttributesFormItem *
>( sourceIndex.internalPointer() ) )
275 setExpanded(
mModel->mapFromSource( sourceIndex ), mDraggedExpandedState.value( item,
true ) );
277 const int rows =
mModel->sourceModel()->rowCount( sourceIndex );
278 for (
int row = 0; row < rows; ++row )
280 restoreExpandedState(
mModel->sourceModel()->index( row, 0, sourceIndex ) );
286 const QMimeData *data =
event->mimeData();
288 if ( data->hasFormat( u
"application/x-qgsattributesformavailablewidgetsrelement"_s ) || data->hasFormat( u
"application/x-qgsattributesformlayoutelement"_s ) )
291 if ( event->source() ==
this )
293 event->setDropAction( Qt::MoveAction );
301 QTreeView::dragEnterEvent( event );
310 const QMimeData *data =
event->mimeData();
312 if ( data->hasFormat( u
"application/x-qgsattributesformavailablewidgetsrelement"_s ) || data->hasFormat( u
"application/x-qgsattributesformlayoutelement"_s ) )
315 if ( event->source() ==
this )
317 event->setDropAction( Qt::MoveAction );
325 QTreeView::dragMoveEvent( event );
330 if ( !( event->mimeData()->hasFormat( u
"application/x-qgsattributesformavailablewidgetsrelement"_s ) || event->mimeData()->hasFormat( u
"application/x-qgsattributesformlayoutelement"_s ) ) )
333 const bool internalMove =
event->source() ==
this &&
event->mimeData()->hasFormat( u
"application/x-qgsattributesformlayoutelement"_s );
340 mDraggedExpandedState.clear();
341 const int topLevelRows =
mModel->sourceModel()->rowCount( QModelIndex() );
342 for (
int row = 0; row < topLevelRows; ++row )
344 storeExpandedState(
mModel->sourceModel()->index( row, 0, QModelIndex() ) );
348 if ( event->source() ==
this )
350 event->setDropAction( Qt::MoveAction );
353 QTreeView::dropEvent( event );
355 if ( internalMove && event->isAccepted() )
358 event->setDropAction( Qt::CopyAction );
363void QgsAttributesFormLayoutView::onItemDoubleClicked(
const QModelIndex &index )
365 QModelIndex sourceIndex =
mModel->mapToSource( index );
370 QGroupBox *baseData =
new QGroupBox( tr(
"Base configuration" ) );
372 QFormLayout *baseLayout =
new QFormLayout();
373 baseData->setLayout( baseLayout );
374 QCheckBox *showLabelCheckbox =
new QCheckBox( u
"Show label"_s );
375 showLabelCheckbox->setChecked( itemData.
showLabel() );
376 baseLayout->addRow( showLabelCheckbox );
377 QWidget *baseWidget =
new QWidget();
378 baseWidget->setLayout( baseLayout );
392 dlg.setObjectName(
"QML Form Configuration Widget" );
394 dlg.setWindowTitle( tr(
"Configure QML Widget" ) );
396 QVBoxLayout *mainLayout =
new QVBoxLayout( &dlg );
397 QSplitter *qmlSplitter =
new QSplitter();
398 QWidget *qmlConfigWiget =
new QWidget();
399 QVBoxLayout *layout =
new QVBoxLayout( qmlConfigWiget );
400 layout->setContentsMargins( 0, 0, 0, 0 );
401 mainLayout->addWidget( qmlSplitter );
402 qmlSplitter->addWidget( qmlConfigWiget );
403 layout->addWidget( baseWidget );
405 QLineEdit *title =
new QLineEdit( itemName );
418 QComboBox *qmlObjectTemplate =
new QComboBox();
419 qmlObjectTemplate->addItem( tr(
"Attribute Form Interaction" ) );
420 qmlObjectTemplate->addItem( tr(
"Rectangle" ) );
421 qmlObjectTemplate->addItem( tr(
"Pie Chart" ) );
422 qmlObjectTemplate->addItem( tr(
"Bar Chart" ) );
423 QToolButton *objectTemplateButton =
new QToolButton();
424 objectTemplateButton->setText( tr(
"Load Template" ) );
425 connect( objectTemplateButton, &QAbstractButton::clicked, qmlCode, [qmlCode, qmlObjectTemplate]() {
427 switch ( qmlObjectTemplate->currentIndex() )
431 qmlCode->
setText( QStringLiteral(
433 "import QtQuick.Layouts\n"
434 "import QtQuick.Controls.Material\n"
437 " width: Math.max(parent.width || 0, 200)\n"
438 " height: mainLayout.childrenRect.height + mainLayout.anchors.margins * 2\n"
442 " anchors.fill: parent\n"
443 " anchors.margins: 4\n"
447 " // The attributeFormBridge.layer property provides access to the\n"
448 " // vector layer attached to the attribute form\n"
449 " text: \"Current layer name: \" + (attributeFormBridge.layer ? attributeFormBridge.layer.name : \"N/A\")\n"
458 " id: myAttributeTextEdit\n"
459 " Layout.fillWidth: true\n"
461 " // The attributeFormBridge.editable property reflects the\n"
462 " // editable state of the attribute form\n"
463 " enabled: attributeFormBridge.editable\n"
465 " // The attributeFormBridge.currentFormFeature provides an up-to-date\n"
466 " // QgsFeature object with all of its properties and invokable functions\n"
467 " text: attributeFormBridge.currentFormFeature.attribute(\"my_attribute\") || \"\"\n"
471 " text: \"Change\"\n"
472 " background.layer.enabled: false\n"
474 " // The attributeFormBridge enables the change of field values through\n"
475 " // changeAttribute(field_name, value) as well as the change of geometry\n"
476 " // through changeGeometry(geometry)\n"
477 " attributeFormBridge.changeAttribute(\"my_attribute\", myAttributeTextEdit.text);\n"
488 qmlCode->
setText( QStringLiteral(
494 " color: \"steelblue\"\n"
495 " Text{ text: \"A rectangle\" }\n"
502 qmlCode->
setText( QStringLiteral(
512 " PieSlice { label: \"First slice\"; value: 25 }\n"
513 " PieSlice { label: \"Second slice\"; value: 45 }\n"
514 " PieSlice { label: \"Third slice\"; value: 30 }\n"
522 qmlCode->
setText( QStringLiteral(
527 " title: \"Bar series\"\n"
530 " legend.alignment: Qt.AlignBottom\n"
531 " antialiasing: true\n"
540 " axisY: valueAxisY\n"
541 " axisX: BarCategoryAxis { categories: [\"2007\", \"2008\", \"2009\", \"2010\", \"2011\", \"2012\" ] }\n"
542 " BarSet { label: \"Bob\"; values: [2, 2, 3, 4, 5, 6] }\n"
543 " BarSet { label: \"Susan\"; values: [5, 1, 2, 4, 1, 7] }\n"
544 " BarSet { label: \"James\"; values: [3, 5, 8, 13, 5, 8] }\n"
555 QgsFieldExpressionWidget *expressionWidget =
new QgsFieldExpressionWidget;
556 expressionWidget->setButtonVisible(
false );
557 expressionWidget->registerExpressionContextGenerator(
this );
558 expressionWidget->setLayer(
mLayer );
559 QToolButton *addFieldButton =
new QToolButton();
562 QToolButton *editExpressionButton =
new QToolButton();
564 editExpressionButton->setToolTip( tr(
"Insert/Edit Expression" ) );
566 connect( addFieldButton, &QAbstractButton::clicked,
this, [expressionWidget, qmlCode] {
567 QString expression = expressionWidget->expression().trimmed().replace(
'"',
"\\\""_L1 );
568 if ( !expression.isEmpty() )
569 qmlCode->
insertText( u
"expression.evaluate(\"%1\")"_s.arg( expression ) );
572 connect( editExpressionButton, &QAbstractButton::clicked,
this, [
this, qmlCode] {
574 expression.replace(
"\\\""_L1,
"\""_L1 );
576 QgsExpressionBuilderDialog exprDlg(
mLayer, expression,
this, u
"generic"_s, context );
578 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
579 if ( exprDlg.exec() == QDialog::Accepted && !exprDlg.expressionText().trimmed().isEmpty() )
581 QString expression = exprDlg.expressionText().trimmed().replace(
'"',
"\\\""_L1 );
582 if ( !expression.isEmpty() )
583 qmlCode->
insertText( u
"expression.evaluate(\"%1\")"_s.arg( expression ) );
587 layout->addWidget(
new QLabel( tr(
"Title" ) ) );
588 layout->addWidget( title );
590 QGroupBox *qmlCodeBox =
new QGroupBox( tr(
"QML Code" ) );
591 qmlCodeBox->setLayout(
new QVBoxLayout() );
593 QWidget *qmlObjectTemplateBox =
new QWidget();
594 qmlCodeBox->layout()->addWidget( qmlObjectTemplateBox );
595 qmlObjectTemplateBox->setLayout(
new QHBoxLayout() );
596 qmlObjectTemplateBox->layout()->setContentsMargins( 0, 0, 0, 0 );
597 qmlObjectTemplateBox->layout()->addWidget( qmlObjectTemplate );
598 qmlObjectTemplateBox->layout()->addWidget( objectTemplateButton );
600 QWidget *expressionWidgetBox =
new QWidget();
601 qmlCodeBox->layout()->addWidget( expressionWidgetBox );
602 expressionWidgetBox->setLayout(
new QHBoxLayout() );
603 expressionWidgetBox->layout()->setContentsMargins( 0, 0, 0, 0 );
604 expressionWidgetBox->layout()->addWidget( expressionWidget );
605 expressionWidgetBox->layout()->addWidget( addFieldButton );
606 expressionWidgetBox->layout()->addWidget( editExpressionButton );
607 layout->addWidget( qmlCodeBox );
608 layout->addWidget( qmlCode );
610 QTextEdit *errorFeedbackWidget =
new QTextEdit();
611 errorFeedbackWidget->setMaximumHeight( 90 );
612 layout->addWidget( errorFeedbackWidget );
616 QQuickWidget *qmlWidget =
dynamic_cast<QQuickWidget *
>( qmlWrapper->
widget() );
617 if ( qmlCode->text().trimmed().isEmpty() )
619 errorFeedbackWidget->setText( QObject::tr(
"No QML code" ) );
622 qmlWidget->setSource( QUrl() );
631 const QList<QQmlError> errors = qmlWidget->errors();
632 if ( !errors.isEmpty() )
634 QStringList errorStrings;
635 for (
const QQmlError &error : errors )
637 errorStrings << u
"%1:%2: %3"_s.arg( QString::number( error.line() ), QString::number( error.column() ), error.description() );
639 errorFeedbackWidget->setText( errorStrings.join(
"\n" ) );
643 errorFeedbackWidget->setText( QObject::tr(
"Valid code" ) );
648 QScrollArea *qmlPreviewBox =
new QgsScrollArea();
649 qmlPreviewBox->setWidgetResizable(
true );
650 qmlPreviewBox->setMinimumWidth( 200 );
651 qmlPreviewBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
653 qmlWrapper->
widget()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
655 QWidget *qmlContainerWidget =
new QWidget( qmlPreviewBox );
656 qmlContainerWidget->setMinimumSize( 200, 0 );
657 qmlContainerWidget->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
658 QVBoxLayout *qmlLayout =
new QVBoxLayout( qmlContainerWidget );
659 qmlLayout->addWidget( qmlWrapper->
widget() );
660 qmlLayout->addSpacerItem(
new QSpacerItem( 20, 40, QSizePolicy::Expanding, QSizePolicy::Expanding ) );
661 qmlContainerWidget->setLayout( qmlLayout );
662 qmlPreviewBox->setWidget( qmlContainerWidget );
665 qmlSplitter->addWidget( qmlPreviewBox );
666 qmlSplitter->setChildrenCollapsible(
false );
667 qmlSplitter->setHandleWidth( 6 );
668 qmlSplitter->setSizes( QList<int>() << 1 << 1 );
670 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help );
672 connect( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
673 connect( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
674 connect( buttonBox, &QDialogButtonBox::helpRequested, &dlg, [] {
QgsHelp::openHelp( u
"working_with_vector/vector_properties.html#other-widgets"_s ); } );
676 mainLayout->addWidget( buttonBox );
680 QgsAttributesFormData::QmlElementEditorConfiguration qmlEdCfg;
681 qmlEdCfg.
qmlCode = qmlCode->text();
683 itemData.
setShowLabel( showLabelCheckbox->isChecked() );
694 dlg.setObjectName(
"HTML Form Configuration Widget" );
696 dlg.setWindowTitle( tr(
"Configure HTML Widget" ) );
698 QVBoxLayout *mainLayout =
new QVBoxLayout( &dlg );
699 QSplitter *htmlSplitter =
new QSplitter();
700 QWidget *htmlConfigWiget =
new QWidget();
701 QVBoxLayout *layout =
new QVBoxLayout( htmlConfigWiget );
702 layout->setContentsMargins( 0, 0, 0, 0 );
703 mainLayout->addWidget( htmlSplitter );
704 htmlSplitter->addWidget( htmlConfigWiget );
705 htmlSplitter->setChildrenCollapsible(
false );
706 htmlSplitter->setHandleWidth( 6 );
707 htmlSplitter->setSizes( QList<int>() << 1 << 1 );
708 layout->addWidget( baseWidget );
710 QLineEdit *title =
new QLineEdit( itemName );
713 QgsCodeEditorHTML *htmlCode =
new QgsCodeEditorHTML();
714 htmlCode->setSizePolicy( QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Expanding );
717 QgsHtmlWidgetWrapper *htmlWrapper =
new QgsHtmlWidgetWrapper(
mLayer,
nullptr,
this );
718 QgsFeature previewFeature;
719 mLayer->getFeatures().nextFeature( previewFeature );
722 connect( htmlCode, &QgsCodeEditorHTML::textChanged,
this, [htmlWrapper, htmlCode, previewFeature] {
728 QgsFieldExpressionWidget *expressionWidget =
new QgsFieldExpressionWidget;
729 expressionWidget->setButtonVisible(
false );
730 expressionWidget->registerExpressionContextGenerator(
this );
731 expressionWidget->setLayer(
mLayer );
732 QToolButton *addFieldButton =
new QToolButton();
735 QToolButton *editExpressionButton =
new QToolButton();
737 editExpressionButton->setToolTip( tr(
"Insert/Edit Expression" ) );
739 connect( addFieldButton, &QAbstractButton::clicked,
this, [expressionWidget, htmlCode] {
740 QString expression = expressionWidget->expression().trimmed().replace(
'"',
"\\\""_L1 );
741 if ( !expression.isEmpty() )
742 htmlCode->
insertText( u
"<script>document.write(expression.evaluate(\"%1\"));</script>"_s.arg( expression ) );
745 connect( editExpressionButton, &QAbstractButton::clicked,
this, [
this, htmlCode] {
748 expression.replace(
"\\\""_L1,
"\""_L1 );
750 QgsExpressionBuilderDialog exprDlg(
mLayer, expression,
this, u
"generic"_s, context );
752 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
753 if ( exprDlg.exec() == QDialog::Accepted && !exprDlg.expressionText().trimmed().isEmpty() )
755 QString expression = exprDlg.expressionText().trimmed().replace(
'"',
"\\\""_L1 );
756 if ( !expression.isEmpty() )
757 htmlCode->
insertText( u
"<script>document.write(expression.evaluate(\"%1\"));</script>"_s.arg( expression ) );
761 layout->addWidget(
new QLabel( tr(
"Title" ) ) );
762 layout->addWidget( title );
763 QGroupBox *expressionWidgetBox =
new QGroupBox( tr(
"HTML Code" ) );
764 layout->addWidget( expressionWidgetBox );
765 expressionWidgetBox->setLayout(
new QHBoxLayout );
766 expressionWidgetBox->layout()->addWidget( expressionWidget );
767 expressionWidgetBox->layout()->addWidget( addFieldButton );
768 expressionWidgetBox->layout()->addWidget( editExpressionButton );
769 layout->addWidget( htmlCode );
770 QScrollArea *htmlPreviewBox =
new QgsScrollArea();
771 htmlPreviewBox->setLayout(
new QGridLayout );
772 htmlPreviewBox->setMinimumWidth( 200 );
773 htmlPreviewBox->layout()->addWidget( htmlWrapper->
widget() );
775 emit htmlCode->textChanged();
776 htmlSplitter->addWidget( htmlPreviewBox );
777 htmlSplitter->setChildrenCollapsible(
false );
778 htmlSplitter->setHandleWidth( 6 );
779 htmlSplitter->setSizes( QList<int>() << 1 << 1 );
781 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help );
783 connect( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
784 connect( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
785 connect( buttonBox, &QDialogButtonBox::helpRequested, &dlg, [] {
QgsHelp::openHelp( u
"working_with_vector/vector_properties.html#other-widgets"_s ); } );
787 mainLayout->addWidget( buttonBox );
791 QgsAttributesFormData::HtmlElementEditorConfiguration htmlEdCfg;
792 htmlEdCfg.
htmlCode = htmlCode->text();
794 itemData.
setShowLabel( showLabelCheckbox->isChecked() );
805 dlg.setObjectName(
"Text Form Configuration Widget" );
807 dlg.setWindowTitle( tr(
"Configure Text Widget" ) );
809 QVBoxLayout *mainLayout =
new QVBoxLayout( &dlg );
810 QSplitter *textSplitter =
new QSplitter();
811 QWidget *textConfigWiget =
new QWidget();
812 QVBoxLayout *layout =
new QVBoxLayout( textConfigWiget );
813 layout->setContentsMargins( 0, 0, 0, 0 );
814 mainLayout->addWidget( textSplitter );
815 textSplitter->addWidget( textConfigWiget );
816 layout->addWidget( baseWidget );
818 QLineEdit *title =
new QLineEdit( itemName );
820 QgsCodeEditorHTML *text =
new QgsCodeEditorHTML();
821 text->setSizePolicy( QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Expanding );
824 QgsTextWidgetWrapper *textWrapper =
new QgsTextWidgetWrapper(
mLayer,
nullptr,
this );
825 QgsFeature previewFeature;
826 ( void )
mLayer->getFeatures( QgsFeatureRequest().setLimit( 1 ) ).nextFeature( previewFeature );
829 connect( text, &QgsCodeEditorExpression::textChanged,
this, [textWrapper, previewFeature, text] {
830 textWrapper->
setText( text->text() );
835 QgsFieldExpressionWidget *expressionWidget =
new QgsFieldExpressionWidget;
836 expressionWidget->setButtonVisible(
false );
837 expressionWidget->registerExpressionContextGenerator(
this );
838 expressionWidget->setLayer(
mLayer );
839 QToolButton *addFieldButton =
new QToolButton();
842 QToolButton *editExpressionButton =
new QToolButton();
844 editExpressionButton->setToolTip( tr(
"Insert/Edit Expression" ) );
846 connect( addFieldButton, &QAbstractButton::clicked,
this, [expressionWidget, text] {
847 QString expression = expressionWidget->expression().trimmed();
848 if ( !expression.isEmpty() )
849 text->
insertText( u
"[%%1%]"_s.arg( expression ) );
851 connect( editExpressionButton, &QAbstractButton::clicked,
this, [
this, text] {
855 QgsExpressionBuilderDialog exprDlg(
mLayer, expression,
this, u
"generic"_s, context );
857 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
858 if ( exprDlg.exec() == QDialog::Accepted && !exprDlg.expressionText().trimmed().isEmpty() )
860 QString expression = exprDlg.expressionText().trimmed();
861 if ( !expression.isEmpty() )
862 text->
insertText( u
"[%%1%]"_s.arg( expression ) );
866 layout->addWidget(
new QLabel( tr(
"Title" ) ) );
867 layout->addWidget( title );
868 QGroupBox *expressionWidgetBox =
new QGroupBox( tr(
"Text" ) );
869 layout->addWidget( expressionWidgetBox );
870 expressionWidgetBox->setLayout(
new QHBoxLayout );
871 expressionWidgetBox->layout()->addWidget( expressionWidget );
872 expressionWidgetBox->layout()->addWidget( addFieldButton );
873 expressionWidgetBox->layout()->addWidget( editExpressionButton );
874 layout->addWidget( text );
875 QScrollArea *textPreviewBox =
new QgsScrollArea();
876 textPreviewBox->setWidgetResizable(
true );
877 textPreviewBox->setMinimumWidth( 200 );
878 textPreviewBox->setWidget( textWrapper->
widget() );
880 emit text->textChanged();
881 textSplitter->addWidget( textPreviewBox );
882 textSplitter->setChildrenCollapsible(
false );
883 textSplitter->setHandleWidth( 6 );
884 textSplitter->setSizes( QList<int>() << 1 << 1 );
886 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help );
888 connect( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
889 connect( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
890 connect( buttonBox, &QDialogButtonBox::helpRequested, &dlg, [] {
QgsHelp::openHelp( u
"working_with_vector/vector_properties.html#other-widgets"_s ); } );
892 mainLayout->addWidget( buttonBox );
896 QgsAttributesFormData::TextElementEditorConfiguration textEdCfg;
897 textEdCfg.
text = text->text();
899 itemData.
setShowLabel( showLabelCheckbox->isChecked() );
910 dlg.setObjectName(
"Spacer Form Configuration Widget" );
912 dlg.setWindowTitle( tr(
"Configure Spacer Widget" ) );
914 QVBoxLayout *mainLayout =
new QVBoxLayout();
915 mainLayout->addWidget(
new QLabel( tr(
"Title" ) ) );
916 QLineEdit *title =
new QLineEdit( itemName );
917 mainLayout->addWidget( title );
919 QHBoxLayout *cbLayout =
new QHBoxLayout();
920 mainLayout->addLayout( cbLayout );
921 dlg.setLayout( mainLayout );
922 QCheckBox *cb =
new QCheckBox { &dlg };
924 cbLayout->addWidget(
new QLabel( tr(
"Draw horizontal line" ), &dlg ) );
925 cbLayout->addWidget( cb );
927 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help );
929 connect( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
930 connect( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
931 connect( buttonBox, &QDialogButtonBox::helpRequested, &dlg, [] {
QgsHelp::openHelp( u
"working_with_vector/vector_properties.html#other-widgets"_s ); } );
933 mainLayout->addWidget( buttonBox );
937 QgsAttributesFormData::SpacerElementEditorConfiguration spacerEdCfg;
938 spacerEdCfg.
drawLine = cb->isChecked();
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
A text editor based on QScintilla2.
@ ScriptEditor
Standard mode, allows for display and edit of entire scripts.
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...
@ CodeFolding
Indicates that code folding should be enabled for the editor.
void insertText(const QString &text)
Insert text at cursor position, or replace any selected text if user has made a selection.
void setLineNumbersVisible(bool visible)
Sets whether line numbers should be visible in the editor.
void editingTimeout()
Emitted when either:
static std::unique_ptr< QgsExpressionContextScope > globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
static std::unique_ptr< QgsExpressionContextScope > layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
static std::unique_ptr< 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 std::unique_ptr< QgsExpressionContextScope > projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
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.
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...
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.
static QgsProject * instance()
Returns the QgsProject singleton instance.
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.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const final
Queries the layer for features specified in request.