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

Method updateScrollbar

launcher/ui/instanceview/InstanceView.cpp:141–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141void InstanceView::updateScrollbar()
142{
143 int previousScroll = verticalScrollBar()->value();
144 if (m_groups.isEmpty()) {
145 verticalScrollBar()->setRange(0, 0);
146 } else {
147 int totalHeight = 0;
148 // top margin
149 totalHeight += m_categoryMargin;
150 int itemScroll = 0;
151 for (auto category : m_groups) {
152 category->m_verticalPosition = totalHeight;
153 totalHeight += category->totalHeight() + m_categoryMargin;
154 if (!itemScroll && category->totalHeight() != 0) {
155 itemScroll = category->contentHeight() / category->numRows();
156 }
157 }
158 // do not divide by zero
159 if (itemScroll == 0)
160 itemScroll = 64;
161
162 totalHeight += m_bottomMargin;
163 verticalScrollBar()->setSingleStep(itemScroll);
164 const int rowsPerPage = qMax(viewport()->height() / itemScroll, 1);
165 verticalScrollBar()->setPageStep(rowsPerPage * itemScroll);
166
167 verticalScrollBar()->setRange(0, totalHeight - height());
168 }
169
170 verticalScrollBar()->setValue(qMin(previousScroll, verticalScrollBar()->maximum()));
171}
172
173void InstanceView::updateGeometries()
174{

Callers

nothing calls this directly

Calls 7

valueMethod · 0.80
setRangeMethod · 0.80
totalHeightMethod · 0.80
contentHeightMethod · 0.80
numRowsMethod · 0.80
setValueMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected