Skip to content

Commit

Permalink
Hide invalid constraints label when it's unused
Browse files Browse the repository at this point in the history
Fix #15452
  • Loading branch information
m-kuhn committed Aug 19, 2016
1 parent c467671 commit 48445e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
11 changes: 7 additions & 4 deletions src/gui/qgsattributeform.cpp
Expand Up @@ -783,12 +783,13 @@ bool QgsAttributeForm::currentFormFeature( QgsFeature &feature )

void QgsAttributeForm::clearInvalidConstraintsMessage()
{
mInvalidConstraintMessage->hide();
mInvalidConstraintMessage->clear();
mInvalidConstraintMessage->setStyleSheet( QString() );
}

void QgsAttributeForm::displayInvalidConstraintMessage( const QStringList &f,
const QStringList &d )
void QgsAttributeForm::displayInvalidConstraintMessage( const QStringList& f,
const QStringList& d )
{
clearInvalidConstraintsMessage();

Expand All @@ -804,6 +805,7 @@ void QgsAttributeForm::displayInvalidConstraintMessage( const QStringList &f,
QString title = QString( "<img src=\"%1\"> <b>%2:" ).arg( icPath ).arg( tr( "Invalid fields" ) );
QString msg = QString( "%1</b><ul>%2</ul>" ).arg( title ).arg( descriptions ) ;

mInvalidConstraintMessage->show();
mInvalidConstraintMessage->setText( msg );
mInvalidConstraintMessage->setStyleSheet( "QLabel { background-color : #ffc800; }" );
}
Expand Down Expand Up @@ -922,8 +924,8 @@ void QgsAttributeForm::onConstraintStatusChanged( const QString& constraint,
}
}

void QgsAttributeForm::constraintDependencies( QgsEditorWidgetWrapper *w,
QList<QgsEditorWidgetWrapper*> &wDeps )
void QgsAttributeForm::constraintDependencies( QgsEditorWidgetWrapper* w,
QList<QgsEditorWidgetWrapper*>& wDeps )
{
QString name = w->field().name();

Expand Down Expand Up @@ -1051,6 +1053,7 @@ void QgsAttributeForm::init()
vl->addWidget( mMessageBar );

mInvalidConstraintMessage = new QLabel( this );
mInvalidConstraintMessage->hide();
vl->addWidget( mInvalidConstraintMessage );

setLayout( vl );
Expand Down
12 changes: 6 additions & 6 deletions src/gui/qgsattributeform.h
Expand Up @@ -320,13 +320,13 @@ class GUI_EXPORT QgsAttributeForm : public QWidget

//! constraints management
void updateAllConstaints();
void updateConstraints( QgsEditorWidgetWrapper *w );
bool currentFormFeature( QgsFeature &feature );
bool currentFormValidConstraints( QStringList &invalidFields, QStringList &descriptions );
void constraintDependencies( QgsEditorWidgetWrapper *w, QList<QgsEditorWidgetWrapper*> &wDeps );
void updateConstraints( QgsEditorWidgetWrapper* w );
bool currentFormFeature( QgsFeature& feature );
bool currentFormValidConstraints( QStringList& invalidFields, QStringList& descriptions );
void constraintDependencies( QgsEditorWidgetWrapper* w, QList<QgsEditorWidgetWrapper*>& wDeps );
void clearInvalidConstraintsMessage();
void displayInvalidConstraintMessage( const QStringList &invalidFields,
const QStringList &description );
void displayInvalidConstraintMessage( const QStringList& invalidFields,
const QStringList& description );

QgsVectorLayer* mLayer;
QgsFeature mFeature;
Expand Down

0 comments on commit 48445e7

Please sign in to comment.