MCPcopy Create free account
hub / github.com/baldurk/renderdoc / scrollTo

Method scrollTo

qrenderdoc/Widgets/Extended/RDTableView.cpp:375–459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373}
374
375void RDTableView::scrollTo(const QModelIndex &index, ScrollHint hint)
376{
377 if(!index.isValid())
378 return;
379
380 QRect cellRect = QRect(columnViewportPosition(index.column()), rowViewportPosition(index.row()),
381 columnWidth(index.column()), rowHeight(index.row()));
382
383 QRect dataRect = viewport()->rect();
384 dataRect.setLeft(horizontalHeader()->pinnedWidth());
385
386 // if it's already visible then just bail, common case
387 if(dataRect.contains(cellRect) && hint == QAbstractItemView::EnsureVisible)
388 return;
389
390 // assume per-item vertical scrolling and per-pixel horizontal scrolling
391
392 // for any hint except position at center, we just ensure it's visible horizontally
393 if(hint == QAbstractItemView::PositionAtCenter)
394 {
395 // center it horizontally from the left
396 QPoint dataCenter = dataRect.center();
397 QPoint cellCenter = cellRect.center();
398
399 if(dataCenter.x() > cellCenter.x())
400 {
401 horizontalScrollBar()->setValue(horizontalScrollBar()->value() -
402 (dataCenter.x() - cellCenter.x()));
403 }
404
405 // center it horizontally from the right
406 if(dataCenter.x() < cellCenter.x())
407 {
408 horizontalScrollBar()->setValue(horizontalScrollBar()->value() +
409 (cellCenter.x() - dataCenter.x()));
410 }
411 }
412 else if(hint == QAbstractItemView::PositionAtTop)
413 {
414 horizontalScrollBar()->setValue(cellRect.left() - dataRect.left());
415 }
416 else if(hint == QAbstractItemView::PositionAtBottom)
417 {
418 horizontalScrollBar()->setValue(cellRect.right() - dataRect.right());
419 }
420
421 // collapse EnsureVisible to either PositionAtTop or PositionAtBottom depending on which side it's
422 // on, or just return if we only had to make it visible horizontally
423 if(hint == QAbstractItemView::EnsureVisible)
424 {
425 if(dataRect.bottom() < cellRect.bottom())
426 hint = QAbstractItemView::PositionAtBottom;
427 else if(dataRect.top() > cellRect.top())
428 hint = QAbstractItemView::PositionAtTop;
429 else
430 return;
431 }
432

Callers 9

SelectMethod · 0.80
RevealParameterMethod · 0.80
OnEventChangedMethod · 0.80
OnCaptureLoadedMethod · 0.80
ExpandNodeMethod · 0.80
ScrollToRowMethod · 0.80
ScrollToColumnMethod · 0.80
jquery-3.6.0.jsFile · 0.80
jquery.jsFile · 0.80

Calls 15

setLeftMethod · 0.80
pinnedWidthMethod · 0.80
bottomMethod · 0.80
visualIndexAtMethod · 0.80
QRectClass · 0.50
isValidMethod · 0.45
columnMethod · 0.45
rowMethod · 0.45
rectMethod · 0.45
containsMethod · 0.45
centerMethod · 0.45

Tested by 1

RevealParameterMethod · 0.64