summaryrefslogtreecommitdiff
path: root/view/sharedcache
diff options
context:
space:
mode:
Diffstat (limited to 'view/sharedcache')
-rw-r--r--view/sharedcache/ui/dsctriage.h29
-rw-r--r--view/sharedcache/ui/symboltable.h29
2 files changed, 28 insertions, 30 deletions
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:
diff --git a/view/sharedcache/ui/symboltable.h b/view/sharedcache/ui/symboltable.h
index 9c7a1eab..ab0174f9 100644
--- a/view/sharedcache/ui/symboltable.h
+++ b/view/sharedcache/ui/symboltable.h
@@ -72,26 +72,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);
}
SharedCacheAPI::CacheSymbol getSymbolAtRow(int row) const