From cddc05a1c5b0ec26b8ff17a0a55ff372b87333c7 Mon Sep 17 00:00:00 2001 From: Wescoeur Date: Mon, 19 Jun 2017 23:34:21 +0200 Subject: [PATCH] fix(ImageProvider): add const when necessary --- src/app/providers/ImageProvider.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/app/providers/ImageProvider.cpp b/src/app/providers/ImageProvider.cpp index d077ec977..4371d1b37 100644 --- a/src/app/providers/ImageProvider.cpp +++ b/src/app/providers/ImageProvider.cpp @@ -46,11 +46,12 @@ static QByteArray buildByteArrayAttribute (const QByteArray &name, const QByteAr return attribute; } -static QByteArray fillFillAndStroke (QXmlStreamAttributes &readerAttributes, bool &fill, bool &stroke, const Colors &colors) { +static QByteArray fillFillAndStroke (const QXmlStreamAttributes &readerAttributes, bool &fill, bool &stroke, const Colors &colors) { static QRegExp regex("^color-([^-]+)-(fill|stroke)$"); QByteArray attributes; - QByteArray value = readerAttributes.value("class").toLatin1(); + + const QByteArray value = readerAttributes.value("class").toLatin1(); if (!value.length()) return attributes; @@ -61,13 +62,13 @@ static QByteArray fillFillAndStroke (QXmlStreamAttributes &readerAttributes, boo continue; const QString colorName = list[1]; - QVariant colorValue = colors.property(colorName.toStdString().c_str()); + const QVariant colorValue = colors.property(colorName.toStdString().c_str()); if (!colorValue.isValid()) { qWarning() << QStringLiteral("Color name `%1` does not exist.").arg(colorName); continue; } - QByteArray property = list[2].toLatin1(); + const QByteArray property = list[2].toLatin1(); if (property == QStringLiteral("fill")) fill = true; else @@ -84,20 +85,20 @@ static QByteArray fillFillAndStroke (QXmlStreamAttributes &readerAttributes, boo return attributes; } -static QByteArray parseAttributes (QXmlStreamReader &reader, const Colors &colors) { - QXmlStreamAttributes readerAttributes = reader.attributes(); +static QByteArray parseAttributes (const QXmlStreamReader &reader, const Colors &colors) { + const QXmlStreamAttributes readerAttributes = reader.attributes(); bool fill = false, stroke = false; QByteArray attributes = fillFillAndStroke(readerAttributes, fill, stroke, colors); for (const auto &attribute : readerAttributes) { - QByteArray name = attribute.name().toLatin1(); + const QByteArray name = attribute.name().toLatin1(); if (fill && name == QStringLiteral("fill")) continue; if (stroke && name == QStringLiteral("stroke")) continue; - QByteArray prefix = attribute.prefix().toLatin1(); - QByteArray value = attribute.value().toLatin1(); + const QByteArray prefix = attribute.prefix().toLatin1(); + const QByteArray value = attribute.value().toLatin1(); if (prefix.length() > 0) { attributes.append(prefix); @@ -110,10 +111,10 @@ static QByteArray parseAttributes (QXmlStreamReader &reader, const Colors &color return attributes; } -static QByteArray parseDeclarations (QXmlStreamReader &reader) { +static QByteArray parseDeclarations (const QXmlStreamReader &reader) { QByteArray declarations; for (const auto &declaration : reader.namespaceDeclarations()) { - QByteArray prefix = declaration.prefix().toLatin1(); + const QByteArray prefix = declaration.prefix().toLatin1(); if (prefix.length() > 0) { declarations.append("xmlns:"); declarations.append(prefix); @@ -128,7 +129,7 @@ static QByteArray parseDeclarations (QXmlStreamReader &reader) { return declarations; } -static QByteArray parseStartDocument (QXmlStreamReader &reader) { +static QByteArray parseStartDocument (const QXmlStreamReader &reader) { QByteArray startDocument = "");