17#include "moc_qgsattributeformeditorwidget.cpp"
30#include <QStackedWidget>
34 , mWidgetType( widgetType )
35 , mEditorWidget( editorWidget )
38 , mBlockValueUpdate( false )
42 mConstraintResultLabel =
new QLabel(
this );
43 mConstraintResultLabel->setObjectName( QStringLiteral(
"ConstraintStatus" ) );
44 mConstraintResultLabel->setSizePolicy( QSizePolicy::Fixed, mConstraintResultLabel->sizePolicy().verticalPolicy() );
51 if ( mEditorWidget->
widget() )
53 mEditorWidget->
widget()->setObjectName( mEditorWidget->
field().
name() );
69 delete mMultiEditButton;
74 Q_ASSERT( !mWidgetType.isEmpty() );
75 const QVariantMap config = mEditorWidget->
config();
76 const int fieldIdx = mEditorWidget->
fieldIdx();
97 mConstraintResultLabel->setText( QStringLiteral(
"<font color=\"#FF9800\">%1</font>" ).arg( QChar( 0x2718 ) ) );
98 mConstraintResultLabel->setToolTip( description.isEmpty() ? QStringLiteral(
"<b>%1</b>: %2" ).arg( constraint, err ) : description );
102 mConstraintResultLabel->setText( QStringLiteral(
"<font color=\"#FFC107\">%1</font>" ).arg( QChar( 0x2718 ) ) );
103 mConstraintResultLabel->setToolTip( description.isEmpty() ? QStringLiteral(
"<b>%1</b>: %2" ).arg( constraint, err ) : description );
107 mConstraintResultLabel->setText( QStringLiteral(
"<font color=\"#259B24\">%1</font>" ).arg( QChar( 0x2714 ) ) );
108 mConstraintResultLabel->setToolTip( description );
115 mConstraintResultLabel->setHidden( !editable );
120 return mEditorWidget;
125 if ( mEditorWidget && mixed )
135 mPreviousValue = mEditorWidget->
value();
150 mBlockValueUpdate =
true;
151 mEditorWidget->
setValues( initialValue, additionalFieldValues );
152 mBlockValueUpdate =
false;
154 mPreviousValue = initialValue;
155 mPreviousAdditionalValues = additionalFieldValues;
164 return mEditorWidget->
value();
169void QgsAttributeFormEditorWidget::editorWidgetValuesChanged(
const QVariant &value,
const QVariantList &additionalFieldValues )
171 if ( mBlockValueUpdate )
192void QgsAttributeFormEditorWidget::resetValue()
195 mBlockValueUpdate =
true;
197 mEditorWidget->
setValues( mPreviousValue, mPreviousAdditionalValues );
198 mBlockValueUpdate =
false;
209 if ( mEditorWidget && mIsMixed )
216void QgsAttributeFormEditorWidget::setFieldTriggered()
221void QgsAttributeFormEditorWidget::onAggregateChanged()
225 searchWidget->setAggregate( mAggregateButton->aggregate() );
228void QgsAttributeFormEditorWidget::updateWidgets()
231 const bool hasMultiEditButton = (
editPage()->layout()->indexOf( mMultiEditButton ) >= 0 );
233 bool shouldShowMultiEditButton =
false;
240 shouldShowMultiEditButton =
false;
249 const int fieldIndex = mEditorWidget->
fieldIdx();
251 if ( shouldShowMultiEditButton )
258 if ( fieldEditabilityDependsOnFeature )
268 shouldShowMultiEditButton =
false;
278 if ( hasMultiEditButton && !shouldShowMultiEditButton )
280 editPage()->layout()->removeWidget( mMultiEditButton );
281 mMultiEditButton->setParent(
nullptr );
283 else if ( !hasMultiEditButton && shouldShowMultiEditButton )
285 editPage()->layout()->addWidget( mMultiEditButton );
295 editPage()->layout()->addWidget( mConstraintResultLabel );
301 mAggregateButton->setVisible(
true );
307 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)
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 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