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

Method moveCursor

launcher/ui/instanceview/InstanceView.cpp:826–962  ·  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 auto real_group = m_groups[group_index];
839 int beginning_row = 0;
840 for(auto group: m_groups)
841 {
842 if(group == real_group)
843 break;
844 beginning_row += group->numRows();
845 }
846
847 QPair<int, int> pos = cat->positionOf(current);
848 int column = pos.first;
849 int row = pos.second;
850 if(m_currentCursorColumn < 0)
851 {
852 m_currentCursorColumn = column;
853 }
854 switch(cursorAction)
855 {
856 case MoveUp:
857 {
858 if(row == 0)
859 {
860 int prevgroupindex = group_index-1;
861 while(prevgroupindex >= 0)
862 {
863 auto prevgroup = m_groups[prevgroupindex];
864 if(prevgroup->collapsed)
865 {
866 prevgroupindex--;
867 continue;
868 }
869 int newRow = prevgroup->numRows() - 1;
870 int newRowSize = prevgroup->rows[newRow].size();
871 int newColumn = m_currentCursorColumn;
872 if (m_currentCursorColumn >= newRowSize)
873 {
874 newColumn = newRowSize - 1;
875 }
876 return prevgroup->rows[newRow][newColumn];
877 }
878 }
879 else
880 {
881 int newRow = row - 1;
882 int newRowSize = cat->rows[newRow].size();
883 int newColumn = m_currentCursorColumn;

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected