diff options
-rw-r--r-- | src/quicktemplates2/qquicktumbler.cpp | 19 | ||||
-rw-r--r-- | src/quicktemplates2/qquicktumbler_p_p.h | 1 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp index 65e9ec4f..4b8b0d30 100644 --- a/src/quicktemplates2/qquicktumbler.cpp +++ b/src/quicktemplates2/qquicktumbler.cpp @@ -214,7 +214,7 @@ void QQuickTumblerPrivate::_q_onViewCountChanged() // If we could successfully set the currentIndex, consider it done. // Otherwise, we'll try again later in updatePolish(). if (currentIndex == pendingCurrentIndex) - pendingCurrentIndex = -1; + setPendingCurrentIndex(-1); else q->polish(); } else if (currentIndex == -1) { @@ -592,7 +592,7 @@ void QQuickTumblerPrivate::syncCurrentIndex() // Nothing to do. if (actualViewIndex == indexToSet) { - pendingCurrentIndex = -1; + setPendingCurrentIndex(-1); return; } @@ -605,11 +605,16 @@ void QQuickTumblerPrivate::syncCurrentIndex() ignoreCurrentIndexChanges = false; if (view->property("currentIndex").toInt() == indexToSet) - pendingCurrentIndex = -1; + setPendingCurrentIndex(-1); else if (isPendingCurrentIndex) q->polish(); } +void QQuickTumblerPrivate::setPendingCurrentIndex(int index) +{ + pendingCurrentIndex = index; +} + void QQuickTumblerPrivate::setCurrentIndex(int newCurrentIndex, QQuickTumblerPrivate::PropertyChangeReason changeReason) { @@ -619,7 +624,7 @@ void QQuickTumblerPrivate::setCurrentIndex(int newCurrentIndex, if (!q->isComponentComplete()) { // Views can't set currentIndex until they're ready. - pendingCurrentIndex = newCurrentIndex; + setPendingCurrentIndex(newCurrentIndex); return; } @@ -628,7 +633,7 @@ void QQuickTumblerPrivate::setCurrentIndex(int newCurrentIndex, // the model is in the process of being set and the user has set // the currentIndex in onModelChanged. We have to queue the currentIndex // change until we're ready. - pendingCurrentIndex = newCurrentIndex; + setPendingCurrentIndex(newCurrentIndex); return; } @@ -767,7 +772,7 @@ void QQuickTumbler::updatePolish() // If the count is still 0, it's not going to happen. if (d->count == 0) { - d->pendingCurrentIndex = -1; + d->setPendingCurrentIndex(-1); return; } @@ -782,7 +787,7 @@ void QQuickTumbler::updatePolish() d->setCurrentIndex(0); } - d->pendingCurrentIndex = -1; + d->setPendingCurrentIndex(-1); } } diff --git a/src/quicktemplates2/qquicktumbler_p_p.h b/src/quicktemplates2/qquicktumbler_p_p.h index a7e5f2ac..9ed0647e 100644 --- a/src/quicktemplates2/qquicktumbler_p_p.h +++ b/src/quicktemplates2/qquicktumbler_p_p.h @@ -104,6 +104,7 @@ public: void disconnectFromView(); void setupViewData(QQuickItem *newControlContentItem); void syncCurrentIndex(); + void setPendingCurrentIndex(int index); enum PropertyChangeReason { UserChange, |