diff options
Diffstat (limited to 'tools/qmleasing/splineeditor.cpp')
-rw-r--r-- | tools/qmleasing/splineeditor.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/tools/qmleasing/splineeditor.cpp b/tools/qmleasing/splineeditor.cpp index 78ed9606db..6fee013c62 100644 --- a/tools/qmleasing/splineeditor.cpp +++ b/tools/qmleasing/splineeditor.cpp @@ -34,6 +34,7 @@ #include <QContextMenuEvent> #include <QDebug> #include <QApplication> +#include <QVector> const int canvasWidth = 640; const int canvasHeight = 320; @@ -287,7 +288,7 @@ QHash<QString, QEasingCurve> SplineEditor::presets() const QString SplineEditor::generateCode() { QString s = QLatin1String("["); - foreach (const QPointF &point, m_controlPoints) { + for (const QPointF &point : qAsConst(m_controlPoints)) { s += QString::number(point.x(), 'g', 2) + QLatin1Char(',') + QString::number(point.y(), 'g', 3) + QLatin1Char(','); } @@ -672,25 +673,23 @@ void SplineEditor::setEasingCurve(const QString &code) if (m_block) return; if (code.startsWith(QLatin1Char('[')) && code.endsWith(QLatin1Char(']'))) { - QString cleanCode = code; - cleanCode.remove(0, 1); - cleanCode.chop(1); - const QStringList stringList = cleanCode.split(QLatin1Char(','), QString::SkipEmptyParts); + const QStringRef cleanCode(&code, 1, code.size() - 2); + const auto stringList = cleanCode.split(QLatin1Char(','), QString::SkipEmptyParts); if (stringList.count() >= 6 && (stringList.count() % 6 == 0)) { - QList<qreal> realList; + QVector<qreal> realList; realList.reserve(stringList.count()); - foreach (const QString &string, stringList) { + for (const QStringRef &string : stringList) { bool ok; realList.append(string.toDouble(&ok)); if (!ok) return; } - QList<QPointF> points; + QVector<QPointF> points; const int count = realList.count() / 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.last() == QPointF(1.0, 1.0)) { + if (points.constLast() == QPointF(1.0, 1.0)) { QEasingCurve easingCurve(QEasingCurve::BezierSpline); for (int i = 0; i < points.count() / 3; ++i) { |