Commit e88b46dd authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

GIT_SILENT: minor qstring optimization

parent 7d4e9d4f
......@@ -132,9 +132,9 @@ bool MainWindow::loadPart()
KPluginFactory *factory = nullptr;
const auto plugins = KPluginLoader::findPlugins(QString(), [](const KPluginMetaData& metaData) {
return metaData.pluginId() == QStringLiteral("arkpart") &&
metaData.serviceTypes().contains(QStringLiteral("KParts/ReadOnlyPart")) &&
metaData.serviceTypes().contains(QStringLiteral("Browser/View"));
return metaData.pluginId() == QLatin1String("arkpart") &&
metaData.serviceTypes().contains(QLatin1String("KParts/ReadOnlyPart")) &&
metaData.serviceTypes().contains(QLatin1String("Browser/View"));
});
if (!plugins.isEmpty()) {
......
......@@ -71,31 +71,31 @@ void AddDialogTest::testBasicWidgets_data()
const auto writeMimeTypes = m_pluginManager.supportedWriteMimeTypes();
if (writeMimeTypes.contains(QStringLiteral("application/zip"))) {
if (writeMimeTypes.contains(QLatin1String("application/zip"))) {
QTest::newRow("zip") << QStringLiteral("application/zip") << true << 3 << 7;
} else {
qDebug() << "zip format not available, skipping test.";
}
if (writeMimeTypes.contains(QStringLiteral("application/x-7z-compressed"))) {
if (writeMimeTypes.contains(QLatin1String("application/x-7z-compressed"))) {
QTest::newRow("7z") << QStringLiteral("application/x-7z-compressed") << true << 3 << 7;
} else {
qDebug() << "7z format not available, skipping test.";
}
if (writeMimeTypes.contains(QStringLiteral("application/vnd.rar"))) {
if (writeMimeTypes.contains(QLatin1String("application/vnd.rar"))) {
QTest::newRow("rar") << QStringLiteral("application/vnd.rar") << true << 2 << 5;
} else {
qDebug() << "rar format not available, skipping test.";
}
if (writeMimeTypes.contains(QStringLiteral("application/x-lrzip-compressed-tar"))) {
if (writeMimeTypes.contains(QLatin1String("application/x-lrzip-compressed-tar"))) {
QTest::newRow("tarlrzip") << QStringLiteral("application/x-lrzip-compressed-tar") << true << 3 << 7;
} else {
qDebug() << "tar.lrzip format not available, skipping test.";
}
if (writeMimeTypes.contains(QStringLiteral("application/x-tzo"))) {
if (writeMimeTypes.contains(QLatin1String("application/x-tzo"))) {
QTest::newRow("tarlzop") << QStringLiteral("application/x-tzo") << true << 3 << 7;
} else {
qDebug() << "tar.lzo format not available, skipping test.";
......
......@@ -65,31 +65,31 @@ void CreateDialogTest::testBasicWidgets_data()
const auto writeMimeTypes = m_pluginManager.supportedWriteMimeTypes();
if (writeMimeTypes.contains(QStringLiteral("application/zip"))) {
if (writeMimeTypes.contains(QLatin1String("application/zip"))) {
QTest::newRow("zip") << QStringLiteral("application/zip");
} else {
qDebug() << "zip format not available in CreateDialog, skipping test.";
}
if (writeMimeTypes.contains(QStringLiteral("application/x-7z-compressed"))) {
if (writeMimeTypes.contains(QLatin1String("application/x-7z-compressed"))) {
QTest::newRow("7z") << QStringLiteral("application/x-7z-compressed");
} else {
qDebug() << "7z format not available in CreateDialog, skipping test.";
}
if (writeMimeTypes.contains(QStringLiteral("application/vnd.rar"))) {
if (writeMimeTypes.contains(QLatin1String("application/vnd.rar"))) {
QTest::newRow("rar") << QStringLiteral("application/vnd.rar");
} else {
qDebug() << "rar format not available in CreateDialog, skipping test.";
}
if (writeMimeTypes.contains(QStringLiteral("application/x-lrzip-compressed-tar"))) {
if (writeMimeTypes.contains(QLatin1String("application/x-lrzip-compressed-tar"))) {
QTest::newRow("tarlrzip") << QStringLiteral("application/x-lrzip-compressed-tar");
} else {
qDebug() << "tar.lrzip format not available in CreateDialog, skipping test.";
}
if (writeMimeTypes.contains(QStringLiteral("application/x-tzo"))) {
if (writeMimeTypes.contains(QLatin1String("application/x-tzo"))) {
QTest::newRow("tarlzop") << QStringLiteral("application/x-tzo");
} else {
qDebug() << "tar.lzo format not available in CreateDialog, skipping test.";
......@@ -126,19 +126,19 @@ void CreateDialogTest::testEncryption_data()
QTest::newRow("tar") << QStringLiteral("application/x-compressed-tar") << false << false;
if (m_pluginManager.supportedWriteMimeTypes().contains(QStringLiteral("application/zip"))) {
if (m_pluginManager.supportedWriteMimeTypes().contains(QLatin1String("application/zip"))) {
QTest::newRow("zip") << QStringLiteral("application/zip") << true << false;
} else {
qDebug() << "zip format not available in CreateDialog, skipping test.";
}
if (m_pluginManager.supportedWriteMimeTypes().contains(QStringLiteral("application/x-7z-compressed"))) {
if (m_pluginManager.supportedWriteMimeTypes().contains(QLatin1String("application/x-7z-compressed"))) {
QTest::newRow("7z") << QStringLiteral("application/x-7z-compressed") << true << true;
} else {
qDebug() << "7z format not available in CreateDialog, skipping test.";
}
if (m_pluginManager.supportedWriteMimeTypes().contains(QStringLiteral("application/vnd.rar"))) {
if (m_pluginManager.supportedWriteMimeTypes().contains(QLatin1String("application/vnd.rar"))) {
QTest::newRow("rar") << QStringLiteral("application/vnd.rar") << true << true;
} else {
qDebug() << "rar format not available in CreateDialog, skipping test.";
......@@ -194,7 +194,7 @@ void CreateDialogTest::testEncryption()
void CreateDialogTest::testHeaderEncryptionTooltip()
{
if (!m_pluginManager.supportedWriteMimeTypes().contains(QStringLiteral("application/zip"))) {
if (!m_pluginManager.supportedWriteMimeTypes().contains(QLatin1String("application/zip"))) {
QSKIP("zip format not available in CreateDialog, skipping test.", SkipSingle);
}
......
......@@ -287,7 +287,7 @@ void ExtractTest::testExtraction_data()
<< 7;
// Only run tests if tar.lzo format is available
if (PluginManager().supportedMimeTypes().contains(QStringLiteral("application/x-tzo"))) {
if (PluginManager().supportedMimeTypes().contains(QLatin1String("application/x-tzo"))) {
archivePath = QFINDTESTDATA("data/simplearchive.tar.lzo");
QTest::newRow("extract selected entries from a lzop-compressed tarball without path")
<< archivePath
......
......@@ -58,7 +58,7 @@ JSONParser::JSONArchive JSONParser::createJSONArchive(const QVariant &json)
for (const QVariant &entry : jsonList) {
const QVariantMap entryMap = entry.toMap();
if (!entryMap.contains(QStringLiteral("fullPath"))) {
if (!entryMap.contains(QLatin1String("fullPath"))) {
continue;
}
......
......@@ -146,7 +146,7 @@ void LoadTest::testProperties_data()
<< QStringLiteral("simplearchive")
<< QString();
if (PluginManager().supportedMimeTypes().contains(QStringLiteral("application/x-tzo"))) {
if (PluginManager().supportedMimeTypes().contains(QLatin1String("application/x-tzo"))) {
QTest::newRow("lzop-compressed tarball")
<< QFINDTESTDATA("data/simplearchive.tar.lzo")
<< QStringLiteral("simplearchive")
......
......@@ -58,22 +58,22 @@ void MetaDataTest::testPluginLoading()
void MetaDataTest::testPluginMetadata()
{
for (const KPluginMetaData& metaData : qAsConst(m_plugins)) {
QVERIFY(metaData.serviceTypes().contains(QStringLiteral("Kerfuffle/Plugin")));
QVERIFY(metaData.serviceTypes().contains(QLatin1String("Kerfuffle/Plugin")));
QVERIFY(!metaData.mimeTypes().isEmpty());
const QJsonObject json = metaData.rawData();
QVERIFY(json.keys().contains(QStringLiteral("X-KDE-Priority")));
QVERIFY(json.keys().contains(QStringLiteral("KPlugin")));
QVERIFY(json.keys().contains(QLatin1String("X-KDE-Priority")));
QVERIFY(json.keys().contains(QLatin1String("KPlugin")));
if (json.keys().contains(QStringLiteral("X-KDE-Kerfuffle-ReadOnlyExecutables"))) {
if (json.keys().contains(QLatin1String("X-KDE-Kerfuffle-ReadOnlyExecutables"))) {
QVERIFY(json[QStringLiteral("X-KDE-Kerfuffle-ReadOnlyExecutables")].isArray());
}
if (json.keys().contains(QStringLiteral("X-KDE-Kerfuffle-ReadWriteExecutables"))) {
if (json.keys().contains(QLatin1String("X-KDE-Kerfuffle-ReadWriteExecutables"))) {
QVERIFY(json[QStringLiteral("X-KDE-Kerfuffle-ReadWriteExecutables")].isArray());
// If there is a list of read-write executables, the plugin has to be read-write.
QVERIFY(json.keys().contains(QStringLiteral("X-KDE-Kerfuffle-ReadWrite")));
QVERIFY(json.keys().contains(QLatin1String("X-KDE-Kerfuffle-ReadWrite")));
QVERIFY(json[QStringLiteral("X-KDE-Kerfuffle-ReadWrite")].toBool());
}
}
......
......@@ -45,7 +45,7 @@ void Cli7zTest::initTestCase()
m_plugin = new Plugin(this);
const auto plugins = m_pluginManger.availablePlugins();
for (Plugin *plugin : plugins) {
if (plugin->metaData().pluginId() == QStringLiteral("kerfuffle_cli7z")) {
if (plugin->metaData().pluginId() == QLatin1String("kerfuffle_cli7z")) {
m_plugin = plugin;
return;
}
......
......@@ -46,7 +46,7 @@ void CliRarTest::initTestCase()
m_plugin = new Plugin(this);
const auto plugins = m_pluginManger.availablePlugins();
for (Plugin *plugin : plugins) {
if (plugin->metaData().pluginId() == QStringLiteral("kerfuffle_clirar")) {
if (plugin->metaData().pluginId() == QLatin1String("kerfuffle_clirar")) {
m_plugin = plugin;
return;
}
......
......@@ -38,7 +38,7 @@ void CliUnarchiverTest::initTestCase()
m_plugin = new Plugin(this);
const auto plugins = m_pluginManger.availablePlugins();
for (Plugin *plugin : plugins) {
if (plugin->metaData().pluginId() == QStringLiteral("kerfuffle_cliunarchiver")) {
if (plugin->metaData().pluginId() == QLatin1String("kerfuffle_cliunarchiver")) {
m_plugin = plugin;
return;
}
......
......@@ -37,7 +37,7 @@ void CliZipTest::initTestCase()
m_plugin = new Plugin(this);
const auto plugins = m_pluginManger.availablePlugins();
for (Plugin *plugin : plugins) {
if (plugin->metaData().pluginId() == QStringLiteral("kerfuffle_clizip")) {
if (plugin->metaData().pluginId() == QLatin1String("kerfuffle_clizip")) {
m_plugin = plugin;
return;
}
......
......@@ -320,7 +320,7 @@ void LoadJob::onNewEntry(const Archive::Entry *entry)
if (m_isSingleFolderArchive) {
// RPM filenames have the ./ prefix, and "." would be detected as the subfolder name, so we remove it.
const QString fullPath = entry->fullPath().replace(QRegularExpression(QStringLiteral("^\\./")), QString());
const QString fullPath = entry->fullPath().remove(QRegularExpression(QStringLiteral("^\\./")));
const QString basePath = fullPath.split(QLatin1Char('/')).at(0);
if (m_basePath.isEmpty()) {
......@@ -434,7 +434,7 @@ void BatchExtractJob::setupDestination()
// Special case for single folder RPM archives.
// We don't want the autodetected folder to have a meaningless "usr" name.
if (isSingleFolderRPM && subfolderName == QStringLiteral("usr")) {
if (isSingleFolderRPM && subfolderName == QLatin1String("usr")) {
qCDebug(ARK) << "Detected single folder RPM archive. Using archive basename as subfolder name";
subfolderName = QFileInfo(archive()->fileName()).completeBaseName();
}
......
......@@ -45,18 +45,18 @@ QMimeType determineMimeType(const QString& filename)
// #328815: since detection-by-content does not work for compressed tar archives (see below why)
// we cannot rely on it when the archive extension is wrong; we need to validate by hand.
if (fileinfo.completeSuffix().toLower().remove(QRegularExpression(QStringLiteral("[^a-z\\.]"))).contains(QStringLiteral("tar."))) {
if (fileinfo.completeSuffix().toLower().remove(QRegularExpression(QStringLiteral("[^a-z\\.]"))).contains(QLatin1String("tar."))) {
inputFile.chop(fileinfo.completeSuffix().length());
QString cleanExtension(fileinfo.completeSuffix().toLower());
// tar.bz2 and tar.lz4 need special treatment since they contain numbers.
bool isBZ2 = false;
bool isLZ4 = false;
if (fileinfo.completeSuffix().toLower().contains(QStringLiteral("bz2"))) {
if (fileinfo.completeSuffix().toLower().contains(QLatin1String("bz2"))) {
cleanExtension.remove(QStringLiteral("bz2"));
isBZ2 = true;
}
if (fileinfo.completeSuffix().toLower().contains(QStringLiteral("lz4"))) {
if (fileinfo.completeSuffix().toLower().contains(QLatin1String("lz4"))) {
cleanExtension.remove(QStringLiteral("lz4"));
isLZ4 = true;
}
......
......@@ -65,7 +65,7 @@ PropertiesDialog::PropertiesDialog(QWidget *parent, Archive *archive, qulonglong
m_ui->lblArchiveName->setText(archive->fileName());
m_ui->lblArchiveType->setText(archive->mimeType().comment());
m_ui->lblMimetype->setText(archive->mimeType().name());
m_ui->lblCompressionMethods->setText(archive->property("compressionMethods").toStringList().join(QStringLiteral(", ")));
m_ui->lblCompressionMethods->setText(archive->property("compressionMethods").toStringList().join(QLatin1String(", ")));
m_ui->lblReadOnly->setText(archive->isReadOnly() ? i18n("yes") : i18n("no"));
m_ui->lblMultiVolume->setText(archive->isMultiVolume() ? i18n("yes (%1 volumes)", archive->numberOfVolumes()) : i18n("no"));
m_ui->lblHasComment->setText(archive->hasComment() ? i18n("yes") : i18n("no"));
......@@ -84,10 +84,10 @@ PropertiesDialog::PropertiesDialog(QWidget *parent, Archive *archive, qulonglong
m_ui->lblPasswordProtected->setText(i18n("no"));
break;
case Archive::Encrypted:
m_ui->lblPasswordProtected->setText(i18n("only file contents (%1)", archive->property("encryptionMethods").toStringList().join(QStringLiteral(", "))));
m_ui->lblPasswordProtected->setText(i18n("only file contents (%1)", archive->property("encryptionMethods").toStringList().join(QLatin1String(", "))));
break;
case Archive::HeaderEncrypted:
m_ui->lblPasswordProtected->setText(i18n("yes (%1)", archive->property("encryptionMethods").toStringList().join(QStringLiteral(", "))));
m_ui->lblPasswordProtected->setText(i18n("yes (%1)", archive->property("encryptionMethods").toStringList().join(QLatin1String(", "))));
break;
}
......
......@@ -55,7 +55,7 @@ void Query::waitForResponse()
{
QMutexLocker locker(&m_responseMutex);
//if there is no response set yet, wait
if (!m_data.contains(QStringLiteral("response"))) {
if (!m_data.contains(QLatin1String("response"))) {
m_responseCondition.wait(&m_responseMutex);
}
}
......
......@@ -209,7 +209,7 @@ bool ArkViewer::viewInInternalViewer(const QString& fileName, const QMimeType &m
KService::Ptr ArkViewer::getViewer(const QString &mimeType)
{
// No point in even trying to find anything for application/octet-stream
if (mimeType == QStringLiteral("application/octet-stream")) {
if (mimeType == QLatin1String("application/octet-stream")) {
return KService::Ptr();
}
......
......@@ -587,7 +587,7 @@ void Part::createArchive()
const QString fixedMimeType = arguments().metaData()[QStringLiteral("fixedMimeType")];
m_model->createEmptyArchive(localFilePath(), fixedMimeType, m_model);
if (arguments().metaData().contains(QStringLiteral("volumeSize"))) {
if (arguments().metaData().contains(QLatin1String("volumeSize"))) {
m_model->archive()->setMultiVolume(true);
}
......@@ -743,16 +743,16 @@ QModelIndexList Part::getSelectedIndexes()
void Part::readCompressionOptions()
{
// Store options from CreateDialog if they are set.
if (!m_compressionOptions.isCompressionLevelSet() && arguments().metaData().contains(QStringLiteral("compressionLevel"))) {
if (!m_compressionOptions.isCompressionLevelSet() && arguments().metaData().contains(QLatin1String("compressionLevel"))) {
m_compressionOptions.setCompressionLevel(arguments().metaData()[QStringLiteral("compressionLevel")].toInt());
}
if (m_compressionOptions.compressionMethod().isEmpty() && arguments().metaData().contains(QStringLiteral("compressionMethod"))) {
if (m_compressionOptions.compressionMethod().isEmpty() && arguments().metaData().contains(QLatin1String("compressionMethod"))) {
m_compressionOptions.setCompressionMethod(arguments().metaData()[QStringLiteral("compressionMethod")]);
}
if (m_compressionOptions.encryptionMethod().isEmpty() && arguments().metaData().contains(QStringLiteral("encryptionMethod"))) {
if (m_compressionOptions.encryptionMethod().isEmpty() && arguments().metaData().contains(QLatin1String("encryptionMethod"))) {
m_compressionOptions.setEncryptionMethod(arguments().metaData()[QStringLiteral("encryptionMethod")]);
}
if (!m_compressionOptions.isVolumeSizeSet() && arguments().metaData().contains(QStringLiteral("volumeSize"))) {
if (!m_compressionOptions.isVolumeSizeSet() && arguments().metaData().contains(QLatin1String("volumeSize"))) {
m_compressionOptions.setVolumeSize(arguments().metaData()[QStringLiteral("volumeSize")].toULong());
}
......@@ -1068,7 +1068,7 @@ void Part::slotWatchedFileModified(const QString& file)
for (QTemporaryDir *tmpDir : qAsConst(m_tmpExtractDirList)) {
relPath.remove(tmpDir->path()); //Remove tmpDir.
}
relPath = relPath.mid(1); //Remove leading slash.
relPath.remove(0, 1); //Remove leading slash.
if (relPath.contains(QLatin1Char('/'))) {
relPath = relPath.section(QLatin1Char('/'), 0, -2); //Remove filename.
} else {
......@@ -1325,7 +1325,7 @@ void Part::slotAddFiles(const QStringList& filesToAdd, const Archive::Entry *des
globalWorkDir.remove(relPath);
qCDebug(ARK) << "Adding" << filesToAdd << "to" << relPath;
} else {
qCDebug(ARK) << "Adding " << filesToAdd << ((destination == nullptr) ? QString() : QStringLiteral("to ") + destination->fullPath());
qCDebug(ARK) << "Adding " << filesToAdd << ((destination == nullptr) ? QString() : QLatin1String("to ") + destination->fullPath());
}
// Remove trailing slash (needed when adding dirs).
......@@ -1433,7 +1433,7 @@ void Part::slotCopyFiles()
void Part::slotRenameFile(const QString &name)
{
if (name == QLatin1String(".") || name == QLatin1String("..") || name.contains(QLatin1Char('/'))) {
if (name == QLatin1Char('.') || name == QLatin1String("..") || name.contains(QLatin1Char('/'))) {
displayMsgWidget(KMessageWidget::Error, i18n("Filename can't contain slashes and can't be equal to \".\" or \"..\""));
return;
}
......
......@@ -236,7 +236,7 @@ bool CliPlugin::readListLine(const QString& line)
} else if (line.startsWith(QLatin1String("Folder = "))) {
const QString isDirectoryStr = line.mid(9).trimmed();
Q_ASSERT(isDirectoryStr == QStringLiteral("+") || isDirectoryStr == QStringLiteral("-"));
Q_ASSERT(isDirectoryStr == QLatin1String("+") || isDirectoryStr == QStringLiteral("-"));
const bool isDirectory = isDirectoryStr.startsWith(QLatin1Char('+'));
m_currentArchiveEntry->setProperty("isDirectory", isDirectory);
fixDirectoryFullName();
......
......@@ -287,7 +287,7 @@ void CliPlugin::handleUnrar5Entry()
e->setProperty("version", compression);
}
m_isPasswordProtected = m_unrar5Details.value(QStringLiteral("flags")).contains(QStringLiteral("encrypted"));
m_isPasswordProtected = m_unrar5Details.value(QStringLiteral("flags")).contains(QLatin1String("encrypted"));
e->setProperty("isPasswordProtected", m_isPasswordProtected);
if (m_isPasswordProtected) {
m_isRAR5 ? emit encryptionMethodFound(QStringLiteral("AES256")) : emit encryptionMethodFound(QStringLiteral("AES128"));
......@@ -527,9 +527,9 @@ void CliPlugin::handleUnrar4Entry()
// whether the archive's position in the volume is displayed
// instead of the compression ratio.
QString compressionRatio = m_unrar4Details.at(3);
if ((compressionRatio == QStringLiteral("<--")) ||
(compressionRatio == QStringLiteral("<->")) ||
(compressionRatio == QStringLiteral("-->"))) {
if ((compressionRatio == QLatin1String("<--")) ||
(compressionRatio == QLatin1String("<->")) ||
(compressionRatio == QLatin1String("-->"))) {
compressionRatio = QLatin1Char('0');
} else {
compressionRatio.chop(1); // Remove the '%'
......
......@@ -99,7 +99,7 @@ bool ReadWriteLibarchivePlugin::addFiles(const QVector<Archive::Entry*> &files,
QString path = it.next();
if ((it.fileName() == QLatin1String("..")) ||
(it.fileName() == QLatin1String("."))) {
(it.fileName() == QLatin1Char('.'))) {
continue;
}
......
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