MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / moveCursor

Method moveCursor

launcher/ui/instanceview/InstanceView.cpp:874–1001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

872}
873
874QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
875{
876 auto current = currentIndex();
877 if(!current.isValid())
878 {
879 return current;
880 }
881 auto cat = category(current);
882 int group_index = m_groups.indexOf(cat);
883 if(group_index < 0)
884 return current;
885
886 QPair<int, int> pos = cat->positionOf(current);
887 int column = pos.first;
888 int row = pos.second;
889 if(m_currentCursorColumn < 0)
890 {
891 m_currentCursorColumn = column;
892 }
893 switch(cursorAction)
894 {
895 case MoveUp:
896 {
897 if(row == 0)
898 {
899 int prevgroupindex = group_index-1;
900 while(prevgroupindex >= 0)
901 {
902 auto prevgroup = m_groups[prevgroupindex];
903 if(prevgroup->collapsed)
904 {
905 prevgroupindex--;
906 continue;
907 }
908 int newRow = prevgroup->numRows() - 1;
909 int newRowSize = prevgroup->rows[newRow].size();
910 int newColumn = m_currentCursorColumn;
911 if (m_currentCursorColumn >= newRowSize)
912 {
913 newColumn = newRowSize - 1;
914 }
915 return prevgroup->rows[newRow][newColumn];
916 }
917 }
918 else
919 {
920 int newRow = row - 1;
921 int newRowSize = cat->rows[newRow].size();
922 int newColumn = m_currentCursorColumn;
923 if (m_currentCursorColumn >= newRowSize)
924 {
925 newColumn = newRowSize - 1;
926 }
927 return cat->rows[newRow][newColumn];
928 }
929 return current;
930 }
931 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