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

Method update

launcher/ui/instanceview/VisualGroup.cpp:35–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35void VisualGroup::update()
36{
37 auto temp_items = items();
38 auto itemsPerRow = view->itemsPerRow();
39
40 int numRows = qMax(1, qCeil((qreal)temp_items.size() / (qreal)itemsPerRow));
41 rows = QVector<VisualRow>(numRows);
42
43 int maxRowHeight = 0;
44 int positionInRow = 0;
45 int currentRow = 0;
46 int offsetFromTop = 0;
47 for (auto item: temp_items)
48 {
49 if(positionInRow == itemsPerRow)
50 {
51 rows[currentRow].height = maxRowHeight;
52 rows[currentRow].top = offsetFromTop;
53 currentRow ++;
54 offsetFromTop += maxRowHeight + 5;
55 positionInRow = 0;
56 maxRowHeight = 0;
57 }
58 auto itemHeight = view->itemDelegate()->sizeHint(view->viewOptions(), item).height();
59 if(itemHeight > maxRowHeight)
60 {
61 maxRowHeight = itemHeight;
62 }
63 rows[currentRow].items.append(item);
64 positionInRow++;
65 }
66 rows[currentRow].height = maxRowHeight;
67 rows[currentRow].top = offsetFromTop;
68}
69
70QPair<int, int> VisualGroup::positionOf(const QModelIndex &index) const
71{

Callers 9

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