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

Method update

launcher/ui/instanceview/VisualGroup.cpp:55–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void VisualGroup::update()
56{
57 auto temp_items = items();
58 auto itemsPerRow = view->itemsPerRow();
59
60 int numRows = qMax(1, qCeil((qreal)temp_items.size() / (qreal)itemsPerRow));
61 rows = QVector<VisualRow>(numRows);
62
63 int maxRowHeight = 0;
64 int positionInRow = 0;
65 int currentRow = 0;
66 int offsetFromTop = 0;
67 for (auto item: temp_items)
68 {
69 if(positionInRow == itemsPerRow)
70 {
71 rows[currentRow].height = maxRowHeight;
72 rows[currentRow].top = offsetFromTop;
73 currentRow ++;
74 offsetFromTop += maxRowHeight + 5;
75 positionInRow = 0;
76 maxRowHeight = 0;
77 }
78#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
79 QStyleOptionViewItem viewItemOption;
80 view->initViewItemOption(&viewItemOption);
81#else
82 QStyleOptionViewItem viewItemOption = view->viewOptions();
83#endif
84
85 auto itemHeight = view->itemDelegate()->sizeHint(viewItemOption, item).height();
86 if(itemHeight > maxRowHeight)
87 {
88 maxRowHeight = itemHeight;
89 }
90 rows[currentRow].items.append(item);
91 positionInRow++;
92 }
93 rows[currentRow].height = maxRowHeight;
94 rows[currentRow].top = offsetFromTop;
95}
96
97QPair<int, int> VisualGroup::positionOf(const QModelIndex &index) const
98{

Callers 11

installModsMethod · 0.45
updateModsMethod · 0.45
updateGeometriesMethod · 0.45
mouseReleaseEventMethod · 0.45
dragEnterEventMethod · 0.45
dragMoveEventMethod · 0.45
dragLeaveEventMethod · 0.45
dropEventMethod · 0.45
scrollToMethod · 0.45
updateEmptyViewPortMethod · 0.45

Calls 4

itemsPerRowMethod · 0.80
appendMethod · 0.80
sizeMethod · 0.45
sizeHintMethod · 0.45

Tested by

no test coverage detected