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();
94 mConstraintResultLabel->setText( QStringLiteral(
"<font color=\"#FF9800\">%1</font>" ).arg( QChar( 0x2718 ) ) );
95 mConstraintResultLabel->setToolTip( description.isEmpty() ? QStringLiteral(
"<b>%1</b>: %2" ).arg( constraint, err ) : description );
99 mConstraintResultLabel->setText( QStringLiteral(
"<font color=\"#FFC107\">%1</font>" ).arg( QChar( 0x2718 ) ) );
100 mConstraintResultLabel->setToolTip( description.isEmpty() ? QStringLiteral(
"<b>%1</b>: %2" ).arg( constraint, err ) : description );
104 mConstraintResultLabel->setText( QStringLiteral(
"<font color=\"#259B24\">%1</font>" ).arg( QChar( 0x2714 ) ) );
105 mConstraintResultLabel->setToolTip( description );
112 mConstraintResultLabel->setHidden( !editable );
117 return mEditorWidget;
122 if ( mEditorWidget && mixed )
132 mPreviousValue = mEditorWidget->
value();
146 mBlockValueUpdate =
true;
147 mEditorWidget->
setValues( initialValue, additionalFieldValues );
148 mBlockValueUpdate =
false;
150 mPreviousValue = initialValue;
151 mPreviousAdditionalValues = additionalFieldValues;
160 return mEditorWidget->
value();
164void QgsAttributeFormEditorWidget::editorWidgetValuesChanged(
const QVariant &value,
const QVariantList &additionalFieldValues )
166 if ( mBlockValueUpdate )
187void QgsAttributeFormEditorWidget::resetValue()
190 mBlockValueUpdate =
true;
192 mEditorWidget->
setValues( mPreviousValue, mPreviousAdditionalValues );
193 mBlockValueUpdate =
false;
204 if ( mEditorWidget && mIsMixed )
211void QgsAttributeFormEditorWidget::setFieldTriggered()
216void QgsAttributeFormEditorWidget::onAggregateChanged()
220 searchWidget->setAggregate( mAggregateButton->aggregate() );
223void QgsAttributeFormEditorWidget::updateWidgets()
226 const bool hasMultiEditButton = (
editPage()->layout()->indexOf( mMultiEditButton ) >= 0 );
228 bool shouldShowMultiEditButton =
false;
235 shouldShowMultiEditButton =
false;
244 const int fieldIndex = mEditorWidget->
fieldIdx();
246 if ( shouldShowMultiEditButton )
253 if ( fieldEditabilityDependsOnFeature )
263 shouldShowMultiEditButton =
false;
273 if ( hasMultiEditButton && !shouldShowMultiEditButton )
275 editPage()->layout()->removeWidget( mMultiEditButton );
276 mMultiEditButton->setParent(
nullptr );
278 else if ( !hasMultiEditButton && shouldShowMultiEditButton )
280 editPage()->layout()->addWidget( mMultiEditButton );
290 editPage()->layout()->addWidget( mConstraintResultLabel );
296 mAggregateButton->setVisible(
true );
302 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