Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Use auto instead of an #ifdef for the type

Halla Rempt53e814ac2817
diff --git a/libs/pigment/resources/KoColorSet.cpp b/libs/pigment/resources/KoColorSet.cpp
index 82cbd78a43..df6e1ae9d6 100644
--- a/libs/pigment/resources/KoColorSet.cpp
+++ b/libs/pigment/resources/KoColorSet.cpp
@@ -1053,11 +1053,7 @@ void KoColorSet::Private::scribusParseColor(KoColorSet *set, QXmlStreamReader *x
KisSwatch colorEntry;
// It's a color, retrieve it
QXmlStreamAttributes colorProperties = xml->attributes();
-#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
- QStringRef colorName = colorProperties.value("NAME");
-#else
- QStringView colorName = colorProperties.value("NAME");
-#endif
+ auto colorName = colorProperties.value("NAME");
colorEntry.setName(colorName.isEmpty() || colorName.isNull() ? i18n("Untitled") : colorName.toString());
// RGB or CMYK?
@@ -1065,11 +1061,8 @@ void KoColorSet::Private::scribusParseColor(KoColorSet *set, QXmlStreamReader *x
dbgPigment << "Color " << colorProperties.value("NAME") << ", RGB " << colorProperties.value("RGB");
KoColor currentColor(KoColorSpaceRegistry::instance()->rgb8());
-#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
- QStringRef colorValue = colorProperties.value("RGB");
-#else
- QStringView colorValue = colorProperties.value("RGB");
-#endif
+ auto colorValue = colorProperties.value("RGB");
+
if (colorValue.length() != 7 && colorValue.at(0) != '#') { // Color is a hexadecimal number
xml->raiseError("Invalid rgb8 color (malformed): " + colorValue);
return;
@@ -1106,11 +1099,8 @@ void KoColorSet::Private::scribusParseColor(KoColorSet *set, QXmlStreamReader *x
dbgPigment << "Color " << colorProperties.value("NAME") << ", CMYK " << colorProperties.value("CMYK");
KoColor currentColor(KoColorSpaceRegistry::instance()->colorSpace(CMYKAColorModelID.id(), Integer8BitsColorDepthID.id(), QString()));
-#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
- QStringRef colorValue = colorProperties.value("CMYK");
-#else
- QStringView colorValue = colorProperties.value("CMYK");
-#endif
+ auto colorValue = colorProperties.value("CMYK");
+
if (colorValue.length() != 9 && colorValue.at(0) != '#') { // Color is a hexadecimal number
xml->raiseError("Invalid cmyk color (malformed): " % colorValue);
return;
@@ -1156,25 +1146,15 @@ bool KoColorSet::Private::loadScribusXmlPalette(KoColorSet *set, QXmlStreamReade
//1. Get name
QXmlStreamAttributes paletteProperties = xml->attributes();
-#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
- QStringRef paletteName = paletteProperties.value("Name");
-#else
- QStringView paletteName = paletteProperties.value("Name");
-#endif
+ auto paletteName = paletteProperties.value("Name");
dbgPigment << "Processed name of palette:" << paletteName;
set->setName(paletteName.toString());
//2. Inside the SCRIBUSCOLORS, there are lots of colors. Retrieve them
while(xml->readNextStartElement()) {
-#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
- QStringRef currentElement = xml->name();
- if (QStringRef::compare(currentElement, "COLOR", Qt::CaseInsensitive) == 0) {
-#else
- QStringView currentElement = xml->name();
- if (currentElement.compare("COLOR", Qt::CaseInsensitive) == 0) {
-#endif
-
+ auto currentElement = xml->name();
+ if (currentElement.compare(QString("COLOR"), Qt::CaseInsensitive) == 0) {
scribusParseColor(set, xml);
}
else {
@@ -1402,11 +1382,7 @@ bool KoColorSet::Private::loadGpl()
if (lines[i].startsWith('#')) {
comment += lines[i].mid(1).trimmed() + ' ';
} else if (!lines[i].isEmpty()) {
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList a = lines[i].replace('\t', ' ').split(' ', Qt::SkipEmptyParts);
-#else
- QStringList a = lines[i].replace('\t', ' ').split(' ', QString::SkipEmptyParts);
-#endif
if (a.count() < 3) {
continue;
@@ -1487,11 +1463,7 @@ bool KoColorSet::Private::loadPsp()
for (int i = 0; i < entries; ++i) {
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList a = l[i + 3].replace('\t', ' ').split(' ', Qt::SkipEmptyParts);
-#else
- QStringList a = l[i + 3].replace('\t', ' ').split(' ', QString::SkipEmptyParts);
-#endif
if (a.count() != 3) {
continue;
@@ -2394,14 +2366,8 @@ bool KoColorSet::Private::loadXml() {
QXmlStreamReader *xml = new QXmlStreamReader(data);
if (xml->readNextStartElement()) {
-#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
- QStringRef paletteId = xml->name();
- if (QStringRef::compare(paletteId, "SCRIBUSCOLORS", Qt::CaseInsensitive) == 0) { // Scribus
-#else
- QStringView paletteId = xml->name();
- if (paletteId.compare("SCRIBUSCOLORS", Qt::CaseInsensitive) == 0) { // Scribus
-#endif
-
+ auto paletteId = xml->name();
+ if (paletteId.compare(QString("SCRIBUSCOLORS"), Qt::CaseInsensitive) == 0) { // Scribus
dbgPigment << "XML palette: " << colorSet->filename() << ", Scribus format";
res = loadScribusXmlPalette(colorSet, xml);
}