| 984 | } |
| 985 | |
| 986 | int 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 | } |