MCPcopy Create free account
hub / github.com/MultiMC/Launcher / moveCursor

Method moveCursor

launcher/ui/instanceview/InstanceView.cpp:826–953  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

824}
825
826QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
827{
828 auto current = currentIndex();
829 if(!current.isValid())
830 {
831 return current;
832 }
833 auto cat = category(current);
834 int group_index = m_groups.indexOf(cat);
835 if(group_index < 0)
836 return current;
837
838 QPair<int, int> pos = cat->positionOf(current);
839 int column = pos.first;
840 int row = pos.second;
841 if(m_currentCursorColumn < 0)
842 {
843 m_currentCursorColumn = column;
844 }
845 switch(cursorAction)
846 {
847 case MoveUp:
848 {
849 if(row == 0)
850 {
851 int prevgroupindex = group_index-1;
852 while(prevgroupindex >= 0)
853 {
854 auto prevgroup = m_groups[prevgroupindex];
855 if(prevgroup->collapsed)
856 {
857 prevgroupindex--;
858 continue;
859 }
860 int newRow = prevgroup->numRows() - 1;
861 int newRowSize = prevgroup->rows[newRow].size();
862 int newColumn = m_currentCursorColumn;
863 if (m_currentCursorColumn >= newRowSize)
864 {
865 newColumn = newRowSize - 1;
866 }
867 return prevgroup->rows[newRow][newColumn];
868 }
869 }
870 else
871 {
872 int newRow = row - 1;
873 int newRowSize = cat->rows[newRow].size();
874 int newColumn = m_currentCursorColumn;
875 if (m_currentCursorColumn >= newRowSize)
876 {
877 newColumn = newRowSize - 1;
878 }
879 return cat->rows[newRow][newColumn];
880 }
881 return current;
882 }
883 case MoveDown:

Callers

nothing calls this directly

Calls 4

positionOfMethod · 0.80
numRowsMethod · 0.80
isValidMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected