diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-07-12 23:27:32 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-07-12 23:27:32 +0200 |
commit | aba1f89e2abfd596eb01c674d1b2deee3bdc1047 (patch) | |
tree | 774f0ea75b5460bf1c63283ff9f6902237b3c5ad /gui/groupview | |
parent | cc6968e9a3059451c4c1a5296ea5da7457ca831f (diff) | |
download | MultiMC-aba1f89e2abfd596eb01c674d1b2deee3bdc1047.tar MultiMC-aba1f89e2abfd596eb01c674d1b2deee3bdc1047.tar.gz MultiMC-aba1f89e2abfd596eb01c674d1b2deee3bdc1047.tar.lz MultiMC-aba1f89e2abfd596eb01c674d1b2deee3bdc1047.tar.xz MultiMC-aba1f89e2abfd596eb01c674d1b2deee3bdc1047.zip |
Add home/end and fix navigation with collapsed groups (they are skipped)
Diffstat (limited to 'gui/groupview')
-rw-r--r-- | gui/groupview/GroupView.cpp | 64 |
1 files changed, 47 insertions, 17 deletions
diff --git a/gui/groupview/GroupView.cpp b/gui/groupview/GroupView.cpp index 3f85c6e9..31d242dd 100644 --- a/gui/groupview/GroupView.cpp +++ b/gui/groupview/GroupView.cpp @@ -463,6 +463,7 @@ void GroupView::resizeEvent(QResizeEvent *event) int newItemsPerRow = calculateItemsPerRow(); if(newItemsPerRow != m_currentItemsPerRow) { + m_currentCursorColumn = -1; m_currentItemsPerRow = newItemsPerRow; updateGeometries(); } @@ -832,17 +833,24 @@ QModelIndex GroupView::moveCursor(QAbstractItemView::CursorAction cursorAction, { if(row == 0) { - if(group_index == 0) - return current; - auto prevgroup = m_groups[group_index-1]; - int newRow = prevgroup->numRows() - 1; - int newRowSize = prevgroup->rows[newRow].size(); - int newColumn = m_currentCursorColumn; - if (m_currentCursorColumn >= newRowSize) + int prevgroupindex = group_index-1; + while(prevgroupindex >= 0) { - newColumn = newRowSize - 1; + auto prevgroup = m_groups[prevgroupindex]; + if(prevgroup->collapsed) + { + prevgroupindex--; + continue; + } + int newRow = prevgroup->numRows() - 1; + int newRowSize = prevgroup->rows[newRow].size(); + int newColumn = m_currentCursorColumn; + if (m_currentCursorColumn >= newRowSize) + { + newColumn = newRowSize - 1; + } + return prevgroup->rows[newRow][newColumn]; } - return prevgroup->rows[newRow][newColumn]; } else { @@ -855,21 +863,29 @@ QModelIndex GroupView::moveCursor(QAbstractItemView::CursorAction cursorAction, } return cat->rows[newRow][newColumn]; } + return current; } case MoveDown: { if(row == cat->rows.size() - 1) { - if(group_index == m_groups.size() - 1) - return current; - auto nextgroup = m_groups[group_index+1]; - int newRowSize = nextgroup->rows[0].size(); - int newColumn = m_currentCursorColumn; - if (m_currentCursorColumn >= newRowSize) + int nextgroupindex = group_index+1; + while (nextgroupindex < m_groups.size()) { - newColumn = newRowSize - 1; + auto nextgroup = m_groups[nextgroupindex]; + if(nextgroup->collapsed) + { + nextgroupindex++; + continue; + } + int newRowSize = nextgroup->rows[0].size(); + int newColumn = m_currentCursorColumn; + if (m_currentCursorColumn >= newRowSize) + { + newColumn = newRowSize - 1; + } + return nextgroup->rows[0][newColumn]; } - return nextgroup->rows[0][newColumn]; } else { @@ -882,6 +898,7 @@ QModelIndex GroupView::moveCursor(QAbstractItemView::CursorAction cursorAction, } return cat->rows[newRow][newColumn]; } + return current; } case MoveLeft: { @@ -890,6 +907,7 @@ QModelIndex GroupView::moveCursor(QAbstractItemView::CursorAction cursorAction, m_currentCursorColumn = column - 1; return cat->rows[row][column - 1]; } + // TODO: moving to previous line return current; } case MoveRight: @@ -899,8 +917,20 @@ QModelIndex GroupView::moveCursor(QAbstractItemView::CursorAction cursorAction, m_currentCursorColumn = column + 1; return cat->rows[row][column + 1]; } + // TODO: moving to next line return current; } + case MoveHome: + { + m_currentCursorColumn = 0; + return cat->rows[row][0]; + } + case MoveEnd: + { + auto last = cat->rows[row].size() - 1; + m_currentCursorColumn = last; + return cat->rows[row][last]; + } default: break; } |