diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,6 @@ include(CMakePackageConfigHelpers) #TODO remove these -remove_definitions(-DQT_NO_CAST_FROM_ASCII) remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY) ecm_setup_version(PROJECT diff --git a/autotests/filemetadatadatedisplaytest.cpp b/autotests/filemetadatadatedisplaytest.cpp --- a/autotests/filemetadatadatedisplaytest.cpp +++ b/autotests/filemetadatadatedisplaytest.cpp @@ -41,7 +41,7 @@ void initLocale() { - QLocale::setDefault(QLocale("en_US")); + QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); } Q_CONSTRUCTOR_FUNCTION(initLocale) @@ -94,25 +94,25 @@ QTest::addRow("Short date, long ago") << Baloo::DateFormats::ShortFormat << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.mp3")) - << QRegularExpression("(?:[1-3][0-9]|[1-9]) (?:[1-2][0-9]|[1-9]):[0-5][0-9] [AP]M") + << QRegularExpression(QStringLiteral("(?:[1-3][0-9]|[1-9]) (?:[1-2][0-9]|[1-9]):[0-5][0-9] [AP]M")) ; QTest::addRow("Short date, yesterday") << Baloo::DateFormats::ShortFormat << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.m4a")) - << QRegularExpression("Yesterday, (?:[1-2][0-9]|[1-9]):[0-5][0-9] [AP]M") + << QRegularExpression(QStringLiteral("Yesterday, (?:[1-2][0-9]|[1-9]):[0-5][0-9] [AP]M")) ; QTest::addRow("Long date, long ago") << Baloo::DateFormats::LongFormat << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.mp3")) - << QRegularExpression("[A-Z][a-z]+, [A-Z][a-z]+ (?:[1-3][0-9]|[1-9]), 20[0-9]{2} (?:1[0-2]|[1-9]):[0-5][0-9]:[0-5][0-9] [AP]M [A-Z]{3,4}") + << QRegularExpression(QStringLiteral("[A-Z][a-z]+, [A-Z][a-z]+ (?:[1-3][0-9]|[1-9]), 20[0-9]{2} (?:1[0-2]|[1-9]):[0-5][0-9]:[0-5][0-9] [AP]M [A-Z]{3,4}")) ; QTest::addRow("Long date, yesterday") << Baloo::DateFormats::LongFormat << QUrl::fromLocalFile(QFINDTESTDATA("samplefiles/testtagged.m4a")) - << QRegularExpression("Yesterday, (?:1[0-2]|[1-9]):[0-5][0-9]:[0-5][0-9] [AP]M [A-Z]{3,4}") + << QRegularExpression(QStringLiteral("Yesterday, (?:1[0-2]|[1-9]):[0-5][0-9]:[0-5][0-9] [AP]M [A-Z]{3,4}")) ; } diff --git a/autotests/filemetadataitemcounttest.cpp b/autotests/filemetadataitemcounttest.cpp --- a/autotests/filemetadataitemcounttest.cpp +++ b/autotests/filemetadataitemcounttest.cpp @@ -45,13 +45,13 @@ QStandardPaths::setTestModeEnabled(true); - KConfig balooConfig("baloofilerc", KConfig::NoGlobals); + KConfig balooConfig(QStringLiteral("baloofilerc"), KConfig::NoGlobals); KConfigGroup balooSettings = balooConfig.group("General"); // If we use .writePathEntry here, the test will fail. balooSettings.writeEntry(QStringLiteral("folders"), QString()); // Ensure show configuration - KConfig config("baloofileinformationrc", KConfig::NoGlobals); + KConfig config(QStringLiteral("baloofileinformationrc"), KConfig::NoGlobals); KConfigGroup settings = config.group("Show"); const auto keys = settings.keyList(); for (const auto &key: keys) { diff --git a/autotests/filemetadatawidgettest.cpp b/autotests/filemetadatawidgettest.cpp --- a/autotests/filemetadatawidgettest.cpp +++ b/autotests/filemetadatawidgettest.cpp @@ -38,7 +38,7 @@ void initLocale() { - QLocale::setDefault(QLocale("en_US")); + QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); } Q_CONSTRUCTOR_FUNCTION(initLocale) @@ -50,13 +50,13 @@ QStandardPaths::setTestModeEnabled(true); - KConfig balooConfig("baloofilerc", KConfig::NoGlobals); + KConfig balooConfig(QStringLiteral("baloofilerc"), KConfig::NoGlobals); KConfigGroup balooSettings = balooConfig.group("General"); // If we use .writePathEntry here, the test will fail. balooSettings.writeEntry(QStringLiteral("folders"), QString()); // Ensure show configuration - KConfig config("baloofileinformationrc", KConfig::NoGlobals); + KConfig config(QStringLiteral("baloofileinformationrc"), KConfig::NoGlobals); KConfigGroup settings = config.group("Show"); const auto keys = settings.keyList(); for (const auto &key: keys) { @@ -142,20 +142,20 @@ QCOMPARE(spy.count(), 1); // simple property - QLabel* valueWidget = m_widget->findChild("kfileitem#type"); + QLabel* valueWidget = m_widget->findChild(QStringLiteral("kfileitem#type")); QVERIFY2(valueWidget, "Type data missing"); QCOMPARE(valueWidget->text(), QLatin1String("MP3 audio")); if (m_mayTestRating) { // editable property - KRatingWidget* ratingWidget = m_widget->findChild("rating"); + KRatingWidget* ratingWidget = m_widget->findChild(QStringLiteral("rating")); QVERIFY2(ratingWidget, "Rating data missing"); QCOMPARE(ratingWidget->rating(), 5u); } else { qDebug() << "Skipped 'Rating' test"; } // async property - valueWidget = m_widget->findChild("albumArtist"); + valueWidget = m_widget->findChild(QStringLiteral("albumArtist")); QVERIFY2(valueWidget, "albumArtist data was not found"); QCOMPARE(valueWidget->text(), QLatin1String("Bill Laswell")); @@ -172,16 +172,16 @@ QCOMPARE(spy.count(), 1); // simple property - QLabel* valueWidget = m_widget->findChild("kfileitem#type"); + QLabel* valueWidget = m_widget->findChild(QStringLiteral("kfileitem#type")); QVERIFY(!valueWidget); - valueWidget = m_widget->findChild("kfileitem#totalSize"); + valueWidget = m_widget->findChild(QStringLiteral("kfileitem#totalSize")); // circumvent i18n formatting QCOMPARE(valueWidget->text().left(3), QLatin1String("153")); // editable property if (m_mayTestRating) { - KRatingWidget* ratingWidget = m_widget->findChild("rating"); + KRatingWidget* ratingWidget = m_widget->findChild(QStringLiteral("rating")); QVERIFY2(ratingWidget, "Rating data missing"); QCOMPARE(ratingWidget->rating(), 5u); } else { @@ -202,8 +202,8 @@ QCOMPARE(spy.count(), 1); auto artistWidget = m_widget->findChild(QStringLiteral("artist")); QVERIFY2(artistWidget, "artist not found"); - QCOMPARE(artistWidget->text(), "Artist1 and Artist2"); + QCOMPARE(artistWidget->text(), QStringLiteral("Artist1 and Artist2")); auto genreWidget = m_widget->findChild(QStringLiteral("genre")); QVERIFY2(genreWidget, "genre not found"); - QCOMPARE(genreWidget->text(), "Genre1, Genre2, and Genre3"); + QCOMPARE(genreWidget->text(), QStringLiteral("Genre1, Genre2, and Genre3")); } diff --git a/src/filemetadataconfigwidget.cpp b/src/filemetadataconfigwidget.cpp --- a/src/filemetadataconfigwidget.cpp +++ b/src/filemetadataconfigwidget.cpp @@ -109,7 +109,7 @@ } // the item is not hidden, add it to the list - KConfig config("baloofileinformationrc", KConfig::NoGlobals); + KConfig config(QStringLiteral("baloofileinformationrc"), KConfig::NoGlobals); KConfigGroup settings = config.group("Show"); const QString label = m_provider->label(key); @@ -130,19 +130,19 @@ QVariantMap data = m_provider->data(); // Always show these 3 - data.remove("rating"); - data.remove("tags"); - data.remove("userComment"); + data.remove(QStringLiteral("rating")); + data.remove(QStringLiteral("tags")); + data.remove(QStringLiteral("userComment")); QVariantMap::const_iterator it = data.constBegin(); while (it != data.constEnd()) { addItem(it.key()); ++it; } - addItem("rating"); - addItem("tags"); - addItem("userComment"); + addItem(QStringLiteral("rating")); + addItem(QStringLiteral("tags")); + addItem(QStringLiteral("userComment")); } FileMetaDataConfigWidget::FileMetaDataConfigWidget(QWidget* parent) : @@ -169,7 +169,7 @@ void FileMetaDataConfigWidget::save() { - KConfig config("baloofileinformationrc", KConfig::NoGlobals); + KConfig config(QStringLiteral("baloofileinformationrc"), KConfig::NoGlobals); KConfigGroup showGroup = config.group("Show"); const int count = d->m_metaDataList->count(); diff --git a/src/filemetadataprovider.cpp b/src/filemetadataprovider.cpp --- a/src/filemetadataprovider.cpp +++ b/src/filemetadataprovider.cpp @@ -166,26 +166,26 @@ if (item.isDir()) { const int count = subDirectoriesCount(item.url().path()); if (count == -1) { - m_data.insert("kfileitem#size", i18nc("unknown file size", "Unknown")); + m_data.insert(QStringLiteral("kfileitem#size"), i18nc("unknown file size", "Unknown")); } else { const QString itemCountString = i18ncp("@item:intable", "%1 item", "%1 items", count); - m_data.insert("kfileitem#size", itemCountString); + m_data.insert(QStringLiteral("kfileitem#size"), itemCountString); } } else { KFormat format; - m_data.insert("kfileitem#size", format.formatByteSize(item.size())); + m_data.insert(QStringLiteral("kfileitem#size"), format.formatByteSize(item.size())); } - m_data.insert("kfileitem#type", item.mimeComment()); - m_data.insert("kfileitem#modified", item.time(KFileItem::ModificationTime)); + m_data.insert(QStringLiteral("kfileitem#type"), item.mimeComment()); + m_data.insert(QStringLiteral("kfileitem#modified"), item.time(KFileItem::ModificationTime)); QDateTime creationTime = item.time(KFileItem::CreationTime); if (creationTime.isValid()) { - m_data.insert("kfileitem#created", creationTime); + m_data.insert(QStringLiteral("kfileitem#created"), creationTime); } - m_data.insert("kfileitem#accessed", item.time(KFileItem::AccessTime)); - m_data.insert("kfileitem#owner", item.user()); - m_data.insert("kfileitem#group", item.group()); - m_data.insert("kfileitem#permissions", item.permissionsString()); + m_data.insert(QStringLiteral("kfileitem#accessed"), item.time(KFileItem::AccessTime)); + m_data.insert(QStringLiteral("kfileitem#owner"), item.user()); + m_data.insert(QStringLiteral("kfileitem#group"), item.group()); + m_data.insert(QStringLiteral("kfileitem#permissions"), item.permissionsString()); } } @@ -207,7 +207,7 @@ count += subDirectoriesCount(item.url().path()); } const QString itemCountString = i18ncp("@item:intable", "%1 item", "%1 items", count); - m_data.insert("kfileitem#totalSize", itemCountString); + m_data.insert(QStringLiteral("kfileitem#totalSize"), itemCountString); } else { // Calculate the size of all items @@ -218,21 +218,21 @@ } } KFormat format; - m_data.insert("kfileitem#totalSize", format.formatByteSize(totalSize)); + m_data.insert(QStringLiteral("kfileitem#totalSize"), format.formatByteSize(totalSize)); } } void FileMetaDataProvider::insertEditableData() { if (!m_readOnly) { - if (!m_data.contains("tags")) { - m_data.insert("tags", QVariant()); + if (!m_data.contains(QStringLiteral("tags"))) { + m_data.insert(QStringLiteral("tags"), QVariant()); } - if (!m_data.contains("rating")) { - m_data.insert("rating", 0); + if (!m_data.contains(QStringLiteral("rating"))) { + m_data.insert(QStringLiteral("rating"), 0); } - if (!m_data.contains("userComment")) { - m_data.insert("userComment", QVariant()); + if (!m_data.contains(QStringLiteral("userComment"))) { + m_data.insert(QStringLiteral("userComment"), QVariant()); } } } @@ -250,10 +250,10 @@ } // Special handling for certain properties - totalPropertyAndInsert("duration", propertyList, allProperties); - totalPropertyAndInsert("characterCount", propertyList, allProperties); - totalPropertyAndInsert("wordCount", propertyList, allProperties); - totalPropertyAndInsert("lineCount", propertyList, allProperties); + totalPropertyAndInsert(QStringLiteral("duration"), propertyList, allProperties); + totalPropertyAndInsert(QStringLiteral("characterCount"), propertyList, allProperties); + totalPropertyAndInsert(QStringLiteral("wordCount"), propertyList, allProperties); + totalPropertyAndInsert(QStringLiteral("lineCount"), propertyList, allProperties); foreach (const QString& propUri, allProperties) { foreach (const QVariantMap& map, propertyList) { @@ -378,41 +378,25 @@ QString FileMetaDataProvider::label(const QString& metaDataLabel) const { - struct TranslationItem { - const char* const key; - const char* const context; - const char* const value; + static QHash hash = { + { QStringLiteral("kfileitem#comment"), i18nc("@label", "Comment") }, + { QStringLiteral("kfileitem#created"), i18nc("@label", "Created") }, + { QStringLiteral("kfileitem#accessed"), i18nc("@label", "Accessed") }, + { QStringLiteral("kfileitem#modified"), i18nc("@label", "Modified") }, + { QStringLiteral("kfileitem#owner"), i18nc("@label", "Owner") }, + { QStringLiteral("kfileitem#group"), i18nc("@label", "Group") }, + { QStringLiteral("kfileitem#permissions"), i18nc("@label", "Permissions") }, + { QStringLiteral("kfileitem#rating"), i18nc("@label", "Rating") }, + { QStringLiteral("kfileitem#size"), i18nc("@label", "Size") }, + { QStringLiteral("kfileitem#tags"), i18nc("@label", "Tags") }, + { QStringLiteral("kfileitem#totalSize"), i18nc("@label", "Total Size") }, + { QStringLiteral("kfileitem#type"), i18nc("@label", "Type") }, + { QStringLiteral("tags"), i18nc("@label", "Tags") }, + { QStringLiteral("rating"), i18nc("@label", "Rating") }, + { QStringLiteral("userComment"), i18nc("@label", "Comment") }, + { QStringLiteral("originUrl"), i18nc("@label", "Downloaded From") }, }; - static const TranslationItem translations[] = { - { "kfileitem#comment", I18N_NOOP2_NOSTRIP("@label", "Comment") }, - { "kfileitem#created", I18N_NOOP2_NOSTRIP("@label", "Created") }, - { "kfileitem#accessed", I18N_NOOP2_NOSTRIP("@label", "Accessed") }, - { "kfileitem#modified", I18N_NOOP2_NOSTRIP("@label", "Modified") }, - { "kfileitem#owner", I18N_NOOP2_NOSTRIP("@label", "Owner") }, - { "kfileitem#group", I18N_NOOP2_NOSTRIP("@label", "Group") }, - { "kfileitem#permissions", I18N_NOOP2_NOSTRIP("@label", "Permissions") }, - { "kfileitem#rating", I18N_NOOP2_NOSTRIP("@label", "Rating") }, - { "kfileitem#size", I18N_NOOP2_NOSTRIP("@label", "Size") }, - { "kfileitem#tags", I18N_NOOP2_NOSTRIP("@label", "Tags") }, - { "kfileitem#totalSize", I18N_NOOP2_NOSTRIP("@label", "Total Size") }, - { "kfileitem#type", I18N_NOOP2_NOSTRIP("@label", "Type") }, - { "tags", I18N_NOOP2_NOSTRIP("@label", "Tags") }, - { "rating", I18N_NOOP2_NOSTRIP("@label", "Rating") }, - { "userComment", I18N_NOOP2_NOSTRIP("@label", "Comment") }, - { "originUrl", I18N_NOOP2_NOSTRIP("@label", "Downloaded From") }, - { nullptr, nullptr, nullptr} // Mandatory last entry - }; - - static QHash hash; - if (hash.isEmpty()) { - const TranslationItem* item = &translations[0]; - while (item->key != nullptr) { - hash.insert(item->key, i18nc(item->context, item->value)); - ++item; - } - } - QString value = hash.value(metaDataLabel); if (value.isEmpty()) { value = KFileMetaData::PropertyInfo::fromName(metaDataLabel).displayName(); @@ -423,61 +407,61 @@ QString FileMetaDataProvider::group(const QString& label) const { - static QHash uriGrouper; - if (uriGrouper.isEmpty()) { + static QHash uriGrouper = { + // KFileItem Data - uriGrouper.insert(QLatin1String("kfileitem#type"), QLatin1String("0FileItemA")); - uriGrouper.insert(QLatin1String("kfileitem#size"), QLatin1String("0FileItemB")); - uriGrouper.insert(QLatin1String("kfileitem#totalSize"), QLatin1String("0FileItemB")); - uriGrouper.insert(QLatin1String("kfileitem#modified"), QLatin1String("0FileItemC")); - uriGrouper.insert(QLatin1String("kfileitem#accessed"), QLatin1String("0FileItemD")); - uriGrouper.insert(QLatin1String("kfileitem#created"), QLatin1String("0FileItemE")); - uriGrouper.insert(QLatin1String("kfileitem#owner"), QLatin1String("0FileItemF")); - uriGrouper.insert(QLatin1String("kfileitem#group"), QLatin1String("0FileItemG")); - uriGrouper.insert(QLatin1String("kfileitem#permissions"), QLatin1String("0FileItemH")); + { QStringLiteral("kfileitem#type"), QStringLiteral("0FileItemA") }, + { QStringLiteral("kfileitem#size"), QStringLiteral("0FileItemB") }, + { QStringLiteral("kfileitem#totalSize"), QStringLiteral("0FileItemB") }, + { QStringLiteral("kfileitem#modified"), QStringLiteral("0FileItemC") }, + { QStringLiteral("kfileitem#accessed"), QStringLiteral("0FileItemD") }, + { QStringLiteral("kfileitem#created"), QStringLiteral("0FileItemE") }, + { QStringLiteral("kfileitem#owner"), QStringLiteral("0FileItemF") }, + { QStringLiteral("kfileitem#group"), QStringLiteral("0FileItemG") }, + { QStringLiteral("kfileitem#permissions"), QStringLiteral("0FileItemH") }, // Editable Data - uriGrouper.insert(QLatin1String("tags"), QLatin1String("1EditableDataA")); - uriGrouper.insert(QLatin1String("rating"), QLatin1String("1EditableDataB")); - uriGrouper.insert(QLatin1String("userComment"), QLatin1String("1EditableDataC")); + { QStringLiteral("tags"), QStringLiteral("1EditableDataA") }, + { QStringLiteral("rating"), QStringLiteral("1EditableDataB") }, + { QStringLiteral("userComment"), QStringLiteral("1EditableDataC") }, // Image Data - uriGrouper.insert(QLatin1String("width"), QLatin1String("2ImageA")); - uriGrouper.insert(QLatin1String("height"), QLatin1String("2ImageB")); - uriGrouper.insert(QLatin1String("photoFNumber"), QLatin1String("2ImageC")); - uriGrouper.insert(QLatin1String("photoExposureTime"), QLatin1String("2ImageD")); - uriGrouper.insert(QLatin1String("photoExposureBiasValue"), QLatin1String("2ImageE")); - uriGrouper.insert(QLatin1String("photoISOSpeedRatings"), QLatin1String("2ImageF")); - uriGrouper.insert(QLatin1String("photoFocalLength"), QLatin1String("2ImageG")); - uriGrouper.insert(QLatin1String("photoFocalLengthIn35mmFilm"), QLatin1String("2ImageH")); - uriGrouper.insert(QLatin1String("photoFlash"), QLatin1String("2ImageI")); - uriGrouper.insert(QLatin1String("imageOrientation"), QLatin1String("2ImageJ")); - uriGrouper.insert(QLatin1String("photoGpsLatitude"), QLatin1String("2ImageK")); - uriGrouper.insert(QLatin1String("photoGpsLongitude"), QLatin1String("2ImageL")); - uriGrouper.insert(QLatin1String("photoGpsAltitude"), QLatin1String("2ImageM")); - uriGrouper.insert(QLatin1String("manufacturer"), QLatin1String("2ImageN")); - uriGrouper.insert(QLatin1String("model"), QLatin1String("2ImageO")); + { QStringLiteral("width"), QStringLiteral("2ImageA") }, + { QStringLiteral("height"), QStringLiteral("2ImageB") }, + { QStringLiteral("photoFNumber"), QStringLiteral("2ImageC") }, + { QStringLiteral("photoExposureTime"), QStringLiteral("2ImageD") }, + { QStringLiteral("photoExposureBiasValue"), QStringLiteral("2ImageE") }, + { QStringLiteral("photoISOSpeedRatings"), QStringLiteral("2ImageF") }, + { QStringLiteral("photoFocalLength"), QStringLiteral("2ImageG") }, + { QStringLiteral("photoFocalLengthIn35mmFilm"), QStringLiteral("2ImageH") }, + { QStringLiteral("photoFlash"), QStringLiteral("2ImageI") }, + { QStringLiteral("imageOrientation"), QStringLiteral("2ImageJ") }, + { QStringLiteral("photoGpsLatitude"), QStringLiteral("2ImageK") }, + { QStringLiteral("photoGpsLongitude"), QStringLiteral("2ImageL") }, + { QStringLiteral("photoGpsAltitude"), QStringLiteral("2ImageM") }, + { QStringLiteral("manufacturer"), QStringLiteral("2ImageN") }, + { QStringLiteral("model"), QStringLiteral("2ImageO") }, // Media Data - uriGrouper.insert("title", QLatin1String("3MediaA")); - uriGrouper.insert("artist", QLatin1String("3MediaB")); - uriGrouper.insert("album", QLatin1String("3MediaC")); - uriGrouper.insert("albumArtist", QLatin1String("3MediaD")); - uriGrouper.insert("genre", QLatin1String("3MediaE")); - uriGrouper.insert("trackNumber", QLatin1String("3MediaF")); - uriGrouper.insert("discNumber", QLatin1String("3MediaG")); - uriGrouper.insert("releaseYear", QLatin1String("3MediaH")); - uriGrouper.insert("duration", QLatin1String("3MediaI")); - uriGrouper.insert("sampleRate", QLatin1String("3MediaJ")); - uriGrouper.insert("bitRate", QLatin1String("3MediaK")); + { QStringLiteral("title"), QStringLiteral("3MediaA") }, + { QStringLiteral("artist"), QStringLiteral("3MediaB") }, + { QStringLiteral("album"), QStringLiteral("3MediaC") }, + { QStringLiteral("albumArtist"), QStringLiteral("3MediaD") }, + { QStringLiteral("genre"), QStringLiteral("3MediaE") }, + { QStringLiteral("trackNumber"), QStringLiteral("3MediaF") }, + { QStringLiteral("discNumber"), QStringLiteral("3MediaG") }, + { QStringLiteral("releaseYear"), QStringLiteral("3MediaH") }, + { QStringLiteral("duration"), QStringLiteral("3MediaI") }, + { QStringLiteral("sampleRate"), QStringLiteral("3MediaJ") }, + { QStringLiteral("bitRate"), QStringLiteral("3MediaK") }, // Miscellaneous Data - uriGrouper.insert("originUrl", QLatin1String("4MiscA")); - } + { QStringLiteral("originUrl"), QStringLiteral("4MiscA") }, + }; const QString val = uriGrouper.value(label); if (val.isEmpty()) { - return "lastGroup"; + return QStringLiteral("lastGroup"); } return val; } diff --git a/src/filemetadatawidget.cpp b/src/filemetadatawidget.cpp --- a/src/filemetadatawidget.cpp +++ b/src/filemetadatawidget.cpp @@ -174,7 +174,7 @@ // Iterate through all remaining items. // Embed the label and the value as new row in the widget const QStringList keys = sortedKeys(data); - const int spacerWidth = QFontMetrics(q->font()).size(Qt::TextSingleLine, " ").width(); + const int spacerWidth = QFontMetrics(q->font()).size(Qt::TextSingleLine, QStringLiteral(" ")).width(); const int labelColumn = m_configureVisibleProperties ? 1 : 0; @@ -271,7 +271,7 @@ return; } - KConfig config("baloofileinformationrc", KConfig::NoGlobals); + KConfig config(QStringLiteral("baloofileinformationrc"), KConfig::NoGlobals); KConfigGroup showGroup = config.group("Show"); auto changedIt = m_visibilityChanged.constBegin(); diff --git a/src/kcommentwidget.cpp b/src/kcommentwidget.cpp --- a/src/kcommentwidget.cpp +++ b/src/kcommentwidget.cpp @@ -62,15 +62,15 @@ QString text; if (comment.isEmpty()) { if (m_readOnly) { - text = "-"; + text = QStringLiteral("-"); } else { - text = "" + i18nc("@label", "Add...") + ""; + text = QStringLiteral("") + i18nc("@label", "Add...") + QStringLiteral(""); } } else { if (m_readOnly) { - text = QString(comment).toHtmlEscaped(); + text = comment.toHtmlEscaped(); } else { - text = "

