Skip to content
Permalink
Browse files

Don't show constraint messages when form is in search mode

  • Loading branch information
nyalldawson committed Jun 9, 2016
1 parent fe26d33 commit ec9762254229489e5e3c4c8f3f02d20d0980a5e1
Showing with 21 additions and 6 deletions.
  1. +21 −6 src/gui/qgsattributeform.cpp
@@ -179,22 +179,34 @@ void QgsAttributeForm::setMode( QgsAttributeForm::Mode mode )
case QgsAttributeForm::SingleEditMode:
setFeature( mFeature );
mSearchButtonBox->setVisible( false );
mInvalidConstraintMessage->show();
break;

case QgsAttributeForm::AddFeatureMode:
synchronizeEnabledState();
mSearchButtonBox->setVisible( false );
mInvalidConstraintMessage->show();
break;

case QgsAttributeForm::MultiEditMode:
resetMultiEdit( false );
synchronizeEnabledState();
mSearchButtonBox->setVisible( false );
mInvalidConstraintMessage->show();
break;

case QgsAttributeForm::SearchMode:
mSearchButtonBox->setVisible( true );
hideButtonBox();
if ( mContext.formMode() != QgsAttributeEditorContext::Embed )
{
delete mInvalidConstraintMessage;
mInvalidConstraintMessage = nullptr;
}
else
{
mInvalidConstraintMessage->hide();
}
break;
}

@@ -763,7 +775,7 @@ bool QgsAttributeForm::currentFormFeature( QgsFeature &feature )
void QgsAttributeForm::clearInvalidConstraintsMessage()
{
mInvalidConstraintMessage->clear();
mInvalidConstraintMessage->setStyleSheet( "" );
mInvalidConstraintMessage->setStyleSheet( QString() );
}

void QgsAttributeForm::displayInvalidConstraintMessage( const QStringList &f,
@@ -974,13 +986,16 @@ void QgsAttributeForm::synchronizeEnabledState()
// push a message and disable the OK button if constraints are invalid
clearInvalidConstraintsMessage();

QStringList invalidFields, descriptions;
bool validConstraint = currentFormValidConstraints( invalidFields, descriptions );
if ( mMode != SearchMode )
{
QStringList invalidFields, descriptions;
bool validConstraint = currentFormValidConstraints( invalidFields, descriptions );

if ( ! validConstraint )
displayInvalidConstraintMessage( invalidFields, descriptions );
if ( ! validConstraint )
displayInvalidConstraintMessage( invalidFields, descriptions );

isEditable = isEditable & validConstraint;
isEditable = isEditable & validConstraint;
}

// change ok button status
QPushButton* okButton = mButtonBox->button( QDialogButtonBox::Ok );

0 comments on commit ec97622

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