summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lund Martsum <tmartsum@gmail.com>2012-10-31 16:01:53 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-23 17:04:00 +0100
commit2e78d7ac30813add2f57f8b50c969fb71212e3e6 (patch)
treef67d02d948c7621a9d304f96068598dbfd7228c7 /src
parentc6754c2720d09488ba7483bb6ef8c37a9b7f833c (diff)
QHeaderView - Fix auto-scroll on manual move on sections
This patch fixes the manual move of sections when auto scroll is on. It is done in QAbstractItemView::doAutoScroll by letting the qheaderView use its parents scrollbars if they are childs of a QTableView or QTreeView. Task-number: QTBUG-993 Task-number: QTBUG-1103 Change-Id: I70d999d9a07c3566e42d01cc5ebb47a69a83d9d4 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp19
-rw-r--r--src/widgets/itemviews/qheaderview.cpp2
2 files changed, 21 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 8ba078ffd3..57c3b44aaa 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -55,6 +55,9 @@
#include <qdatetime.h>
#include <qlineedit.h>
#include <qspinbox.h>
+#include <qtreeview.h>
+#include <qtableview.h>
+#include <qheaderview.h>
#include <qstyleditemdelegate.h>
#include <private/qabstractitemview_p.h>
#include <private/qabstractitemmodel_p.h>
@@ -3749,6 +3752,22 @@ void QAbstractItemView::doAutoScroll()
QScrollBar *verticalScroll = verticalScrollBar();
QScrollBar *horizontalScroll = horizontalScrollBar();
+ // QHeaderView does not (normally) have scrollbars
+ // It needs to use its parents scroll instead
+ QHeaderView *hv = qobject_cast<QHeaderView*>(this);
+ if (hv) {
+ QAbstractScrollArea *parent = qobject_cast<QAbstractScrollArea*>(parentWidget());
+ if (parent) {
+ if (hv->orientation() == Qt::Horizontal) {
+ if (!hv->horizontalScrollBar() || !hv->horizontalScrollBar()->isVisible())
+ horizontalScroll = parent->horizontalScrollBar();
+ } else {
+ if (!hv->verticalScrollBar() || !hv->verticalScrollBar()->isVisible())
+ verticalScroll = parent->verticalScrollBar();
+ }
+ }
+ }
+
int verticalStep = verticalScroll->pageStep();
int horizontalStep = horizontalScroll->pageStep();
if (d->autoScrollCount < qMax(verticalStep, horizontalStep))
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index dc80a4b81f..6326b497c5 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -2333,6 +2333,8 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e)
return;
}
case QHeaderViewPrivate::MoveSection: {
+ if (d->shouldAutoScroll(e->pos()))
+ d->startAutoScroll();
if (qAbs(pos - d->firstPos) >= QApplication::startDragDistance()
|| !d->sectionIndicator->isHidden()) {
int visual = visualIndexAt(pos);