From 841da58f10d9dbd767ceaef7b0e41a0ba4982ee4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 25 Oct 2021 11:23:41 +0200 Subject: [PATCH] #8187 Multiple object edit : Improve identification of selected items at multiple levels Find all selected items at one level starting from the largest level. This is required to be able to modify multiple rows in the table editor. Items in the table editor use by default SelectionManager::FIRST_LEVEL --- .../cafPdmUiCommandSystemProxy.cpp | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp index 51a0f15238..2f0b719b17 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp @@ -149,14 +149,24 @@ std::vector PdmUiCommandSystemProxy::fieldsFromSelection( PdmFi if ( !editorField ) return {}; if ( !editorField->ownerObject() ) return {}; + std::vector items; + + // Find all selected items at one level starting from the largest level. This is required to be able to modify + // multiple rows in the table editor. Items in the table editor use by default SelectionManager::FIRST_LEVEL + for ( int candidateSelectionLevel = SelectionManager::SECOND_LEVEL; + candidateSelectionLevel != SelectionManager::UNDEFINED; + candidateSelectionLevel-- ) + { + SelectionManager::instance()->selectedItems( items, candidateSelectionLevel ); + if ( !items.empty() ) break; + } + + if ( items.size() < 2 ) return {}; + + const auto fieldKeyword = editorField->keyword(); + const auto& fieldOwnerTypeId = typeid( *editorField->ownerObject() ); std::vector additionalFieldsToUpdate; - const auto fieldKeyword = editorField->keyword(); - const auto& fieldOwnerTypeId = typeid( *editorField->ownerObject() ); - - int selectionLevel = 0; - std::vector items; - SelectionManager::instance()->selectedItems( items, selectionLevel ); for ( auto& item : items ) { auto* objectHandle = dynamic_cast( item );