diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-10-05 07:29:16 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-10-07 23:38:48 +0200 |
commit | 958cd3ee1094a068b6d0ff27c73a4b3caff088ad (patch) | |
tree | 6d3816fedf5dab2307675fd6ef70d39758e246f5 /tools/qmleasing/splineeditor.cpp | |
parent | e8e03215654ca730243336a80453cf9396cbdf58 (diff) | |
download | qtdeclarative-958cd3ee1094a068b6d0ff27c73a4b3caff088ad.tar.gz |
Port from container::count() and length() to size()
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8:
auto QtContainerClass = anyOf(
expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o),
expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o));
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container',
with the extended set of container classes recognized.
Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools/qmleasing/splineeditor.cpp')
-rw-r--r-- | tools/qmleasing/splineeditor.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/tools/qmleasing/splineeditor.cpp b/tools/qmleasing/splineeditor.cpp index 4dd725afbc..700cb9ff34 100644 --- a/tools/qmleasing/splineeditor.cpp +++ b/tools/qmleasing/splineeditor.cpp @@ -169,7 +169,7 @@ void SplineEditor::paintEvent(QPaintEvent *) paintControlPoint(QPointF(0.0, 0.0), &painter, false, true, false, false); paintControlPoint(QPointF(1.0, 1.0), &painter, false, true, false, false); - for (int i = 0; i < m_controlPoints.count() - 1; ++i) + for (int i = 0; i < m_controlPoints.size() - 1; ++i) paintControlPoint(m_controlPoints.at(i), &painter, true, @@ -344,7 +344,7 @@ void SplineEditor::smoothPoint(int index) before = m_controlPoints.at(index - 3); QPointF after = QPointF(1.0, 1.0); - if ((index + 3) < m_controlPoints.count()) + if ((index + 3) < m_controlPoints.size()) after = m_controlPoints.at(index + 3); QPointF tangent = (after - before) / 6; @@ -354,7 +354,7 @@ void SplineEditor::smoothPoint(int index) if (index > 0) m_controlPoints[index - 1] = thisPoint - tangent; - if (index + 1 < m_controlPoints.count()) + if (index + 1 < m_controlPoints.size()) m_controlPoints[index + 1] = thisPoint + tangent; m_smoothList[index / 3] = true; @@ -372,7 +372,7 @@ void SplineEditor::cornerPoint(int index) before = m_controlPoints.at(index - 3); QPointF after = QPointF(1.0, 1.0); - if ((index + 3) < m_controlPoints.count()) + if ((index + 3) < m_controlPoints.size()) after = m_controlPoints.at(index + 3); QPointF thisPoint = m_controlPoints.at(index); @@ -380,7 +380,7 @@ void SplineEditor::cornerPoint(int index) if (index > 0) m_controlPoints[index - 1] = (before - thisPoint) / 3 + thisPoint; - if (index + 1 < m_controlPoints.count()) + if (index + 1 < m_controlPoints.size()) m_controlPoints[index + 1] = (after - thisPoint) / 3 + thisPoint; m_smoothList[(index) / 3] = false; @@ -412,7 +412,7 @@ void SplineEditor::addPoint(const QPointF point) before = m_controlPoints.at(splitIndex); QPointF after = QPointF(1.0, 1.0); - if ((splitIndex + 3) < m_controlPoints.count()) + if ((splitIndex + 3) < m_controlPoints.size()) after = m_controlPoints.at(splitIndex + 3); if (splitIndex > 0) { @@ -541,7 +541,7 @@ bool SplineEditor::isControlPointSmooth(int i) const if (i == 0) return false; - if (i == m_controlPoints.count() - 1) + if (i == m_controlPoints.size() - 1) return false; if (m_numberOfSegments == 1) @@ -552,7 +552,7 @@ bool SplineEditor::isControlPointSmooth(int i) const if (index == 0) return false; - if (index == m_controlPoints.count() - 1) + if (index == m_controlPoints.size() - 1) return false; return m_smoothList.at(index / 3); @@ -611,7 +611,7 @@ void SplineEditor::mouseMoveEvent(QMouseEvent *e) if ((m_activeControlPoint > 1) && (m_activeControlPoint % 3) == 0) { //right control point m_controlPoints[m_activeControlPoint - 2] -= distance; - } else if ((m_activeControlPoint < (m_controlPoints.count() - 2)) //left control point + } else if ((m_activeControlPoint < (m_controlPoints.size() - 2)) //left control point && (m_activeControlPoint % 3) == 1) { m_controlPoints[m_activeControlPoint + 2] -= distance; } @@ -628,7 +628,7 @@ void SplineEditor::setEasingCurve(const QEasingCurve &easingCurve) m_block = true; m_easingCurve = easingCurve; m_controlPoints = m_easingCurve.toCubicSpline(); - m_numberOfSegments = m_controlPoints.count() / 3; + m_numberOfSegments = m_controlPoints.size() / 3; update(); emit easingCurveChanged(); @@ -652,9 +652,9 @@ void SplineEditor::setEasingCurve(const QString &code) if (code.startsWith(QLatin1Char('[')) && code.endsWith(QLatin1Char(']'))) { const auto cleanCode = QStringView(code).mid(1, code.size() - 2); const auto stringList = cleanCode.split(QLatin1Char(','), Qt::SkipEmptyParts); - if (stringList.count() >= 6 && (stringList.count() % 6 == 0)) { + if (stringList.size() >= 6 && (stringList.size() % 6 == 0)) { QVector<qreal> realList; - realList.reserve(stringList.count()); + realList.reserve(stringList.size()); for (const QStringView &string : stringList) { bool ok; realList.append(string.toDouble(&ok)); @@ -662,14 +662,14 @@ void SplineEditor::setEasingCurve(const QString &code) return; } QVector<QPointF> points; - const int count = realList.count() / 2; + const int count = realList.size() / 2; points.reserve(count); for (int i = 0; i < count; ++i) points.append(QPointF(realList.at(i * 2), realList.at(i * 2 + 1))); if (points.constLast() == QPointF(1.0, 1.0)) { QEasingCurve easingCurve(QEasingCurve::BezierSpline); - for (int i = 0; i < points.count() / 3; ++i) { + for (int i = 0; i < points.size() / 3; ++i) { easingCurve.addCubicBezierSegment(points.at(i * 3), points.at(i * 3 + 1), points.at(i * 3 + 2)); |