From 4ab88ea2180a491e342e70abf1024cae50e1095b Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Sat, 10 Dec 2022 17:20:41 +0100 Subject: [PATCH] Add option to not reset seletion on any / all index type change --- src/utils/scene-item-selection.cpp | 11 +++++++++-- src/utils/scene-item-selection.hpp | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/utils/scene-item-selection.cpp b/src/utils/scene-item-selection.cpp index 35b1f2ea..98a5ecd1 100644 --- a/src/utils/scene-item-selection.cpp +++ b/src/utils/scene-item-selection.cpp @@ -369,10 +369,17 @@ void SceneItemSelectionWidget::SetShowAll(bool value) _hasAllEntry = value; } -void SceneItemSelectionWidget::SetShowAllSelectionType(AllSelectionType t) +void SceneItemSelectionWidget::SetShowAllSelectionType(AllSelectionType t, + bool resetSelection) { _allType = t; - _sceneItems->setCurrentIndex(0); + if (resetSelection) { + _sceneItems->setCurrentIndex(0); + } else { + auto count = _idx->count() - 1; + const QSignalBlocker b(_idx); + SetupIdxSelection(count > 0 ? count : 1); + } } void SceneItemSelectionWidget::SceneChanged(const SceneSelection &s) diff --git a/src/utils/scene-item-selection.hpp b/src/utils/scene-item-selection.hpp index f77f7492..1817dd55 100644 --- a/src/utils/scene-item-selection.hpp +++ b/src/utils/scene-item-selection.hpp @@ -51,7 +51,7 @@ public: void SetSceneItem(const SceneItemSelection &); void SetScene(const SceneSelection &); void SetShowAll(bool); - void SetShowAllSelectionType(AllSelectionType t); + void SetShowAllSelectionType(AllSelectionType t, bool resetSelection = true); signals: void SceneItemChanged(const SceneItemSelection &);