summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2016-11-23 11:09:47 +0100
committerAndy Shaw <andy.shaw@qt.io>2017-09-12 12:56:18 +0000
commit764854dc4799c21f739abc35e68f053849267f89 (patch)
tree662e415a8360e1d941475a7c3ad84cbc95df3175 /src
parent5a64696264decb561ff6d8b661e783752fdc0b61 (diff)
Call canFetchMore/fetchMore when scrolled to the bottom of the view
When scrolling to the bottom of the view, if there are expanded items then it should call canFetchMore/fetchMore up the chain until it finds one with more items that can possibly be retrieved. This brings it in line with the QAbstractItemView implementation which would call canFetchMore on the root index, therefore we go up the chain to the root to see if anything before that can be fetched. [ChangeLog][QtWidgets][QTreeView] QTreeView now calls canFetchMore and fetchMore when the bottom of the QTreeView is scrolled to. Task-number: QTBUG-48725 Change-Id: I2b2145684bb34c8c317bfce4a0ef14f243a64719 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/itemviews/qtreeview.cpp21
-rw-r--r--src/widgets/itemviews/qtreeview.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 61721143ef..d504263bd1 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -3992,6 +3992,27 @@ int QTreeView::visualIndex(const QModelIndex &index) const
return d->viewIndex(index);
}
+/*!
+ \reimp
+*/
+
+void QTreeView::verticalScrollbarValueChanged(int value)
+{
+ Q_D(QTreeView);
+ if (!d->viewItems.isEmpty() && value == verticalScrollBar()->maximum()) {
+ QModelIndex ret = d->viewItems.last().index;
+ // Root index will be handled by base class implementation
+ while (ret.isValid()) {
+ if (isExpanded(ret) && d->model->canFetchMore(ret)) {
+ d->model->fetchMore(ret);
+ break;
+ }
+ ret = ret.parent();
+ }
+ }
+ QAbstractItemView::verticalScrollbarValueChanged(value);
+}
+
QT_END_NAMESPACE
#include "moc_qtreeview.cpp"
diff --git a/src/widgets/itemviews/qtreeview.h b/src/widgets/itemviews/qtreeview.h
index c32c127cd1..e9bc8189f8 100644
--- a/src/widgets/itemviews/qtreeview.h
+++ b/src/widgets/itemviews/qtreeview.h
@@ -169,6 +169,7 @@ protected Q_SLOTS:
void columnMoved();
void reexpand();
void rowsRemoved(const QModelIndex &parent, int first, int last);
+ void verticalScrollbarValueChanged(int value) Q_DECL_OVERRIDE;
protected:
QTreeView(QTreeViewPrivate &dd, QWidget *parent = Q_NULLPTR);