Changeset View
Changeset View
Standalone View
Standalone View
src/kiconloader.cpp
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Line(s) | |||||
96 | } | 96 | } | ||
97 | 97 | | |||
98 | /** | 98 | /** | ||
99 | * Checks for relative paths quickly on UNIX-alikes, slowly on everything else. | 99 | * Checks for relative paths quickly on UNIX-alikes, slowly on everything else. | ||
100 | */ | 100 | */ | ||
101 | static bool pathIsRelative(const QString &path) | 101 | static bool pathIsRelative(const QString &path) | ||
102 | { | 102 | { | ||
103 | #ifdef Q_OS_UNIX | 103 | #ifdef Q_OS_UNIX | ||
104 | return (!path.isEmpty() && path[0] != QChar('/')); | 104 | return (!path.isEmpty() && path[0] != QLatin1Char('/')); | ||
105 | #else | 105 | #else | ||
106 | return QDir::isRelativePath(path); | 106 | return QDir::isRelativePath(path); | ||
107 | #endif | 107 | #endif | ||
108 | } | 108 | } | ||
109 | 109 | | |||
110 | /** | 110 | /** | ||
111 | * Holds a QPixmap for this process, along with its associated path on disk. | 111 | * Holds a QPixmap for this process, along with its associated path on disk. | ||
112 | */ | 112 | */ | ||
Show All 10 Lines | |||||
123 | */ | 123 | */ | ||
124 | KICONTHEMES_EXPORT void uintToHex(uint32_t colorData, QChar *buffer) | 124 | KICONTHEMES_EXPORT void uintToHex(uint32_t colorData, QChar *buffer) | ||
125 | { | 125 | { | ||
126 | static const char hexLookup[] = "0123456789abcdef"; | 126 | static const char hexLookup[] = "0123456789abcdef"; | ||
127 | buffer += 7; | 127 | buffer += 7; | ||
128 | uchar *colorFields = reinterpret_cast<uchar*>(&colorData); | 128 | uchar *colorFields = reinterpret_cast<uchar*>(&colorData); | ||
129 | 129 | | |||
130 | for (int i = 0; i < 4; i++) { | 130 | for (int i = 0; i < 4; i++) { | ||
131 | *buffer-- = hexLookup[*colorFields & 0xf]; | 131 | *buffer-- = QLatin1Char(hexLookup[*colorFields & 0xf]); | ||
132 | *buffer-- = hexLookup[*colorFields >> 4]; | 132 | *buffer-- = QLatin1Char(hexLookup[*colorFields >> 4]); | ||
133 | colorFields++; | 133 | colorFields++; | ||
134 | } | 134 | } | ||
135 | } | 135 | } | ||
136 | 136 | | |||
137 | static QString paletteId(const QPalette &pal) | 137 | static QString paletteId(const QPalette &pal) | ||
138 | { | 138 | { | ||
139 | // 8 per color. We want 3 colors thus 8*4=32. | 139 | // 8 per color. We want 3 colors thus 8*4=32. | ||
140 | QString buffer(32, Qt::Uninitialized); | 140 | QString buffer(32, Qt::Uninitialized); | ||
▲ Show 20 Lines • Show All 302 Lines • ▼ Show 20 Line(s) | |||||
443 | void KIconLoaderGlobalData::parseGenericIconsFiles(const QString &fileName) | 443 | void KIconLoaderGlobalData::parseGenericIconsFiles(const QString &fileName) | ||
444 | { | 444 | { | ||
445 | QFile file(fileName); | 445 | QFile file(fileName); | ||
446 | if (file.open(QIODevice::ReadOnly)) { | 446 | if (file.open(QIODevice::ReadOnly)) { | ||
447 | QTextStream stream(&file); | 447 | QTextStream stream(&file); | ||
448 | stream.setCodec("ISO 8859-1"); | 448 | stream.setCodec("ISO 8859-1"); | ||
449 | while (!stream.atEnd()) { | 449 | while (!stream.atEnd()) { | ||
450 | const QString line = stream.readLine(); | 450 | const QString line = stream.readLine(); | ||
451 | if (line.isEmpty() || line[0] == '#') { | 451 | if (line.isEmpty() || line[0] == QLatin1Char('#')) { | ||
452 | continue; | 452 | continue; | ||
453 | } | 453 | } | ||
454 | const int pos = line.indexOf(':'); | 454 | const int pos = line.indexOf(QLatin1Char(':')); | ||
455 | if (pos == -1) { // syntax error | 455 | if (pos == -1) { // syntax error | ||
456 | continue; | 456 | continue; | ||
457 | } | 457 | } | ||
458 | QString mimeIcon = line.left(pos); | 458 | QString mimeIcon = line.left(pos); | ||
459 | const int slashindex = mimeIcon.indexOf(QLatin1Char('/')); | 459 | const int slashindex = mimeIcon.indexOf(QLatin1Char('/')); | ||
460 | if (slashindex != -1) { | 460 | if (slashindex != -1) { | ||
461 | mimeIcon[slashindex] = QLatin1Char('-'); | 461 | mimeIcon[slashindex] = QLatin1Char('-'); | ||
462 | } | 462 | } | ||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Line(s) | 584 | { | |||
607 | initIconThemes(); | 607 | initIconThemes(); | ||
608 | KIconTheme *defaultSizesTheme = links.empty() ? nullptr : links.first()->theme; | 608 | KIconTheme *defaultSizesTheme = links.empty() ? nullptr : links.first()->theme; | ||
609 | mpGroups = new KIconGroup[(int) KIconLoader::LastGroup]; | 609 | mpGroups = new KIconGroup[(int) KIconLoader::LastGroup]; | ||
610 | for (KIconLoader::Group i = KIconLoader::FirstGroup; i < KIconLoader::LastGroup; ++i) { | 610 | for (KIconLoader::Group i = KIconLoader::FirstGroup; i < KIconLoader::LastGroup; ++i) { | ||
611 | if (groups[i] == nullptr) { | 611 | if (groups[i] == nullptr) { | ||
612 | break; | 612 | break; | ||
613 | } | 613 | } | ||
614 | 614 | | |||
615 | KConfigGroup cg(config, QLatin1String(groups[i]) + "Icons"); | 615 | KConfigGroup cg(config, QLatin1String(groups[i]) + QStringLiteral("Icons")); | ||
616 | mpGroups[i].size = cg.readEntry("Size", 0); | 616 | mpGroups[i].size = cg.readEntry("Size", 0); | ||
617 | 617 | | |||
618 | if (!mpGroups[i].size && defaultSizesTheme) { | 618 | if (!mpGroups[i].size && defaultSizesTheme) { | ||
619 | mpGroups[i].size = defaultSizesTheme->defaultSize(i); | 619 | mpGroups[i].size = defaultSizesTheme->defaultSize(i); | ||
620 | } | 620 | } | ||
621 | } | 621 | } | ||
622 | } | 622 | } | ||
623 | 623 | | |||
Show All 20 Lines | 635 | if (!def->isValid()) { | |||
644 | } | 644 | } | ||
645 | } | 645 | } | ||
646 | mpThemeRoot = new KIconThemeNode(def); | 646 | mpThemeRoot = new KIconThemeNode(def); | ||
647 | mThemesInTree.append(def->internalName()); | 647 | mThemesInTree.append(def->internalName()); | ||
648 | links.append(mpThemeRoot); | 648 | links.append(mpThemeRoot); | ||
649 | addBaseThemes(mpThemeRoot, appname); | 649 | addBaseThemes(mpThemeRoot, appname); | ||
650 | 650 | | |||
651 | // Insert application specific themes at the top. | 651 | // Insert application specific themes at the top. | ||
652 | searchPaths.append(appname + "/pics"); | 652 | searchPaths.append(appname + QStringLiteral("/pics")); | ||
653 | 653 | | |||
654 | // Add legacy icon dirs. | 654 | // Add legacy icon dirs. | ||
655 | searchPaths.append(QStringLiteral("icons")); // was xdgdata-icon in KStandardDirs | 655 | searchPaths.append(QStringLiteral("icons")); // was xdgdata-icon in KStandardDirs | ||
656 | // These are not in the icon spec, but e.g. GNOME puts some icons there anyway. | 656 | // These are not in the icon spec, but e.g. GNOME puts some icons there anyway. | ||
657 | searchPaths.append(QStringLiteral("pixmaps")); // was xdgdata-pixmaps in KStandardDirs | 657 | searchPaths.append(QStringLiteral("pixmaps")); // was xdgdata-pixmaps in KStandardDirs | ||
658 | 658 | | |||
659 | return true; | 659 | return true; | ||
660 | } | 660 | } | ||
661 | 661 | | |||
662 | KIconLoader::~KIconLoader() | 662 | KIconLoader::~KIconLoader() | ||
663 | { | 663 | { | ||
664 | delete d; | 664 | delete d; | ||
665 | } | 665 | } | ||
666 | 666 | | |||
667 | QStringList KIconLoader::searchPaths() const | 667 | QStringList KIconLoader::searchPaths() const | ||
668 | { | 668 | { | ||
669 | return d->searchPaths; | 669 | return d->searchPaths; | ||
670 | } | 670 | } | ||
671 | 671 | | |||
672 | void KIconLoader::addAppDir(const QString &appname, const QString &themeBaseDir) | 672 | void KIconLoader::addAppDir(const QString &appname, const QString &themeBaseDir) | ||
673 | { | 673 | { | ||
674 | d->initIconThemes(); | 674 | d->initIconThemes(); | ||
675 | 675 | | |||
676 | d->searchPaths.append(appname + "/pics"); | 676 | d->searchPaths.append(appname + QStringLiteral("/pics")); | ||
677 | d->addAppThemes(appname, themeBaseDir); | 677 | d->addAppThemes(appname, themeBaseDir); | ||
678 | } | 678 | } | ||
679 | 679 | | |||
680 | void KIconLoaderPrivate::addAppThemes(const QString &appname, const QString &themeBaseDir) | 680 | void KIconLoaderPrivate::addAppThemes(const QString &appname, const QString &themeBaseDir) | ||
681 | { | 681 | { | ||
682 | initIconThemes(); | 682 | initIconThemes(); | ||
683 | 683 | | |||
684 | KIconTheme *def = new KIconTheme(QStringLiteral("hicolor"), appname, themeBaseDir); | 684 | KIconTheme *def = new KIconTheme(QStringLiteral("hicolor"), appname, themeBaseDir); | ||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 753 | { | |||
764 | for (it = icnlibs.begin(); it != icnlibs.end(); ++it) { | 764 | for (it = icnlibs.begin(); it != icnlibs.end(); ++it) { | ||
765 | QDir dir(*it); | 765 | QDir dir(*it); | ||
766 | if (!dir.exists()) { | 766 | if (!dir.exists()) { | ||
767 | continue; | 767 | continue; | ||
768 | } | 768 | } | ||
769 | const QStringList lst = dir.entryList(QStringList(QStringLiteral("default.*")), QDir::Dirs); | 769 | const QStringList lst = dir.entryList(QStringList(QStringLiteral("default.*")), QDir::Dirs); | ||
770 | QStringList::ConstIterator it2; | 770 | QStringList::ConstIterator it2; | ||
771 | for (it2 = lst.begin(); it2 != lst.end(); ++it2) { | 771 | for (it2 = lst.begin(); it2 != lst.end(); ++it2) { | ||
772 | if (!QFileInfo::exists(*it + *it2 + "/index.desktop") | 772 | if (!QFileInfo::exists(*it + *it2 + QStringLiteral("/index.desktop")) | ||
773 | && !QFileInfo::exists(*it + *it2 + "/index.theme")) { | 773 | && !QFileInfo::exists(*it + *it2 + QStringLiteral("/index.theme"))) { | ||
774 | continue; | 774 | continue; | ||
775 | } | 775 | } | ||
776 | //TODO: Is any special handling required for NTFS symlinks? | 776 | //TODO: Is any special handling required for NTFS symlinks? | ||
777 | #ifndef Q_OS_WIN | 777 | #ifndef Q_OS_WIN | ||
778 | const int r = readlink(QFile::encodeName(*it + *it2), buf, sizeof(buf) - 1); | 778 | const int r = readlink(QFile::encodeName(*it + *it2).constData(), buf, sizeof(buf) - 1); | ||
779 | if (r > 0) { | 779 | if (r > 0) { | ||
780 | buf[r] = 0; | 780 | buf[r] = 0; | ||
781 | const QDir dir2(buf); | 781 | const QDir dir2(QFile::decodeName(buf)); | ||
782 | QString themeName = dir2.dirName(); | 782 | QString themeName = dir2.dirName(); | ||
783 | 783 | | |||
784 | if (!list.contains(themeName)) { | 784 | if (!list.contains(themeName)) { | ||
785 | list.append(themeName); | 785 | list.append(themeName); | ||
786 | } | 786 | } | ||
787 | } | 787 | } | ||
788 | #endif | 788 | #endif | ||
789 | } | 789 | } | ||
▲ Show 20 Lines • Show All 292 Lines • ▼ Show 20 Line(s) | 1081 | foreach (KIconThemeNode *themeNode, links) { | |||
1082 | QString currentName = name; | 1082 | QString currentName = name; | ||
1083 | 1083 | | |||
1084 | while (!currentName.isEmpty()) { | 1084 | while (!currentName.isEmpty()) { | ||
1085 | if (genericFallback) { | 1085 | if (genericFallback) { | ||
1086 | // we already tested the base name | 1086 | // we already tested the base name | ||
1087 | break; | 1087 | break; | ||
1088 | } | 1088 | } | ||
1089 | 1089 | | |||
1090 | int rindex = currentName.lastIndexOf('-'); | 1090 | int rindex = currentName.lastIndexOf(QLatin1Char('-')); | ||
1091 | if (rindex > 1) { // > 1 so that we don't split x-content or x-epoc | 1091 | if (rindex > 1) { // > 1 so that we don't split x-content or x-epoc | ||
1092 | currentName.truncate(rindex); | 1092 | currentName.truncate(rindex); | ||
1093 | 1093 | | |||
1094 | if (currentName.endsWith(QLatin1String("-x"))) { | 1094 | if (currentName.endsWith(QLatin1String("-x"))) { | ||
1095 | currentName.chop(2); | 1095 | currentName.chop(2); | ||
1096 | } | 1096 | } | ||
1097 | } else { | 1097 | } else { | ||
1098 | // From update-mime-database.c | 1098 | // From update-mime-database.c | ||
Show All 35 Lines | 1132 | if (path.isEmpty()) { | |||
1134 | return QString(); | 1134 | return QString(); | ||
1135 | } | 1135 | } | ||
1136 | return path; | 1136 | return path; | ||
1137 | } | 1137 | } | ||
1138 | 1138 | | |||
1139 | QString KIconLoaderPrivate::locate(const QString &fileName) | 1139 | QString KIconLoaderPrivate::locate(const QString &fileName) | ||
1140 | { | 1140 | { | ||
1141 | Q_FOREACH (const QString &dir, searchPaths) { | 1141 | Q_FOREACH (const QString &dir, searchPaths) { | ||
1142 | const QString path = dir + '/' + fileName; | 1142 | const QString path = dir + QLatin1Char('/') + fileName; | ||
1143 | if (QDir(dir).isAbsolute()) { | 1143 | if (QDir(dir).isAbsolute()) { | ||
1144 | if (QFileInfo::exists(path)) { | 1144 | if (QFileInfo::exists(path)) { | ||
1145 | return path; | 1145 | return path; | ||
1146 | } | 1146 | } | ||
1147 | } else { | 1147 | } else { | ||
1148 | const QString fullPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, path); | 1148 | const QString fullPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, path); | ||
1149 | if (!fullPath.isEmpty()) { | 1149 | if (!fullPath.isEmpty()) { | ||
1150 | return fullPath; | 1150 | return fullPath; | ||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Line(s) | 1249 | { | |||
1262 | * 4. If not, initialize the theme and find/load the icon. | 1262 | * 4. If not, initialize the theme and find/load the icon. | ||
1263 | * 4a Apply overlays | 1263 | * 4a Apply overlays | ||
1264 | * 4b Re-add to cache. | 1264 | * 4b Re-add to cache. | ||
1265 | */ | 1265 | */ | ||
1266 | 1266 | | |||
1267 | // Special case for absolute path icons. | 1267 | // Special case for absolute path icons. | ||
1268 | if (name.startsWith(QLatin1String("favicons/"))) { | 1268 | if (name.startsWith(QLatin1String("favicons/"))) { | ||
1269 | favIconOverlay = true; | 1269 | favIconOverlay = true; | ||
1270 | name = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + '/' + name + ".png"; | 1270 | name = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1Char('/') + name + QStringLiteral(".png"); | ||
1271 | } | 1271 | } | ||
1272 | 1272 | | |||
1273 | bool absolutePath = !pathIsRelative(name); | 1273 | bool absolutePath = !pathIsRelative(name); | ||
1274 | if (!absolutePath) { | 1274 | if (!absolutePath) { | ||
1275 | name = d->removeIconExtension(name); | 1275 | name = d->removeIconExtension(name); | ||
1276 | } | 1276 | } | ||
1277 | 1277 | | |||
1278 | // Don't bother looking for an icon with no name. | 1278 | // Don't bother looking for an icon with no name. | ||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Line(s) | |||||
1388 | } | 1388 | } | ||
1389 | 1389 | | |||
1390 | QMovie *KIconLoader::loadMovie(const QString &name, KIconLoader::Group group, int size, QObject *parent) const | 1390 | QMovie *KIconLoader::loadMovie(const QString &name, KIconLoader::Group group, int size, QObject *parent) const | ||
1391 | { | 1391 | { | ||
1392 | QString file = moviePath(name, group, size); | 1392 | QString file = moviePath(name, group, size); | ||
1393 | if (file.isEmpty()) { | 1393 | if (file.isEmpty()) { | ||
1394 | return nullptr; | 1394 | return nullptr; | ||
1395 | } | 1395 | } | ||
1396 | int dirLen = file.lastIndexOf('/'); | 1396 | int dirLen = file.lastIndexOf(QLatin1Char('/')); | ||
1397 | QString icon = iconPath(name, size ? -size : group, true); | 1397 | QString icon = iconPath(name, size ? -size : group, true); | ||
1398 | if (!icon.isEmpty() && file.left(dirLen) != icon.left(dirLen)) { | 1398 | if (!icon.isEmpty() && file.leftRef(dirLen) != icon.leftRef(dirLen)) { | ||
1399 | return nullptr; | 1399 | return nullptr; | ||
1400 | } | 1400 | } | ||
1401 | QMovie *movie = new QMovie(file, QByteArray(), parent); | 1401 | QMovie *movie = new QMovie(file, QByteArray(), parent); | ||
1402 | if (!movie->isValid()) { | 1402 | if (!movie->isValid()) { | ||
1403 | delete movie; | 1403 | delete movie; | ||
1404 | return nullptr; | 1404 | return nullptr; | ||
1405 | } | 1405 | } | ||
1406 | return movie; | 1406 | return movie; | ||
Show All 11 Lines | 1417 | if ((group < -1 || group >= KIconLoader::LastGroup) && group != KIconLoader::User) { | |||
1418 | qCDebug(KICONTHEMES) << "Illegal icon group:" << group; | 1418 | qCDebug(KICONTHEMES) << "Illegal icon group:" << group; | ||
1419 | group = KIconLoader::Desktop; | 1419 | group = KIconLoader::Desktop; | ||
1420 | } | 1420 | } | ||
1421 | if (size == 0 && group < 0) { | 1421 | if (size == 0 && group < 0) { | ||
1422 | qCDebug(KICONTHEMES) << "Neither size nor group specified!"; | 1422 | qCDebug(KICONTHEMES) << "Neither size nor group specified!"; | ||
1423 | group = KIconLoader::Desktop; | 1423 | group = KIconLoader::Desktop; | ||
1424 | } | 1424 | } | ||
1425 | 1425 | | |||
1426 | QString file = name + ".mng"; | 1426 | QString file = name + QStringLiteral(".mng"); | ||
1427 | if (group == KIconLoader::User) { | 1427 | if (group == KIconLoader::User) { | ||
1428 | file = d->locate(file); | 1428 | file = d->locate(file); | ||
1429 | } else { | 1429 | } else { | ||
1430 | if (size == 0) { | 1430 | if (size == 0) { | ||
1431 | size = d->mpGroups[group].size; | 1431 | size = d->mpGroups[group].size; | ||
1432 | } | 1432 | } | ||
1433 | 1433 | | |||
1434 | QString path; | 1434 | QString path; | ||
Show All 33 Lines | 1467 | if ((group < -1) || (group >= KIconLoader::LastGroup)) { | |||
1468 | qCDebug(KICONTHEMES) << "Illegal icon group: " << group; | 1468 | qCDebug(KICONTHEMES) << "Illegal icon group: " << group; | ||
1469 | group = KIconLoader::Desktop; | 1469 | group = KIconLoader::Desktop; | ||
1470 | } | 1470 | } | ||
1471 | if ((size == 0) && (group < 0)) { | 1471 | if ((size == 0) && (group < 0)) { | ||
1472 | qCDebug(KICONTHEMES) << "Neither size nor group specified!"; | 1472 | qCDebug(KICONTHEMES) << "Neither size nor group specified!"; | ||
1473 | group = KIconLoader::Desktop; | 1473 | group = KIconLoader::Desktop; | ||
1474 | } | 1474 | } | ||
1475 | 1475 | | |||
1476 | QString file = name + "/0001"; | 1476 | QString file = name + QStringLiteral("/0001"); | ||
1477 | if (group == KIconLoader::User) { | 1477 | if (group == KIconLoader::User) { | ||
1478 | file = d->locate(file + ".png"); | 1478 | file = d->locate(file + QStringLiteral(".png")); | ||
1479 | } else { | 1479 | } else { | ||
1480 | if (size == 0) { | 1480 | if (size == 0) { | ||
1481 | size = d->mpGroups[group].size; | 1481 | size = d->mpGroups[group].size; | ||
1482 | } | 1482 | } | ||
1483 | file = d->findMatchingIcon(file, size); | 1483 | file = d->findMatchingIcon(file, size); | ||
1484 | } | 1484 | } | ||
1485 | if (file.isEmpty()) { | 1485 | if (file.isEmpty()) { | ||
1486 | return lst; | 1486 | return lst; | ||
1487 | } | 1487 | } | ||
1488 | 1488 | | |||
1489 | QString path = file.left(file.length() - 8); | 1489 | QString path = file.left(file.length() - 8); | ||
1490 | QDir dir(QFile::encodeName(path)); | 1490 | QDir dir(path); | ||
1491 | if (!dir.exists()) { | 1491 | if (!dir.exists()) { | ||
1492 | return lst; | 1492 | return lst; | ||
1493 | } | 1493 | } | ||
1494 | 1494 | | |||
1495 | foreach (const QString &entry, dir.entryList()) { | 1495 | foreach (const QString &entry, dir.entryList()) { | ||
1496 | if (!(entry.leftRef(4)).toUInt()) { | 1496 | if (!(entry.leftRef(4)).toUInt()) { | ||
1497 | continue; | 1497 | continue; | ||
1498 | } | 1498 | } | ||
Show All 29 Lines | |||||
1528 | QStringList KIconLoader::queryIconsByDir(const QString &iconsDir) const | 1528 | QStringList KIconLoader::queryIconsByDir(const QString &iconsDir) const | ||
1529 | { | 1529 | { | ||
1530 | const QDir dir(iconsDir); | 1530 | const QDir dir(iconsDir); | ||
1531 | const QStringList formats = QStringList() << QStringLiteral("*.png") << QStringLiteral("*.xpm") << QStringLiteral("*.svg") << QStringLiteral("*.svgz"); | 1531 | const QStringList formats = QStringList() << QStringLiteral("*.png") << QStringLiteral("*.xpm") << QStringLiteral("*.svg") << QStringLiteral("*.svgz"); | ||
1532 | const QStringList lst = dir.entryList(formats, QDir::Files); | 1532 | const QStringList lst = dir.entryList(formats, QDir::Files); | ||
1533 | QStringList result; | 1533 | QStringList result; | ||
1534 | QStringList::ConstIterator it; | 1534 | QStringList::ConstIterator it; | ||
1535 | for (it = lst.begin(); it != lst.end(); ++it) { | 1535 | for (it = lst.begin(); it != lst.end(); ++it) { | ||
1536 | result += iconsDir + '/' + *it; | 1536 | result += iconsDir + QLatin1Char('/') + *it; | ||
1537 | } | 1537 | } | ||
1538 | return result; | 1538 | return result; | ||
1539 | } | 1539 | } | ||
1540 | 1540 | | |||
1541 | QStringList KIconLoader::queryIconsByContext(int group_or_size, | 1541 | QStringList KIconLoader::queryIconsByContext(int group_or_size, | ||
1542 | KIconLoader::Context context) const | 1542 | KIconLoader::Context context) const | ||
1543 | { | 1543 | { | ||
1544 | d->initIconThemes(); | 1544 | d->initIconThemes(); | ||
Show All 14 Lines | 1558 | foreach (KIconThemeNode *themeNode, d->links) { | |||
1559 | themeNode->queryIconsByContext(&result, size, context); | 1559 | themeNode->queryIconsByContext(&result, size, context); | ||
1560 | } | 1560 | } | ||
1561 | 1561 | | |||
1562 | // Eliminate duplicate entries (same icon in different directories) | 1562 | // Eliminate duplicate entries (same icon in different directories) | ||
1563 | QString name; | 1563 | QString name; | ||
1564 | QStringList res2, entries; | 1564 | QStringList res2, entries; | ||
1565 | QStringList::ConstIterator it; | 1565 | QStringList::ConstIterator it; | ||
1566 | for (it = result.constBegin(); it != result.constEnd(); ++it) { | 1566 | for (it = result.constBegin(); it != result.constEnd(); ++it) { | ||
1567 | int n = (*it).lastIndexOf('/'); | 1567 | int n = (*it).lastIndexOf(QLatin1Char('/')); | ||
1568 | if (n == -1) { | 1568 | if (n == -1) { | ||
1569 | name = *it; | 1569 | name = *it; | ||
1570 | } else { | 1570 | } else { | ||
1571 | name = (*it).mid(n + 1); | 1571 | name = (*it).mid(n + 1); | ||
1572 | } | 1572 | } | ||
1573 | name = d->removeIconExtension(name); | 1573 | name = d->removeIconExtension(name); | ||
1574 | if (!entries.contains(name)) { | 1574 | if (!entries.contains(name)) { | ||
1575 | entries += name; | 1575 | entries += name; | ||
Show All 24 Lines | 1599 | foreach (KIconThemeNode *themeNode, d->links) { | |||
1600 | themeNode->queryIcons(&result, size, context); | 1600 | themeNode->queryIcons(&result, size, context); | ||
1601 | } | 1601 | } | ||
1602 | 1602 | | |||
1603 | // Eliminate duplicate entries (same icon in different directories) | 1603 | // Eliminate duplicate entries (same icon in different directories) | ||
1604 | QString name; | 1604 | QString name; | ||
1605 | QStringList res2, entries; | 1605 | QStringList res2, entries; | ||
1606 | QStringList::ConstIterator it; | 1606 | QStringList::ConstIterator it; | ||
1607 | for (it = result.constBegin(); it != result.constEnd(); ++it) { | 1607 | for (it = result.constBegin(); it != result.constEnd(); ++it) { | ||
1608 | int n = (*it).lastIndexOf('/'); | 1608 | int n = (*it).lastIndexOf(QLatin1Char('/')); | ||
1609 | if (n == -1) { | 1609 | if (n == -1) { | ||
1610 | name = *it; | 1610 | name = *it; | ||
1611 | } else { | 1611 | } else { | ||
1612 | name = (*it).mid(n + 1); | 1612 | name = (*it).mid(n + 1); | ||
1613 | } | 1613 | } | ||
1614 | name = d->removeIconExtension(name); | 1614 | name = d->removeIconExtension(name); | ||
1615 | if (!entries.contains(name)) { | 1615 | if (!entries.contains(name)) { | ||
1616 | entries += name; | 1616 | entries += name; | ||
▲ Show 20 Lines • Show All 227 Lines • Show Last 20 Lines |