Skip to content

Commit 48445e7

Browse files
committed
Hide invalid constraints label when it's unused
Fix #15452
1 parent c467671 commit 48445e7

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/gui/qgsattributeform.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -783,12 +783,13 @@ bool QgsAttributeForm::currentFormFeature( QgsFeature &feature )
783783

784784
void QgsAttributeForm::clearInvalidConstraintsMessage()
785785
{
786+
mInvalidConstraintMessage->hide();
786787
mInvalidConstraintMessage->clear();
787788
mInvalidConstraintMessage->setStyleSheet( QString() );
788789
}
789790

790-
void QgsAttributeForm::displayInvalidConstraintMessage( const QStringList &f,
791-
const QStringList &d )
791+
void QgsAttributeForm::displayInvalidConstraintMessage( const QStringList& f,
792+
const QStringList& d )
792793
{
793794
clearInvalidConstraintsMessage();
794795

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

808+
mInvalidConstraintMessage->show();
807809
mInvalidConstraintMessage->setText( msg );
808810
mInvalidConstraintMessage->setStyleSheet( "QLabel { background-color : #ffc800; }" );
809811
}
@@ -922,8 +924,8 @@ void QgsAttributeForm::onConstraintStatusChanged( const QString& constraint,
922924
}
923925
}
924926

925-
void QgsAttributeForm::constraintDependencies( QgsEditorWidgetWrapper *w,
926-
QList<QgsEditorWidgetWrapper*> &wDeps )
927+
void QgsAttributeForm::constraintDependencies( QgsEditorWidgetWrapper* w,
928+
QList<QgsEditorWidgetWrapper*>& wDeps )
927929
{
928930
QString name = w->field().name();
929931

@@ -1051,6 +1053,7 @@ void QgsAttributeForm::init()
10511053
vl->addWidget( mMessageBar );
10521054

10531055
mInvalidConstraintMessage = new QLabel( this );
1056+
mInvalidConstraintMessage->hide();
10541057
vl->addWidget( mInvalidConstraintMessage );
10551058

10561059
setLayout( vl );

src/gui/qgsattributeform.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,13 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
320320

321321
//! constraints management
322322
void updateAllConstaints();
323-
void updateConstraints( QgsEditorWidgetWrapper *w );
324-
bool currentFormFeature( QgsFeature &feature );
325-
bool currentFormValidConstraints( QStringList &invalidFields, QStringList &descriptions );
326-
void constraintDependencies( QgsEditorWidgetWrapper *w, QList<QgsEditorWidgetWrapper*> &wDeps );
323+
void updateConstraints( QgsEditorWidgetWrapper* w );
324+
bool currentFormFeature( QgsFeature& feature );
325+
bool currentFormValidConstraints( QStringList& invalidFields, QStringList& descriptions );
326+
void constraintDependencies( QgsEditorWidgetWrapper* w, QList<QgsEditorWidgetWrapper*>& wDeps );
327327
void clearInvalidConstraintsMessage();
328-
void displayInvalidConstraintMessage( const QStringList &invalidFields,
329-
const QStringList &description );
328+
void displayInvalidConstraintMessage( const QStringList& invalidFields,
329+
const QStringList& description );
330330

331331
QgsVectorLayer* mLayer;
332332
QgsFeature mFeature;

0 commit comments

Comments
 (0)