From fceda45677c9bf1b2452edec01ac22dc6aa50ea5 Mon Sep 17 00:00:00 2001 From: Richard Kello Date: Fri, 28 Aug 2026 16:10:15 +0200 Subject: [PATCH 1/2] Add condition so readOnly child cannot be added from parent --- app/qml/form/editors/MMFormGalleryEditor.qml | 2 +- app/qml/form/editors/MMFormRelationEditor.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/qml/form/editors/MMFormGalleryEditor.qml b/app/qml/form/editors/MMFormGalleryEditor.qml index 37221230b..b1259b854 100644 --- a/app/qml/form/editors/MMFormGalleryEditor.qml +++ b/app/qml/form/editors/MMFormGalleryEditor.qml @@ -75,7 +75,7 @@ MMPrivateComponents.MMBaseInput { } } - header: __activeProject.projectRole !== "reader" ? addFeatureComponent : null + header: (__activeProject.projectRole !== "reader" && !rmodel?.layer.readOnly) ? addFeatureComponent : null } Component { diff --git a/app/qml/form/editors/MMFormRelationEditor.qml b/app/qml/form/editors/MMFormRelationEditor.qml index 3ac0eb4c0..7a7222a66 100644 --- a/app/qml/form/editors/MMFormRelationEditor.qml +++ b/app/qml/form/editors/MMFormRelationEditor.qml @@ -86,7 +86,7 @@ MMPrivateComponents.MMBaseInput { height: privates.itemHeight radius: 8 * __dp color: __style.lightGreenColor - visible: __activeProject.projectRole !== "reader" + visible: (__activeProject.projectRole !== "reader" && !rmodel?.layer.readOnly) MMComponents.MMIcon { anchors.centerIn: parent From f1b7110e50738f284635375b6d64ffff47347f83 Mon Sep 17 00:00:00 2001 From: Richard Kello Date: Wed, 9 Sep 2026 09:37:58 +0200 Subject: [PATCH 2/2] Fix some relation issues --- app/qml/form/editors/MMFormGalleryEditor.qml | 2 +- app/qml/form/editors/MMFormRelationEditor.qml | 2 +- app/relationfeaturesmodel.cpp | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/qml/form/editors/MMFormGalleryEditor.qml b/app/qml/form/editors/MMFormGalleryEditor.qml index b1259b854..e3365d1ae 100644 --- a/app/qml/form/editors/MMFormGalleryEditor.qml +++ b/app/qml/form/editors/MMFormGalleryEditor.qml @@ -75,7 +75,7 @@ MMPrivateComponents.MMBaseInput { } } - header: (__activeProject.projectRole !== "reader" && !rmodel?.layer.readOnly) ? addFeatureComponent : null + header: (__activeProject.projectRole !== "reader" && !rmodel?.layer?.readOnly) ? addFeatureComponent : null } Component { diff --git a/app/qml/form/editors/MMFormRelationEditor.qml b/app/qml/form/editors/MMFormRelationEditor.qml index 7a7222a66..bcc6459ba 100644 --- a/app/qml/form/editors/MMFormRelationEditor.qml +++ b/app/qml/form/editors/MMFormRelationEditor.qml @@ -86,7 +86,7 @@ MMPrivateComponents.MMBaseInput { height: privates.itemHeight radius: 8 * __dp color: __style.lightGreenColor - visible: (__activeProject.projectRole !== "reader" && !rmodel?.layer.readOnly) + visible: (__activeProject.projectRole !== "reader" && !rmodel?.layer?.readOnly) MMComponents.MMIcon { anchors.centerIn: parent diff --git a/app/relationfeaturesmodel.cpp b/app/relationfeaturesmodel.cpp index 0992ba180..b5783a401 100644 --- a/app/relationfeaturesmodel.cpp +++ b/app/relationfeaturesmodel.cpp @@ -75,12 +75,10 @@ void RelationFeaturesModel::setParentFeatureLayerPair( FeatureLayerPair pair ) if ( !InputUtils::isFeatureIdValid( pair.feature().id() ) ) { - // - // Clear the model in case parent feature has invalid id (e.g. is new) and do not populate it - // + // Parent has no valid id yet (e.g. new feature) - clear features but keep mLayer known. beginResetModel(); - reset(); + mFeatures.clear(); endResetModel(); } else @@ -96,6 +94,9 @@ void RelationFeaturesModel::setRelation( QgsRelation relation ) mRelation = relation; emit relationChanged( mRelation ); + // set layer early so it's known even before the parent feature has a valid id (e.g. new feature) + LayerFeaturesModel::setLayer( mRelation.isValid() ? mRelation.referencingLayer() : nullptr ); + setup(); } }