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

Method verticalScrollToValue

launcher/ui/instanceview/InstanceView.cpp:1034–1049  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1032}
1033
1034int InstanceView::verticalScrollToValue(const QModelIndex &index, const QRect &rect, QListView::ScrollHint hint) const
1035{
1036 const QRect area = viewport()->rect();
1037 const bool above = (hint == QListView::EnsureVisible && rect.top() < area.top());
1038 const bool below = (hint == QListView::EnsureVisible && rect.bottom() > area.bottom());
1039
1040 int verticalValue = verticalScrollBar()->value();
1041 QRect adjusted = rect.adjusted(-spacing(), -spacing(), spacing(), spacing());
1042 if (hint == QListView::PositionAtTop || above)
1043 verticalValue += adjusted.top();
1044 else if (hint == QListView::PositionAtBottom || below)
1045 verticalValue += qMin(adjusted.top(), adjusted.bottom() - area.height() + 1);
1046 else if (hint == QListView::PositionAtCenter)
1047 verticalValue += adjusted.top() - ((area.height() - adjusted.height()) / 2);
1048 return verticalValue;
1049}

Callers

nothing calls this directly

Calls 1

rectMethod · 0.80

Tested by

no test coverage detected