summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lund Martsum <tmartsum@gmail.com>2012-10-31 15:07:40 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-23 17:04:00 +0100
commitc6754c2720d09488ba7483bb6ef8c37a9b7f833c (patch)
treeadd373636cc6678e9ff43c4b14a29d05da5cdda8 /src
parent02c110e989c44dcc18c5f0498dbc01ead87e069f (diff)
QAbstractItemView - prepare fix for auto scroll on sectionmove
There are no semantic changes in this patch. We just avoid many calls to horizontalScrollBar() and verticalScrollBar() by storing the result of them in local variables, that are used instead. This is just a prepare for auto-scroll when a user is moving a section. Change-Id: I4b3d3ecbf3a29992e6f578d4b0442d7f494125e4 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 0308fb44a9..8ba078ffd3 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -3746,30 +3746,33 @@ void QAbstractItemView::doAutoScroll()
{
// find how much we should scroll with
Q_D(QAbstractItemView);
- int verticalStep = verticalScrollBar()->pageStep();
- int horizontalStep = horizontalScrollBar()->pageStep();
+ QScrollBar *verticalScroll = verticalScrollBar();
+ QScrollBar *horizontalScroll = horizontalScrollBar();
+
+ int verticalStep = verticalScroll->pageStep();
+ int horizontalStep = horizontalScroll->pageStep();
if (d->autoScrollCount < qMax(verticalStep, horizontalStep))
++d->autoScrollCount;
int margin = d->autoScrollMargin;
- int verticalValue = verticalScrollBar()->value();
- int horizontalValue = horizontalScrollBar()->value();
+ int verticalValue = verticalScroll->value();
+ int horizontalValue = horizontalScroll->value();
QPoint pos = d->viewport->mapFromGlobal(QCursor::pos());
QRect area = static_cast<QAbstractItemView*>(d->viewport)->d_func()->clipRect(); // access QWidget private by bending C++ rules
// do the scrolling if we are in the scroll margins
if (pos.y() - area.top() < margin)
- verticalScrollBar()->setValue(verticalValue - d->autoScrollCount);
+ verticalScroll->setValue(verticalValue - d->autoScrollCount);
else if (area.bottom() - pos.y() < margin)
- verticalScrollBar()->setValue(verticalValue + d->autoScrollCount);
+ verticalScroll->setValue(verticalValue + d->autoScrollCount);
if (pos.x() - area.left() < margin)
- horizontalScrollBar()->setValue(horizontalValue - d->autoScrollCount);
+ horizontalScroll->setValue(horizontalValue - d->autoScrollCount);
else if (area.right() - pos.x() < margin)
- horizontalScrollBar()->setValue(horizontalValue + d->autoScrollCount);
+ horizontalScroll->setValue(horizontalValue + d->autoScrollCount);
// if nothing changed, stop scrolling
- bool verticalUnchanged = (verticalValue == verticalScrollBar()->value());
- bool horizontalUnchanged = (horizontalValue == horizontalScrollBar()->value());
+ bool verticalUnchanged = (verticalValue == verticalScroll->value());
+ bool horizontalUnchanged = (horizontalValue == horizontalScroll->value());
if (verticalUnchanged && horizontalUnchanged) {
stopAutoScroll();
} else {