31 #include <QStackedWidget>
35 , mWidgetType( widgetType )
36 , mEditorWidget( editorWidget )
39 , mBlockValueUpdate( false )
43 mConstraintResultLabel =
new QLabel(
this );
44 mConstraintResultLabel->setObjectName( QStringLiteral(
"ConstraintStatus" ) );
45 mConstraintResultLabel->setSizePolicy( QSizePolicy::Fixed, mConstraintResultLabel->sizePolicy().verticalPolicy() );
52 if ( mEditorWidget->
widget() )
54 mEditorWidget->
widget()->setObjectName( mEditorWidget->
field().
name() );
70 delete mMultiEditButton;
75 Q_ASSERT( !mWidgetType.isEmpty() );
76 const QVariantMap config = mEditorWidget->
config();
77 const int fieldIdx = mEditorWidget->
fieldIdx();
98 mConstraintResultLabel->setText( QStringLiteral(
"<font color=\"#FF9800\">%1</font>" ).arg( QChar( 0x2718 ) ) );
99 mConstraintResultLabel->setToolTip( description.isEmpty() ? QStringLiteral(
"<b>%1</b>: %2" ).arg( constraint, err ) : description );
103 mConstraintResultLabel->setText( QStringLiteral(
"<font color=\"#FFC107\">%1</font>" ).arg( QChar( 0x2718 ) ) );
104 mConstraintResultLabel->setToolTip( description.isEmpty() ? QStringLiteral(
"<b>%1</b>: %2" ).arg( constraint, err ) : description );
108 mConstraintResultLabel->setText( QStringLiteral(
"<font color=\"#259B24\">%1</font>" ).arg( QChar( 0x2714 ) ) );
109 mConstraintResultLabel->setToolTip( description );
116 mConstraintResultLabel->setHidden( !editable );
121 return mEditorWidget;
126 if ( mEditorWidget && mixed )
136 mPreviousValue = mEditorWidget->
value();
151 mBlockValueUpdate =
true;
152 mEditorWidget->
setValues( initialValue, additionalFieldValues );
153 mBlockValueUpdate =
false;
155 mPreviousValue = initialValue;
156 mPreviousAdditionalValues = additionalFieldValues;
165 return mEditorWidget->
value();
170 void QgsAttributeFormEditorWidget::editorWidgetValuesChanged(
const QVariant &value,
const QVariantList &additionalFieldValues )
172 if ( mBlockValueUpdate )
193 void QgsAttributeFormEditorWidget::resetValue()
196 mBlockValueUpdate =
true;
198 mEditorWidget->
setValues( mPreviousValue, mPreviousAdditionalValues );
199 mBlockValueUpdate =
false;
210 if ( mEditorWidget && mIsMixed )
217 void QgsAttributeFormEditorWidget::setFieldTriggered()
222 void QgsAttributeFormEditorWidget::onAggregateChanged()
226 searchWidget->setAggregate( mAggregateButton->
aggregate() );
229 void QgsAttributeFormEditorWidget::updateWidgets()
232 const bool hasMultiEditButton = (
editPage()->layout()->indexOf( mMultiEditButton ) >= 0 );
234 bool shouldShowMultiEditButton =
false;
241 shouldShowMultiEditButton =
false;
250 const int fieldIndex = mEditorWidget->
fieldIdx();
252 if ( shouldShowMultiEditButton )
259 if ( fieldEditabilityDependsOnFeature )
269 shouldShowMultiEditButton =
false;
279 if ( hasMultiEditButton && !shouldShowMultiEditButton )
281 editPage()->layout()->removeWidget( mMultiEditButton );
282 mMultiEditButton->setParent(
nullptr );
284 else if ( !hasMultiEditButton && shouldShowMultiEditButton )
286 editPage()->layout()->addWidget( mMultiEditButton );
295 editPage()->layout()->addWidget( mConstraintResultLabel );
301 mAggregateButton->setVisible(
true );
308 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