mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 22:22:54 +02:00
BUGZ-699: Make PSFListModel fetch early when making container bigger
This commit is contained in:
parent
57fef21e30
commit
9cb4ad61ee
2 changed files with 29 additions and 14 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
3
interface/resources/qml/hifi/models/qmldir
Normal file
3
interface/resources/qml/hifi/models/qmldir
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
module hifiModels
|
||||||
|
PSFListModel 1.0 PSFListModel.qml
|
||||||
|
S3Model 1.0 S3Model.qml
|
Loading…
Reference in a new issue