Skip to content

Commit

Permalink
add invalid label inly once
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Sep 23, 2014
1 parent 0f8fef1 commit 443fa8c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/gui/editorwidgets/qgsrelationreferencewidget.cpp
Expand Up @@ -127,6 +127,16 @@ QgsRelationReferenceWidget::QgsRelationReferenceWidget( QWidget* parent )
mAttributeEditorFrame->setSizePolicy( mAttributeEditorFrame->sizePolicy().horizontalPolicy(), QSizePolicy::Expanding );
mTopLayout->addWidget( mAttributeEditorFrame );

// invalid label
mInvalidLabel = new QLabel( tr( "The relation is not valid. Please make sure your relation definitions are ok." ) );
mInvalidLabel->setWordWrap( true );
QFont font = mInvalidLabel->font();
font.setItalic( true );
mInvalidLabel->setStyleSheet( "QLabel { color: red; } " );
mInvalidLabel->setFont( font );
mTopLayout->addWidget( mInvalidLabel, 1, 0 );
mInvalidLabel->hide();

// default mode is combobox, no geometric relation and no embed form
mLineEdit->hide();
mMapIdentificationButton->hide();
Expand All @@ -149,13 +159,14 @@ void QgsRelationReferenceWidget::setRelation( QgsRelation relation, bool allowNu

if ( relation.isValid() )
{
mInvalidLabel->hide();

mRelation = relation;
mReferencingLayer = relation.referencingLayer();
mRelationName = relation.name();
mReferencedLayer = relation.referencedLayer();
mFkeyFieldIdx = mReferencedLayer->fieldNameIndex( relation.fieldPairs().first().second );


QgsAttributeEditorContext context( mEditorContext, relation, QgsAttributeEditorContext::Single, QgsAttributeEditorContext::Embed );

if ( mEmbedForm )
Expand All @@ -168,13 +179,7 @@ void QgsRelationReferenceWidget::setRelation( QgsRelation relation, bool allowNu
}
else
{
QLabel* lbl = new QLabel( tr( "The relation is not valid. Please make sure your relation definitions are ok." ) );
lbl->setWordWrap( true );
QFont font = lbl->font();
font.setItalic( true );
lbl->setStyleSheet( "QLabel { color: red; } " );
lbl->setFont( font );
mTopLayout->addWidget( lbl, 1, 0 );
mInvalidLabel->show();
}

if ( mShown && isVisible() )
Expand Down
1 change: 1 addition & 0 deletions src/gui/editorwidgets/qgsrelationreferencewidget.h
Expand Up @@ -152,6 +152,7 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget
QgsCollapsibleGroupBox* mAttributeEditorFrame;
QVBoxLayout* mAttributeEditorLayout;
QLineEdit* mLineEdit;
QLabel* mInvalidLabel;
};

#endif // QGSRELATIONREFERENCEWIDGET_H

0 comments on commit 443fa8c

Please sign in to comment.