29#include <QStackedWidget>
33 , mWidgetType( widgetType )
34 , mEditorWidget( editorWidget )
37 , mBlockValueUpdate( false )
41 mConstraintResultLabel =
new QLabel(
this );
42 mConstraintResultLabel->setObjectName( QStringLiteral(
"ConstraintStatus" ) );
43 mConstraintResultLabel->setSizePolicy( QSizePolicy::Fixed, mConstraintResultLabel->sizePolicy().verticalPolicy() );
50 if ( mEditorWidget->
widget() )
52 mEditorWidget->
widget()->setObjectName( mEditorWidget->
field().
name() );
68 delete mMultiEditButton;
73 Q_ASSERT( !mWidgetType.isEmpty() );
74 const QVariantMap config = mEditorWidget->
config();
75 const int fieldIdx = mEditorWidget->
fieldIdx();
96 mConstraintResultLabel->setText( QStringLiteral(
"<font color=\"#FF9800\">%1</font>" ).arg( QChar( 0x2718 ) ) );
97 mConstraintResultLabel->setToolTip( description.isEmpty() ? QStringLiteral(
"<b>%1</b>: %2" ).arg( constraint, err ) : description );
101 mConstraintResultLabel->setText( QStringLiteral(
"<font color=\"#FFC107\">%1</font>" ).arg( QChar( 0x2718 ) ) );
102 mConstraintResultLabel->setToolTip( description.isEmpty() ? QStringLiteral(
"<b>%1</b>: %2" ).arg( constraint, err ) : description );
106 mConstraintResultLabel->setText( QStringLiteral(
"<font color=\"#259B24\">%1</font>" ).arg( QChar( 0x2714 ) ) );
107 mConstraintResultLabel->setToolTip( description );
114 mConstraintResultLabel->setHidden( !editable );
119 return mEditorWidget;
124 if ( mEditorWidget && mixed )
134 mPreviousValue = mEditorWidget->
value();
149 mBlockValueUpdate =
true;
150 mEditorWidget->
setValues( initialValue, additionalFieldValues );
151 mBlockValueUpdate =
false;
153 mPreviousValue = initialValue;
154 mPreviousAdditionalValues = additionalFieldValues;
163 return mEditorWidget->
value();
168void QgsAttributeFormEditorWidget::editorWidgetValuesChanged(
const QVariant &value,
const QVariantList &additionalFieldValues )
170 if ( mBlockValueUpdate )
191void QgsAttributeFormEditorWidget::resetValue()
194 mBlockValueUpdate =
true;
196 mEditorWidget->
setValues( mPreviousValue, mPreviousAdditionalValues );
197 mBlockValueUpdate =
false;
208 if ( mEditorWidget && mIsMixed )
215void QgsAttributeFormEditorWidget::setFieldTriggered()
220void QgsAttributeFormEditorWidget::onAggregateChanged()
224 searchWidget->setAggregate( mAggregateButton->aggregate() );
227void QgsAttributeFormEditorWidget::updateWidgets()
230 const bool hasMultiEditButton = (
editPage()->layout()->indexOf( mMultiEditButton ) >= 0 );
232 bool shouldShowMultiEditButton =
false;
239 shouldShowMultiEditButton =
false;
248 const int fieldIndex = mEditorWidget->
fieldIdx();
250 if ( shouldShowMultiEditButton )
257 if ( fieldEditabilityDependsOnFeature )
267 shouldShowMultiEditButton =
false;
277 if ( hasMultiEditButton && !shouldShowMultiEditButton )
279 editPage()->layout()->removeWidget( mMultiEditButton );
280 mMultiEditButton->setParent(
nullptr );
282 else if ( !hasMultiEditButton && shouldShowMultiEditButton )
284 editPage()->layout()->addWidget( mMultiEditButton );
294 editPage()->layout()->addWidget( mConstraintResultLabel );
300 mAggregateButton->setVisible(
true );
306 mAggregateButton->setVisible(
false );
This class contains context information for attribute editor widgets.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
static QgsEditorWidgetRegistry * editorWidgetRegistry()
Returns the global editor widget registry, used for managing all known edit widget factories.
static bool fieldEditabilityDependsOnFeature(const QgsVectorLayer *layer, int fieldIndex)
Returns true if the editability of the field at index fieldIndex from layer may vary feature by featu...
static bool fieldIsEditable(const QgsVectorLayer *layer, int fieldIndex, const QgsFeature &feature)
Tests whether a field is editable for a particular feature.
static bool fieldIsReadOnly(const QgsVectorLayer *layer, int fieldIndex)
QgsFeatureIterator getSelectedFeatures(QgsFeatureRequest request=QgsFeatureRequest()) const
Returns an iterator of the selected features.
#define Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_PUSH