Skip to content

Commit

Permalink
relation cardinality bugfix
Browse files Browse the repository at this point in the history
relation cardinality was handled with it's name as QString instead of it's value as QVector and this leaded to problems in the attribute form.

Fix #17805
  • Loading branch information
signedav authored and m-kuhn committed Jan 12, 2018
1 parent 8074dc4 commit 8eaecd1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/app/qgsattributerelationedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ void QgsAttributeRelationEdit::setCardinalityCombo( const QString &cardinalityCo
coCardinality->addItem( cardinalityComboItem, auserData );
}

void QgsAttributeRelationEdit::setCardinality( const QString &cardinality )
void QgsAttributeRelationEdit::setCardinality( const QVariant &auserData )
{
int idx = coCardinality->findText( cardinality );
int idx = coCardinality->findData( auserData );

if ( idx != -1 )
coCardinality->setCurrentIndex( idx );
}

QString QgsAttributeRelationEdit::cardinality()
QVariant QgsAttributeRelationEdit::cardinality()
{
return coCardinality->currentText();
return coCardinality->currentData();
}
4 changes: 2 additions & 2 deletions src/app/qgsattributerelationedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ class APP_EXPORT QgsAttributeRelationEdit: public QWidget, private Ui::QgsAttrib
/**
* Setter for combo cardinality
*/
void setCardinality( const QString &cardinality );
void setCardinality( const QVariant &auserData = QVariant() );

/**
* Getter for combo cardinality
*/
QString cardinality();
QVariant cardinality();

QString mRelationId;
private:
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgsattributesformproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ void QgsAttributesFormProperties::apply()
RelationConfig relCfg = configForRelation( itemData.name() );

QVariantMap cfg;
cfg[QStringLiteral( "nm-rel" )] = relCfg.mCardinality;
cfg[QStringLiteral( "nm-rel" )] = relCfg.mCardinality.toString();

editFormConfig.setWidgetConfig( itemData.name(), cfg );
}
Expand Down Expand Up @@ -749,15 +749,15 @@ QgsAttributesFormProperties::FieldConfig::operator QVariant()
* RelationConfig implementation
*/
QgsAttributesFormProperties::RelationConfig::RelationConfig()
: mCardinality( QString() )
: mCardinality( QVariant() )
{
}

QgsAttributesFormProperties::RelationConfig::RelationConfig( QgsVectorLayer *layer, const QString &relationId )
{
const QVariant nmrelcfg = layer->editFormConfig().widgetConfig( relationId ).value( QStringLiteral( "nm-rel" ) );

mCardinality = nmrelcfg.toString();
mCardinality = nmrelcfg;
}

QgsAttributesFormProperties::RelationConfig::operator QVariant()
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsattributesformproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class APP_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAtt
RelationConfig();
RelationConfig( QgsVectorLayer *layer, const QString &relationId );

QString mCardinality;
QVariant mCardinality;

operator QVariant();
};
Expand Down

0 comments on commit 8eaecd1

Please sign in to comment.