From ade58079a0a3e6b9d1a0793ab4c084d0f9431f4d Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Fri, 24 Oct 2025 08:21:26 -0700 Subject: Update FilterEdit and FilterTarget to preserve existing selections The down and enter keys now preserve an existing selection in the associated list or table views, rather than unconditionally selecting or activating the first item. --- view/sharedcache/ui/dsctriage.h | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'view/sharedcache/ui/dsctriage.h') diff --git a/view/sharedcache/ui/dsctriage.h b/view/sharedcache/ui/dsctriage.h index 33f45bcf..02a41eab 100644 --- a/view/sharedcache/ui/dsctriage.h +++ b/view/sharedcache/ui/dsctriage.h @@ -150,24 +150,23 @@ public: } } - void selectFirstItem() override { - if (model()->rowCount() > 0) { - QModelIndex top = indexAt(rect().topLeft()); - if (top.isValid()) { - selectionModel()->select(top, QItemSelectionModel::ClearAndSelect); - setCurrentIndex(top); - } + void ensureSelection() override { + QModelIndex current = selectionModel()->currentIndex(); + if (current.isValid() && !isRowHidden(current.row())) + return; + + if (auto top = indexAt(rect().topLeft()); top.isValid()) + { + selectionModel()->select(top, QItemSelectionModel::ClearAndSelect); + setCurrentIndex(top); } } - void activateFirstItem() override { - if (model()->rowCount() > 0) { - QModelIndex topLeft = indexAt(rect().topLeft()); - if (topLeft.isValid()) { - setCurrentIndex(topLeft); - emit activated(topLeft); - } - } + + void activateSelection() override { + ensureSelection(); + if (auto current = selectionModel()->currentIndex(); current.isValid()) + emit activated(current); } signals: -- cgit v1.3.1