ProfileViewer: Fix treeview selection looking unselected on Left key

When pressing the Left arrow key, we now travel to the parent_index()
of the currently selected index. Our implementation of parent_index()
was always returning an index with column 0, instead of using the
same column as the current index.

This prevented the selected item from looking selected.
This commit is contained in:
Andreas Kling 2020-02-22 11:27:09 +01:00
parent bb7d6fb310
commit af02d0ee97
Notes: sideshowbarker 2024-07-19 09:10:22 +09:00

View File

@ -64,7 +64,7 @@ GUI::ModelIndex ProfileModel::parent_index(const GUI::ModelIndex& index) const
if (!node.parent()->parent()) {
for (int row = 0; row < m_profile.roots().size(); ++row) {
if (m_profile.roots()[row].ptr() == node.parent()) {
return create_index(row, 0, node.parent());
return create_index(row, index.column(), node.parent());
}
}
ASSERT_NOT_REACHED();
@ -73,7 +73,7 @@ GUI::ModelIndex ProfileModel::parent_index(const GUI::ModelIndex& index) const
for (int row = 0; row < node.parent()->parent()->children().size(); ++row) {
if (node.parent()->parent()->children()[row].ptr() == node.parent())
return create_index(row, 0, node.parent());
return create_index(row, index.column(), node.parent());
}
ASSERT_NOT_REACHED();