diff options
Diffstat (limited to 'view/kernelcache/ui/symboltable.h')
| -rw-r--r-- | view/kernelcache/ui/symboltable.h | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/view/kernelcache/ui/symboltable.h b/view/kernelcache/ui/symboltable.h index 866390c7..28d07199 100644 --- a/view/kernelcache/ui/symboltable.h +++ b/view/kernelcache/ui/symboltable.h @@ -68,26 +68,25 @@ public: scrollTo(currentIndex); } - void selectFirstItem() override + void ensureSelection() override { - if (model()->rowCount() > 0) { - QModelIndex top = indexAt(rect().topLeft()); - if (top.isValid()) { - selectionModel()->select(top, QItemSelectionModel::ClearAndSelect); - setCurrentIndex(top); - } + QModelIndex current = selectionModel()->currentIndex(); + if (current.isValid() || model()->rowCount() == 0) + return; + + if (auto top = indexAt(rect().topLeft()); top.isValid()) + { + selectionModel()->select(top, QItemSelectionModel::ClearAndSelect); + setCurrentIndex(top); } } - void activateFirstItem() override + + void activateSelection() override { - if (model()->rowCount() > 0) { - QModelIndex topLeft = indexAt(rect().topLeft()); - if (topLeft.isValid()) { - setCurrentIndex(topLeft); - emit activated(topLeft); - } - } + ensureSelection(); + if (auto current = selectionModel()->currentIndex(); current.isValid()) + emit activated(current); } KernelCacheAPI::CacheSymbol getSymbolAtRow(int row) const |
