diff options
author | Liang Qi <liang.qi@qt.io> | 2016-09-17 23:08:00 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-09-18 22:11:24 +0200 |
commit | d9aae9ff99d20b58487b0a48801864d13115363b (patch) | |
tree | e98089900164f7a1008e6fb59d1815dc9eab8d2c /src/controls/Private | |
parent | 49bd4b76d08ec11d08105ca71e8dda4f8d459b5c (diff) | |
parent | c2356328f88b044c8956fe7860c4c04fca4f2c30 (diff) | |
download | qtquickcontrols-d9aae9ff99d20b58487b0a48801864d13115363b.tar.gz |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
src/controls/Private/qquickrangemodel.cpp
src/controls/Private/qquickrangemodel_p.h
src/controls/Private/qquickrangemodel_p_p.h
src/layouts/qquicklayout.cpp
tests/auto/controls/data/tst_rangemodel.qml
Change-Id: I9c8f6326c6edf9ebb18dd538f76830e1b439ba8e
Diffstat (limited to 'src/controls/Private')
-rw-r--r-- | src/controls/Private/qquickrangemodel.cpp | 33 | ||||
-rw-r--r-- | src/controls/Private/qquickrangemodel_p.h | 7 | ||||
-rw-r--r-- | src/controls/Private/qquickrangemodel_p_p.h | 3 |
3 files changed, 38 insertions, 5 deletions
diff --git a/src/controls/Private/qquickrangemodel.cpp b/src/controls/Private/qquickrangemodel.cpp index d881e3c8..ca393c83 100644 --- a/src/controls/Private/qquickrangemodel.cpp +++ b/src/controls/Private/qquickrangemodel.cpp @@ -72,6 +72,9 @@ void QQuickRangeModel1Private::init() posatmin = 0; posatmax = 0; inverted = false; + isComplete = false; + positionChanged = false; + valueChanged = false; } /*! @@ -158,10 +161,16 @@ void QQuickRangeModel1Private::emitValueAndPositionIfChanged(const qreal oldValu // unchanged. This will be the case when operating with values outside range: const qreal newValue = q->value(); const qreal newPosition = q->position(); - if (!qFuzzyCompare(newValue, oldValue)) - emit q->valueChanged(newValue); - if (!qFuzzyCompare(newPosition, oldPosition)) - emit q->positionChanged(newPosition); + + if (isComplete) { + if (!qFuzzyCompare(newValue, oldValue)) + emit q->valueChanged(newValue); + if (!qFuzzyCompare(newPosition, oldPosition)) + emit q->positionChanged(newPosition); + } else { + positionChanged |= qFuzzyCompare(oldPosition, newPosition); + valueChanged |= !qFuzzyCompare(oldValue, newValue); + } } /*! @@ -349,6 +358,22 @@ qreal QQuickRangeModel1::positionForValue(qreal value) const return d->publicPosition(unconstrainedPosition); } +void QQuickRangeModel1::classBegin() +{ +} + +void QQuickRangeModel1::componentComplete() +{ + Q_D(QQuickRangeModel1); + d->isComplete = true; + emit minimumChanged(minimum()); + emit maximumChanged(maximum()); + if (d->valueChanged) + emit valueChanged(value()); + if (d->positionChanged) + emit positionChanged(position()); +} + /*! \property QQuickRangeModel1::position \brief the current position of the model diff --git a/src/controls/Private/qquickrangemodel_p.h b/src/controls/Private/qquickrangemodel_p.h index 0c93bed3..e5796725 100644 --- a/src/controls/Private/qquickrangemodel_p.h +++ b/src/controls/Private/qquickrangemodel_p.h @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE class QQuickRangeModel1Private; -class QQuickRangeModel1 : public QObject +class QQuickRangeModel1 : public QObject, public QQmlParserStatus { Q_OBJECT Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged USER true) @@ -59,6 +59,8 @@ class QQuickRangeModel1 : public QObject Q_PROPERTY(qreal positionAtMaximum READ positionAtMaximum WRITE setPositionAtMaximum NOTIFY positionAtMaximumChanged) Q_PROPERTY(bool inverted READ inverted WRITE setInverted NOTIFY invertedChanged) + Q_INTERFACES(QQmlParserStatus) + public: QQuickRangeModel1(QObject *parent = 0); virtual ~QQuickRangeModel1(); @@ -90,6 +92,9 @@ public: Q_INVOKABLE qreal valueForPosition(qreal position) const; Q_INVOKABLE qreal positionForValue(qreal value) const; + void classBegin(); + void componentComplete(); + public Q_SLOTS: void toMinimum(); void toMaximum(); diff --git a/src/controls/Private/qquickrangemodel_p_p.h b/src/controls/Private/qquickrangemodel_p_p.h index 5c56814e..ab0627d3 100644 --- a/src/controls/Private/qquickrangemodel_p_p.h +++ b/src/controls/Private/qquickrangemodel_p_p.h @@ -70,6 +70,9 @@ public: uint inverted : 1; QQuickRangeModel1 *q_ptr; + bool isComplete; + bool positionChanged; + bool valueChanged; inline qreal effectivePosAtMin() const { return inverted ? posatmax : posatmin; |