Commit cddc05a1 authored by Wescoeur's avatar Wescoeur

fix(ImageProvider): add const when necessary

parent b74698da
...@@ -46,11 +46,12 @@ static QByteArray buildByteArrayAttribute (const QByteArray &name, const QByteAr ...@@ -46,11 +46,12 @@ static QByteArray buildByteArrayAttribute (const QByteArray &name, const QByteAr
return attribute; 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)$"); static QRegExp regex("^color-([^-]+)-(fill|stroke)$");
QByteArray attributes; QByteArray attributes;
QByteArray value = readerAttributes.value("class").toLatin1();
const QByteArray value = readerAttributes.value("class").toLatin1();
if (!value.length()) if (!value.length())
return attributes; return attributes;
...@@ -61,13 +62,13 @@ static QByteArray fillFillAndStroke (QXmlStreamAttributes &readerAttributes, boo ...@@ -61,13 +62,13 @@ static QByteArray fillFillAndStroke (QXmlStreamAttributes &readerAttributes, boo
continue; continue;
const QString colorName = list[1]; 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()) { if (!colorValue.isValid()) {
qWarning() << QStringLiteral("Color name `%1` does not exist.").arg(colorName); qWarning() << QStringLiteral("Color name `%1` does not exist.").arg(colorName);
continue; continue;
} }
QByteArray property = list[2].toLatin1(); const QByteArray property = list[2].toLatin1();
if (property == QStringLiteral("fill")) if (property == QStringLiteral("fill"))
fill = true; fill = true;
else else
...@@ -84,20 +85,20 @@ static QByteArray fillFillAndStroke (QXmlStreamAttributes &readerAttributes, boo ...@@ -84,20 +85,20 @@ static QByteArray fillFillAndStroke (QXmlStreamAttributes &readerAttributes, boo
return attributes; return attributes;
} }
static QByteArray parseAttributes (QXmlStreamReader &reader, const Colors &colors) { static QByteArray parseAttributes (const QXmlStreamReader &reader, const Colors &colors) {
QXmlStreamAttributes readerAttributes = reader.attributes(); const QXmlStreamAttributes readerAttributes = reader.attributes();
bool fill = false, stroke = false; bool fill = false, stroke = false;
QByteArray attributes = fillFillAndStroke(readerAttributes, fill, stroke, colors); QByteArray attributes = fillFillAndStroke(readerAttributes, fill, stroke, colors);
for (const auto &attribute : readerAttributes) { for (const auto &attribute : readerAttributes) {
QByteArray name = attribute.name().toLatin1(); const QByteArray name = attribute.name().toLatin1();
if (fill && name == QStringLiteral("fill")) if (fill && name == QStringLiteral("fill"))
continue; continue;
if (stroke && name == QStringLiteral("stroke")) if (stroke && name == QStringLiteral("stroke"))
continue; continue;
QByteArray prefix = attribute.prefix().toLatin1(); const QByteArray prefix = attribute.prefix().toLatin1();
QByteArray value = attribute.value().toLatin1(); const QByteArray value = attribute.value().toLatin1();
if (prefix.length() > 0) { if (prefix.length() > 0) {
attributes.append(prefix); attributes.append(prefix);
...@@ -110,10 +111,10 @@ static QByteArray parseAttributes (QXmlStreamReader &reader, const Colors &color ...@@ -110,10 +111,10 @@ static QByteArray parseAttributes (QXmlStreamReader &reader, const Colors &color
return attributes; return attributes;
} }
static QByteArray parseDeclarations (QXmlStreamReader &reader) { static QByteArray parseDeclarations (const QXmlStreamReader &reader) {
QByteArray declarations; QByteArray declarations;
for (const auto &declaration : reader.namespaceDeclarations()) { for (const auto &declaration : reader.namespaceDeclarations()) {
QByteArray prefix = declaration.prefix().toLatin1(); const QByteArray prefix = declaration.prefix().toLatin1();
if (prefix.length() > 0) { if (prefix.length() > 0) {
declarations.append("xmlns:"); declarations.append("xmlns:");
declarations.append(prefix); declarations.append(prefix);
...@@ -128,7 +129,7 @@ static QByteArray parseDeclarations (QXmlStreamReader &reader) { ...@@ -128,7 +129,7 @@ static QByteArray parseDeclarations (QXmlStreamReader &reader) {
return declarations; return declarations;
} }
static QByteArray parseStartDocument (QXmlStreamReader &reader) { static QByteArray parseStartDocument (const QXmlStreamReader &reader) {
QByteArray startDocument = "<?xml version=\""; QByteArray startDocument = "<?xml version=\"";
startDocument.append(reader.documentVersion().toLatin1()); startDocument.append(reader.documentVersion().toLatin1());
startDocument.append("\" encoding=\""); startDocument.append("\" encoding=\"");
...@@ -137,7 +138,7 @@ static QByteArray parseStartDocument (QXmlStreamReader &reader) { ...@@ -137,7 +138,7 @@ static QByteArray parseStartDocument (QXmlStreamReader &reader) {
return startDocument; return startDocument;
} }
static QByteArray parseStartElement (QXmlStreamReader &reader, const Colors &colors) { static QByteArray parseStartElement (const QXmlStreamReader &reader, const Colors &colors) {
QByteArray startElement = "<"; QByteArray startElement = "<";
startElement.append(reader.name().toLatin1()); startElement.append(reader.name().toLatin1());
startElement.append(" "); startElement.append(" ");
...@@ -148,7 +149,7 @@ static QByteArray parseStartElement (QXmlStreamReader &reader, const Colors &col ...@@ -148,7 +149,7 @@ static QByteArray parseStartElement (QXmlStreamReader &reader, const Colors &col
return startElement; return startElement;
} }
static QByteArray parseEndElement (QXmlStreamReader &reader) { static QByteArray parseEndElement (const QXmlStreamReader &reader) {
QByteArray endElement = "</"; QByteArray endElement = "</";
endElement.append(reader.name().toLatin1()); endElement.append(reader.name().toLatin1());
endElement.append(">"); endElement.append(">");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment