mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 13:18:06 -06:00
Sort languages combobox by language code
* Avoid creating redundant file lists * Sort languages combobox by language code PR #20365.
This commit is contained in:
@@ -105,7 +105,7 @@ BitTorrent::BencodeResumeDataStorage::BencodeResumeDataStorage(const Path &path,
|
||||
}
|
||||
|
||||
const QRegularExpression filenamePattern {u"^([A-Fa-f0-9]{40})\\.fastresume$"_s};
|
||||
const QStringList filenames = QDir(path.data()).entryList(QStringList(u"*.fastresume"_s), QDir::Files, QDir::Unsorted);
|
||||
const QStringList filenames = QDir(path.data()).entryList({u"*.fastresume"_s}, QDir::Files);
|
||||
|
||||
m_registeredTorrents.reserve(filenames.size());
|
||||
for (const QString &filename : filenames)
|
||||
|
||||
@@ -124,8 +124,8 @@ void TorrentCreator::run()
|
||||
QDirIterator dirIter {m_params.inputPath.data(), (QDir::AllDirs | QDir::NoDotAndDotDot), QDirIterator::Subdirectories};
|
||||
while (dirIter.hasNext())
|
||||
{
|
||||
dirIter.next();
|
||||
dirs.append(dirIter.filePath());
|
||||
const QString filePath = dirIter.next();
|
||||
dirs.append(filePath);
|
||||
}
|
||||
std::sort(dirs.begin(), dirs.end(), naturalLessThan);
|
||||
|
||||
@@ -139,11 +139,11 @@ void TorrentCreator::run()
|
||||
QDirIterator fileIter {dir, QDir::Files};
|
||||
while (fileIter.hasNext())
|
||||
{
|
||||
fileIter.next();
|
||||
const QFileInfo fileInfo = fileIter.nextFileInfo();
|
||||
|
||||
const auto relFilePath = parentPath.relativePathOf(Path(fileIter.filePath()));
|
||||
const Path relFilePath = parentPath.relativePathOf(Path(fileInfo.filePath()));
|
||||
tmpNames.append(relFilePath.toString());
|
||||
fileSizeMap[tmpNames.last()] = fileIter.fileInfo().size();
|
||||
fileSizeMap[tmpNames.last()] = fileInfo.size();
|
||||
}
|
||||
|
||||
std::sort(tmpNames.begin(), tmpNames.end(), naturalLessThan);
|
||||
|
||||
@@ -74,12 +74,11 @@ namespace
|
||||
}
|
||||
|
||||
// python 2: remove "*.pyc" files
|
||||
const QStringList files = QDir(dir.data()).entryList(QDir::Files);
|
||||
for (const QString &file : files)
|
||||
QDirIterator it {dir.data(), {u"*.pyc"_s}, QDir::Files};
|
||||
while (it.hasNext())
|
||||
{
|
||||
const Path path {file};
|
||||
if (path.hasExtension(u".pyc"_s))
|
||||
Utils::Fs::removeFile(path);
|
||||
const QString filePath = it.next();
|
||||
Utils::Fs::removeFile(Path(filePath));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -298,11 +297,13 @@ bool SearchPluginManager::uninstallPlugin(const QString &name)
|
||||
clearPythonCache(engineLocation());
|
||||
|
||||
// remove it from hard drive
|
||||
const Path pluginsPath = pluginsLocation();
|
||||
const QStringList filters {name + u".*"};
|
||||
const QStringList files = QDir(pluginsPath.data()).entryList(filters, QDir::Files, QDir::Unsorted);
|
||||
for (const QString &file : files)
|
||||
Utils::Fs::removeFile(pluginsPath / Path(file));
|
||||
QDirIterator iter {pluginsLocation().data(), {name + u".*"}, QDir::Files};
|
||||
while (iter.hasNext())
|
||||
{
|
||||
const QString filePath = iter.next();
|
||||
Utils::Fs::removeFile(Path(filePath));
|
||||
}
|
||||
|
||||
// Remove it from supported engines
|
||||
delete m_plugins.take(name);
|
||||
|
||||
|
||||
@@ -443,10 +443,10 @@ void TorrentFilesWatcher::Worker::processFolder(const Path &path, const Path &wa
|
||||
|
||||
if (options.recursive)
|
||||
{
|
||||
QDirIterator dirIter {path.data(), (QDir::Dirs | QDir::NoDot | QDir::NoDotDot)};
|
||||
while (dirIter.hasNext())
|
||||
QDirIterator iter {path.data(), (QDir::Dirs | QDir::NoDotAndDotDot)};
|
||||
while (iter.hasNext())
|
||||
{
|
||||
const Path folderPath {dirIter.next()};
|
||||
const Path folderPath {iter.next()};
|
||||
// Skip processing of subdirectory that is explicitly set as watched folder
|
||||
if (!m_watchedFolders.contains(folderPath))
|
||||
processFolder(folderPath, watchedFolderPath, options);
|
||||
|
||||
@@ -151,11 +151,11 @@ qint64 Utils::Fs::computePathSize(const Path &path)
|
||||
|
||||
// Compute folder size based on its content
|
||||
qint64 size = 0;
|
||||
QDirIterator iter {path.data(), QDir::Files | QDir::Hidden | QDir::NoSymLinks, QDirIterator::Subdirectories};
|
||||
QDirIterator iter {path.data(), (QDir::Files | QDir::Hidden | QDir::NoSymLinks), QDirIterator::Subdirectories};
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
size += iter.fileInfo().size();
|
||||
const QFileInfo fileInfo = iter.nextFileInfo();
|
||||
size += fileInfo.size();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
#include <QStringView>
|
||||
#include <QSysInfo>
|
||||
|
||||
#include "base/path.h"
|
||||
@@ -252,7 +253,7 @@ QString Utils::Misc::userFriendlyDuration(const qlonglong seconds, const qlonglo
|
||||
return QCoreApplication::translate("misc", "%1y %2d", "e.g: 2 years 10 days").arg(QString::number(years), QString::number(days));
|
||||
}
|
||||
|
||||
QString Utils::Misc::languageToLocalizedString(const QString &localeStr)
|
||||
QString Utils::Misc::languageToLocalizedString(const QStringView localeStr)
|
||||
{
|
||||
if (localeStr.startsWith(u"eo", Qt::CaseInsensitive))
|
||||
{
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "base/pathfwd.h"
|
||||
|
||||
class QString;
|
||||
class QStringView;
|
||||
|
||||
/* Miscellaneous functions that can be useful */
|
||||
namespace Utils::Misc
|
||||
@@ -82,5 +83,5 @@ namespace Utils::Misc
|
||||
// time duration like "1d 2h 10m".
|
||||
QString userFriendlyDuration(qlonglong seconds, qlonglong maxCap = -1, TimeResolution resolution = TimeResolution::Minutes);
|
||||
|
||||
QString languageToLocalizedString(const QString &localeStr);
|
||||
QString languageToLocalizedString(QStringView localeStr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user