Q*Animation: s/QPair/std::pair/
Also port from qMakePair() to just braced initialization and CTAD. As a drive-by, de-duplicate some code around a lower_bound(), and port from `typedef` to `using`. Task-number: QTBUG-115841 Change-Id: I3e907ad3bb10b5ca169422ad90d3a65b1b33f926 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> (cherry picked from commit 0d09b4f6b9cae84b78d59cecab6d6feb993b112a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
3727e97f32
commit
c7f4939ab6
@ -261,7 +261,7 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State newState,
|
||||
{
|
||||
Q_CONSTINIT static QBasicMutex mutex;
|
||||
auto locker = qt_unique_lock(mutex);
|
||||
typedef QPair<QObject *, QByteArray> QPropertyAnimationPair;
|
||||
using QPropertyAnimationPair = std::pair<QObject *, QByteArray>;
|
||||
typedef QHash<QPropertyAnimationPair, QPropertyAnimation*> QPropertyAnimationHash;
|
||||
Q_CONSTINIT static QPropertyAnimationHash hash;
|
||||
|
||||
|
@ -203,7 +203,7 @@ void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/)
|
||||
//let's update currentInterval
|
||||
QVariantAnimation::KeyValues::const_iterator it = std::lower_bound(keyValues.constBegin(),
|
||||
keyValues.constEnd(),
|
||||
qMakePair(progress, QVariant()),
|
||||
std::pair{progress, QVariant{}},
|
||||
animationValueLessThan);
|
||||
if (it == keyValues.constBegin()) {
|
||||
//the item pointed to by it is the start element in the range
|
||||
@ -211,7 +211,7 @@ void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/)
|
||||
currentInterval.start = *it;
|
||||
currentInterval.end = *(it+1);
|
||||
} else {
|
||||
currentInterval.start = qMakePair(qreal(0), defaultStartEndValue);
|
||||
currentInterval.start = {qreal(0), defaultStartEndValue};
|
||||
currentInterval.end = *it;
|
||||
}
|
||||
} else if (it == keyValues.constEnd()) {
|
||||
@ -223,7 +223,7 @@ void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/)
|
||||
} else {
|
||||
//we use the default end value here
|
||||
currentInterval.start = *it;
|
||||
currentInterval.end = qMakePair(qreal(1), defaultStartEndValue);
|
||||
currentInterval.end = {qreal(1), defaultStartEndValue};
|
||||
}
|
||||
} else {
|
||||
currentInterval.start = *(it-1);
|
||||
@ -264,9 +264,10 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
|
||||
|
||||
QVariant QVariantAnimationPrivate::valueAt(qreal step) const
|
||||
{
|
||||
QVariantAnimation::KeyValues::const_iterator result =
|
||||
std::lower_bound(keyValues.constBegin(), keyValues.constEnd(), qMakePair(step, QVariant()), animationValueLessThan);
|
||||
if (result != keyValues.constEnd() && !animationValueLessThan(qMakePair(step, QVariant()), *result))
|
||||
const auto sought = std::pair{step, QVariant()};
|
||||
const auto result = std::lower_bound(keyValues.cbegin(), keyValues.cend(), sought,
|
||||
animationValueLessThan);
|
||||
if (result != keyValues.cend() && !animationValueLessThan(sought, *result))
|
||||
return result->second;
|
||||
|
||||
return QVariant();
|
||||
@ -552,7 +553,7 @@ QVariant QVariantAnimation::keyValueAt(qreal step) const
|
||||
/*!
|
||||
\typedef QVariantAnimation::KeyValue
|
||||
|
||||
This is a typedef for QPair<qreal, QVariant>.
|
||||
This is a typedef for std::pair<qreal, QVariant>.
|
||||
*/
|
||||
/*!
|
||||
\typedef QVariantAnimation::KeyValues
|
||||
|
@ -26,7 +26,7 @@ class Q_CORE_EXPORT QVariantAnimation : public QAbstractAnimation
|
||||
BINDABLE bindableEasingCurve)
|
||||
|
||||
public:
|
||||
typedef QPair<qreal, QVariant> KeyValue;
|
||||
using KeyValue = std::pair<qreal, QVariant>;
|
||||
typedef QList<KeyValue> KeyValues;
|
||||
|
||||
QVariantAnimation(QObject *parent = nullptr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user