feat: Automatically select newly added table rows (#4216)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
kornes
2022-12-06 22:52:58 +00:00
committed by GitHub
parent 783b05c103
commit 36c8fffee2
4 changed files with 9 additions and 25 deletions
@@ -40,13 +40,6 @@ KeyboardSettingsPage::KeyboardSettingsPage()
auto newHotkey = dialog.data();
int vectorIndex = getApp()->hotkeys->hotkeys_.append(newHotkey);
getApp()->hotkeys->save();
// Select and scroll to newly added hotkey
auto modelRow = model->getModelIndexFromVectorIndex(vectorIndex);
auto modelIndex = model->index(modelRow, 0);
view->selectRow(modelRow);
view->getTableView()->scrollTo(modelIndex,
QAbstractItemView::PositionAtCenter);
}
});
@@ -89,11 +82,6 @@ void KeyboardSettingsPage::tableCellClicked(const QModelIndex &clicked,
auto vectorIndex =
getApp()->hotkeys->replaceHotkey(hotkey->name(), newHotkey);
getApp()->hotkeys->save();
// Select the replaced hotkey
auto modelRow = model->getModelIndexFromVectorIndex(vectorIndex);
auto modelIndex = model->index(modelRow, 0);
view->selectRow(modelRow);
}
}