MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / update

Method update

launcher/ui/instanceview/VisualGroup.cpp:52–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 9

updateIconsMethod · 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