" + QString(comment).toHtmlEscaped() + " " + i18nc("@label", "Edit...") + "

"; + text = QStringLiteral("

") + comment.toHtmlEscaped() + QStringLiteral(" ") + i18nc("@label", "Edit...") + QStringLiteral("

"); } } @@ -115,7 +115,7 @@ void KCommentWidget::slotLinkActivated(const QString& link) { - const QString caption = (link == "editComment") ? + const QString caption = (link == QLatin1String("editComment")) ? i18nc("@title:window", "Edit Comment") : i18nc("@title:window", "Add Comment"); diff --git a/src/kedittagsdialog.cpp b/src/kedittagsdialog.cpp --- a/src/kedittagsdialog.cpp +++ b/src/kedittagsdialog.cpp @@ -132,7 +132,7 @@ // mandatory, as the user cannot see the difference // between a tag "Test" and "Test ". QString tagText = text.simplified(); - while (tagText.endsWith("//")) { + while (tagText.endsWith(QLatin1String("//"))) { tagText.chop(1); m_newTagEdit->setText(tagText); return; diff --git a/src/metadatafilter.cpp b/src/metadatafilter.cpp --- a/src/metadatafilter.cpp +++ b/src/metadatafilter.cpp @@ -44,7 +44,7 @@ const int currentVersion = 11; // increase version, if the blacklist of disabled // properties should be updated - KConfig config("baloofileinformationrc", KConfig::NoGlobals); + KConfig config(QStringLiteral("baloofileinformationrc"), KConfig::NoGlobals); if (config.group("Misc").readEntry("version", 0) < currentVersion) { // The resource file is read the first time. Assure // that some meta information is disabled per default. @@ -101,7 +101,7 @@ // // Remove all items, that are marked as hidden in kmetainformationrc - KConfig config("baloofileinformationrc", KConfig::NoGlobals); + KConfig config(QStringLiteral("baloofileinformationrc"), KConfig::NoGlobals); KConfigGroup settings = config.group("Show"); QVariantMap::iterator it = finalData.begin(); while (it != finalData.end()) { diff --git a/src/tagcheckbox.cpp b/src/tagcheckbox.cpp --- a/src/tagcheckbox.cpp +++ b/src/tagcheckbox.cpp @@ -39,7 +39,7 @@ QHBoxLayout* layout = new QHBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); - m_label = new QLabel(tag.split('/', QString::SkipEmptyParts).last(), this); + m_label = new QLabel(tag.split(QLatin1Char('/'), QString::SkipEmptyParts).last(), this); m_label->setToolTip(tag); m_label->setMouseTracking(true); m_label->setTextFormat(Qt::PlainText); diff --git a/src/tagsfileitemactionplugin/tagsfileitemaction.cpp b/src/tagsfileitemactionplugin/tagsfileitemaction.cpp --- a/src/tagsfileitemactionplugin/tagsfileitemaction.cpp +++ b/src/tagsfileitemactionplugin/tagsfileitemaction.cpp @@ -116,7 +116,7 @@ return {}; } - m_tagsLister.openUrl(QUrl("tags:/"), KCoreDirLister::OpenUrlFlag::Reload); + m_tagsLister.openUrl(QUrl(QStringLiteral("tags:/")), KCoreDirLister::OpenUrlFlag::Reload); return {m_menu->menuAction()}; } diff --git a/src/tagwidget.cpp b/src/tagwidget.cpp --- a/src/tagwidget.cpp +++ b/src/tagwidget.cpp @@ -75,7 +75,7 @@ m_showAllLinkLabel = new QLabel( q ); m_flowLayout->addWidget( m_showAllLinkLabel ); if (m_readOnly) { - m_showAllLinkLabel->setText("-"); + m_showAllLinkLabel->setText(QStringLiteral("-")); } else { QFont f(q->font()); diff --git a/src/widgetfactory.cpp b/src/widgetfactory.cpp --- a/src/widgetfactory.cpp +++ b/src/widgetfactory.cpp @@ -320,7 +320,7 @@ void WidgetFactory::slotTagClicked(const QString& tag) { QUrl url; - url.setScheme("tags"); + url.setScheme(QStringLiteral("tags")); url.setPath(tag); emit urlActivated(url); diff --git a/test/metadataconfigwidgetapp.cpp b/test/metadataconfigwidgetapp.cpp --- a/test/metadataconfigwidgetapp.cpp +++ b/test/metadataconfigwidgetapp.cpp @@ -65,7 +65,7 @@ int main( int argc, char** argv ) { QApplication app( argc, argv ); - app.setApplicationName( "FileMetaDataConfigWidgetApp" ); + app.setApplicationName(QStringLiteral("FileMetaDataConfigWidgetApp")); FileMetadataWidgetTest test; test.show(); return app.exec(); diff --git a/test/metadatawidgetapp.cpp b/test/metadatawidgetapp.cpp --- a/test/metadatawidgetapp.cpp +++ b/test/metadatawidgetapp.cpp @@ -26,10 +26,10 @@ int main(int argc, char** argv) { QApplication app(argc, argv); - app.setApplicationName("FileMetadataWidgetApp"); + app.setApplicationName(QStringLiteral("FileMetadataWidgetApp")); QCommandLineParser parser; - parser.addPositionalArgument("filename", "files"); + parser.addPositionalArgument(QStringLiteral("filename"), QStringLiteral("files")); parser.process(app); Baloo::FileMetaDataWidget* widget = new Baloo::FileMetaDataWidget(); diff --git a/test/tagwidgetapp.cpp b/test/tagwidgetapp.cpp --- a/test/tagwidgetapp.cpp +++ b/test/tagwidgetapp.cpp @@ -26,7 +26,7 @@ int main( int argc, char** argv ) { QApplication app( argc, argv ); - QCoreApplication::setApplicationName("TagWidgetApp"); + QCoreApplication::setApplicationName(QStringLiteral("TagWidgetApp")); TagWidgetTest tw; tw.show(); return app.exec(); diff --git a/test/tagwidgettest.cpp b/test/tagwidgettest.cpp --- a/test/tagwidgettest.cpp +++ b/test/tagwidgettest.cpp @@ -36,11 +36,11 @@ connect(m_tagWidget, SIGNAL(selectionChanged(QStringList)), this, SLOT(slotSelectionChanged(QStringList))); - QCheckBox* box = new QCheckBox( "Align Right", this ); + QCheckBox* box = new QCheckBox(QStringLiteral("Align Right"), this ); connect(box, SIGNAL(toggled(bool)), this, SLOT(alignRight(bool))); lay->addWidget(box); - box = new QCheckBox( "Read only", this ); + box = new QCheckBox(QStringLiteral("Read only"), this ); connect(box, SIGNAL(toggled(bool)), this, SLOT(setReadOnly(bool))); lay->addWidget(box); }