aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2018-06-28 11:41:57 +0200
committerMitch Curtis <mitch.curtis@qt.io>2018-07-03 10:17:18 +0000
commit1b94294a34150a051f78b97278047a8ed173213c (patch)
treed0e1a3a6d734a67870141d94fd71a1ef632ace5e /src/quicktemplates2
parentbbc106599334cb46e3aeaf9ee5b1b54435dc1fa6 (diff)
Move all pendingCurrentIndex assignments to a private setter
This makes debugging significantly easier, in that it's now possible to use one qDebug() statement for the assignment rather than a handful at different places in the code. Change-Id: Ic6fdc2943b6eeb0496148b07d7a3ece0b6399c1b Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquicktumbler.cpp19
-rw-r--r--src/quicktemplates2/qquicktumbler_p_p.h1
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,