Skip to content

Commit

Permalink
Harmonize handling of QField's (multi)value relation editor widget wi…
Browse files Browse the repository at this point in the history
…th that of QGIS
  • Loading branch information
nirvn committed Aug 12, 2024
1 parent edb9e67 commit b8dbba5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions src/core/featurechecklistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ QHash<int, QByteArray> FeatureCheckListModel::roleNames() const

QVariant FeatureCheckListModel::attributeValue() const
{
QVariant value;

QVariantList vl;
//store as QVariantList because the field type supports data structure
for ( const QString &s : std::as_const( mCheckedEntries ) )
Expand All @@ -83,23 +81,26 @@ QVariant FeatureCheckListModel::attributeValue() const
}
}

if ( mAllowMulti )
QVariant value;
if ( !vl.isEmpty() )
{
if ( mAttributeField.type() == QMetaType::QVariantMap || mAttributeField.type() == QMetaType::QVariantList || mAttributeField.type() == QMetaType::QStringList )
if ( mAllowMulti )
{
value = vl;
if ( mAttributeField.type() == QMetaType::QVariantMap || mAttributeField.type() == QMetaType::QVariantList || mAttributeField.type() == QMetaType::QStringList )
{
value = vl;
}
else
{
//make string
value = QgsPostgresStringUtils::buildArray( vl );
}
}
else
{
//make string
value = QgsPostgresStringUtils::buildArray( vl );
value = vl.first();
}
}
else
{
value = vl.first();
}

return value;
}

Expand Down
2 changes: 1 addition & 1 deletion src/qml/editorwidgets/ValueRelation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ EditorWidgetBase {
attributeValue: value !== undefined ? value : ""

onListUpdated: {
valueChangeRequested(attributeValue, false);
valueChangeRequested(attributeValue, attributeValue === "");
}
}

Expand Down

0 comments on commit b8dbba5

Please sign in to comment.