Skip to content

Commit

Permalink
feat: Improve left and right cursor navigation in Instances
Browse files Browse the repository at this point in the history
Signed-off-by: Edgars Cirulis <edgarsciruliss@gmail.com>
  • Loading branch information
Edgars-Cirulis committed Aug 25, 2024
1 parent 23c69e7 commit d2c2433
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions launcher/ui/instanceview/InstanceView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ QRegion InstanceView::visualRegionForSelection(const QItemSelection& selection)
return region;
}

QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorAction, [[maybe_unused]] Qt::KeyboardModifiers modifiers)
QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
{
auto current = currentIndex();
if (!current.isValid()) {
Expand All @@ -865,6 +865,7 @@ QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorActio
if (m_currentCursorColumn < 0) {
m_currentCursorColumn = column;
}
// Handle different movement actions.
switch (cursorAction) {
case MoveUp: {
if (row == 0) {
Expand Down Expand Up @@ -925,16 +926,23 @@ QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorActio
if (column > 0) {
m_currentCursorColumn = column - 1;
return cat->rows[row][column - 1];
} else if (row > 0) {
row -= 1;
int newRowSize = cat->rows[row].size();
m_currentCursorColumn = newRowSize - 1;
return cat->rows[row][m_currentCursorColumn];
}
// TODO: moving to previous line
return current;
}
case MoveRight: {
if (column < cat->rows[row].size() - 1) {
m_currentCursorColumn = column + 1;
return cat->rows[row][column + 1];
} else if (row < cat->rows.size() - 1) {
row += 1;
m_currentCursorColumn = 0;
return cat->rows[row][m_currentCursorColumn];
}
// TODO: moving to next line
return current;
}
case MoveHome: {
Expand All @@ -947,6 +955,7 @@ QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorActio
return cat->rows[row][last];
}
default:
// For unsupported cursor actions, return the current index.
break;
}
return current;
Expand Down

0 comments on commit d2c2433

Please sign in to comment.