BUGZ-699: Make PSFListModel fetch early when making container bigger

This commit is contained in:
Zach Fox 2019-06-17 15:06:20 -07:00
parent 57fef21e30
commit 9cb4ad61ee
2 changed files with 29 additions and 14 deletions

View file

@ -75,21 +75,31 @@ ListModel {
// 1: equivalent to paging when reaching end (and not before). // 1: equivalent to paging when reaching end (and not before).
// 0: don't getNextPage on scroll at all here. The application code will do it. // 0: don't getNextPage on scroll at all here. The application code will do it.
property real pageAhead: 2.0; property real pageAhead: 2.0;
function needsEarlyYFetch() { function onContentXChanged() {
return flickable if (flickable &&
&& !flickable.atYBeginning !flickable.atXBeginning &&
&& (flickable.contentY - flickable.originY) >= (flickable.contentHeight - (pageAhead * flickable.height)); (flickable.contentX - flickable.originX) >= (flickable.contentWidth - (pageAhead * flickable.width))) {
getNextPage();
}
} }
function needsEarlyXFetch() { function onContentYChanged() {
return flickable if (flickable &&
&& !flickable.atXBeginning !flickable.atYBeginning &&
&& (flickable.contentX - flickable.originX) >= (flickable.contentWidth - (pageAhead * flickable.width)); (flickable.contentY - flickable.originY) >= (flickable.contentHeight - (pageAhead * flickable.height))) {
getNextPage();
}
} }
function getNextPageIfHorizontalScroll() { function onWidthChanged() {
if (needsEarlyXFetch()) { getNextPage(); } if (flickable &&
(flickable.contentX - flickable.originX) >= (flickable.contentWidth - (pageAhead * flickable.width))) {
getNextPage();
}
} }
function getNextPageIfVerticalScroll() { function onHeightChanged() {
if (needsEarlyYFetch()) { getNextPage(); } if (flickable &&
(flickable.contentY - flickable.originY) >= (flickable.contentHeight - (pageAhead * flickable.height))) {
getNextPage();
}
} }
function needsMoreHorizontalResults() { function needsMoreHorizontalResults() {
return flickable return flickable
@ -118,8 +128,10 @@ ListModel {
initialized = true; initialized = true;
if (flickable && pageAhead > 0.0) { if (flickable && pageAhead > 0.0) {
// Pun: Scrollers are usually one direction or another, such that only one of the following will actually fire. // Pun: Scrollers are usually one direction or another, such that only one of the following will actually fire.
flickable.contentXChanged.connect(getNextPageIfHorizontalScroll); flickable.contentXChanged.connect(onContentXChanged);
flickable.contentYChanged.connect(getNextPageIfVerticalScroll); flickable.contentYChanged.connect(onContentYChanged);
flickable.widthChanged.connect(onWidthChanged);
flickable.heightChanged.connect(onHeightChanged);
flickable.contentWidthChanged.connect(getNextPageIfNotEnoughHorizontalResults); flickable.contentWidthChanged.connect(getNextPageIfNotEnoughHorizontalResults);
flickable.contentHeightChanged.connect(getNextPageIfNotEnoughVerticalResults); flickable.contentHeightChanged.connect(getNextPageIfNotEnoughVerticalResults);
} }

View file

@ -0,0 +1,3 @@
module hifiModels
PSFListModel 1.0 PSFListModel.qml
S3Model 1.0 S3Model.qml