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

Make it compile without foreach

Summary: Port to for(...:...)

Reviewers: elvisangelaccio

Reviewed By: elvisangelaccio

Subscribers: kde-utils-devel, #ark

Tags: #ark

Differential Revision: https://phabricator.kde.org/D21515
parent 42c8e2d8
......@@ -86,6 +86,11 @@ endif (WITH_TEST_COVERAGE)
set(SUPPORTED_ARK_MIMETYPES "")
add_definitions(-DTRANSLATION_DOMAIN="ark")
# Until kf5 5.56 kconfig had some header which used Q_FOREACH
# Q_FOREACH will be deprecated/removed in qt6. With QT_NO_FOREACH we prepare the migration to qt6.
if (${KF5Config_VERSION} STRGREATER "5.56.0")
add_definitions(-DQT_NO_FOREACH)
endif()
add_subdirectory(plugins)
add_subdirectory(kerfuffle)
......
......@@ -112,7 +112,7 @@ void BatchExtract::slotStartJob()
return;
}
foreach (const auto& url, m_inputs) {
for (const auto& url : qAsConst(m_inputs)) {
addExtraction(url);
}
......
......@@ -42,7 +42,7 @@ void ExtractHereDndPlugin::slotTriggered()
batchJob->setAutoSubfolder(true);
batchJob->setDestinationFolder(m_dest.toDisplayString(QUrl::PreferLocalFile));
batchJob->setPreservePaths(true);
foreach(const QUrl& url, m_urls) {
for (const QUrl& url : qAsConst(m_urls)) {
batchJob->addInput(url);
}
......
......@@ -48,7 +48,8 @@ QList<QAction*> ExtractFileItemAction::actions(const KFileItemListProperties& fi
bool readOnlyParentDir = false;
QList<QUrl> supportedUrls;
// Filter URLs by supported mimetypes.
foreach (const QUrl &url, fileItemInfos.urlList()) {
const auto urlList = fileItemInfos.urlList();
for (const QUrl &url : urlList) {
const QMimeType mimeType = determineMimeType(url.path());
if (m_pluginManager->preferredPluginsFor(mimeType).isEmpty()) {
continue;
......
......@@ -246,7 +246,8 @@ void MainWindow::setShowExtractDialog(bool option)
void MainWindow::closeEvent(QCloseEvent *event)
{
// Preview windows don't have a parent, so we need to manually close them.
foreach (QWidget *widget, qApp->topLevelWidgets()) {
const auto topLevelWidgets = qApp->topLevelWidgets();
for (QWidget *widget : topLevelWidgets) {
if (widget->isVisible()) {
widget->close();
}
......@@ -271,7 +272,8 @@ void MainWindow::showSettings()
auto dialog = new Kerfuffle::SettingsDialog(this, QStringLiteral("settings"), iface->config());
foreach (Kerfuffle::SettingsPage *page, iface->settingsPages(this)) {
const auto pages = iface->settingsPages(this);
for (Kerfuffle::SettingsPage *page : pages) {
dialog->addPage(page, page->name(), page->iconName());
connect(dialog, &KConfigDialog::settingsChanged, page, &Kerfuffle::SettingsPage::slotSettingsChanged);
connect(dialog, &Kerfuffle::SettingsDialog::defaultsButtonClicked, page, &Kerfuffle::SettingsPage::slotDefaultsButtonClicked);
......
......@@ -158,7 +158,7 @@ void AddTest::testAdding()
QStringList oldPaths = getEntryPaths(archive);
// Check that the expected paths (after the AddJob) are not in the archive.
foreach (const auto &expectedPath, expectedNewPaths) {
for (const auto &expectedPath : qAsConst(expectedNewPaths)) {
QVERIFY(!oldPaths.contains(expectedPath));
}
......@@ -171,7 +171,7 @@ void AddTest::testAdding()
QStringList newPaths = getEntryPaths(archive);
// Check that the expected paths are now in the archive.
foreach (const auto &path, expectedNewPaths) {
for (const auto &path : qAsConst(expectedNewPaths)) {
QVERIFY(newPaths.contains(path));
}
......
......@@ -221,7 +221,7 @@ void AddToArchiveTest::testCompressHere()
}
QFETCH(QStringList, inputFiles);
foreach (const QString &file, inputFiles) {
for (const QString &file : qAsConst(inputFiles)) {
addToArchiveJob->addInput(QUrl::fromUserInput(file));
}
......
......@@ -267,12 +267,12 @@ void CopyTest::testCopying()
QStringList oldPaths = getEntryPaths(archive);
// Check that the entries to be copied are in the archive.
foreach (const auto entry, targetEntries) {
for (const auto entry : qAsConst(targetEntries)) {
QVERIFY(oldPaths.contains(entry->fullPath()));
}
// Check that the expected paths (after the CopyJob) are not in the archive.
foreach (const auto &expectedPath, expectedNewPaths) {
for (const auto &expectedPath : qAsConst(expectedNewPaths)) {
QVERIFY(!oldPaths.contains(expectedPath));
}
......@@ -285,12 +285,12 @@ void CopyTest::testCopying()
QStringList newPaths = getEntryPaths(archive);
// Check that the expected paths are now in the archive.
foreach (const auto &path, expectedNewPaths) {
for (const auto &path : qAsConst(expectedNewPaths)) {
QVERIFY(newPaths.contains(path));
}
// Check also that the target paths are still in the archive.
foreach (const auto entry, targetEntries) {
for (const auto entry : qAsConst(targetEntries)) {
QVERIFY(newPaths.contains(entry->fullPath()));
}
......
......@@ -56,12 +56,13 @@ void DeleteTest::testDelete_data()
QTest::addColumn<uint>("expectedRemainingEntriesCount");
// Repeat the same test case for each format and for each plugin supporting the format.
foreach (const QString &format, TestHelper::testFormats()) {
const QStringList formats = TestHelper::testFormats();
for (const QString &format : formats) {
const QString filename = QStringLiteral("test.%1").arg(format);
const auto mime = QMimeDatabase().mimeTypeForFile(filename, QMimeDatabase::MatchExtension);
const auto plugins = m_pluginManager.preferredWritePluginsFor(mime);
foreach (const auto plugin, plugins) {
for (const auto plugin : plugins) {
QTest::newRow(qPrintable(QStringLiteral("delete a single file (%1, %2)").arg(format, plugin->metaData().pluginId())))
<< filename
<< plugin
......
......@@ -482,11 +482,12 @@ void ExtractTest::testPreservePermissions_data()
QTest::addColumn<int>("expectedPermissions");
// Repeat the same test case for each format and for each plugin supporting the format.
foreach (const QString &format, TestHelper::testFormats()) {
const QStringList formats = TestHelper::testFormats();
for (const QString &format : formats) {
const QString filename = QFINDTESTDATA(QStringLiteral("data/test_permissions.%1").arg(format));
const auto mime = QMimeDatabase().mimeTypeForFile(filename, QMimeDatabase::MatchExtension);
const auto plugins = m_pluginManager.preferredWritePluginsFor(mime);
foreach (const auto plugin, plugins) {
for (const auto plugin : plugins) {
QTest::newRow(QStringLiteral("test preserve 0755 permissions (%1, %2)").arg(format, plugin->metaData().pluginId()).toUtf8().constData())
<< filename
<< plugin
......
......@@ -318,7 +318,7 @@ void JobsTest::testRemoveEntries()
QStringList fullPathsToDelete = iface->entryFullPaths(entriesToDelete);
QVector<Archive::Entry*> expectedRemainingEntries;
Q_FOREACH (Archive::Entry *entry, entries) {
for (Archive::Entry *entry : qAsConst(entries)) {
if (!fullPathsToDelete.contains(entry->fullPath())) {
expectedRemainingEntries.append(entry);
}
......@@ -412,7 +412,7 @@ void JobsTest::testAddEntries()
QFETCH(QVector<Archive::Entry*>, originalEntries);
QStringList originalFullPaths = QStringList();
Q_FOREACH (const Archive::Entry *entry, originalEntries) {
for (const Archive::Entry *entry : qAsConst(originalEntries)) {
originalFullPaths.append(entry->fullPath());
}
auto currentEntries = listEntries(iface);
......@@ -426,7 +426,7 @@ void JobsTest::testAddEntries()
QStringList expectedAddedFullPaths = QStringList();
const QString destinationPath = destinationEntry->fullPath();
int expectedEntriesCount = originalEntries.size();
Q_FOREACH (const Archive::Entry *entry, entriesToAdd) {
for (const Archive::Entry *entry : qAsConst(entriesToAdd)) {
const QString fullPath = destinationPath + entry->fullPath();
if (!originalFullPaths.contains(fullPath)) {
expectedEntriesCount++;
......@@ -438,11 +438,11 @@ void JobsTest::testAddEntries()
QCOMPARE(currentEntries.size(), expectedEntriesCount);
QStringList currentFullPaths = QStringList();
Q_FOREACH (const Archive::Entry* entry, currentEntries) {
for (const Archive::Entry* entry : qAsConst(currentEntries)) {
currentFullPaths << entry->fullPath();
}
Q_FOREACH (const QString &fullPath, expectedAddedFullPaths) {
for (const QString &fullPath : qAsConst(expectedAddedFullPaths)) {
QVERIFY(currentFullPaths.contains(fullPath));
}
......
......@@ -69,7 +69,7 @@ bool JSONArchiveInterface::addFiles(const QVector<Kerfuffle::Archive::Entry*>& f
Q_UNUSED(options)
Q_UNUSED(numberOfEntriesToAdd)
foreach (const Kerfuffle::Archive::Entry *entry, files) {
for (const Kerfuffle::Archive::Entry *entry : files) {
const QString &path = destination->fullPath() + entry->fullPath();
if (m_archive.contains(path)) {
return false;
......@@ -113,7 +113,7 @@ bool JSONArchiveInterface::extractFiles(const QVector<Kerfuffle::Archive::Entry*
bool JSONArchiveInterface::deleteFiles(const QVector<Kerfuffle::Archive::Entry*>& files)
{
foreach (const Kerfuffle::Archive::Entry *file, files) {
for (const Kerfuffle::Archive::Entry *file : files) {
const QString &fileName = file->fullPath();
if (m_archive.contains(fileName)) {
m_archive.remove(fileName);
......
......@@ -55,7 +55,8 @@ JSONParser::JSONArchive JSONParser::createJSONArchive(const QVariant &json)
{
JSONParser::JSONArchive archive;
foreach (const QVariant &entry, json.toList()) {
const auto jsonList = json.toList();
for (const QVariant &entry : jsonList) {
const QVariantMap entryMap = entry.toMap();
if (!entryMap.contains(QStringLiteral("fullPath"))) {
......
......@@ -57,7 +57,7 @@ void MetaDataTest::testPluginLoading()
void MetaDataTest::testPluginMetadata()
{
foreach (const KPluginMetaData& metaData, m_plugins) {
for (const KPluginMetaData& metaData : qAsConst(m_plugins)) {
QVERIFY(metaData.serviceTypes().contains(QStringLiteral("Kerfuffle/Plugin")));
QVERIFY(!metaData.mimeTypes().isEmpty());
......
......@@ -231,12 +231,12 @@ void MoveTest::testMoving()
QStringList oldPaths = getEntryPaths(archive);
// Check that the entries to be moved are in the archive.
foreach (const auto entry, targetEntries) {
for (const auto entry : qAsConst(targetEntries)) {
QVERIFY(oldPaths.contains(entry->fullPath()));
}
// Check that the expected paths (after the MoveJob) are not in the archive.
foreach (const auto &expectedPath, expectedNewPaths) {
for (const auto &expectedPath : qAsConst(expectedNewPaths)) {
QVERIFY(!oldPaths.contains(expectedPath));
}
......@@ -249,12 +249,12 @@ void MoveTest::testMoving()
QStringList newPaths = getEntryPaths(archive);
// Check that the expected paths are now in the archive.
foreach (const auto &path, expectedNewPaths) {
for (const auto &path : qAsConst(expectedNewPaths)) {
QVERIFY(newPaths.contains(path));
}
// Check that the target paths are no longer in the archive.
foreach (const auto entry, targetEntries) {
for (const auto entry : qAsConst(targetEntries)) {
QVERIFY(!newPaths.contains(entry->fullPath()));
}
......
......@@ -43,7 +43,8 @@ using namespace Kerfuffle;
void Cli7zTest::initTestCase()
{
m_plugin = new Plugin(this);
foreach (Plugin *plugin, m_pluginManger.availablePlugins()) {
const auto plugins = m_pluginManger.availablePlugins();
for (Plugin *plugin : plugins) {
if (plugin->metaData().pluginId() == QStringLiteral("kerfuffle_cli7z")) {
m_plugin = plugin;
return;
......@@ -463,7 +464,7 @@ void Cli7zTest::testExtractArgs()
QFETCH(QVector<Archive::Entry*>, files);
QStringList filesList;
foreach (const Archive::Entry *e, files) {
for (const Archive::Entry *e : qAsConst(files)) {
filesList << e->fullPath(NoTrailingSlash);
}
......
......@@ -44,7 +44,8 @@ using namespace Kerfuffle;
void CliRarTest::initTestCase()
{
m_plugin = new Plugin(this);
foreach (Plugin *plugin, m_pluginManger.availablePlugins()) {
const auto plugins = m_pluginManger.availablePlugins();
for (Plugin *plugin : plugins) {
if (plugin->metaData().pluginId() == QStringLiteral("kerfuffle_clirar")) {
m_plugin = plugin;
return;
......@@ -506,7 +507,7 @@ void CliRarTest::testExtractArgs()
QFETCH(QVector<Archive::Entry*>, files);
QStringList filesList;
foreach (const Archive::Entry *e, files) {
for (const Archive::Entry *e : qAsConst(files)) {
filesList << e->fullPath(NoTrailingSlash);
}
......
......@@ -36,7 +36,8 @@ using namespace Kerfuffle;
void CliUnarchiverTest::initTestCase()
{
m_plugin = new Plugin(this);
foreach (Plugin *plugin, m_pluginManger.availablePlugins()) {
const auto plugins = m_pluginManger.availablePlugins();
for (Plugin *plugin : plugins) {
if (plugin->metaData().pluginId() == QStringLiteral("kerfuffle_cliunarchiver")) {
m_plugin = plugin;
return;
......@@ -392,7 +393,7 @@ void CliUnarchiverTest::testExtractArgs()
QFETCH(QVector<Archive::Entry*>, files);
QStringList filesList;
foreach (const Archive::Entry *e, files) {
for (const Archive::Entry *e : qAsConst(files)) {
filesList << e->fullPath(NoTrailingSlash);
}
......
......@@ -35,7 +35,8 @@ using namespace Kerfuffle;
void CliZipTest::initTestCase()
{
m_plugin = new Plugin(this);
foreach (Plugin *plugin, m_pluginManger.availablePlugins()) {
const auto plugins = m_pluginManger.availablePlugins();
for (Plugin *plugin : plugins) {
if (plugin->metaData().pluginId() == QStringLiteral("kerfuffle_clizip")) {
m_plugin = plugin;
return;
......@@ -230,7 +231,7 @@ void CliZipTest::testExtractArgs()
QFETCH(QVector<Archive::Entry*>, files);
QStringList filesList;
foreach (const Archive::Entry *e, files) {
for (const Archive::Entry *e : qAsConst(files)) {
filesList << e->fullPath(NoTrailingSlash);
}
......
......@@ -48,12 +48,13 @@ QStringList AbstractAddTest::getEntryPaths(Archive *archive)
void AbstractAddTest::setupRows(const QString &testName, const QString &archiveName, const QVector<Archive::Entry *> &targetEntries, Archive::Entry *destination, const QStringList &expectedNewPaths, uint numberOfEntries) const
{
// Repeat the same test case for each format and for each plugin supporting the format.
foreach (const QString &format, TestHelper::testFormats()) {
const QStringList formats = TestHelper::testFormats();
for (const QString &format : formats) {
const QString filename = QStringLiteral("%1.%2").arg(archiveName, format);
const auto mime = QMimeDatabase().mimeTypeForFile(filename, QMimeDatabase::MatchExtension);
const auto plugins = m_pluginManager.preferredWritePluginsFor(mime);
foreach (const auto plugin, plugins) {
for (const auto plugin : plugins) {
QTest::newRow(QStringLiteral("%1 (%2, %3)").arg(testName, format, plugin->metaData().pluginId()).toUtf8().constData())
<< filename
<< plugin
......
......@@ -182,7 +182,7 @@ void AddToArchive::slotStartJob()
const QDir stripDir(m_firstPath);
foreach (Archive::Entry *entry, m_entries) {
for (Archive::Entry *entry : qAsConst(m_entries)) {
entry->setFullPath(stripDir.absoluteFilePath(entry->fullPath()));
}
......
......@@ -62,7 +62,7 @@ Archive *Archive::create(const QString &fileName, const QString &fixedMimeType,
}
Archive *archive = nullptr;
foreach (Plugin *plugin, offers) {
for (Plugin *plugin : offers) {
archive = create(fileName, plugin, parent);
// Use the first valid plugin, according to the priority sorting.
if (archive->isValid()) {
......
......@@ -144,7 +144,7 @@ int Archive::Entry::row() const
Archive::Entry *Archive::Entry::find(const QString &name) const
{
foreach (Entry *entry, m_entries) {
for (Entry *entry : qAsConst(m_entries)) {
if (entry && (entry->name() == name)) {
return entry;
}
......@@ -175,7 +175,8 @@ void Archive::Entry::countChildren(uint &dirs, uint &files) const
return;
}
foreach (auto entry, entries()) {
const auto archiveEntries = entries();
for (auto entry : archiveEntries) {
if (entry->isDir()) {
dirs++;
} else {
......
......@@ -65,7 +65,8 @@ ArchiveFormat::ArchiveFormat(const QMimeType& mimeType,
ArchiveFormat ArchiveFormat::fromMetadata(const QMimeType& mimeType, const KPluginMetaData& metadata)
{
const QJsonObject json = metadata.rawData();
foreach (const QString& mime, metadata.mimeTypes()) {
const QStringList mimeTypes = metadata.mimeTypes();
for (const QString& mime : mimeTypes) {
if (mimeType.name() != mime) {
continue;
}
......@@ -86,8 +87,8 @@ ArchiveFormat ArchiveFormat::fromMetadata(const QMimeType& mimeType, const KPlug
// We use a QStringList instead of QVariantMap for encryption methods, to
// allow arbitrary ordering of the items.
QStringList encryptionMethods;
QJsonArray array = formatProps[QStringLiteral("EncryptionMethods")].toArray();
foreach (const QJsonValue &value, array) {
const QJsonArray array = formatProps[QStringLiteral("EncryptionMethods")].toArray();
for (const QJsonValue &value : array) {
encryptionMethods.append(value.toString());
}
QString defaultEncMethod = formatProps[QStringLiteral("EncryptionMethodDefault")].toString();
......
......@@ -169,7 +169,7 @@ void ReadOnlyArchiveInterface::setWaitForFinishedSignal(bool value)
QStringList ReadOnlyArchiveInterface::entryFullPaths(const QVector<Archive::Entry*> &entries, PathFormat format)
{
QStringList filesList;
foreach (const Archive::Entry *file, entries) {
for (const Archive::Entry *file : entries) {
filesList << file->fullPath(format);
}
return filesList;
......@@ -179,13 +179,13 @@ QVector<Archive::Entry*> ReadOnlyArchiveInterface::entriesWithoutChildren(const
{
// QMap is easy way to get entries sorted by their fullPath.
QMap<QString, Archive::Entry*> sortedEntries;
foreach (Archive::Entry *entry, entries) {
for (Archive::Entry *entry : entries) {
sortedEntries.insert(entry->fullPath(), entry);
}
QVector<Archive::Entry*> filteredEntries;
QString lastFolder;
foreach (Archive::Entry *entry, sortedEntries) {
for (Archive::Entry *entry : qAsConst(sortedEntries)) {
if (lastFolder.count() > 0 && entry->fullPath().startsWith(lastFolder)) {
continue;
}
......@@ -206,7 +206,7 @@ QStringList ReadOnlyArchiveInterface::entryPathsFromDestination(QStringList entr
QString newPath;
int nameLength = 0;
foreach (const QString &entryPath, entries) {
for (const QString &entryPath : qAsConst(entries)) {
if (lastFolder.count() > 0 && entryPath.startsWith(lastFolder)) {
// Replace last moved or copied folder path with destination path.
int charsCount = entryPath.count() - lastFolder.count();
......
......@@ -167,7 +167,7 @@ bool CliInterface::addFiles(const QVector<Archive::Entry*> &files, const Archive
qDir.mkpath(absoluteDestinationPath);
QObject *preservedParent = nullptr;
foreach (Archive::Entry *file, files) {
for (Archive::Entry *file : files) {
// The entries may have parent. We have to save and apply it to our new entry in order to prevent memory
// leaks.
if (preservedParent == nullptr) {
......@@ -325,11 +325,11 @@ void CliInterface::processFinished(int exitCode, QProcess::ExitStatus exitStatus
}
if (m_operationMode == Delete || m_operationMode == Move) {
QStringList removedFullPaths = entryFullPaths(m_removedFiles);
foreach (const QString &fullPath, removedFullPaths) {
const QStringList removedFullPaths = entryFullPaths(m_removedFiles);
for (const QString &fullPath : removedFullPaths) {
emit entryRemoved(fullPath);
}
foreach (Archive::Entry *e, m_newMovedFiles) {
for (Archive::Entry *e : qAsConst(m_newMovedFiles)) {
emit entry(e);
}
m_newMovedFiles.clear();
......@@ -455,7 +455,7 @@ bool CliInterface::moveDroppedFilesToDest(const QVector<Archive::Entry*> &files,
bool overwriteAll = false;
bool skipAll = false;
foreach (const Archive::Entry *file, files) {
for (const Archive::Entry *file : files) {
QFileInfo relEntry(file->fullPath().remove(file->rootNode));
QFileInfo absSourceEntry(QDir::current().absolutePath() + QLatin1Char('/') + file->fullPath());
......@@ -647,7 +647,7 @@ void CliInterface::setNewMovedFiles(const QVector<Archive::Entry*> &entries, con
{
m_newMovedFiles.clear();
QMap<QString, const Archive::Entry*> entryMap;
foreach (const Archive::Entry* entry, entries) {
for (const Archive::Entry* entry : entries) {
entryMap.insert(entry->fullPath(), entry);
}
......@@ -655,7 +655,7 @@ void CliInterface::setNewMovedFiles(const QVector<Archive::Entry*> &entries, con
QString newPath;
int nameLength = 0;
foreach (const Archive::Entry* entry, entryMap) {
for (const Archive::Entry* entry : qAsConst(entryMap)) {
if (lastFolder.count() > 0 && entry->fullPath().startsWith(lastFolder)) {
// Replace last moved or copied folder path with destination path.
int charsCount = entry->fullPath().count() - lastFolder.count();
......@@ -690,7 +690,7 @@ void CliInterface::setNewMovedFiles(const QVector<Archive::Entry*> &entries, con
QStringList CliInterface::extractFilesList(const QVector<Archive::Entry*> &entries) const
{
QStringList filesList;
foreach (const Archive::Entry *e, entries) {
for (const Archive::Entry *e : entries) {
filesList << escapeFileName(e->fullPath(NoTrailingSlash));
}
......@@ -812,7 +812,7 @@ void CliInterface::readStdout(bool handleAll)
m_stdOutData = lines.takeLast();
}
foreach(const QByteArray& line, lines) {
for (const QByteArray& line : qAsConst(lines)) {
if (!line.isEmpty() || (m_listEmptyLines && m_operationMode == List)) {
if (!handleLine(QString::fromLocal8Bit(line))) {
killProcess();
......@@ -825,7 +825,7 @@ void CliInterface::readStdout(bool handleAll)
bool CliInterface::setAddedFiles()
{
QDir::setCurrent(m_tempAddDir->path());
foreach (const Archive::Entry *file, m_passedFiles) {
for (const Archive::Entry *file : qAsConst(m_passedFiles)) {
const QString oldPath = m_tempWorkingDir->path() + QLatin1Char('/') + file->fullPath(NoTrailingSlash);
const QString newPath = m_tempAddDir->path() + QLatin1Char('/') + file->name();
if (!QFile::rename(oldPath, newPath)) {
......@@ -961,7 +961,8 @@ bool CliInterface::handleFileExistsMessage(const QString& line)
{
// Check for a filename and store it.
if (isFileExistsFileName(line)) {
foreach (const QString &pattern, m_cliProps->property("fileExistsFileNameRegExp").toStringList()) {
const QStringList fileExistsFileNameRegExp = m_cliProps->property("fileExistsFileNameRegExp").toStringList();
for (const QString &pattern : fileExistsFileNameRegExp) {
const QRegularExpression rxFileNamePattern(pattern);
const QRegularExpressionMatch rxMatch = rxFileNamePattern.match(line);
......@@ -1027,7 +1028,7 @@ QStringList CliInterface::entryPathDestinationPairs(const QVector<Archive::Entry
{
QStringList pairList;
if (entriesWithoutChildren.count() > 1) {
foreach (const Archive::Entry *file, entriesWithoutChildren) {
for (const Archive::Entry *file : entriesWithoutChildren) {
pairList << file->fullPath(NoTrailingSlash) << destination->fullPath() + file->name();
}
} else {
......@@ -1078,7 +1079,8 @@ QString CliInterface::multiVolumeName() const
QString oldSuffix = QMimeDatabase().suffixForFileName(filename());
QString name;
foreach (const QString &multiSuffix, m_cliProps->property("multiVolumeSuffix").toStringList()) {
const QStringList multiVolumeSuffix = m_cliProps->property("multiVolumeSuffix").toStringList();
for (const QString &multiSuffix : multiVolumeSuffix) {
QString newSuffix = multiSuffix;
newSuffix.replace(QStringLiteral("$Suffix"), oldSuffix);
name = filename().remove(oldSuffix).append(newSuffix);
......
......@@ -47,7 +47,7 @@ QStringList CliProperties::addArgs(const QString &archive, const QStringList &fi
}
QStringList args;
foreach (const QString &s, m_addSwitch) {
for (const QString &s : qAsConst(m_addSwitch)) {
args << s;
}
if (!password.isEmpty()) {
......@@ -75,7 +75,8 @@ QStringList CliProperties::addArgs(const QString &archive, const QStringList &fi
QStringList CliProperties::commentArgs(const QString &archive, const QString &commentfile)
{
QStringList args;
foreach (const QString &s, substituteCommentSwitch(commentfile)) {
const QStringList commentSwitches = substituteCommentSwitch(commentfile);
for (const QString &s : commentSwitches) {
args << s;
}
args << archive;
......@@ -92,7 +93,7 @@ QStringList CliProperties::deleteArgs(const QString &archive, const QVector<Arch
args << substitutePasswordSwitch(password);