From 3e85ad3f6631d601bdb1602570ef46d88e5d0a71 Mon Sep 17 00:00:00 2001 From: Richard Kello Date: Fri, 28 Aug 2026 16:10:15 +0200 Subject: [PATCH 1/4] 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 7d482ae426697faa18fad8f6259141ad0eb93a2d Mon Sep 17 00:00:00 2001 From: Richard Kello Date: Wed, 9 Sep 2026 09:37:58 +0200 Subject: [PATCH 2/4] 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(); } } From b2aa432d51c5871b044861dea826d71a50333430 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 28 Sep 2026 10:17:23 +0200 Subject: [PATCH 3/4] Fix missing condition --- app/qml/form/components/MMFeaturesListPageDrawer.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/qml/form/components/MMFeaturesListPageDrawer.qml b/app/qml/form/components/MMFeaturesListPageDrawer.qml index b463a687f..9ba9ae6d9 100644 --- a/app/qml/form/components/MMFeaturesListPageDrawer.qml +++ b/app/qml/form/components/MMFeaturesListPageDrawer.qml @@ -126,7 +126,7 @@ Drawer { } text: qsTr( "Add feature" ) - visible: __activeProject.projectRole !== "reader" + visible: __activeProject.projectRole !== "reader" && !listView.model?.layer?.readOnly onClicked: { root.close() From 6a498bca0c23c955be34fe0c483c1dd4cd8f8958 Mon Sep 17 00:00:00 2001 From: Richard Kello Date: Wed, 30 Sep 2026 16:45:20 +0200 Subject: [PATCH 4/4] Add condition so we dont setLayer multiple times for some features --- app/relationfeaturesmodel.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/relationfeaturesmodel.cpp b/app/relationfeaturesmodel.cpp index b5783a401..2c75b8f16 100644 --- a/app/relationfeaturesmodel.cpp +++ b/app/relationfeaturesmodel.cpp @@ -94,8 +94,10 @@ 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 ); + if ( !mRelation.isValid() || !mParentFeatureLayerPair.isValid() ) + { + LayerFeaturesModel::setLayer( mRelation.isValid() ? mRelation.referencingLayer() : nullptr ); + } setup(); }