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

Method verticalScrollToValue

launcher/ui/instanceview/InstanceView.cpp:986–1001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

984}
985
986int InstanceView::verticalScrollToValue(const QModelIndex &index, const QRect &rect, QListView::ScrollHint hint) const
987{
988 const QRect area = viewport()->rect();
989 const bool above = (hint == QListView::EnsureVisible && rect.top() < area.top());
990 const bool below = (hint == QListView::EnsureVisible && rect.bottom() > area.bottom());
991
992 int verticalValue = verticalScrollBar()->value();
993 QRect adjusted = rect.adjusted(-spacing(), -spacing(), spacing(), spacing());
994 if (hint == QListView::PositionAtTop || above)
995 verticalValue += adjusted.top();
996 else if (hint == QListView::PositionAtBottom || below)
997 verticalValue += qMin(adjusted.top(), adjusted.bottom() - area.height() + 1);
998 else if (hint == QListView::PositionAtCenter)
999 verticalValue += adjusted.top() - ((area.height() - adjusted.height()) / 2);
1000 return verticalValue;
1001}

Callers

nothing calls this directly

Calls 1

rectMethod · 0.80

Tested by

no test coverage detected