Skip to content
Permalink
Browse files

add invalid label inly once

  • Loading branch information
3nids committed Sep 23, 2014
1 parent 0f8fef1 commit 443fa8cc920216bb0ac470babf1709e1242d169c
@@ -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();
@@ -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 )
@@ -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() )
@@ -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.
You can’t perform that action at this time.