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

Method verticalScrollToValue

launcher/ui/instanceview/InstanceView.cpp:995–1010  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

993}
994
995int InstanceView::verticalScrollToValue(const QModelIndex &index, const QRect &rect, QListView::ScrollHint hint) const
996{
997 const QRect area = viewport()->rect();
998 const bool above = (hint == QListView::EnsureVisible && rect.top() < area.top());
999 const bool below = (hint == QListView::EnsureVisible && rect.bottom() > area.bottom());
1000
1001 int verticalValue = verticalScrollBar()->value();
1002 QRect adjusted = rect.adjusted(-spacing(), -spacing(), spacing(), spacing());
1003 if (hint == QListView::PositionAtTop || above)
1004 verticalValue += adjusted.top();
1005 else if (hint == QListView::PositionAtBottom || below)
1006 verticalValue += qMin(adjusted.top(), adjusted.bottom() - area.height() + 1);
1007 else if (hint == QListView::PositionAtCenter)
1008 verticalValue += adjusted.top() - ((area.height() - adjusted.height()) / 2);
1009 return verticalValue;
1010}

Callers

nothing calls this directly

Calls 1

rectMethod · 0.80

Tested by

no test coverage detected