Skip to content
Permalink
Browse files

Update widget wrapper status only when necessary

  • Loading branch information
pblottiere committed Nov 30, 2017
1 parent 512acca commit 33737a63217c010b22bffb6685853f3f6164b8b2
Showing with 16 additions and 12 deletions.
  1. +15 −11 src/gui/qgsattributeform.cpp
  2. +1 −1 src/gui/qgsattributeform.h
@@ -740,8 +740,8 @@ void QgsAttributeForm::updateConstraints( QgsEditorWidgetWrapper *eww )
Q_FOREACH ( QgsEditorWidgetWrapper* depsEww, deps )
depsEww->updateConstraint( ft );

// sync ok button status
synchronizeEnabledState();
// sync ok button status only
synchronizeEnabledState( false );

mExpressionContext.setFeature( ft );

@@ -986,23 +986,27 @@ void QgsAttributeForm::refreshFeature()
setFeature( mFeature );
}

void QgsAttributeForm::synchronizeEnabledState()
void QgsAttributeForm::synchronizeEnabledState( bool synchronizeWidgetWrapper )
{
bool isEditable = ( mFeature.isValid()
|| mMode == AddFeatureMode
|| mMode == MultiEditMode ) && mLayer->isEditable();

Q_FOREACH ( QgsWidgetWrapper* ww, mWidgets )
if ( synchronizeWidgetWrapper )
{
bool fieldEditable = true;
QgsEditorWidgetWrapper* eww = qobject_cast<QgsEditorWidgetWrapper*>( ww );
if ( eww )
Q_FOREACH ( QgsWidgetWrapper* ww, mWidgets )
{
fieldEditable = !mLayer->editFormConfig()->readOnly( eww->fieldIdx() ) &&
(( mLayer->dataProvider() && layer()->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) ||
FID_IS_NEW( mFeature.id() ) );
bool fieldEditable = true;
QgsEditorWidgetWrapper* eww = qobject_cast<QgsEditorWidgetWrapper*>( ww );
if ( eww )
{
fieldEditable = !mLayer->editFormConfig()->readOnly( eww->fieldIdx() ) &&
(( mLayer->dataProvider() && layer()->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) ||
FID_IS_NEW( mFeature.id() ) );
}

ww->setEnabled( isEditable && fieldEditable );
}
ww->setEnabled( isEditable && fieldEditable );
}

// push a message and disable the OK button if constraints are invalid
@@ -259,7 +259,7 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
void onConstraintStatusChanged( const QString& constraint,
const QString& description, const QString& err, bool ok );
void preventFeatureRefresh();
void synchronizeEnabledState();
void synchronizeEnabledState( bool synchronizeWidgetWrapper = true );
void layerSelectionChanged();

//! Save multi edit changes

0 comments on commit 33737a6

Please sign in to comment.
You can’t perform that action at this time.