From d3365ff28149c4633d0c092587c0ad0d49bcf944 Mon Sep 17 00:00:00 2001 From: mbs Date: Thu, 13 Apr 2023 11:43:32 +0100 Subject: [PATCH] fixed bos#34401 --- src/XGUI/XGUI_Workshop.cpp | 39 +++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 482fcb8e8..edc1d5e50 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -2414,6 +2414,7 @@ bool XGUI_Workshop::canMoveFeature() QObjectPtrList anObjects = mySelector->selection()->selectedObjects(); QObjectPtrList aValidatedObjects; + std::list aSelectedFeatures; foreach (ObjectPtr anObject, anObjects) { if (!myModule->canApplyAction(anObject, anActionId)) continue; @@ -2421,6 +2422,8 @@ bool XGUI_Workshop::canMoveFeature() if (anObject->document() != ModelAPI_Session::get()->activeDocument()) continue; aValidatedObjects.append(anObject); + FeaturePtr aFeat = std::dynamic_pointer_cast(anObject); + aSelectedFeatures.push_back(aFeat); } if (aValidatedObjects.size() != anObjects.size()) anObjects = aValidatedObjects; @@ -2435,12 +2438,25 @@ bool XGUI_Workshop::canMoveFeature() break; } FeaturePtr aFeat = std::dynamic_pointer_cast(anObject); - // only groups can be moved to the end for now (#2451) - if (aFeat.get() && aFeat->getKind() != "Group") { - aCanMove = false; - break; + // only groups can be moved to the end for now (#2451 old_id, #23105 tuleap id) + // and groups created by other groups (#34401) + if (aFeat.get()) { + std::string aKindOfFeature = aFeat->getKind(); + if (aKindOfFeature != "Group" && + aKindOfFeature != "GroupSubstraction" && + aKindOfFeature != "GroupAddition" && + aKindOfFeature != "GroupIntersection") { + aCanMove = false; + break; + } } + // Check that the feature can be moved due to its dependencies + // i.e. Check that there are no features between the moved one and its destination + // with references to it + // Details on #21340 (old_id #660) + // NOTE: we can ignore dependend features, if they are also moved! + // 1. Get features placed between selected and current in the document std::list aFeaturesBetween = toCurrentFeatures(anObject); // if aFeaturesBetween is empty it means wrong order or anObject is the current feature @@ -2455,12 +2471,21 @@ bool XGUI_Workshop::canMoveFeature() if (aRefFeatures.empty()) continue; else { - // 3. Find any placed features in all reference features + // 3.1. Check, if any reference feature is going to be moved, too. + // If it is, we can ignore its dependency in our subsequent check (3.2) + std::set aNoMoveRefFeatures; + std::set_difference(aRefFeatures.begin(), aRefFeatures.end(), + aSelectedFeatures.begin(), aSelectedFeatures.end(), + std::inserter(aNoMoveRefFeatures, aNoMoveRefFeatures.begin())); + if (aNoMoveRefFeatures.empty()) + continue; + + // 3.2. Find any placed features in all remaining (non-moved) reference features std::set aIntersectionFeatures; - std::set_intersection(aRefFeatures.begin(), aRefFeatures.end(), + std::set_intersection(aNoMoveRefFeatures.begin(), aNoMoveRefFeatures.end(), aPlacedFeatures.begin(), aPlacedFeatures.end(), std::inserter(aIntersectionFeatures, aIntersectionFeatures.begin())); - // 4. Return false if any reference feature is placed before current feature + // 4. Return false if any (non-moved) reference feature is placed before current feature if (!aIntersectionFeatures.empty()) aCanMove = false; } -- 2.39.2