Skip to content
Permalink
Browse files

relation cardinality bugfix

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 11, 2018
1 parent 8074dc4 commit 8eaecd1c2211723655468c34b2c143a5c4c78564
@@ -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();
}
@@ -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:
@@ -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 );
}
@@ -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()
@@ -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();
};

0 comments on commit 8eaecd1

Please sign in to comment.
You can’t perform that action at this time.