mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 20:58:07 -06:00
Construct QString more efficiently
This commit is contained in:
@@ -1810,7 +1810,7 @@ bool Session::deleteTorrent(const InfoHash &hash, const DeleteOption deleteOptio
|
||||
// Remove it from torrent resume directory
|
||||
const QDir resumeDataDir(m_resumeFolderPath);
|
||||
QStringList filters;
|
||||
filters << QString("%1.*").arg(torrent->hash());
|
||||
filters << QString::fromLatin1("%1.*").arg(torrent->hash());
|
||||
const QStringList files = resumeDataDir.entryList(filters, QDir::Files, QDir::Unsorted);
|
||||
for (const QString &file : files)
|
||||
Utils::Fs::forceRemove(resumeDataDir.absoluteFilePath(file));
|
||||
@@ -2457,8 +2457,8 @@ void Session::exportTorrentFile(TorrentHandle *const torrent, TorrentExportFolde
|
||||
((folder == TorrentExportFolder::Finished) && !finishedTorrentExportDirectory().isEmpty()));
|
||||
|
||||
const QString validName = Utils::Fs::toValidFileSystemName(torrent->name());
|
||||
const QString torrentFilename = QString("%1.torrent").arg(torrent->hash());
|
||||
QString torrentExportFilename = QString("%1.torrent").arg(validName);
|
||||
const QString torrentFilename = QString::fromLatin1("%1.torrent").arg(torrent->hash());
|
||||
QString torrentExportFilename = QString::fromLatin1("%1.torrent").arg(validName);
|
||||
const QString torrentPath = QDir(m_resumeFolderPath).absoluteFilePath(torrentFilename);
|
||||
const QDir exportPath(folder == TorrentExportFolder::Regular ? torrentExportDirectory() : finishedTorrentExportDirectory());
|
||||
if (exportPath.exists() || exportPath.mkpath(exportPath.absolutePath())) {
|
||||
@@ -2466,7 +2466,7 @@ void Session::exportTorrentFile(TorrentHandle *const torrent, TorrentExportFolde
|
||||
int counter = 0;
|
||||
while (QFile::exists(newTorrentPath) && !Utils::Fs::sameFiles(torrentPath, newTorrentPath)) {
|
||||
// Append number to torrent name to make it unique
|
||||
torrentExportFilename = QString("%1 %2.torrent").arg(validName).arg(++counter);
|
||||
torrentExportFilename = QString::fromLatin1("%1 %2.torrent").arg(validName).arg(++counter);
|
||||
newTorrentPath = exportPath.absoluteFilePath(torrentExportFilename);
|
||||
}
|
||||
|
||||
@@ -3923,7 +3923,7 @@ void Session::handleTorrentResumeDataReady(TorrentHandle *const torrent, const l
|
||||
out.reserve(1024 * 1024); // most fastresume file sizes are under 1 MB
|
||||
lt::bencode(std::back_inserter(out), data);
|
||||
|
||||
const QString filename = QString("%1.fastresume").arg(torrent->hash());
|
||||
const QString filename = QString::fromLatin1("%1.fastresume").arg(torrent->hash());
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
QMetaObject::invokeMethod(m_resumeDataSavingManager
|
||||
, [this, filename, out]() { m_resumeDataSavingManager->save(filename, out); });
|
||||
@@ -4160,7 +4160,7 @@ void Session::startUpTorrents()
|
||||
int resumedTorrentsCount = 0;
|
||||
const auto startupTorrent = [this, &resumeDataDir, &resumedTorrentsCount](const TorrentResumeData ¶ms)
|
||||
{
|
||||
const QString filePath = resumeDataDir.filePath(QString("%1.torrent").arg(params.hash));
|
||||
const QString filePath = resumeDataDir.filePath(QString::fromLatin1("%1.torrent").arg(params.hash));
|
||||
qDebug() << "Starting up torrent" << params.hash << "...";
|
||||
if (!addTorrent_impl(params.addTorrentData, params.magnetUri, TorrentInfo::loadFromFile(filePath), params.data))
|
||||
LogMsg(tr("Unable to resume torrent '%1'.", "e.g: Unable to resume torrent 'hash'.")
|
||||
|
||||
@@ -54,7 +54,7 @@ QByteArray Http::toByteArray(Response response)
|
||||
|
||||
// Header Fields
|
||||
for (auto i = response.headers.constBegin(); i != response.headers.constEnd(); ++i)
|
||||
buf += QString("%1: %2").arg(i.key(), i.value()).toLatin1().append(CRLF);
|
||||
buf += QString::fromLatin1("%1: %2").arg(i.key(), i.value()).toLatin1().append(CRLF);
|
||||
|
||||
// the first empty line
|
||||
buf += CRLF;
|
||||
|
||||
@@ -88,7 +88,7 @@ void GeoIPManager::loadDatabase()
|
||||
m_geoIPDatabase = nullptr;
|
||||
|
||||
const QString filepath = Utils::Fs::expandPathAbs(
|
||||
QString("%1%2/%3").arg(specialFolderLocation(SpecialFolder::Data), GEODB_FOLDER, GEODB_FILENAME));
|
||||
QString::fromLatin1("%1%2/%3").arg(specialFolderLocation(SpecialFolder::Data), GEODB_FOLDER, GEODB_FILENAME));
|
||||
|
||||
QString error;
|
||||
m_geoIPDatabase = GeoIPDatabase::load(filepath, error);
|
||||
@@ -442,7 +442,7 @@ void GeoIPManager::downloadFinished(const DownloadResult &result)
|
||||
specialFolderLocation(SpecialFolder::Data) + GEODB_FOLDER);
|
||||
if (!QDir(targetPath).exists())
|
||||
QDir().mkpath(targetPath);
|
||||
QFile targetFile(QString("%1/%2").arg(targetPath, GEODB_FILENAME));
|
||||
QFile targetFile(QString::fromLatin1("%1/%2").arg(targetPath, GEODB_FILENAME));
|
||||
if (!targetFile.open(QFile::WriteOnly) || (targetFile.write(data) == -1))
|
||||
LogMsg(tr("Couldn't save downloaded IP geolocation database file."), Log::WARNING);
|
||||
else
|
||||
|
||||
@@ -139,17 +139,17 @@ void ProxyConfigurationManager::configureProxy()
|
||||
if (!m_isProxyOnlyForTorrents) {
|
||||
switch (m_config.type) {
|
||||
case ProxyType::HTTP_PW:
|
||||
proxyStrHTTP = QString("http://%1:%2@%3:%4").arg(m_config.username
|
||||
proxyStrHTTP = QString::fromLatin1("http://%1:%2@%3:%4").arg(m_config.username
|
||||
, m_config.password, m_config.ip, QString::number(m_config.port));
|
||||
break;
|
||||
case ProxyType::HTTP:
|
||||
proxyStrHTTP = QString("http://%1:%2").arg(m_config.ip, QString::number(m_config.port));
|
||||
proxyStrHTTP = QString::fromLatin1("http://%1:%2").arg(m_config.ip, QString::number(m_config.port));
|
||||
break;
|
||||
case ProxyType::SOCKS5:
|
||||
proxyStrSOCK = QString("%1:%2").arg(m_config.ip, QString::number(m_config.port));
|
||||
proxyStrSOCK = QString::fromLatin1("%1:%2").arg(m_config.ip, QString::number(m_config.port));
|
||||
break;
|
||||
case ProxyType::SOCKS5_PW:
|
||||
proxyStrSOCK = QString("%1:%2@%3:%4").arg(m_config.username
|
||||
proxyStrSOCK = QString::fromLatin1("%1:%2@%3:%4").arg(m_config.username
|
||||
, m_config.password, m_config.ip, QString::number(m_config.port));
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -100,7 +100,7 @@ QPointer<AutoDownloader> AutoDownloader::m_instance = nullptr;
|
||||
|
||||
QString computeSmartFilterRegex(const QStringList &filters)
|
||||
{
|
||||
return QString("(?:_|\\b)(?:%1)(?:_|\\b)").arg(filters.join(QString(")|(?:")));
|
||||
return QString::fromLatin1("(?:_|\\b)(?:%1)(?:_|\\b)").arg(filters.join(QString(")|(?:")));
|
||||
}
|
||||
|
||||
AutoDownloader::AutoDownloader()
|
||||
|
||||
@@ -323,7 +323,7 @@ bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString &articleTitl
|
||||
}
|
||||
}
|
||||
else { // Single number
|
||||
const QString expStr {QString("\\b(?:s0?%1[ -_\\.]?e0?%2|%1x0?%2)(?:\\D|\\b)").arg(season, episode)};
|
||||
const QString expStr {QString::fromLatin1("\\b(?:s0?%1[ -_\\.]?e0?%2|%1x0?%2)(?:\\D|\\b)").arg(season, episode)};
|
||||
if (cachedRegex(expStr).match(articleTitle).hasMatch())
|
||||
return true;
|
||||
}
|
||||
@@ -354,7 +354,7 @@ bool AutoDownloadRule::matchesSmartEpisodeFilter(const QString &articleTitle) co
|
||||
if (!isRepack && !isProper)
|
||||
return false;
|
||||
|
||||
const QString fullEpisodeStr = QString("%1%2%3").arg(episodeStr,
|
||||
const QString fullEpisodeStr = QString::fromLatin1("%1%2%3").arg(episodeStr,
|
||||
isRepack ? "-REPACK" : "",
|
||||
isProper ? "-PROPER" : "");
|
||||
const bool previouslyMatchedFull = m_dataPtr->previouslyMatchedEpisodes.contains(fullEpisodeStr);
|
||||
@@ -366,8 +366,8 @@ bool AutoDownloadRule::matchesSmartEpisodeFilter(const QString &articleTitle) co
|
||||
// If this is a REPACK and PROPER download, add the individual entries to the list
|
||||
// so we don't download those
|
||||
if (isRepack && isProper) {
|
||||
m_dataPtr->lastComputedEpisodes.append(QString("%1-REPACK").arg(episodeStr));
|
||||
m_dataPtr->lastComputedEpisodes.append(QString("%1-PROPER").arg(episodeStr));
|
||||
m_dataPtr->lastComputedEpisodes.append(episodeStr + QLatin1String("-REPACK"));
|
||||
m_dataPtr->lastComputedEpisodes.append(episodeStr + QLatin1String("-PROPER"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -400,7 +400,7 @@ void Feed::downloadIcon()
|
||||
// Download the RSS Feed icon
|
||||
// XXX: This works for most sites but it is not perfect
|
||||
const QUrl url(m_url);
|
||||
const auto iconUrl = QString("%1://%2/favicon.ico").arg(url.scheme(), url.host());
|
||||
const auto iconUrl = QString::fromLatin1("%1://%2/favicon.ico").arg(url.scheme(), url.host());
|
||||
Net::DownloadManager::instance()->download(
|
||||
Net::DownloadRequest(iconUrl).saveToFile(true)
|
||||
, this, &Feed::handleIconDownloadFinished);
|
||||
|
||||
@@ -330,7 +330,7 @@ void Session::loadFolder(const QJsonObject &jsonObj, Folder *folder)
|
||||
}
|
||||
else {
|
||||
LogMsg(tr("Couldn't load RSS Item '%1'. Invalid data format.")
|
||||
.arg(QString("%1\\%2").arg(folder->path(), key)), Log::WARNING);
|
||||
.arg(QString::fromLatin1("%1\\%2").arg(folder->path(), key)), Log::WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ void SearchPluginManager::enablePlugin(const QString &name, const bool enabled)
|
||||
// Updates shipped plugin
|
||||
void SearchPluginManager::updatePlugin(const QString &name)
|
||||
{
|
||||
installPlugin(QString("%1%2.py").arg(m_updateUrl, name));
|
||||
installPlugin(QString::fromLatin1("%1%2.py").arg(m_updateUrl, name));
|
||||
}
|
||||
|
||||
// Install or update plugin from file or url
|
||||
@@ -283,12 +283,12 @@ bool SearchPluginManager::uninstallPlugin(const QString &name)
|
||||
void SearchPluginManager::updateIconPath(PluginInfo *const plugin)
|
||||
{
|
||||
if (!plugin) return;
|
||||
QString iconPath = QString("%1/%2.png").arg(pluginsLocation(), plugin->name);
|
||||
QString iconPath = QString::fromLatin1("%1/%2.png").arg(pluginsLocation(), plugin->name);
|
||||
if (QFile::exists(iconPath)) {
|
||||
plugin->iconPath = iconPath;
|
||||
}
|
||||
else {
|
||||
iconPath = QString("%1/%2.ico").arg(pluginsLocation(), plugin->name);
|
||||
iconPath = QString::fromLatin1("%1/%2.ico").arg(pluginsLocation(), plugin->name);
|
||||
if (QFile::exists(iconPath))
|
||||
plugin->iconPath = iconPath;
|
||||
}
|
||||
@@ -338,7 +338,7 @@ QString SearchPluginManager::pluginFullName(const QString &pluginName)
|
||||
|
||||
QString SearchPluginManager::pluginsLocation()
|
||||
{
|
||||
return QString("%1/engines").arg(engineLocation());
|
||||
return QString::fromLatin1("%1/engines").arg(engineLocation());
|
||||
}
|
||||
|
||||
QString SearchPluginManager::engineLocation()
|
||||
@@ -526,7 +526,7 @@ bool SearchPluginManager::isUpdateNeeded(const QString &pluginName, const Plugin
|
||||
|
||||
QString SearchPluginManager::pluginPath(const QString &name)
|
||||
{
|
||||
return QString("%1/%2.py").arg(pluginsLocation(), name);
|
||||
return QString::fromLatin1("%1/%2.py").arg(pluginsLocation(), name);
|
||||
}
|
||||
|
||||
PluginVersion SearchPluginManager::getPluginVersion(const QString &filePath)
|
||||
|
||||
Reference in New Issue
Block a user