mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
Merge pull request #9824 from thalieht/style
Convert all foreach() to range-based for()
This commit is contained in:
commit
0ab5b8fcba
84 changed files with 471 additions and 441 deletions
|
@ -428,7 +428,7 @@ void Application::processParams(const QStringList ¶ms)
|
||||||
BitTorrent::AddTorrentParams torrentParams;
|
BitTorrent::AddTorrentParams torrentParams;
|
||||||
TriStateBool skipTorrentDialog;
|
TriStateBool skipTorrentDialog;
|
||||||
|
|
||||||
foreach (QString param, params) {
|
for (QString param : params) {
|
||||||
param = param.trimmed();
|
param = param.trimmed();
|
||||||
|
|
||||||
// Process strings indicating options specified by the user.
|
// Process strings indicating options specified by the user.
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
#include "base/utils/string.h"
|
#include "base/utils/string.h"
|
||||||
|
|
||||||
|
@ -486,7 +487,7 @@ CommandLineParameterError::CommandLineParameterError(const QString &messageForUs
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& CommandLineParameterError::messageForUser() const
|
const QString &CommandLineParameterError::messageForUser() const
|
||||||
{
|
{
|
||||||
return m_messageForUser;
|
return m_messageForUser;
|
||||||
}
|
}
|
||||||
|
@ -497,7 +498,7 @@ QString wrapText(const QString &text, int initialIndentation = USAGE_TEXT_COLUMN
|
||||||
QStringList lines = {words.first()};
|
QStringList lines = {words.first()};
|
||||||
int currentLineMaxLength = wrapAtColumn - initialIndentation;
|
int currentLineMaxLength = wrapAtColumn - initialIndentation;
|
||||||
|
|
||||||
foreach (const QString &word, words.mid(1)) {
|
for (const QString &word : asConst(words.mid(1))) {
|
||||||
if (lines.last().length() + word.length() + 1 < currentLineMaxLength) {
|
if (lines.last().length() + word.length() + 1 < currentLineMaxLength) {
|
||||||
lines.last().append(' ' + word);
|
lines.last().append(' ' + word);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/logger.h"
|
#include "base/logger.h"
|
||||||
#include "base/utils/fs.h"
|
#include "base/utils/fs.h"
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ FileLogger::FileLogger(const QString &path, const bool backup, const int maxSize
|
||||||
this->deleteOld(age, ageType);
|
this->deleteOld(age, ageType);
|
||||||
|
|
||||||
const Logger *const logger = Logger::instance();
|
const Logger *const logger = Logger::instance();
|
||||||
foreach (const Log::Msg &msg, logger->getMessages())
|
for (const Log::Msg &msg : asConst(logger->getMessages()))
|
||||||
addLogMessage(msg);
|
addLogMessage(msg);
|
||||||
|
|
||||||
connect(logger, &Logger::newLogMessage, this, &FileLogger::addLogMessage);
|
connect(logger, &Logger::newLogMessage, this, &FileLogger::addLogMessage);
|
||||||
|
@ -87,7 +88,7 @@ void FileLogger::deleteOld(const int age, const FileLogAgeType ageType)
|
||||||
QDateTime date = QDateTime::currentDateTime();
|
QDateTime date = QDateTime::currentDateTime();
|
||||||
QDir dir(Utils::Fs::branchPath(m_path));
|
QDir dir(Utils::Fs::branchPath(m_path));
|
||||||
|
|
||||||
foreach (const QFileInfo file, dir.entryInfoList(QStringList("qbittorrent.log.bak*"), QDir::Files | QDir::Writable, QDir::Time | QDir::Reversed)) {
|
for (const QFileInfo &file : asConst(dir.entryInfoList(QStringList("qbittorrent.log.bak*"), QDir::Files | QDir::Writable, QDir::Time | QDir::Reversed))) {
|
||||||
QDateTime modificationDate = file.lastModified();
|
QDateTime modificationDate = file.lastModified();
|
||||||
switch (ageType) {
|
switch (ageType) {
|
||||||
case DAYS:
|
case DAYS:
|
||||||
|
|
|
@ -202,7 +202,7 @@ int main(int argc, char *argv[])
|
||||||
// this is the default in Qt6
|
// this is the default in Qt6
|
||||||
app->setAttribute(Qt::AA_DisableWindowContextHelpButton);
|
app->setAttribute(Qt::AA_DisableWindowContextHelpButton);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif // Q_OS_WIN
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
// Since Apple made difficult for users to set PATH, we set here for convenience.
|
// Since Apple made difficult for users to set PATH, we set here for convenience.
|
||||||
|
|
|
@ -83,7 +83,7 @@ bool userAcceptsUpgrade()
|
||||||
msgBox.move(Utils::Misc::screenCenter(&msgBox));
|
msgBox.move(Utils::Misc::screenCenter(&msgBox));
|
||||||
if (msgBox.exec() == QMessageBox::Ok)
|
if (msgBox.exec() == QMessageBox::Ok)
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif // DISABLE_GUI
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -179,9 +179,9 @@ bool upgrade(bool ask = true)
|
||||||
|
|
||||||
// ****************************************************************************************
|
// ****************************************************************************************
|
||||||
// Silently converts old v3.3.x .fastresume files
|
// Silently converts old v3.3.x .fastresume files
|
||||||
QStringList backupFiles_3_3 = backupFolderDir.entryList(
|
const QStringList backupFiles_3_3 = backupFolderDir.entryList(
|
||||||
QStringList(QLatin1String("*.fastresume.*")), QDir::Files, QDir::Unsorted);
|
QStringList(QLatin1String("*.fastresume.*")), QDir::Files, QDir::Unsorted);
|
||||||
foreach (const QString &backupFile, backupFiles_3_3)
|
for (const QString &backupFile : backupFiles_3_3)
|
||||||
upgradeResumeFile(backupFolderDir.absoluteFilePath(backupFile));
|
upgradeResumeFile(backupFolderDir.absoluteFilePath(backupFile));
|
||||||
// ****************************************************************************************
|
// ****************************************************************************************
|
||||||
|
|
||||||
|
@ -197,10 +197,10 @@ bool upgrade(bool ask = true)
|
||||||
|
|
||||||
if (ask && !userAcceptsUpgrade()) return false;
|
if (ask && !userAcceptsUpgrade()) return false;
|
||||||
|
|
||||||
QStringList backupFiles = backupFolderDir.entryList(
|
const QStringList backupFiles = backupFolderDir.entryList(
|
||||||
QStringList(QLatin1String("*.fastresume")), QDir::Files, QDir::Unsorted);
|
QStringList(QLatin1String("*.fastresume")), QDir::Files, QDir::Unsorted);
|
||||||
const QRegularExpression rx(QLatin1String("^([A-Fa-f0-9]{40})\\.fastresume$"));
|
const QRegularExpression rx(QLatin1String("^([A-Fa-f0-9]{40})\\.fastresume$"));
|
||||||
foreach (QString backupFile, backupFiles) {
|
for (const QString &backupFile : backupFiles) {
|
||||||
const QRegularExpressionMatch rxMatch = rx.match(backupFile);
|
const QRegularExpressionMatch rxMatch = rx.match(backupFile);
|
||||||
if (rxMatch.hasMatch()) {
|
if (rxMatch.hasMatch()) {
|
||||||
const QString hashStr = rxMatch.captured(1);
|
const QString hashStr = rxMatch.captured(1);
|
||||||
|
@ -265,7 +265,7 @@ void migratePlistToIni(const QString &application)
|
||||||
plistFile->setFallbacksEnabled(false);
|
plistFile->setFallbacksEnabled(false);
|
||||||
const QStringList plist = plistFile->allKeys();
|
const QStringList plist = plistFile->allKeys();
|
||||||
if (!plist.isEmpty()) {
|
if (!plist.isEmpty()) {
|
||||||
foreach (const QString &key, plist)
|
for (const QString &key : plist)
|
||||||
iniFile.setValue(key, plistFile->value(key));
|
iniFile.setValue(key, plistFile->value(key));
|
||||||
plistFile->clear();
|
plistFile->clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,10 +83,10 @@ MagnetUri::MagnetUri(const QString &source)
|
||||||
m_hash = m_addTorrentParams.info_hash;
|
m_hash = m_addTorrentParams.info_hash;
|
||||||
m_name = QString::fromStdString(m_addTorrentParams.name);
|
m_name = QString::fromStdString(m_addTorrentParams.name);
|
||||||
|
|
||||||
foreach (const std::string &tracker, m_addTorrentParams.trackers)
|
for (const std::string &tracker : m_addTorrentParams.trackers)
|
||||||
m_trackers.append(QString::fromStdString(tracker));
|
m_trackers.append(QString::fromStdString(tracker));
|
||||||
|
|
||||||
foreach (const std::string &urlSeed, m_addTorrentParams.url_seeds)
|
for (const std::string &urlSeed : m_addTorrentParams.url_seeds)
|
||||||
m_urlSeeds.append(QUrl(urlSeed.c_str()));
|
m_urlSeeds.append(QUrl(urlSeed.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ namespace
|
||||||
|
|
||||||
for (auto i = categories.cbegin(); i != categories.cend(); ++i) {
|
for (auto i = categories.cbegin(); i != categories.cend(); ++i) {
|
||||||
const QString &category = i.key();
|
const QString &category = i.key();
|
||||||
foreach (const QString &subcat, Session::expandCategory(category)) {
|
for (const QString &subcat : asConst(Session::expandCategory(category))) {
|
||||||
if (!expanded.contains(subcat))
|
if (!expanded.contains(subcat))
|
||||||
expanded[subcat] = "";
|
expanded[subcat] = "";
|
||||||
}
|
}
|
||||||
|
@ -469,7 +469,7 @@ Session::Session(QObject *parent)
|
||||||
});
|
});
|
||||||
|
|
||||||
configurePeerClasses();
|
configurePeerClasses();
|
||||||
#endif
|
#endif // LIBTORRENT_VERSION_NUM < 10100
|
||||||
|
|
||||||
// Enabling plugins
|
// Enabling plugins
|
||||||
//m_nativeSession->add_extension(&libt::create_metadata_plugin);
|
//m_nativeSession->add_extension(&libt::create_metadata_plugin);
|
||||||
|
@ -610,7 +610,7 @@ void Session::setTempPathEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
if (enabled != isTempPathEnabled()) {
|
if (enabled != isTempPathEnabled()) {
|
||||||
m_isTempPathEnabled = enabled;
|
m_isTempPathEnabled = enabled;
|
||||||
foreach (TorrentHandle *const torrent, m_torrents)
|
for (TorrentHandle *const torrent : asConst(m_torrents))
|
||||||
torrent->handleTempPathChanged();
|
torrent->handleTempPathChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -624,7 +624,7 @@ void Session::setAppendExtensionEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
if (isAppendExtensionEnabled() != enabled) {
|
if (isAppendExtensionEnabled() != enabled) {
|
||||||
// append or remove .!qB extension for incomplete files
|
// append or remove .!qB extension for incomplete files
|
||||||
foreach (TorrentHandle *const torrent, m_torrents)
|
for (TorrentHandle *const torrent : asConst(m_torrents))
|
||||||
torrent->handleAppendExtensionToggled();
|
torrent->handleAppendExtensionToggled();
|
||||||
|
|
||||||
m_isAppendExtensionEnabled = enabled;
|
m_isAppendExtensionEnabled = enabled;
|
||||||
|
@ -752,7 +752,7 @@ bool Session::addCategory(const QString &name, const QString &savePath)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (isSubcategoriesEnabled()) {
|
if (isSubcategoriesEnabled()) {
|
||||||
foreach (const QString &parent, expandCategory(name)) {
|
for (const QString &parent : asConst(expandCategory(name))) {
|
||||||
if ((parent != name) && !m_categories.contains(parent)) {
|
if ((parent != name) && !m_categories.contains(parent)) {
|
||||||
m_categories[parent] = "";
|
m_categories[parent] = "";
|
||||||
emit categoryAdded(parent);
|
emit categoryAdded(parent);
|
||||||
|
@ -775,12 +775,12 @@ bool Session::editCategory(const QString &name, const QString &savePath)
|
||||||
m_categories[name] = savePath;
|
m_categories[name] = savePath;
|
||||||
m_storedCategories = map_cast(m_categories);
|
m_storedCategories = map_cast(m_categories);
|
||||||
if (isDisableAutoTMMWhenCategorySavePathChanged()) {
|
if (isDisableAutoTMMWhenCategorySavePathChanged()) {
|
||||||
foreach (TorrentHandle *const torrent, torrents())
|
for (TorrentHandle *const torrent : asConst(torrents()))
|
||||||
if (torrent->category() == name)
|
if (torrent->category() == name)
|
||||||
torrent->setAutoTMMEnabled(false);
|
torrent->setAutoTMMEnabled(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
foreach (TorrentHandle *const torrent, torrents())
|
for (TorrentHandle *const torrent : asConst(torrents()))
|
||||||
if (torrent->category() == name)
|
if (torrent->category() == name)
|
||||||
torrent->handleCategorySavePathChanged();
|
torrent->handleCategorySavePathChanged();
|
||||||
}
|
}
|
||||||
|
@ -790,7 +790,7 @@ bool Session::editCategory(const QString &name, const QString &savePath)
|
||||||
|
|
||||||
bool Session::removeCategory(const QString &name)
|
bool Session::removeCategory(const QString &name)
|
||||||
{
|
{
|
||||||
foreach (TorrentHandle *const torrent, torrents())
|
for (TorrentHandle *const torrent : asConst(torrents()))
|
||||||
if (torrent->belongsToCategory(name))
|
if (torrent->belongsToCategory(name))
|
||||||
torrent->setCategory("");
|
torrent->setCategory("");
|
||||||
|
|
||||||
|
@ -877,7 +877,7 @@ bool Session::addTag(const QString &tag)
|
||||||
bool Session::removeTag(const QString &tag)
|
bool Session::removeTag(const QString &tag)
|
||||||
{
|
{
|
||||||
if (m_tags.remove(tag)) {
|
if (m_tags.remove(tag)) {
|
||||||
foreach (TorrentHandle *const torrent, torrents())
|
for (TorrentHandle *const torrent : asConst(torrents()))
|
||||||
torrent->removeTag(tag);
|
torrent->removeTag(tag);
|
||||||
m_storedTags = m_tags.toList();
|
m_storedTags = m_tags.toList();
|
||||||
emit tagRemoved(tag);
|
emit tagRemoved(tag);
|
||||||
|
@ -1085,7 +1085,7 @@ void Session::configure()
|
||||||
void Session::processBannedIPs(libt::ip_filter &filter)
|
void Session::processBannedIPs(libt::ip_filter &filter)
|
||||||
{
|
{
|
||||||
// First, import current filter
|
// First, import current filter
|
||||||
foreach (const QString &ip, m_bannedIPs.value()) {
|
for (const QString &ip : asConst(m_bannedIPs.value())) {
|
||||||
boost::system::error_code ec;
|
boost::system::error_code ec;
|
||||||
libt::address addr = libt::address::from_string(ip.toLatin1().constData(), ec);
|
libt::address addr = libt::address::from_string(ip.toLatin1().constData(), ec);
|
||||||
Q_ASSERT(!ec);
|
Q_ASSERT(!ec);
|
||||||
|
@ -1204,7 +1204,7 @@ void Session::configure(libtorrent::settings_pack &settingsPack)
|
||||||
const ushort port = this->port();
|
const ushort port = this->port();
|
||||||
std::pair<int, int> ports(port, port);
|
std::pair<int, int> ports(port, port);
|
||||||
settingsPack.set_int(libt::settings_pack::max_retry_port_bind, ports.second - ports.first);
|
settingsPack.set_int(libt::settings_pack::max_retry_port_bind, ports.second - ports.first);
|
||||||
foreach (QString ip, getListeningIPs()) {
|
for (QString ip : getListeningIPs()) {
|
||||||
libt::error_code ec;
|
libt::error_code ec;
|
||||||
std::string interfacesStr;
|
std::string interfacesStr;
|
||||||
|
|
||||||
|
@ -1253,7 +1253,7 @@ void Session::configure(libtorrent::settings_pack &settingsPack)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
settingsPack.set_str(libt::settings_pack::outgoing_interfaces, networkInterface().toStdString());
|
settingsPack.set_str(libt::settings_pack::outgoing_interfaces, networkInterface().toStdString());
|
||||||
#endif
|
#endif // Q_OS_WIN
|
||||||
m_listenInterfaceChanged = false;
|
m_listenInterfaceChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1462,7 +1462,7 @@ void Session::configurePeerClasses()
|
||||||
, 1 << libt::session::global_peer_class_id);
|
, 1 << libt::session::global_peer_class_id);
|
||||||
}
|
}
|
||||||
catch (std::exception &) {}
|
catch (std::exception &) {}
|
||||||
#endif
|
#endif // TORRENT_USE_IPV6
|
||||||
if (ignoreLimitsOnLAN()) {
|
if (ignoreLimitsOnLAN()) {
|
||||||
// local networks
|
// local networks
|
||||||
f.add_rule(libt::address_v4::from_string("10.0.0.0")
|
f.add_rule(libt::address_v4::from_string("10.0.0.0")
|
||||||
|
@ -1501,7 +1501,7 @@ void Session::configurePeerClasses()
|
||||||
, 1 << libt::session::local_peer_class_id);
|
, 1 << libt::session::local_peer_class_id);
|
||||||
}
|
}
|
||||||
catch (std::exception &) {}
|
catch (std::exception &) {}
|
||||||
#endif
|
#endif // TORRENT_USE_IPV6
|
||||||
}
|
}
|
||||||
m_nativeSession->set_peer_class_filter(f);
|
m_nativeSession->set_peer_class_filter(f);
|
||||||
|
|
||||||
|
@ -1518,7 +1518,7 @@ void Session::configurePeerClasses()
|
||||||
m_nativeSession->set_peer_class_type_filter(peerClassTypeFilter);
|
m_nativeSession->set_peer_class_type_filter(peerClassTypeFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else // LIBTORRENT_VERSION_NUM >= 10100
|
||||||
|
|
||||||
void Session::adjustLimits(libt::session_settings &sessionSettings)
|
void Session::adjustLimits(libt::session_settings &sessionSettings)
|
||||||
{
|
{
|
||||||
|
@ -1735,7 +1735,7 @@ void Session::configure(libtorrent::session_settings &sessionSettings)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif // LIBTORRENT_VERSION_NUM >= 10100
|
||||||
|
|
||||||
void Session::enableTracker(bool enable)
|
void Session::enableTracker(bool enable)
|
||||||
{
|
{
|
||||||
|
@ -1770,7 +1770,7 @@ void Session::enableBandwidthScheduler()
|
||||||
void Session::populateAdditionalTrackers()
|
void Session::populateAdditionalTrackers()
|
||||||
{
|
{
|
||||||
m_additionalTrackerList.clear();
|
m_additionalTrackerList.clear();
|
||||||
foreach (QString tracker, additionalTrackers().split('\n')) {
|
for (QString tracker : asConst(additionalTrackers().split('\n'))) {
|
||||||
tracker = tracker.trimmed();
|
tracker = tracker.trimmed();
|
||||||
if (!tracker.isEmpty())
|
if (!tracker.isEmpty())
|
||||||
m_additionalTrackerList << tracker;
|
m_additionalTrackerList << tracker;
|
||||||
|
@ -1781,7 +1781,7 @@ void Session::processShareLimits()
|
||||||
{
|
{
|
||||||
qDebug("Processing share limits...");
|
qDebug("Processing share limits...");
|
||||||
|
|
||||||
foreach (TorrentHandle *const torrent, m_torrents) {
|
for (TorrentHandle *const torrent : asConst(torrents())) {
|
||||||
if (torrent->isSeed() && !torrent->isForced()) {
|
if (torrent->isSeed() && !torrent->isForced()) {
|
||||||
if (torrent->ratioLimit() != TorrentHandle::NO_RATIO_LIMIT) {
|
if (torrent->ratioLimit() != TorrentHandle::NO_RATIO_LIMIT) {
|
||||||
const qreal ratio = torrent->realRatio();
|
const qreal ratio = torrent->realRatio();
|
||||||
|
@ -1934,7 +1934,7 @@ bool Session::deleteTorrent(const QString &hash, bool deleteLocalFiles)
|
||||||
m_nativeSession->remove_torrent(torrent->nativeHandle(), libt::session::delete_partfile);
|
m_nativeSession->remove_torrent(torrent->nativeHandle(), libt::session::delete_partfile);
|
||||||
#endif
|
#endif
|
||||||
// Remove unwanted and incomplete files
|
// Remove unwanted and incomplete files
|
||||||
foreach (const QString &unwantedFile, unwantedFiles) {
|
for (const QString &unwantedFile : asConst(unwantedFiles)) {
|
||||||
qDebug("Removing unwanted file: %s", qUtf8Printable(unwantedFile));
|
qDebug("Removing unwanted file: %s", qUtf8Printable(unwantedFile));
|
||||||
Utils::Fs::forceRemove(unwantedFile);
|
Utils::Fs::forceRemove(unwantedFile);
|
||||||
const QString parentFolder = Utils::Fs::branchPath(unwantedFile);
|
const QString parentFolder = Utils::Fs::branchPath(unwantedFile);
|
||||||
|
@ -1948,7 +1948,7 @@ bool Session::deleteTorrent(const QString &hash, bool deleteLocalFiles)
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
filters << QString("%1.*").arg(torrent->hash());
|
filters << QString("%1.*").arg(torrent->hash());
|
||||||
const QStringList files = resumeDataDir.entryList(filters, QDir::Files, QDir::Unsorted);
|
const QStringList files = resumeDataDir.entryList(filters, QDir::Files, QDir::Unsorted);
|
||||||
foreach (const QString &file, files)
|
for (const QString &file : files)
|
||||||
Utils::Fs::forceRemove(resumeDataDir.absoluteFilePath(file));
|
Utils::Fs::forceRemove(resumeDataDir.absoluteFilePath(file));
|
||||||
|
|
||||||
delete torrent;
|
delete torrent;
|
||||||
|
@ -1983,8 +1983,8 @@ void Session::increaseTorrentsPriority(const QStringList &hashes)
|
||||||
std::greater<QPair<int, TorrentHandle *>>> torrentQueue;
|
std::greater<QPair<int, TorrentHandle *>>> torrentQueue;
|
||||||
|
|
||||||
// Sort torrents by priority
|
// Sort torrents by priority
|
||||||
foreach (const InfoHash &hash, hashes) {
|
for (const InfoHash infoHash : hashes) {
|
||||||
TorrentHandle *const torrent = m_torrents.value(hash);
|
TorrentHandle *const torrent = m_torrents.value(infoHash);
|
||||||
if (torrent && !torrent->isSeed())
|
if (torrent && !torrent->isSeed())
|
||||||
torrentQueue.push(qMakePair(torrent->queuePosition(), torrent));
|
torrentQueue.push(qMakePair(torrent->queuePosition(), torrent));
|
||||||
}
|
}
|
||||||
|
@ -2006,8 +2006,8 @@ void Session::decreaseTorrentsPriority(const QStringList &hashes)
|
||||||
std::less<QPair<int, TorrentHandle *>>> torrentQueue;
|
std::less<QPair<int, TorrentHandle *>>> torrentQueue;
|
||||||
|
|
||||||
// Sort torrents by priority
|
// Sort torrents by priority
|
||||||
foreach (const InfoHash &hash, hashes) {
|
for (const InfoHash infoHash : hashes) {
|
||||||
TorrentHandle *const torrent = m_torrents.value(hash);
|
TorrentHandle *const torrent = m_torrents.value(infoHash);
|
||||||
if (torrent && !torrent->isSeed())
|
if (torrent && !torrent->isSeed())
|
||||||
torrentQueue.push(qMakePair(torrent->queuePosition(), torrent));
|
torrentQueue.push(qMakePair(torrent->queuePosition(), torrent));
|
||||||
}
|
}
|
||||||
|
@ -2032,8 +2032,8 @@ void Session::topTorrentsPriority(const QStringList &hashes)
|
||||||
std::greater<QPair<int, TorrentHandle *>>> torrentQueue;
|
std::greater<QPair<int, TorrentHandle *>>> torrentQueue;
|
||||||
|
|
||||||
// Sort torrents by priority
|
// Sort torrents by priority
|
||||||
foreach (const InfoHash &hash, hashes) {
|
for (const InfoHash infoHash : hashes) {
|
||||||
TorrentHandle *const torrent = m_torrents.value(hash);
|
TorrentHandle *const torrent = m_torrents.value(infoHash);
|
||||||
if (torrent && !torrent->isSeed())
|
if (torrent && !torrent->isSeed())
|
||||||
torrentQueue.push(qMakePair(torrent->queuePosition(), torrent));
|
torrentQueue.push(qMakePair(torrent->queuePosition(), torrent));
|
||||||
}
|
}
|
||||||
|
@ -2055,8 +2055,8 @@ void Session::bottomTorrentsPriority(const QStringList &hashes)
|
||||||
std::less<QPair<int, TorrentHandle *>>> torrentQueue;
|
std::less<QPair<int, TorrentHandle *>>> torrentQueue;
|
||||||
|
|
||||||
// Sort torrents by priority
|
// Sort torrents by priority
|
||||||
foreach (const InfoHash &hash, hashes) {
|
for (const InfoHash infoHash : hashes) {
|
||||||
TorrentHandle *const torrent = m_torrents.value(hash);
|
TorrentHandle *const torrent = m_torrents.value(infoHash);
|
||||||
if (torrent && !torrent->isSeed())
|
if (torrent && !torrent->isSeed())
|
||||||
torrentQueue.push(qMakePair(torrent->queuePosition(), torrent));
|
torrentQueue.push(qMakePair(torrent->queuePosition(), torrent));
|
||||||
}
|
}
|
||||||
|
@ -2367,7 +2367,7 @@ void Session::exportTorrentFile(TorrentHandle *const torrent, TorrentExportFolde
|
||||||
|
|
||||||
void Session::generateResumeData(bool final)
|
void Session::generateResumeData(bool final)
|
||||||
{
|
{
|
||||||
foreach (TorrentHandle *const torrent, m_torrents) {
|
for (TorrentHandle *const torrent : asConst(m_torrents)) {
|
||||||
if (!torrent->isValid()) continue;
|
if (!torrent->isValid()) continue;
|
||||||
if (torrent->isChecking() || torrent->isPaused()) continue;
|
if (torrent->isChecking() || torrent->isPaused()) continue;
|
||||||
if (!final && !torrent->needSaveResumeData()) continue;
|
if (!final && !torrent->needSaveResumeData()) continue;
|
||||||
|
@ -2397,7 +2397,7 @@ void Session::saveResumeData()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto a: alerts) {
|
for (const auto a : alerts) {
|
||||||
switch (a->type()) {
|
switch (a->type()) {
|
||||||
case libt::save_resume_data_failed_alert::alert_type:
|
case libt::save_resume_data_failed_alert::alert_type:
|
||||||
case libt::save_resume_data_alert::alert_type:
|
case libt::save_resume_data_alert::alert_type:
|
||||||
|
@ -2414,7 +2414,7 @@ void Session::saveResumeData()
|
||||||
void Session::saveTorrentsQueue()
|
void Session::saveTorrentsQueue()
|
||||||
{
|
{
|
||||||
QMap<int, QString> queue; // Use QMap since it should be ordered by key
|
QMap<int, QString> queue; // Use QMap since it should be ordered by key
|
||||||
for (const TorrentHandle *torrent : copyAsConst(torrents())) {
|
for (const TorrentHandle *torrent : asConst(torrents())) {
|
||||||
// We require actual (non-cached) queue position here!
|
// We require actual (non-cached) queue position here!
|
||||||
const int queuePos = torrent->nativeHandle().queue_position();
|
const int queuePos = torrent->nativeHandle().queue_position();
|
||||||
if (queuePos >= 0)
|
if (queuePos >= 0)
|
||||||
|
@ -2422,7 +2422,7 @@ void Session::saveTorrentsQueue()
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
for (const QString &hash : qAsConst(queue))
|
for (const QString &hash : asConst(queue))
|
||||||
data += (hash.toLatin1() + '\n');
|
data += (hash.toLatin1() + '\n');
|
||||||
|
|
||||||
const QString filename = QLatin1String {"queue"};
|
const QString filename = QLatin1String {"queue"};
|
||||||
|
@ -2444,10 +2444,10 @@ void Session::setDefaultSavePath(QString path)
|
||||||
m_defaultSavePath = path;
|
m_defaultSavePath = path;
|
||||||
|
|
||||||
if (isDisableAutoTMMWhenDefaultSavePathChanged())
|
if (isDisableAutoTMMWhenDefaultSavePathChanged())
|
||||||
foreach (TorrentHandle *const torrent, torrents())
|
for (TorrentHandle *const torrent : asConst(torrents()))
|
||||||
torrent->setAutoTMMEnabled(false);
|
torrent->setAutoTMMEnabled(false);
|
||||||
else
|
else
|
||||||
foreach (TorrentHandle *const torrent, torrents())
|
for (TorrentHandle *const torrent : asConst(torrents()))
|
||||||
torrent->handleCategorySavePathChanged();
|
torrent->handleCategorySavePathChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2458,7 +2458,7 @@ void Session::setTempPath(QString path)
|
||||||
|
|
||||||
m_tempPath = path;
|
m_tempPath = path;
|
||||||
|
|
||||||
foreach (TorrentHandle *const torrent, m_torrents)
|
for (TorrentHandle *const torrent : asConst(m_torrents))
|
||||||
torrent->handleTempPathChanged();
|
torrent->handleTempPathChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2532,7 +2532,7 @@ const QStringList Session::getListeningIPs()
|
||||||
QHostAddress ip;
|
QHostAddress ip;
|
||||||
QString ipString;
|
QString ipString;
|
||||||
QAbstractSocket::NetworkLayerProtocol protocol;
|
QAbstractSocket::NetworkLayerProtocol protocol;
|
||||||
foreach (const QNetworkAddressEntry &entry, addresses) {
|
for (const QNetworkAddressEntry &entry : addresses) {
|
||||||
ip = entry.ip();
|
ip = entry.ip();
|
||||||
ipString = ip.toString();
|
ipString = ip.toString();
|
||||||
protocol = ip.protocol();
|
protocol = ip.protocol();
|
||||||
|
@ -2578,7 +2578,7 @@ void Session::configureListeningInterface()
|
||||||
libt::error_code ec;
|
libt::error_code ec;
|
||||||
const QStringList IPs = getListeningIPs();
|
const QStringList IPs = getListeningIPs();
|
||||||
|
|
||||||
foreach (const QString ip, IPs) {
|
for (const QString ip : IPs) {
|
||||||
if (ip.isEmpty()) {
|
if (ip.isEmpty()) {
|
||||||
logger->addMessage(tr("qBittorrent is trying to listen on any interface port: %1", "e.g: qBittorrent is trying to listen on any interface port: TCP/6881").arg(QString::number(port)), Log::INFO);
|
logger->addMessage(tr("qBittorrent is trying to listen on any interface port: %1", "e.g: qBittorrent is trying to listen on any interface port: TCP/6881").arg(QString::number(port)), Log::INFO);
|
||||||
m_nativeSession->listen_on(ports, ec, 0, libt::session::listen_no_system_port);
|
m_nativeSession->listen_on(ports, ec, 0, libt::session::listen_no_system_port);
|
||||||
|
@ -2598,7 +2598,7 @@ void Session::configureListeningInterface()
|
||||||
#else
|
#else
|
||||||
m_listenInterfaceChanged = true;
|
m_listenInterfaceChanged = true;
|
||||||
configureDeferred();
|
configureDeferred();
|
||||||
#endif
|
#endif // LIBTORRENT_VERSION_NUM < 10100
|
||||||
}
|
}
|
||||||
|
|
||||||
int Session::globalDownloadSpeedLimit() const
|
int Session::globalDownloadSpeedLimit() const
|
||||||
|
@ -3011,7 +3011,7 @@ void Session::setMaxConnectionsPerTorrent(int max)
|
||||||
m_maxConnectionsPerTorrent = max;
|
m_maxConnectionsPerTorrent = max;
|
||||||
|
|
||||||
// Apply this to all session torrents
|
// Apply this to all session torrents
|
||||||
for (const auto &handle: m_nativeSession->get_torrents()) {
|
for (const auto &handle : m_nativeSession->get_torrents()) {
|
||||||
if (!handle.is_valid()) continue;
|
if (!handle.is_valid()) continue;
|
||||||
try {
|
try {
|
||||||
handle.set_max_connections(max);
|
handle.set_max_connections(max);
|
||||||
|
@ -3033,7 +3033,7 @@ void Session::setMaxUploadsPerTorrent(int max)
|
||||||
m_maxUploadsPerTorrent = max;
|
m_maxUploadsPerTorrent = max;
|
||||||
|
|
||||||
// Apply this to all session torrents
|
// Apply this to all session torrents
|
||||||
for (const auto &handle: m_nativeSession->get_torrents()) {
|
for (const auto &handle : m_nativeSession->get_torrents()) {
|
||||||
if (!handle.is_valid()) continue;
|
if (!handle.is_valid()) continue;
|
||||||
try {
|
try {
|
||||||
handle.set_max_uploads(max);
|
handle.set_max_uploads(max);
|
||||||
|
@ -3776,7 +3776,7 @@ void Session::handleTorrentTrackerWarning(TorrentHandle *const torrent, const QS
|
||||||
|
|
||||||
bool Session::hasPerTorrentRatioLimit() const
|
bool Session::hasPerTorrentRatioLimit() const
|
||||||
{
|
{
|
||||||
foreach (TorrentHandle *const torrent, m_torrents)
|
for (TorrentHandle *const torrent : asConst(m_torrents))
|
||||||
if (torrent->ratioLimit() >= 0) return true;
|
if (torrent->ratioLimit() >= 0) return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -3784,7 +3784,7 @@ bool Session::hasPerTorrentRatioLimit() const
|
||||||
|
|
||||||
bool Session::hasPerTorrentSeedingTimeLimit() const
|
bool Session::hasPerTorrentSeedingTimeLimit() const
|
||||||
{
|
{
|
||||||
foreach (TorrentHandle *const torrent, m_torrents)
|
for (TorrentHandle *const torrent : asConst(m_torrents))
|
||||||
if (torrent->seedingTimeLimit() >= 0) return true;
|
if (torrent->seedingTimeLimit() >= 0) return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -3928,7 +3928,7 @@ void Session::startUpTorrents()
|
||||||
QMap<int, TorrentResumeData> queuedResumeData;
|
QMap<int, TorrentResumeData> queuedResumeData;
|
||||||
int nextQueuePosition = 1;
|
int nextQueuePosition = 1;
|
||||||
int numOfRemappedFiles = 0;
|
int numOfRemappedFiles = 0;
|
||||||
foreach (const QString &fastresumeName, fastresumes) {
|
for (const QString &fastresumeName : asConst(fastresumes)) {
|
||||||
const QRegularExpressionMatch rxMatch = rx.match(fastresumeName);
|
const QRegularExpressionMatch rxMatch = rx.match(fastresumeName);
|
||||||
if (!rxMatch.hasMatch()) continue;
|
if (!rxMatch.hasMatch()) continue;
|
||||||
|
|
||||||
|
@ -3967,7 +3967,7 @@ void Session::startUpTorrents()
|
||||||
}
|
}
|
||||||
|
|
||||||
// starting up downloading torrents (queue position > 0)
|
// starting up downloading torrents (queue position > 0)
|
||||||
foreach (const TorrentResumeData &torrentResumeData, queuedResumeData)
|
for (const TorrentResumeData &torrentResumeData : asConst(queuedResumeData))
|
||||||
startupTorrent(torrentResumeData);
|
startupTorrent(torrentResumeData);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -3989,7 +3989,7 @@ void Session::startUpTorrents()
|
||||||
fastresumes = queue + fastresumes.toSet().subtract(queue.toSet()).toList();
|
fastresumes = queue + fastresumes.toSet().subtract(queue.toSet()).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const QString &fastresumeName : qAsConst(fastresumes)) {
|
for (const QString &fastresumeName : asConst(fastresumes)) {
|
||||||
const QRegularExpressionMatch rxMatch = rx.match(fastresumeName);
|
const QRegularExpressionMatch rxMatch = rx.match(fastresumeName);
|
||||||
if (!rxMatch.hasMatch()) continue;
|
if (!rxMatch.hasMatch()) continue;
|
||||||
|
|
||||||
|
@ -4095,7 +4095,7 @@ void Session::readAlerts()
|
||||||
std::vector<libt::alert *> alerts;
|
std::vector<libt::alert *> alerts;
|
||||||
getPendingAlerts(alerts);
|
getPendingAlerts(alerts);
|
||||||
|
|
||||||
for (const auto a: alerts) {
|
for (const auto a : alerts) {
|
||||||
handleAlert(a);
|
handleAlert(a);
|
||||||
#if LIBTORRENT_VERSION_NUM < 10100
|
#if LIBTORRENT_VERSION_NUM < 10100
|
||||||
delete a;
|
delete a;
|
||||||
|
@ -4502,7 +4502,7 @@ void Session::handleSessionStatsAlert(libt::session_stats_alert *p)
|
||||||
|
|
||||||
emit statsUpdated();
|
emit statsUpdated();
|
||||||
}
|
}
|
||||||
#else
|
#else // LIBTORRENT_VERSION_NUM >= 10100
|
||||||
void Session::updateStats()
|
void Session::updateStats()
|
||||||
{
|
{
|
||||||
libt::session_status ss = m_nativeSession->status();
|
libt::session_status ss = m_nativeSession->status();
|
||||||
|
@ -4539,7 +4539,7 @@ void Session::updateStats()
|
||||||
|
|
||||||
emit statsUpdated();
|
emit statsUpdated();
|
||||||
}
|
}
|
||||||
#endif
|
#endif // LIBTORRENT_VERSION_NUM >= 10100
|
||||||
|
|
||||||
void Session::handleStateUpdateAlert(libt::state_update_alert *p)
|
void Session::handleStateUpdateAlert(libt::state_update_alert *p)
|
||||||
{
|
{
|
||||||
|
@ -4547,14 +4547,14 @@ void Session::handleStateUpdateAlert(libt::state_update_alert *p)
|
||||||
updateStats();
|
updateStats();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
foreach (const libt::torrent_status &status, p->status) {
|
for (const libt::torrent_status &status : p->status) {
|
||||||
TorrentHandle *const torrent = m_torrents.value(status.info_hash);
|
TorrentHandle *const torrent = m_torrents.value(status.info_hash);
|
||||||
if (torrent)
|
if (torrent)
|
||||||
torrent->handleStateUpdate(status);
|
torrent->handleStateUpdate(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_torrentStatusReport = TorrentStatusReport();
|
m_torrentStatusReport = TorrentStatusReport();
|
||||||
foreach (TorrentHandle *const torrent, m_torrents) {
|
for (TorrentHandle *const torrent : asConst(m_torrents)) {
|
||||||
if (torrent->isDownloading())
|
if (torrent->isDownloading())
|
||||||
++m_torrentStatusReport.nbDownloading;
|
++m_torrentStatusReport.nbDownloading;
|
||||||
if (torrent->isUploading())
|
if (torrent->isUploading())
|
||||||
|
@ -4590,7 +4590,7 @@ namespace
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool loadTorrentResumeData(const QByteArray &data, CreateTorrentParams &torrentParams, int &prio, MagnetUri &magnetUri)
|
bool loadTorrentResumeData(const QByteArray &data, CreateTorrentParams &torrentParams, int &prio, MagnetUri &magnetUri)
|
||||||
{
|
{
|
||||||
torrentParams = CreateTorrentParams();
|
torrentParams = CreateTorrentParams();
|
||||||
torrentParams.restored = true;
|
torrentParams.restored = true;
|
||||||
|
|
|
@ -237,7 +237,7 @@ namespace BitTorrent
|
||||||
int diskJobTime = 0;
|
int diskJobTime = 0;
|
||||||
} disk;
|
} disk;
|
||||||
};
|
};
|
||||||
#endif
|
#endif // LIBTORRENT_VERSION_NUM >= 10100
|
||||||
|
|
||||||
class Session : public QObject
|
class Session : public QObject
|
||||||
{
|
{
|
||||||
|
|
|
@ -110,7 +110,7 @@ void TorrentCreatorThread::run()
|
||||||
QStringList fileNames;
|
QStringList fileNames;
|
||||||
QHash<QString, boost::int64_t> fileSizeMap;
|
QHash<QString, boost::int64_t> fileSizeMap;
|
||||||
|
|
||||||
for (const auto &dir : qAsConst(dirs)) {
|
for (const auto &dir : asConst(dirs)) {
|
||||||
QStringList tmpNames; // natural sort files within each dir
|
QStringList tmpNames; // natural sort files within each dir
|
||||||
|
|
||||||
QDirIterator fileIter(dir, QDir::Files);
|
QDirIterator fileIter(dir, QDir::Files);
|
||||||
|
@ -126,7 +126,7 @@ void TorrentCreatorThread::run()
|
||||||
fileNames += tmpNames;
|
fileNames += tmpNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &fileName : qAsConst(fileNames))
|
for (const auto &fileName : asConst(fileNames))
|
||||||
fs.add_file(fileName.toStdString(), fileSizeMap[fileName]);
|
fs.add_file(fileName.toStdString(), fileSizeMap[fileName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,14 +141,14 @@ void TorrentCreatorThread::run()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Add url seeds
|
// Add url seeds
|
||||||
foreach (QString seed, m_params.urlSeeds) {
|
for (QString seed : asConst(m_params.urlSeeds)) {
|
||||||
seed = seed.trimmed();
|
seed = seed.trimmed();
|
||||||
if (!seed.isEmpty())
|
if (!seed.isEmpty())
|
||||||
newTorrent.add_url_seed(seed.toStdString());
|
newTorrent.add_url_seed(seed.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
int tier = 0;
|
int tier = 0;
|
||||||
foreach (const QString &tracker, m_params.trackers) {
|
for (const QString &tracker : asConst(m_params.trackers)) {
|
||||||
if (tracker.isEmpty())
|
if (tracker.isEmpty())
|
||||||
++tier;
|
++tier;
|
||||||
else
|
else
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/logger.h"
|
#include "base/logger.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
#include "base/profile.h"
|
#include "base/profile.h"
|
||||||
|
@ -77,7 +78,7 @@ namespace
|
||||||
ListType setToEntryList(const QSet<QString> &input)
|
ListType setToEntryList(const QSet<QString> &input)
|
||||||
{
|
{
|
||||||
ListType entryList;
|
ListType entryList;
|
||||||
foreach (const QString &setValue, input)
|
for (const QString &setValue : input)
|
||||||
entryList.emplace_back(setValue.toStdString());
|
entryList.emplace_back(setValue.toStdString());
|
||||||
return entryList;
|
return entryList;
|
||||||
}
|
}
|
||||||
|
@ -158,14 +159,14 @@ namespace
|
||||||
{
|
{
|
||||||
// new constructor is available
|
// new constructor is available
|
||||||
template<typename T, typename std::enable_if<std::is_constructible<T, libt::torrent_info, bool>::value, int>::type = 0>
|
template<typename T, typename std::enable_if<std::is_constructible<T, libt::torrent_info, bool>::value, int>::type = 0>
|
||||||
T makeTorrentCreator(const libtorrent::torrent_info & ti)
|
T makeTorrentCreator(const libtorrent::torrent_info &ti)
|
||||||
{
|
{
|
||||||
return T(ti, true);
|
return T(ti, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// new constructor isn't available
|
// new constructor isn't available
|
||||||
template<typename T, typename std::enable_if<!std::is_constructible<T, libt::torrent_info, bool>::value, int>::type = 0>
|
template<typename T, typename std::enable_if<!std::is_constructible<T, libt::torrent_info, bool>::value, int>::type = 0>
|
||||||
T makeTorrentCreator(const libtorrent::torrent_info & ti)
|
T makeTorrentCreator(const libtorrent::torrent_info &ti)
|
||||||
{
|
{
|
||||||
return T(ti);
|
return T(ti);
|
||||||
}
|
}
|
||||||
|
@ -374,10 +375,9 @@ QString TorrentHandle::nativeActualSavePath() const
|
||||||
QList<TrackerEntry> TorrentHandle::trackers() const
|
QList<TrackerEntry> TorrentHandle::trackers() const
|
||||||
{
|
{
|
||||||
QList<TrackerEntry> entries;
|
QList<TrackerEntry> entries;
|
||||||
std::vector<libt::announce_entry> announces;
|
const std::vector<libt::announce_entry> announces = m_nativeHandle.trackers();
|
||||||
|
|
||||||
announces = m_nativeHandle.trackers();
|
for (const libt::announce_entry &tracker : announces)
|
||||||
foreach (const libt::announce_entry &tracker, announces)
|
|
||||||
entries << tracker;
|
entries << tracker;
|
||||||
|
|
||||||
return entries;
|
return entries;
|
||||||
|
@ -391,7 +391,7 @@ QHash<QString, TrackerInfo> TorrentHandle::trackerInfos() const
|
||||||
void TorrentHandle::addTrackers(const QList<TrackerEntry> &trackers)
|
void TorrentHandle::addTrackers(const QList<TrackerEntry> &trackers)
|
||||||
{
|
{
|
||||||
QList<TrackerEntry> addedTrackers;
|
QList<TrackerEntry> addedTrackers;
|
||||||
foreach (const TrackerEntry &tracker, trackers) {
|
for (const TrackerEntry &tracker : trackers) {
|
||||||
if (addTracker(tracker))
|
if (addTracker(tracker))
|
||||||
addedTrackers << tracker;
|
addedTrackers << tracker;
|
||||||
}
|
}
|
||||||
|
@ -400,13 +400,13 @@ void TorrentHandle::addTrackers(const QList<TrackerEntry> &trackers)
|
||||||
m_session->handleTorrentTrackersAdded(this, addedTrackers);
|
m_session->handleTorrentTrackersAdded(this, addedTrackers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentHandle::replaceTrackers(QList<TrackerEntry> trackers)
|
void TorrentHandle::replaceTrackers(const QList<TrackerEntry> &trackers)
|
||||||
{
|
{
|
||||||
QList<TrackerEntry> existingTrackers = this->trackers();
|
QList<TrackerEntry> existingTrackers = this->trackers();
|
||||||
QList<TrackerEntry> addedTrackers;
|
QList<TrackerEntry> addedTrackers;
|
||||||
|
|
||||||
std::vector<libt::announce_entry> announces;
|
std::vector<libt::announce_entry> announces;
|
||||||
foreach (const TrackerEntry &tracker, trackers) {
|
for (const TrackerEntry &tracker : trackers) {
|
||||||
announces.push_back(tracker.nativeEntry());
|
announces.push_back(tracker.nativeEntry());
|
||||||
if (!existingTrackers.contains(tracker))
|
if (!existingTrackers.contains(tracker))
|
||||||
addedTrackers << tracker;
|
addedTrackers << tracker;
|
||||||
|
@ -438,9 +438,9 @@ bool TorrentHandle::addTracker(const TrackerEntry &tracker)
|
||||||
QList<QUrl> TorrentHandle::urlSeeds() const
|
QList<QUrl> TorrentHandle::urlSeeds() const
|
||||||
{
|
{
|
||||||
QList<QUrl> urlSeeds;
|
QList<QUrl> urlSeeds;
|
||||||
std::set<std::string> seeds = m_nativeHandle.url_seeds();
|
const std::set<std::string> seeds = m_nativeHandle.url_seeds();
|
||||||
|
|
||||||
foreach (const std::string &urlSeed, seeds)
|
for (const std::string &urlSeed : seeds)
|
||||||
urlSeeds.append(QUrl(urlSeed.c_str()));
|
urlSeeds.append(QUrl(urlSeed.c_str()));
|
||||||
|
|
||||||
return urlSeeds;
|
return urlSeeds;
|
||||||
|
@ -449,7 +449,7 @@ QList<QUrl> TorrentHandle::urlSeeds() const
|
||||||
void TorrentHandle::addUrlSeeds(const QList<QUrl> &urlSeeds)
|
void TorrentHandle::addUrlSeeds(const QList<QUrl> &urlSeeds)
|
||||||
{
|
{
|
||||||
QList<QUrl> addedUrlSeeds;
|
QList<QUrl> addedUrlSeeds;
|
||||||
foreach (const QUrl &urlSeed, urlSeeds) {
|
for (const QUrl &urlSeed : urlSeeds) {
|
||||||
if (addUrlSeed(urlSeed))
|
if (addUrlSeed(urlSeed))
|
||||||
addedUrlSeeds << urlSeed;
|
addedUrlSeeds << urlSeed;
|
||||||
}
|
}
|
||||||
|
@ -461,7 +461,7 @@ void TorrentHandle::addUrlSeeds(const QList<QUrl> &urlSeeds)
|
||||||
void TorrentHandle::removeUrlSeeds(const QList<QUrl> &urlSeeds)
|
void TorrentHandle::removeUrlSeeds(const QList<QUrl> &urlSeeds)
|
||||||
{
|
{
|
||||||
QList<QUrl> removedUrlSeeds;
|
QList<QUrl> removedUrlSeeds;
|
||||||
foreach (const QUrl &urlSeed, urlSeeds) {
|
for (const QUrl &urlSeed : urlSeeds) {
|
||||||
if (removeUrlSeed(urlSeed))
|
if (removeUrlSeed(urlSeed))
|
||||||
removedUrlSeeds << urlSeed;
|
removedUrlSeeds << urlSeed;
|
||||||
}
|
}
|
||||||
|
@ -596,8 +596,7 @@ bool TorrentHandle::removeTag(const QString &tag)
|
||||||
|
|
||||||
void TorrentHandle::removeAllTags()
|
void TorrentHandle::removeAllTags()
|
||||||
{
|
{
|
||||||
// QT automatically copies the container in foreach, so it's safe to mutate it.
|
for (const QString &tag : asConst(tags()))
|
||||||
foreach (const QString &tag, m_tags)
|
|
||||||
removeTag(tag);
|
removeTag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,7 +622,7 @@ QString TorrentHandle::filePath(int index) const
|
||||||
|
|
||||||
QString TorrentHandle::fileName(int index) const
|
QString TorrentHandle::fileName(int index) const
|
||||||
{
|
{
|
||||||
if (!hasMetadata()) return QString();
|
if (!hasMetadata()) return QString();
|
||||||
return Utils::Fs::fileName(filePath(index));
|
return Utils::Fs::fileName(filePath(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,7 +635,7 @@ qlonglong TorrentHandle::fileSize(int index) const
|
||||||
// to all files in a torrent
|
// to all files in a torrent
|
||||||
QStringList TorrentHandle::absoluteFilePaths() const
|
QStringList TorrentHandle::absoluteFilePaths() const
|
||||||
{
|
{
|
||||||
if (!hasMetadata()) return QStringList();
|
if (!hasMetadata()) return QStringList();
|
||||||
|
|
||||||
QDir saveDir(savePath(true));
|
QDir saveDir(savePath(true));
|
||||||
QStringList res;
|
QStringList res;
|
||||||
|
@ -647,7 +646,7 @@ QStringList TorrentHandle::absoluteFilePaths() const
|
||||||
|
|
||||||
QStringList TorrentHandle::absoluteFilePathsUnwanted() const
|
QStringList TorrentHandle::absoluteFilePathsUnwanted() const
|
||||||
{
|
{
|
||||||
if (!hasMetadata()) return QStringList();
|
if (!hasMetadata()) return QStringList();
|
||||||
|
|
||||||
QDir saveDir(savePath(true));
|
QDir saveDir(savePath(true));
|
||||||
QStringList res;
|
QStringList res;
|
||||||
|
@ -883,9 +882,9 @@ bool TorrentHandle::hasError() const
|
||||||
|
|
||||||
bool TorrentHandle::hasFilteredPieces() const
|
bool TorrentHandle::hasFilteredPieces() const
|
||||||
{
|
{
|
||||||
std::vector<int> pp = m_nativeHandle.piece_priorities();
|
const std::vector<int> pp = m_nativeHandle.piece_priorities();
|
||||||
|
|
||||||
foreach (const int priority, pp)
|
for (const int priority : pp)
|
||||||
if (priority == 0) return true;
|
if (priority == 0) return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -1087,7 +1086,7 @@ QList<PeerInfo> TorrentHandle::peers() const
|
||||||
|
|
||||||
m_nativeHandle.get_peer_info(nativePeers);
|
m_nativeHandle.get_peer_info(nativePeers);
|
||||||
|
|
||||||
foreach (const libt::peer_info &peer, nativePeers)
|
for (const libt::peer_info &peer : nativePeers)
|
||||||
peers << PeerInfo(this, peer);
|
peers << PeerInfo(this, peer);
|
||||||
|
|
||||||
return peers;
|
return peers;
|
||||||
|
@ -2063,7 +2062,7 @@ void TorrentHandle::prioritizeFiles(const QVector<int> &priorities)
|
||||||
if (created) {
|
if (created) {
|
||||||
// Hide the folder on Windows
|
// Hide the folder on Windows
|
||||||
qDebug() << "Hiding folder (Windows)";
|
qDebug() << "Hiding folder (Windows)";
|
||||||
std::wstring winPath = Utils::Fs::toNativePath(unwantedAbsPath).toStdWString();
|
std::wstring winPath = Utils::Fs::toNativePath(unwantedAbsPath).toStdWString();
|
||||||
DWORD dwAttrs = ::GetFileAttributesW(winPath.c_str());
|
DWORD dwAttrs = ::GetFileAttributesW(winPath.c_str());
|
||||||
bool ret = ::SetFileAttributesW(winPath.c_str(), dwAttrs | FILE_ATTRIBUTE_HIDDEN);
|
bool ret = ::SetFileAttributesW(winPath.c_str(), dwAttrs | FILE_ATTRIBUTE_HIDDEN);
|
||||||
Q_ASSERT(ret != 0); Q_UNUSED(ret);
|
Q_ASSERT(ret != 0); Q_UNUSED(ret);
|
||||||
|
|
|
@ -356,7 +356,7 @@ namespace BitTorrent
|
||||||
void setSuperSeeding(bool enable);
|
void setSuperSeeding(bool enable);
|
||||||
void flushCache();
|
void flushCache();
|
||||||
void addTrackers(const QList<TrackerEntry> &trackers);
|
void addTrackers(const QList<TrackerEntry> &trackers);
|
||||||
void replaceTrackers(QList<TrackerEntry> trackers);
|
void replaceTrackers(const QList<TrackerEntry> &trackers);
|
||||||
void addUrlSeeds(const QList<QUrl> &urlSeeds);
|
void addUrlSeeds(const QList<QUrl> &urlSeeds);
|
||||||
void removeUrlSeeds(const QList<QUrl> &urlSeeds);
|
void removeUrlSeeds(const QList<QUrl> &urlSeeds);
|
||||||
bool connectPeer(const PeerAddress &peerAddress);
|
bool connectPeer(const PeerAddress &peerAddress);
|
||||||
|
|
|
@ -247,7 +247,7 @@ QList<TrackerEntry> TorrentInfo::trackers() const
|
||||||
if (!isValid()) return QList<TrackerEntry>();
|
if (!isValid()) return QList<TrackerEntry>();
|
||||||
|
|
||||||
QList<TrackerEntry> trackers;
|
QList<TrackerEntry> trackers;
|
||||||
foreach (const libt::announce_entry &tracker, m_nativeInfo->trackers())
|
for (const libt::announce_entry &tracker : m_nativeInfo->trackers())
|
||||||
trackers.append(tracker);
|
trackers.append(tracker);
|
||||||
|
|
||||||
return trackers;
|
return trackers;
|
||||||
|
@ -258,7 +258,7 @@ QList<QUrl> TorrentInfo::urlSeeds() const
|
||||||
if (!isValid()) return QList<QUrl>();
|
if (!isValid()) return QList<QUrl>();
|
||||||
|
|
||||||
QList<QUrl> urlSeeds;
|
QList<QUrl> urlSeeds;
|
||||||
foreach (const libt::web_seed_entry &webSeed, m_nativeInfo->web_seeds())
|
for (const libt::web_seed_entry &webSeed : m_nativeInfo->web_seeds())
|
||||||
if (webSeed.type == libt::web_seed_entry::url_seed)
|
if (webSeed.type == libt::web_seed_entry::url_seed)
|
||||||
urlSeeds.append(QUrl(webSeed.url.c_str()));
|
urlSeeds.append(QUrl(webSeed.url.c_str()));
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ void TorrentInfo::renameFile(const int index, const QString &newPath)
|
||||||
nativeInfo()->rename_file(index, Utils::Fs::toNativePath(newPath).toStdString());
|
nativeInfo()->rename_file(index, Utils::Fs::toNativePath(newPath).toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
int BitTorrent::TorrentInfo::fileIndex(const QString& fileName) const
|
int BitTorrent::TorrentInfo::fileIndex(const QString &fileName) const
|
||||||
{
|
{
|
||||||
// the check whether the object is valid is not needed here
|
// the check whether the object is valid is not needed here
|
||||||
// because if filesCount() returns -1 the loop exits immediately
|
// because if filesCount() returns -1 the loop exits immediately
|
||||||
|
|
|
@ -136,7 +136,7 @@ void Tracker::respondToAnnounceRequest()
|
||||||
QMap<QString, QByteArray> queryParams;
|
QMap<QString, QByteArray> queryParams;
|
||||||
// Parse GET parameters
|
// Parse GET parameters
|
||||||
using namespace Utils::ByteArray;
|
using namespace Utils::ByteArray;
|
||||||
for (const QByteArray ¶m : copyAsConst(splitToViews(m_request.query, "&"))) {
|
for (const QByteArray ¶m : asConst(splitToViews(m_request.query, "&"))) {
|
||||||
const int sepPos = param.indexOf('=');
|
const int sepPos = param.indexOf('=');
|
||||||
if (sepPos <= 0) continue; // ignores params without name
|
if (sepPos <= 0) continue; // ignores params without name
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ FileSystemWatcher::FileSystemWatcher(QObject *parent)
|
||||||
QStringList FileSystemWatcher::directories() const
|
QStringList FileSystemWatcher::directories() const
|
||||||
{
|
{
|
||||||
QStringList dirs = QFileSystemWatcher::directories();
|
QStringList dirs = QFileSystemWatcher::directories();
|
||||||
for (const QDir &dir : qAsConst(m_watchedFolders))
|
for (const QDir &dir : asConst(m_watchedFolders))
|
||||||
dirs << dir.canonicalPath();
|
dirs << dir.canonicalPath();
|
||||||
return dirs;
|
return dirs;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ void FileSystemWatcher::scanLocalFolder(const QString &path)
|
||||||
|
|
||||||
void FileSystemWatcher::scanNetworkFolders()
|
void FileSystemWatcher::scanNetworkFolders()
|
||||||
{
|
{
|
||||||
for (const QDir &dir : qAsConst(m_watchedFolders))
|
for (const QDir &dir : asConst(m_watchedFolders))
|
||||||
processTorrentsInDir(dir);
|
processTorrentsInDir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,16 +33,13 @@
|
||||||
|
|
||||||
const char C_TORRENT_FILE_EXTENSION[] = ".torrent";
|
const char C_TORRENT_FILE_EXTENSION[] = ".torrent";
|
||||||
|
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr typename std::add_const<T>::type &qAsConst(T &t) noexcept { return t; }
|
constexpr typename std::add_const<T>::type &asConst(T &t) noexcept { return t; }
|
||||||
|
|
||||||
// prevent rvalue arguments:
|
// Forward rvalue as const
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void qAsConst(const T &&) = delete;
|
constexpr typename std::add_const<T>::type asConst(T &&t) noexcept { return std::move(t); }
|
||||||
#endif
|
|
||||||
|
|
||||||
// returns a const object copy
|
// Prevent const rvalue arguments
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr typename std::add_const<T>::type copyAsConst(T &&t) noexcept { return std::move(t); }
|
void asConst(const T &&) = delete;
|
||||||
|
|
|
@ -133,7 +133,7 @@ bool Connection::acceptsGzipEncoding(QString codings)
|
||||||
|
|
||||||
const auto isCodingAvailable = [](const QStringList &list, const QString &encoding) -> bool
|
const auto isCodingAvailable = [](const QStringList &list, const QString &encoding) -> bool
|
||||||
{
|
{
|
||||||
foreach (const QString &str, list) {
|
for (const QString &str : list) {
|
||||||
if (!str.startsWith(encoding))
|
if (!str.startsWith(encoding))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -146,9 +146,9 @@ QList<QSslCipher> Server::safeCipherList() const
|
||||||
const QStringList badCiphers = {"idea", "rc4"};
|
const QStringList badCiphers = {"idea", "rc4"};
|
||||||
const QList<QSslCipher> allCiphers = QSslSocket::supportedCiphers();
|
const QList<QSslCipher> allCiphers = QSslSocket::supportedCiphers();
|
||||||
QList<QSslCipher> safeCiphers;
|
QList<QSslCipher> safeCiphers;
|
||||||
foreach (const QSslCipher &cipher, allCiphers) {
|
for (const QSslCipher &cipher : allCiphers) {
|
||||||
bool isSafe = true;
|
bool isSafe = true;
|
||||||
foreach (const QString &badCipher, badCiphers) {
|
for (const QString &badCipher : badCiphers) {
|
||||||
if (cipher.name().contains(badCipher, Qt::CaseInsensitive)) {
|
if (cipher.name().contains(badCipher, Qt::CaseInsensitive)) {
|
||||||
isSafe = false;
|
isSafe = false;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -107,7 +107,7 @@ namespace Http
|
||||||
uint code;
|
uint code;
|
||||||
QString text;
|
QString text;
|
||||||
|
|
||||||
ResponseStatus(uint code = 200, const QString& text = "OK"): code(code), text(text) {}
|
ResponseStatus(uint code = 200, const QString &text = "OK"): code(code), text(text) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Response
|
struct Response
|
||||||
|
@ -116,7 +116,7 @@ namespace Http
|
||||||
QStringMap headers;
|
QStringMap headers;
|
||||||
QByteArray content;
|
QByteArray content;
|
||||||
|
|
||||||
Response(uint code = 200, const QString& text = "OK"): status(code, text) {}
|
Response(uint code = 200, const QString &text = "OK"): status(code, text) {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <QSslError>
|
#include <QSslError>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
#include "downloadhandler.h"
|
#include "downloadhandler.h"
|
||||||
#include "proxyconfigurationmanager.h"
|
#include "proxyconfigurationmanager.h"
|
||||||
|
@ -56,7 +57,7 @@ namespace
|
||||||
{
|
{
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
QDateTime now = QDateTime::currentDateTime();
|
||||||
QList<QNetworkCookie> cookies = Preferences::instance()->getNetworkCookies();
|
QList<QNetworkCookie> cookies = Preferences::instance()->getNetworkCookies();
|
||||||
foreach (const QNetworkCookie &cookie, Preferences::instance()->getNetworkCookies()) {
|
for (const QNetworkCookie &cookie : asConst(Preferences::instance()->getNetworkCookies())) {
|
||||||
if (cookie.isSessionCookie() || (cookie.expirationDate() <= now))
|
if (cookie.isSessionCookie() || (cookie.expirationDate() <= now))
|
||||||
cookies.removeAll(cookie);
|
cookies.removeAll(cookie);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +69,7 @@ namespace
|
||||||
{
|
{
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
QDateTime now = QDateTime::currentDateTime();
|
||||||
QList<QNetworkCookie> cookies = allCookies();
|
QList<QNetworkCookie> cookies = allCookies();
|
||||||
foreach (const QNetworkCookie &cookie, allCookies()) {
|
for (const QNetworkCookie &cookie : asConst(allCookies())) {
|
||||||
if (cookie.isSessionCookie() || (cookie.expirationDate() <= now))
|
if (cookie.isSessionCookie() || (cookie.expirationDate() <= now))
|
||||||
cookies.removeAll(cookie);
|
cookies.removeAll(cookie);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +84,7 @@ namespace
|
||||||
{
|
{
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
QDateTime now = QDateTime::currentDateTime();
|
||||||
QList<QNetworkCookie> cookies = QNetworkCookieJar::cookiesForUrl(url);
|
QList<QNetworkCookie> cookies = QNetworkCookieJar::cookiesForUrl(url);
|
||||||
foreach (const QNetworkCookie &cookie, QNetworkCookieJar::cookiesForUrl(url)) {
|
for (const QNetworkCookie &cookie : asConst(QNetworkCookieJar::cookiesForUrl(url))) {
|
||||||
if (!cookie.isSessionCookie() && (cookie.expirationDate() <= now))
|
if (!cookie.isSessionCookie() && (cookie.expirationDate() <= now))
|
||||||
cookies.removeAll(cookie);
|
cookies.removeAll(cookie);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +96,7 @@ namespace
|
||||||
{
|
{
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
QDateTime now = QDateTime::currentDateTime();
|
||||||
QList<QNetworkCookie> cookies = cookieList;
|
QList<QNetworkCookie> cookies = cookieList;
|
||||||
foreach (const QNetworkCookie &cookie, cookieList) {
|
for (const QNetworkCookie &cookie : cookieList) {
|
||||||
if (!cookie.isSessionCookie() && (cookie.expirationDate() <= now))
|
if (!cookie.isSessionCookie() && (cookie.expirationDate() <= now))
|
||||||
cookies.removeAll(cookie);
|
cookies.removeAll(cookie);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ const QString KEY_PASSWORD = SETTINGS_KEY("Password");
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
inline SettingsStorage *settings() { return SettingsStorage::instance(); }
|
inline SettingsStorage *settings() { return SettingsStorage::instance(); }
|
||||||
|
|
||||||
inline bool isSameConfig(const Net::ProxyConfiguration &conf1, const Net::ProxyConfiguration &conf2)
|
inline bool isSameConfig(const Net::ProxyConfiguration &conf1, const Net::ProxyConfiguration &conf2)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/logger.h"
|
#include "base/logger.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
|
|
||||||
|
@ -291,7 +292,7 @@ QByteArray Smtp::encodeMimeHeader(const QString &key, const QString &value, QTex
|
||||||
if (!prefix.isEmpty()) line += prefix;
|
if (!prefix.isEmpty()) line += prefix;
|
||||||
if (!value.contains("=?") && latin1->canEncode(value)) {
|
if (!value.contains("=?") && latin1->canEncode(value)) {
|
||||||
bool firstWord = true;
|
bool firstWord = true;
|
||||||
foreach (const QByteArray& word, value.toLatin1().split(' ')) {
|
for (const QByteArray &word : asConst(value.toLatin1().split(' '))) {
|
||||||
if (line.size() > 78) {
|
if (line.size() > 78) {
|
||||||
rv = rv + line + "\r\n";
|
rv = rv + line + "\r\n";
|
||||||
line.clear();
|
line.clear();
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#include <CoreServices/CoreServices.h>
|
#include <CoreServices/CoreServices.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "global.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "settingsstorage.h"
|
#include "settingsstorage.h"
|
||||||
#include "utils/fs.h"
|
#include "utils/fs.h"
|
||||||
|
@ -212,7 +213,7 @@ void Preferences::setCloseToTrayNotified(bool b)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/CloseToTrayNotified", b);
|
setValue("Preferences/General/CloseToTrayNotified", b);
|
||||||
}
|
}
|
||||||
#endif
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
bool Preferences::isToolbarDisplayed() const
|
bool Preferences::isToolbarDisplayed() const
|
||||||
{
|
{
|
||||||
|
@ -293,7 +294,7 @@ void Preferences::setWinStartup(bool b)
|
||||||
settings.remove("qBittorrent");
|
settings.remove("qBittorrent");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif // Q_OS_WIN
|
||||||
|
|
||||||
// Downloads
|
// Downloads
|
||||||
QString Preferences::lastLocationPath() const
|
QString Preferences::lastLocationPath() const
|
||||||
|
@ -505,7 +506,7 @@ void Preferences::setWebUiAuthSubnetWhitelistEnabled(bool enabled)
|
||||||
QList<Utils::Net::Subnet> Preferences::getWebUiAuthSubnetWhitelist() const
|
QList<Utils::Net::Subnet> Preferences::getWebUiAuthSubnetWhitelist() const
|
||||||
{
|
{
|
||||||
QList<Utils::Net::Subnet> subnets;
|
QList<Utils::Net::Subnet> subnets;
|
||||||
foreach (const QString &rawSubnet, value("Preferences/WebUI/AuthSubnetWhitelist").toStringList()) {
|
for (const QString &rawSubnet : asConst(value("Preferences/WebUI/AuthSubnetWhitelist").toStringList())) {
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
const Utils::Net::Subnet subnet = Utils::Net::parseSubnet(rawSubnet.trimmed(), &ok);
|
const Utils::Net::Subnet subnet = Utils::Net::parseSubnet(rawSubnet.trimmed(), &ok);
|
||||||
if (ok)
|
if (ok)
|
||||||
|
@ -967,7 +968,7 @@ void Preferences::setMagnetLinkAssoc(bool set)
|
||||||
|
|
||||||
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
|
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif // Q_OS_WIN
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
namespace
|
namespace
|
||||||
|
@ -1023,7 +1024,7 @@ void Preferences::setMagnetLinkAssoc()
|
||||||
CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
|
CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
|
||||||
LSSetDefaultHandlerForURLScheme(magnetUrlScheme, myBundleId);
|
LSSetDefaultHandlerForURLScheme(magnetUrlScheme, myBundleId);
|
||||||
}
|
}
|
||||||
#endif
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
int Preferences::getTrackerPort() const
|
int Preferences::getTrackerPort() const
|
||||||
{
|
{
|
||||||
|
@ -1426,8 +1427,8 @@ void Preferences::setToolbarTextPosition(const int position)
|
||||||
QList<QNetworkCookie> Preferences::getNetworkCookies() const
|
QList<QNetworkCookie> Preferences::getNetworkCookies() const
|
||||||
{
|
{
|
||||||
QList<QNetworkCookie> cookies;
|
QList<QNetworkCookie> cookies;
|
||||||
QStringList rawCookies = value("Network/Cookies").toStringList();
|
const QStringList rawCookies = value("Network/Cookies").toStringList();
|
||||||
foreach (const QString &rawCookie, rawCookies)
|
for (const QString &rawCookie : rawCookies)
|
||||||
cookies << QNetworkCookie::parseCookies(rawCookie.toUtf8());
|
cookies << QNetworkCookie::parseCookies(rawCookie.toUtf8());
|
||||||
|
|
||||||
return cookies;
|
return cookies;
|
||||||
|
@ -1436,7 +1437,7 @@ QList<QNetworkCookie> Preferences::getNetworkCookies() const
|
||||||
void Preferences::setNetworkCookies(const QList<QNetworkCookie> &cookies)
|
void Preferences::setNetworkCookies(const QList<QNetworkCookie> &cookies)
|
||||||
{
|
{
|
||||||
QStringList rawCookies;
|
QStringList rawCookies;
|
||||||
foreach (const QNetworkCookie &cookie, cookies)
|
for (const QNetworkCookie &cookie : cookies)
|
||||||
rawCookies << cookie.toRawForm();
|
rawCookies << cookie.toRawForm();
|
||||||
|
|
||||||
setValue("Network/Cookies", rawCookies);
|
setValue("Network/Cookies", rawCookies);
|
||||||
|
@ -1477,10 +1478,10 @@ void Preferences::upgrade()
|
||||||
{
|
{
|
||||||
SettingsStorage *settingsStorage = SettingsStorage::instance();
|
SettingsStorage *settingsStorage = SettingsStorage::instance();
|
||||||
|
|
||||||
QStringList labels = value("TransferListFilters/customLabels").toStringList();
|
const QStringList labels = value("TransferListFilters/customLabels").toStringList();
|
||||||
if (!labels.isEmpty()) {
|
if (!labels.isEmpty()) {
|
||||||
QVariantMap categories = value("BitTorrent/Session/Categories").toMap();
|
QVariantMap categories = value("BitTorrent/Session/Categories").toMap();
|
||||||
foreach (const QString &label, labels) {
|
for (const QString &label : labels) {
|
||||||
if (!categories.contains(label))
|
if (!categories.contains(label))
|
||||||
categories[label] = "";
|
categories[label] = "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,7 +299,7 @@ public:
|
||||||
void setCloseToTrayNotified(bool b);
|
void setCloseToTrayNotified(bool b);
|
||||||
TrayIcon::Style trayIconStyle() const;
|
TrayIcon::Style trayIconStyle() const;
|
||||||
void setTrayIconStyle(TrayIcon::Style style);
|
void setTrayIconStyle(TrayIcon::Style style);
|
||||||
#endif
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
// Stuff that don't appear in the Options GUI but are saved
|
// Stuff that don't appear in the Options GUI but are saved
|
||||||
// in the same file.
|
// in the same file.
|
||||||
|
|
|
@ -435,13 +435,13 @@ namespace
|
||||||
if (leapSecond)
|
if (leapSecond)
|
||||||
second = 59; // apparently a leap second - validate below, once time zone is known
|
second = 59; // apparently a leap second - validate below, once time zone is known
|
||||||
int month = 0;
|
int month = 0;
|
||||||
for ( ; (month < 12) && (parts[nmonth] != shortMonth[month]); ++month);
|
for ( ; (month < 12) && (parts[nmonth] != shortMonth[month]); ++month);
|
||||||
int dayOfWeek = -1;
|
int dayOfWeek = -1;
|
||||||
if (!parts[nwday].isEmpty()) {
|
if (!parts[nwday].isEmpty()) {
|
||||||
// Look up the weekday name
|
// Look up the weekday name
|
||||||
while (++dayOfWeek < 7 && (shortDay[dayOfWeek] != parts[nwday]));
|
while ((++dayOfWeek < 7) && (shortDay[dayOfWeek] != parts[nwday]));
|
||||||
if (dayOfWeek >= 7)
|
if (dayOfWeek >= 7)
|
||||||
for (dayOfWeek = 0; dayOfWeek < 7 && (longDay[dayOfWeek] != parts[nwday]); ++dayOfWeek);
|
for (dayOfWeek = 0; (dayOfWeek < 7) && (longDay[dayOfWeek] != parts[nwday]); ++dayOfWeek);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (month >= 12 || dayOfWeek >= 7
|
// if (month >= 12 || dayOfWeek >= 7
|
||||||
|
@ -450,7 +450,7 @@ namespace
|
||||||
int i = parts[nyear].size();
|
int i = parts[nyear].size();
|
||||||
if (i < 4) {
|
if (i < 4) {
|
||||||
// It's an obsolete year specification with less than 4 digits
|
// It's an obsolete year specification with less than 4 digits
|
||||||
year += (i == 2 && year < 50) ? 2000 : 1900;
|
year += ((i == 2) && (year < 50)) ? 2000 : 1900;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the UTC offset part
|
// Parse the UTC offset part
|
||||||
|
@ -473,17 +473,17 @@ namespace
|
||||||
else {
|
else {
|
||||||
// Check for an obsolete time zone name
|
// Check for an obsolete time zone name
|
||||||
QByteArray zone = parts[10].toLatin1();
|
QByteArray zone = parts[10].toLatin1();
|
||||||
if (zone.length() == 1 && isalpha(zone[0]) && toupper(zone[0]) != 'J') {
|
if ((zone.length() == 1) && (isalpha(zone[0])) && (toupper(zone[0]) != 'J')) {
|
||||||
negOffset = true; // military zone: RFC 2822 treats as '-0000'
|
negOffset = true; // military zone: RFC 2822 treats as '-0000'
|
||||||
}
|
}
|
||||||
else if (zone != "UT" && zone != "GMT") { // treated as '+0000'
|
else if ((zone != "UT") && (zone != "GMT")) { // treated as '+0000'
|
||||||
offset = (zone == "EDT")
|
offset = (zone == "EDT")
|
||||||
? -4 * 3600
|
? -4 * 3600
|
||||||
: ((zone == "EST") || (zone == "CDT"))
|
: ((zone == "EST") || (zone == "CDT"))
|
||||||
? -5 * 3600
|
? -5 * 3600
|
||||||
: ((zone == "CST") || (zone == "MDT"))
|
: ((zone == "CST") || (zone == "MDT"))
|
||||||
? -6 * 3600
|
? -6 * 3600
|
||||||
: (zone == "MST" || zone == "PDT")
|
: ((zone == "MST") || (zone == "PDT"))
|
||||||
? -7 * 3600
|
? -7 * 3600
|
||||||
: (zone == "PST")
|
: (zone == "PST")
|
||||||
? -8 * 3600
|
? -8 * 3600
|
||||||
|
@ -502,12 +502,12 @@ namespace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QDate qdate(year, month + 1, day); // convert date, and check for out-of-range
|
QDate qDate(year, month + 1, day); // convert date, and check for out-of-range
|
||||||
if (!qdate.isValid())
|
if (!qDate.isValid())
|
||||||
return QDateTime::currentDateTime();
|
return QDateTime::currentDateTime();
|
||||||
|
|
||||||
QTime qTime(hour, minute, second);
|
QTime qTime(hour, minute, second);
|
||||||
QDateTime result(qdate, qTime, Qt::UTC);
|
QDateTime result(qDate, qTime, Qt::UTC);
|
||||||
if (offset)
|
if (offset)
|
||||||
result = result.addSecs(-offset);
|
result = result.addSecs(-offset);
|
||||||
if (!result.isValid())
|
if (!result.isValid())
|
||||||
|
|
|
@ -241,7 +241,7 @@ void AutoDownloader::importRules(const QByteArray &data, AutoDownloader::RulesFi
|
||||||
QByteArray AutoDownloader::exportRulesToJSONFormat() const
|
QByteArray AutoDownloader::exportRulesToJSONFormat() const
|
||||||
{
|
{
|
||||||
QJsonObject jsonObj;
|
QJsonObject jsonObj;
|
||||||
for (const auto &rule : copyAsConst(rules()))
|
for (const auto &rule : asConst(rules()))
|
||||||
jsonObj.insert(rule.name(), rule.toJsonObject());
|
jsonObj.insert(rule.name(), rule.toJsonObject());
|
||||||
|
|
||||||
return QJsonDocument(jsonObj).toJson();
|
return QJsonDocument(jsonObj).toJson();
|
||||||
|
@ -249,14 +249,14 @@ QByteArray AutoDownloader::exportRulesToJSONFormat() const
|
||||||
|
|
||||||
void AutoDownloader::importRulesFromJSONFormat(const QByteArray &data)
|
void AutoDownloader::importRulesFromJSONFormat(const QByteArray &data)
|
||||||
{
|
{
|
||||||
for (const auto &rule : copyAsConst(rulesFromJSON(data)))
|
for (const auto &rule : asConst(rulesFromJSON(data)))
|
||||||
insertRule(rule);
|
insertRule(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray AutoDownloader::exportRulesToLegacyFormat() const
|
QByteArray AutoDownloader::exportRulesToLegacyFormat() const
|
||||||
{
|
{
|
||||||
QVariantHash dict;
|
QVariantHash dict;
|
||||||
for (const auto &rule : copyAsConst(rules()))
|
for (const auto &rule : asConst(rules()))
|
||||||
dict[rule.name()] = rule.toLegacyDict();
|
dict[rule.name()] = rule.toLegacyDict();
|
||||||
|
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
|
@ -276,7 +276,7 @@ void AutoDownloader::importRulesFromLegacyFormat(const QByteArray &data)
|
||||||
if (in.status() != QDataStream::Ok)
|
if (in.status() != QDataStream::Ok)
|
||||||
throw ParsingError(tr("Invalid data format"));
|
throw ParsingError(tr("Invalid data format"));
|
||||||
|
|
||||||
for (const QVariant &val : qAsConst(dict))
|
for (const QVariant &val : asConst(dict))
|
||||||
insertRule(AutoDownloadRule::fromLegacyDict(val.toHash()));
|
insertRule(AutoDownloadRule::fromLegacyDict(val.toHash()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ void AutoDownloader::addJobForArticle(Article *article)
|
||||||
|
|
||||||
void AutoDownloader::processJob(const QSharedPointer<ProcessingJob> &job)
|
void AutoDownloader::processJob(const QSharedPointer<ProcessingJob> &job)
|
||||||
{
|
{
|
||||||
for (AutoDownloadRule &rule: m_rules) {
|
for (AutoDownloadRule &rule : m_rules) {
|
||||||
if (!rule.isEnabled()) continue;
|
if (!rule.isEnabled()) continue;
|
||||||
if (!rule.feedURLs().contains(job->feedURL)) continue;
|
if (!rule.feedURLs().contains(job->feedURL)) continue;
|
||||||
if (!rule.accepts(job->articleData)) continue;
|
if (!rule.accepts(job->articleData)) continue;
|
||||||
|
@ -435,8 +435,8 @@ void AutoDownloader::loadRules(const QByteArray &data)
|
||||||
void AutoDownloader::loadRulesLegacy()
|
void AutoDownloader::loadRulesLegacy()
|
||||||
{
|
{
|
||||||
SettingsPtr settings = Profile::instance().applicationSettings(QStringLiteral("qBittorrent-rss"));
|
SettingsPtr settings = Profile::instance().applicationSettings(QStringLiteral("qBittorrent-rss"));
|
||||||
QVariantHash rules = settings->value(QStringLiteral("download_rules")).toHash();
|
const QVariantHash rules = settings->value(QStringLiteral("download_rules")).toHash();
|
||||||
foreach (const QVariant &ruleVar, rules) {
|
for (const QVariant &ruleVar : rules) {
|
||||||
auto rule = AutoDownloadRule::fromLegacyDict(ruleVar.toHash());
|
auto rule = AutoDownloadRule::fromLegacyDict(ruleVar.toHash());
|
||||||
if (!rule.name().isEmpty())
|
if (!rule.name().isEmpty())
|
||||||
insertRule(rule);
|
insertRule(rule);
|
||||||
|
@ -451,7 +451,7 @@ void AutoDownloader::store()
|
||||||
m_savingTimer.stop();
|
m_savingTimer.stop();
|
||||||
|
|
||||||
QJsonObject jsonObj;
|
QJsonObject jsonObj;
|
||||||
foreach (auto rule, m_rules)
|
for (const auto &rule : asConst(m_rules))
|
||||||
jsonObj.insert(rule.name(), rule.toJsonObject());
|
jsonObj.insert(rule.name(), rule.toJsonObject());
|
||||||
|
|
||||||
m_fileStorage->store(RulesFileName, QJsonDocument(jsonObj).toJson());
|
m_fileStorage->store(RulesFileName, QJsonDocument(jsonObj).toJson());
|
||||||
|
@ -473,7 +473,7 @@ void AutoDownloader::resetProcessingQueue()
|
||||||
m_processingQueue.clear();
|
m_processingQueue.clear();
|
||||||
if (!m_processingEnabled) return;
|
if (!m_processingEnabled) return;
|
||||||
|
|
||||||
foreach (Article *article, Session::instance()->rootFolder()->articles()) {
|
for (Article *article : asConst(Session::instance()->rootFolder()->articles())) {
|
||||||
if (!article->isRead() && !article->torrentUrl().isEmpty())
|
if (!article->isRead() && !article->torrentUrl().isEmpty())
|
||||||
addJobForArticle(article);
|
addJobForArticle(article);
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@ bool AutoDownloadRule::matchesMustContainExpression(const QString &articleTitle)
|
||||||
|
|
||||||
// Each expression is either a regex, or a set of wildcards separated by whitespace.
|
// Each expression is either a regex, or a set of wildcards separated by whitespace.
|
||||||
// Accept if any complete expression matches.
|
// Accept if any complete expression matches.
|
||||||
for (const QString &expression : qAsConst(m_dataPtr->mustContain)) {
|
for (const QString &expression : asConst(m_dataPtr->mustContain)) {
|
||||||
// A regex of the form "expr|" will always match, so do the same for wildcards
|
// A regex of the form "expr|" will always match, so do the same for wildcards
|
||||||
if (matchesExpression(articleTitle, expression))
|
if (matchesExpression(articleTitle, expression))
|
||||||
return true;
|
return true;
|
||||||
|
@ -246,14 +246,14 @@ bool AutoDownloadRule::matchesMustContainExpression(const QString &articleTitle)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AutoDownloadRule::matchesMustNotContainExpression(const QString& articleTitle) const
|
bool AutoDownloadRule::matchesMustNotContainExpression(const QString &articleTitle) const
|
||||||
{
|
{
|
||||||
if (m_dataPtr->mustNotContain.empty())
|
if (m_dataPtr->mustNotContain.empty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Each expression is either a regex, or a set of wildcards separated by whitespace.
|
// Each expression is either a regex, or a set of wildcards separated by whitespace.
|
||||||
// Reject if any complete expression matches.
|
// Reject if any complete expression matches.
|
||||||
for (const QString &expression : qAsConst(m_dataPtr->mustNotContain)) {
|
for (const QString &expression : asConst(m_dataPtr->mustNotContain)) {
|
||||||
// A regex of the form "expr|" will always match, so do the same for wildcards
|
// A regex of the form "expr|" will always match, so do the same for wildcards
|
||||||
if (matchesExpression(articleTitle, expression))
|
if (matchesExpression(articleTitle, expression))
|
||||||
return false;
|
return false;
|
||||||
|
@ -262,7 +262,7 @@ bool AutoDownloadRule::matchesMustNotContainExpression(const QString& articleTit
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString& articleTitle) const
|
bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString &articleTitle) const
|
||||||
{
|
{
|
||||||
// Reset the lastComputedEpisode, we don't want to leak it between matches
|
// Reset the lastComputedEpisode, we don't want to leak it between matches
|
||||||
m_dataPtr->lastComputedEpisode.clear();
|
m_dataPtr->lastComputedEpisode.clear();
|
||||||
|
@ -332,7 +332,7 @@ bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString& articleTitl
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AutoDownloadRule::matchesSmartEpisodeFilter(const QString& articleTitle) const
|
bool AutoDownloadRule::matchesSmartEpisodeFilter(const QString &articleTitle) const
|
||||||
{
|
{
|
||||||
if (!useSmartFilter())
|
if (!useSmartFilter())
|
||||||
return true;
|
return true;
|
||||||
|
@ -442,7 +442,7 @@ AutoDownloadRule AutoDownloadRule::fromJsonObject(const QJsonObject &jsonObj, co
|
||||||
QStringList feedURLs;
|
QStringList feedURLs;
|
||||||
if (feedsVal.isString())
|
if (feedsVal.isString())
|
||||||
feedURLs << feedsVal.toString();
|
feedURLs << feedsVal.toString();
|
||||||
else foreach (const QJsonValue &urlVal, feedsVal.toArray())
|
else for (const QJsonValue &urlVal : asConst(feedsVal.toArray()))
|
||||||
feedURLs << urlVal.toString();
|
feedURLs << urlVal.toString();
|
||||||
rule.setFeedURLs(feedURLs);
|
rule.setFeedURLs(feedURLs);
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ AutoDownloadRule AutoDownloadRule::fromJsonObject(const QJsonObject &jsonObj, co
|
||||||
previouslyMatched << previouslyMatchedVal.toString();
|
previouslyMatched << previouslyMatchedVal.toString();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
foreach (const QJsonValue &val, previouslyMatchedVal.toArray())
|
for (const QJsonValue &val : asConst(previouslyMatchedVal.toArray()))
|
||||||
previouslyMatched << val.toString();
|
previouslyMatched << val.toString();
|
||||||
}
|
}
|
||||||
rule.setPreviouslyMatchedEpisodes(previouslyMatched);
|
rule.setPreviouslyMatchedEpisodes(previouslyMatched);
|
||||||
|
|
|
@ -109,7 +109,7 @@ QList<Article *> Feed::articles() const
|
||||||
void Feed::markAsRead()
|
void Feed::markAsRead()
|
||||||
{
|
{
|
||||||
auto oldUnreadCount = m_unreadCount;
|
auto oldUnreadCount = m_unreadCount;
|
||||||
foreach (Article *article, m_articles) {
|
for (Article *article : asConst(m_articles)) {
|
||||||
if (!article->isRead()) {
|
if (!article->isRead()) {
|
||||||
article->disconnect(this);
|
article->disconnect(this);
|
||||||
article->markAsRead();
|
article->markAsRead();
|
||||||
|
@ -282,9 +282,9 @@ void Feed::loadArticles(const QByteArray &data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray jsonArr = jsonDoc.array();
|
const QJsonArray jsonArr = jsonDoc.array();
|
||||||
int i = -1;
|
int i = -1;
|
||||||
foreach (const QJsonValue &jsonVal, jsonArr) {
|
for (const QJsonValue &jsonVal : jsonArr) {
|
||||||
++i;
|
++i;
|
||||||
if (!jsonVal.isObject()) {
|
if (!jsonVal.isObject()) {
|
||||||
LogMsg(tr("Couldn't load RSS article '%1#%2'. Invalid data format.").arg(m_url).arg(i)
|
LogMsg(tr("Couldn't load RSS article '%1#%2'. Invalid data format.").arg(m_url).arg(i)
|
||||||
|
@ -304,9 +304,9 @@ void Feed::loadArticles(const QByteArray &data)
|
||||||
void Feed::loadArticlesLegacy()
|
void Feed::loadArticlesLegacy()
|
||||||
{
|
{
|
||||||
SettingsPtr qBTRSSFeeds = Profile::instance().applicationSettings(QStringLiteral("qBittorrent-rss-feeds"));
|
SettingsPtr qBTRSSFeeds = Profile::instance().applicationSettings(QStringLiteral("qBittorrent-rss-feeds"));
|
||||||
QVariantHash allOldItems = qBTRSSFeeds->value("old_items").toHash();
|
const QVariantHash allOldItems = qBTRSSFeeds->value("old_items").toHash();
|
||||||
|
|
||||||
foreach (const QVariant &var, allOldItems.value(m_url).toList()) {
|
for (const QVariant &var : asConst(allOldItems.value(m_url).toList())) {
|
||||||
auto hash = var.toHash();
|
auto hash = var.toHash();
|
||||||
// update legacy keys
|
// update legacy keys
|
||||||
hash[Article::KeyLink] = hash.take(QLatin1String("news_link"));
|
hash[Article::KeyLink] = hash.take(QLatin1String("news_link"));
|
||||||
|
@ -329,7 +329,7 @@ void Feed::store()
|
||||||
m_savingTimer.stop();
|
m_savingTimer.stop();
|
||||||
|
|
||||||
QJsonArray jsonArr;
|
QJsonArray jsonArr;
|
||||||
foreach (Article *article, m_articles)
|
for (Article *article :asConst(m_articles))
|
||||||
jsonArr << article->toJsonObject();
|
jsonArr << article->toJsonObject();
|
||||||
|
|
||||||
m_session->dataFileStorage()->store(m_dataFileName, QJsonDocument(jsonArr).toJson());
|
m_session->dataFileStorage()->store(m_dataFileName, QJsonDocument(jsonArr).toJson());
|
||||||
|
@ -507,7 +507,7 @@ QJsonValue Feed::toJsonValue(bool withData) const
|
||||||
jsonObj.insert(KEY_HASERROR, hasError());
|
jsonObj.insert(KEY_HASERROR, hasError());
|
||||||
|
|
||||||
QJsonArray jsonArr;
|
QJsonArray jsonArr;
|
||||||
for (Article *article : qAsConst(m_articles))
|
for (Article *article : asConst(m_articles))
|
||||||
jsonArr << article->toJsonObject();
|
jsonArr << article->toJsonObject();
|
||||||
jsonObj.insert(KEY_ARTICLES, jsonArr);
|
jsonObj.insert(KEY_ARTICLES, jsonArr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ Folder::~Folder()
|
||||||
{
|
{
|
||||||
emit aboutToBeDestroyed(this);
|
emit aboutToBeDestroyed(this);
|
||||||
|
|
||||||
foreach (auto item, items())
|
for (auto item : asConst(items()))
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ QList<Article *> Folder::articles() const
|
||||||
{
|
{
|
||||||
QList<Article *> news;
|
QList<Article *> news;
|
||||||
|
|
||||||
foreach (Item *item, items()) {
|
for (Item *item : asConst(items())) {
|
||||||
int n = news.size();
|
int n = news.size();
|
||||||
news << item->articles();
|
news << item->articles();
|
||||||
std::inplace_merge(news.begin(), news.begin() + n, news.end()
|
std::inplace_merge(news.begin(), news.begin() + n, news.end()
|
||||||
|
@ -70,20 +70,20 @@ QList<Article *> Folder::articles() const
|
||||||
int Folder::unreadCount() const
|
int Folder::unreadCount() const
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
foreach (Item *item, items())
|
for (Item *item : asConst(items()))
|
||||||
count += item->unreadCount();
|
count += item->unreadCount();
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Folder::markAsRead()
|
void Folder::markAsRead()
|
||||||
{
|
{
|
||||||
foreach (Item *item, items())
|
for (Item *item : asConst(items()))
|
||||||
item->markAsRead();
|
item->markAsRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Folder::refresh()
|
void Folder::refresh()
|
||||||
{
|
{
|
||||||
foreach (Item *item, items())
|
for (Item *item : asConst(items()))
|
||||||
item->refresh();
|
item->refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ QList<Item *> Folder::items() const
|
||||||
QJsonValue Folder::toJsonValue(bool withData) const
|
QJsonValue Folder::toJsonValue(bool withData) const
|
||||||
{
|
{
|
||||||
QJsonObject jsonObj;
|
QJsonObject jsonObj;
|
||||||
foreach (Item *item, items())
|
for (Item *item : asConst(items()))
|
||||||
jsonObj.insert(item->name(), item->toJsonValue(withData));
|
jsonObj.insert(item->name(), item->toJsonValue(withData));
|
||||||
|
|
||||||
return jsonObj;
|
return jsonObj;
|
||||||
|
@ -108,7 +108,7 @@ void Folder::handleItemUnreadCountChanged()
|
||||||
|
|
||||||
void Folder::cleanup()
|
void Folder::cleanup()
|
||||||
{
|
{
|
||||||
foreach (Item *item, items())
|
for (Item *item : asConst(items()))
|
||||||
item->cleanup();
|
item->cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ void Folder::addItem(Item *item)
|
||||||
connect(item, &Item::articleAboutToBeRemoved, this, &Item::articleAboutToBeRemoved);
|
connect(item, &Item::articleAboutToBeRemoved, this, &Item::articleAboutToBeRemoved);
|
||||||
connect(item, &Item::unreadCountChanged, this, &Folder::handleItemUnreadCountChanged);
|
connect(item, &Item::unreadCountChanged, this, &Folder::handleItemUnreadCountChanged);
|
||||||
|
|
||||||
for (auto article: copyAsConst(item->articles()))
|
for (auto article : asConst(item->articles()))
|
||||||
emit newArticle(article);
|
emit newArticle(article);
|
||||||
|
|
||||||
if (item->unreadCount() > 0)
|
if (item->unreadCount() > 0)
|
||||||
|
@ -134,7 +134,7 @@ void Folder::removeItem(Item *item)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_items.contains(item));
|
Q_ASSERT(m_items.contains(item));
|
||||||
|
|
||||||
for (auto article: copyAsConst(item->articles()))
|
for (auto article : asConst(item->articles()))
|
||||||
emit articleAboutToBeRemoved(article);
|
emit articleAboutToBeRemoved(article);
|
||||||
|
|
||||||
item->disconnect(this);
|
item->disconnect(this);
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include <QVariantHash>
|
#include <QVariantHash>
|
||||||
|
|
||||||
#include "../asyncfilestorage.h"
|
#include "../asyncfilestorage.h"
|
||||||
|
#include "../global.h"
|
||||||
#include "../logger.h"
|
#include "../logger.h"
|
||||||
#include "../profile.h"
|
#include "../profile.h"
|
||||||
#include "../settingsstorage.h"
|
#include "../settingsstorage.h"
|
||||||
|
@ -283,7 +284,7 @@ void Session::load()
|
||||||
void Session::loadFolder(const QJsonObject &jsonObj, Folder *folder)
|
void Session::loadFolder(const QJsonObject &jsonObj, Folder *folder)
|
||||||
{
|
{
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
foreach (const QString &key, jsonObj.keys()) {
|
for (const QString &key : asConst(jsonObj.keys())) {
|
||||||
const QJsonValue val {jsonObj[key]};
|
const QJsonValue val {jsonObj[key]};
|
||||||
if (val.isString()) {
|
if (val.isString()) {
|
||||||
// previous format (reduced form) doesn't contain UID
|
// previous format (reduced form) doesn't contain UID
|
||||||
|
@ -355,7 +356,7 @@ void Session::loadLegacy()
|
||||||
const QString parentFolderPath = Item::parentPath(legacyPath);
|
const QString parentFolderPath = Item::parentPath(legacyPath);
|
||||||
const QString feedUrl = Item::relativeName(legacyPath);
|
const QString feedUrl = Item::relativeName(legacyPath);
|
||||||
|
|
||||||
foreach (const QString &folderPath, Item::expandPath(parentFolderPath))
|
for (const QString &folderPath : asConst(Item::expandPath(parentFolderPath)))
|
||||||
addFolder(folderPath);
|
addFolder(folderPath);
|
||||||
|
|
||||||
const QString feedPath = feedAliases[i].isEmpty()
|
const QString feedPath = feedAliases[i].isEmpty()
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#include "bittorrent/session.h"
|
#include "bittorrent/session.h"
|
||||||
#include "filesystemwatcher.h"
|
#include "filesystemwatcher.h"
|
||||||
|
#include "global.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
#include "utils/fs.h"
|
#include "utils/fs.h"
|
||||||
|
|
||||||
|
@ -254,7 +255,7 @@ void ScanFoldersModel::addToFSWatcher(const QStringList &watchPaths)
|
||||||
if (!m_fsWatcher)
|
if (!m_fsWatcher)
|
||||||
return; // addPath() wasn't called before this
|
return; // addPath() wasn't called before this
|
||||||
|
|
||||||
foreach (const QString &path, watchPaths) {
|
for (const QString &path : watchPaths) {
|
||||||
QDir watchDir(path);
|
QDir watchDir(path);
|
||||||
const QString canonicalWatchPath = watchDir.canonicalPath();
|
const QString canonicalWatchPath = watchDir.canonicalPath();
|
||||||
m_fsWatcher->addPath(canonicalWatchPath);
|
m_fsWatcher->addPath(canonicalWatchPath);
|
||||||
|
@ -282,7 +283,7 @@ bool ScanFoldersModel::removePath(const QString &path, bool removeFromFSWatcher)
|
||||||
|
|
||||||
void ScanFoldersModel::removeFromFSWatcher(const QStringList &watchPaths)
|
void ScanFoldersModel::removeFromFSWatcher(const QStringList &watchPaths)
|
||||||
{
|
{
|
||||||
foreach (const QString &path, watchPaths)
|
for (const QString &path : watchPaths)
|
||||||
m_fsWatcher->removePath(path);
|
m_fsWatcher->removePath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +327,7 @@ void ScanFoldersModel::makePersistent()
|
||||||
{
|
{
|
||||||
QVariantHash dirs;
|
QVariantHash dirs;
|
||||||
|
|
||||||
foreach (const PathData *pathData, m_pathList) {
|
for (const PathData *pathData : asConst(m_pathList)) {
|
||||||
if (pathData->downloadType == CUSTOM_LOCATION)
|
if (pathData->downloadType == CUSTOM_LOCATION)
|
||||||
dirs.insert(Utils::Fs::fromNativePath(pathData->watchPath), Utils::Fs::fromNativePath(pathData->downloadPath));
|
dirs.insert(Utils::Fs::fromNativePath(pathData->watchPath), Utils::Fs::fromNativePath(pathData->downloadPath));
|
||||||
else
|
else
|
||||||
|
@ -350,7 +351,7 @@ void ScanFoldersModel::configure()
|
||||||
|
|
||||||
void ScanFoldersModel::addTorrentsToSession(const QStringList &pathList)
|
void ScanFoldersModel::addTorrentsToSession(const QStringList &pathList)
|
||||||
{
|
{
|
||||||
foreach (const QString &file, pathList) {
|
for (const QString &file : pathList) {
|
||||||
qDebug("File %s added", qUtf8Printable(file));
|
qDebug("File %s added", qUtf8Printable(file));
|
||||||
|
|
||||||
BitTorrent::AddTorrentParams params;
|
BitTorrent::AddTorrentParams params;
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include "../global.h"
|
||||||
#include "../utils/foreignapps.h"
|
#include "../utils/foreignapps.h"
|
||||||
#include "../utils/fs.h"
|
#include "../utils/fs.h"
|
||||||
#include "searchpluginmanager.h"
|
#include "searchpluginmanager.h"
|
||||||
|
@ -138,7 +139,7 @@ void SearchHandler::readSearchOutput()
|
||||||
m_searchResultLineTruncated = lines.takeLast().trimmed();
|
m_searchResultLineTruncated = lines.takeLast().trimmed();
|
||||||
|
|
||||||
QList<SearchResult> searchResultList;
|
QList<SearchResult> searchResultList;
|
||||||
foreach (const QByteArray &line, lines) {
|
for (const QByteArray &line : asConst(lines)) {
|
||||||
SearchResult searchResult;
|
SearchResult searchResult;
|
||||||
if (parseSearchResult(QString::fromUtf8(line), searchResult))
|
if (parseSearchResult(QString::fromUtf8(line), searchResult))
|
||||||
searchResultList << searchResult;
|
searchResultList << searchResult;
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
dirs += iter.next();
|
dirs += iter.next();
|
||||||
|
|
||||||
for (const QString &dir : qAsConst(dirs)) {
|
for (const QString &dir : asConst(dirs)) {
|
||||||
// python 3: remove "__pycache__" folders
|
// python 3: remove "__pycache__" folders
|
||||||
if (dir.endsWith("/__pycache__")) {
|
if (dir.endsWith("/__pycache__")) {
|
||||||
Utils::Fs::removeDirRecursive(dir);
|
Utils::Fs::removeDirRecursive(dir);
|
||||||
|
@ -120,7 +120,7 @@ QStringList SearchPluginManager::allPlugins() const
|
||||||
QStringList SearchPluginManager::enabledPlugins() const
|
QStringList SearchPluginManager::enabledPlugins() const
|
||||||
{
|
{
|
||||||
QStringList plugins;
|
QStringList plugins;
|
||||||
for (const PluginInfo *plugin : qAsConst(m_plugins)) {
|
for (const PluginInfo *plugin : asConst(m_plugins)) {
|
||||||
if (plugin->enabled)
|
if (plugin->enabled)
|
||||||
plugins << plugin->name;
|
plugins << plugin->name;
|
||||||
}
|
}
|
||||||
|
@ -131,9 +131,9 @@ QStringList SearchPluginManager::enabledPlugins() const
|
||||||
QStringList SearchPluginManager::supportedCategories() const
|
QStringList SearchPluginManager::supportedCategories() const
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
for (const PluginInfo *plugin : qAsConst(m_plugins)) {
|
for (const PluginInfo *plugin : asConst(m_plugins)) {
|
||||||
if (plugin->enabled) {
|
if (plugin->enabled) {
|
||||||
foreach (QString cat, plugin->supportedCategories) {
|
for (const QString &cat : plugin->supportedCategories) {
|
||||||
if (!result.contains(cat))
|
if (!result.contains(cat))
|
||||||
result << cat;
|
result << cat;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ QStringList SearchPluginManager::getPluginCategories(const QString &pluginName)
|
||||||
plugins << pluginName.trimmed();
|
plugins << pluginName.trimmed();
|
||||||
|
|
||||||
QSet<QString> categories;
|
QSet<QString> categories;
|
||||||
for (const QString &name : qAsConst(plugins)) {
|
for (const QString &name : asConst(plugins)) {
|
||||||
const PluginInfo *plugin = pluginInfo(name);
|
const PluginInfo *plugin = pluginInfo(name);
|
||||||
if (!plugin) continue; // plugin wasn't found
|
if (!plugin) continue; // plugin wasn't found
|
||||||
for (const QString &category : plugin->supportedCategories)
|
for (const QString &category : plugin->supportedCategories)
|
||||||
|
@ -277,9 +277,8 @@ bool SearchPluginManager::uninstallPlugin(const QString &name)
|
||||||
QDir pluginsFolder(pluginsLocation());
|
QDir pluginsFolder(pluginsLocation());
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
filters << name + ".*";
|
filters << name + ".*";
|
||||||
QStringList files = pluginsFolder.entryList(filters, QDir::Files, QDir::Unsorted);
|
const QStringList files = pluginsFolder.entryList(filters, QDir::Files, QDir::Unsorted);
|
||||||
QString file;
|
for (const QString &file : files)
|
||||||
foreach (file, files)
|
|
||||||
Utils::Fs::forceRemove(pluginsFolder.absoluteFilePath(file));
|
Utils::Fs::forceRemove(pluginsFolder.absoluteFilePath(file));
|
||||||
// Remove it from supported engines
|
// Remove it from supported engines
|
||||||
delete m_plugins.take(name);
|
delete m_plugins.take(name);
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
|
#include "global.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "profile.h"
|
#include "profile.h"
|
||||||
#include "utils/fs.h"
|
#include "utils/fs.h"
|
||||||
|
@ -286,7 +287,7 @@ QString TransactionalSettings::deserialize(const QString &name, QVariantHash &da
|
||||||
// Copy everything into memory. This means even keys inserted in the file manually
|
// Copy everything into memory. This means even keys inserted in the file manually
|
||||||
// or that we don't touch directly in this code (eg disabled by ifdef). This ensures
|
// or that we don't touch directly in this code (eg disabled by ifdef). This ensures
|
||||||
// that they will be copied over when save our settings to disk.
|
// that they will be copied over when save our settings to disk.
|
||||||
foreach (const QString &key, settings->allKeys())
|
for (const QString &key : asConst(settings->allKeys()))
|
||||||
data.insert(key, settings->value(key));
|
data.insert(key, settings->value(key));
|
||||||
|
|
||||||
return settings->fileName();
|
return settings->fileName();
|
||||||
|
|
|
@ -229,7 +229,7 @@ namespace
|
||||||
|
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
#endif
|
#endif // Q_OS_WIN
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Utils::ForeignApps::PythonInfo::isValid() const
|
bool Utils::ForeignApps::PythonInfo::isValid() const
|
||||||
|
|
|
@ -133,7 +133,7 @@ bool Utils::Fs::smartRemoveEmptyFolderTree(const QString &path)
|
||||||
std::sort(dirList.begin(), dirList.end()
|
std::sort(dirList.begin(), dirList.end()
|
||||||
, [](const QString &l, const QString &r) { return l.count('/') > r.count('/'); });
|
, [](const QString &l, const QString &r) { return l.count('/') > r.count('/'); });
|
||||||
|
|
||||||
for (const QString &p : qAsConst(dirList)) {
|
for (const QString &p : asConst(dirList)) {
|
||||||
// remove unwanted files
|
// remove unwanted files
|
||||||
for (const QString &f : deleteFilesList) {
|
for (const QString &f : deleteFilesList) {
|
||||||
forceRemove(p + f);
|
forceRemove(p + f);
|
||||||
|
@ -141,7 +141,7 @@ bool Utils::Fs::smartRemoveEmptyFolderTree(const QString &path)
|
||||||
|
|
||||||
// remove temp files on linux (file ends with '~'), e.g. `filename~`
|
// remove temp files on linux (file ends with '~'), e.g. `filename~`
|
||||||
QDir dir(p);
|
QDir dir(p);
|
||||||
QStringList tmpFileList = dir.entryList(QDir::Files);
|
const QStringList tmpFileList = dir.entryList(QDir::Files);
|
||||||
for (const QString &f : tmpFileList) {
|
for (const QString &f : tmpFileList) {
|
||||||
if (f.endsWith('~'))
|
if (f.endsWith('~'))
|
||||||
forceRemove(p + f);
|
forceRemove(p + f);
|
||||||
|
@ -329,7 +329,7 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path)
|
||||||
return ((strncmp(buf.f_fstypename, "cifs", sizeof(buf.f_fstypename)) == 0)
|
return ((strncmp(buf.f_fstypename, "cifs", sizeof(buf.f_fstypename)) == 0)
|
||||||
|| (strncmp(buf.f_fstypename, "nfs", sizeof(buf.f_fstypename)) == 0)
|
|| (strncmp(buf.f_fstypename, "nfs", sizeof(buf.f_fstypename)) == 0)
|
||||||
|| (strncmp(buf.f_fstypename, "smbfs", sizeof(buf.f_fstypename)) == 0));
|
|| (strncmp(buf.f_fstypename, "smbfs", sizeof(buf.f_fstypename)) == 0));
|
||||||
#else
|
#else // Q_OS_WIN
|
||||||
QString file = path;
|
QString file = path;
|
||||||
if (!file.endsWith('/'))
|
if (!file.endsWith('/'))
|
||||||
file += '/';
|
file += '/';
|
||||||
|
@ -351,6 +351,6 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path)
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // Q_OS_WIN
|
||||||
}
|
}
|
||||||
#endif
|
#endif // Q_OS_HAIKU
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
||||||
#include "base/utils/version.h"
|
#include "base/utils/version.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif // DISABLE_GUI
|
||||||
|
|
||||||
#include "base/logger.h"
|
#include "base/logger.h"
|
||||||
#include "base/unicodestrings.h"
|
#include "base/unicodestrings.h"
|
||||||
|
@ -391,7 +391,7 @@ QString Utils::Misc::getUserIDString()
|
||||||
QStringList Utils::Misc::toStringList(const QList<bool> &l)
|
QStringList Utils::Misc::toStringList(const QList<bool> &l)
|
||||||
{
|
{
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
foreach (const bool &b, l)
|
for (const bool b : l)
|
||||||
ret << (b ? "1" : "0");
|
ret << (b ? "1" : "0");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -399,7 +399,7 @@ QStringList Utils::Misc::toStringList(const QList<bool> &l)
|
||||||
QList<int> Utils::Misc::intListfromStringList(const QStringList &l)
|
QList<int> Utils::Misc::intListfromStringList(const QStringList &l)
|
||||||
{
|
{
|
||||||
QList<int> ret;
|
QList<int> ret;
|
||||||
foreach (const QString &s, l)
|
for (const QString &s : l)
|
||||||
ret << s.toInt();
|
ret << s.toInt();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -407,7 +407,7 @@ QList<int> Utils::Misc::intListfromStringList(const QStringList &l)
|
||||||
QList<bool> Utils::Misc::boolListfromStringList(const QStringList &l)
|
QList<bool> Utils::Misc::boolListfromStringList(const QStringList &l)
|
||||||
{
|
{
|
||||||
QList<bool> ret;
|
QList<bool> ret;
|
||||||
foreach (const QString &s, l)
|
for (const QString &s : l)
|
||||||
ret << (s == "1");
|
ret << (s == "1");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ namespace Utils
|
||||||
return reinterpret_cast<T>(
|
return reinterpret_cast<T>(
|
||||||
::GetProcAddress(::LoadLibraryW(pathWchar.get()), funcName));
|
::GetProcAddress(::LoadLibraryW(pathWchar.get()), funcName));
|
||||||
}
|
}
|
||||||
#endif
|
#endif // Q_OS_WIN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace Utils
|
||||||
{
|
{
|
||||||
if (str.length() < 2) return str;
|
if (str.length() < 2) return str;
|
||||||
|
|
||||||
for (auto const quote : quotes) {
|
for (const auto "e : quotes) {
|
||||||
if (str.startsWith(quote) && str.endsWith(quote))
|
if (str.startsWith(quote) && str.endsWith(quote))
|
||||||
return str.mid(1, str.length() - 2);
|
return str.mid(1, str.length() - 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
|
||||||
m_ui->categoryComboBox->addItem(defaultCategory);
|
m_ui->categoryComboBox->addItem(defaultCategory);
|
||||||
m_ui->categoryComboBox->addItem("");
|
m_ui->categoryComboBox->addItem("");
|
||||||
|
|
||||||
foreach (const QString &category, categories)
|
for (const QString &category : asConst(categories))
|
||||||
if (category != defaultCategory && category != m_torrentParams.category)
|
if (category != defaultCategory && category != m_torrentParams.category)
|
||||||
m_ui->categoryComboBox->addItem(category);
|
m_ui->categoryComboBox->addItem(category);
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ void AddNewTorrentDialog::saveSavePathHistory() const
|
||||||
// Get current history
|
// Get current history
|
||||||
QStringList history = settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList();
|
QStringList history = settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList();
|
||||||
QVector<QDir> historyDirs;
|
QVector<QDir> historyDirs;
|
||||||
for (const QString &path : qAsConst(history))
|
for (const QString &path : asConst(history))
|
||||||
historyDirs << QDir {path};
|
historyDirs << QDir {path};
|
||||||
|
|
||||||
const QDir selectedSavePath {m_ui->savePath->selectedPath()};
|
const QDir selectedSavePath {m_ui->savePath->selectedPath()};
|
||||||
|
@ -631,7 +631,7 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
|
||||||
prio = prio::IGNORED;
|
prio = prio::IGNORED;
|
||||||
|
|
||||||
qDebug("Setting files priority");
|
qDebug("Setting files priority");
|
||||||
foreach (const QModelIndex &index, selectedRows) {
|
for (const QModelIndex &index : selectedRows) {
|
||||||
qDebug("Setting priority(%d) for file at row %d", prio, index.row());
|
qDebug("Setting priority(%d) for file at row %d", prio, index.row());
|
||||||
m_contentModel->setData(m_contentModel->index(index.row(), PRIORITY, index.parent()), prio);
|
m_contentModel->setData(m_contentModel->index(index.row(), PRIORITY, index.parent()), prio);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <QNetworkInterface>
|
#include <QNetworkInterface>
|
||||||
|
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
#include "base/unicodestrings.h"
|
#include "base/unicodestrings.h"
|
||||||
#include "app/application.h"
|
#include "app/application.h"
|
||||||
|
@ -286,13 +287,13 @@ void AdvancedSettings::updateInterfaceAddressCombo()
|
||||||
};
|
};
|
||||||
|
|
||||||
if (ifaceName.isEmpty()) {
|
if (ifaceName.isEmpty()) {
|
||||||
foreach (const QHostAddress &ip, QNetworkInterface::allAddresses())
|
for (const QHostAddress &ip : asConst(QNetworkInterface::allAddresses()))
|
||||||
populateCombo(ip.toString(), ip.protocol());
|
populateCombo(ip.toString(), ip.protocol());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const QNetworkInterface iface = QNetworkInterface::interfaceFromName(ifaceName);
|
const QNetworkInterface iface = QNetworkInterface::interfaceFromName(ifaceName);
|
||||||
const QList<QNetworkAddressEntry> addresses = iface.addressEntries();
|
const QList<QNetworkAddressEntry> addresses = iface.addressEntries();
|
||||||
foreach (const QNetworkAddressEntry &entry, addresses) {
|
for (const QNetworkAddressEntry &entry : addresses) {
|
||||||
const QHostAddress ip = entry.ip();
|
const QHostAddress ip = entry.ip();
|
||||||
populateCombo(ip.toString(), ip.protocol());
|
populateCombo(ip.toString(), ip.protocol());
|
||||||
}
|
}
|
||||||
|
@ -425,7 +426,7 @@ void AdvancedSettings::loadAdvancedSettings()
|
||||||
const QString currentInterface = session->networkInterface();
|
const QString currentInterface = session->networkInterface();
|
||||||
bool interfaceExists = currentInterface.isEmpty();
|
bool interfaceExists = currentInterface.isEmpty();
|
||||||
int i = 1;
|
int i = 1;
|
||||||
foreach (const QNetworkInterface& iface, QNetworkInterface::allInterfaces()) {
|
for (const QNetworkInterface &iface : asConst(QNetworkInterface::allInterfaces())) {
|
||||||
// This line fixes a Qt bug => https://bugreports.qt.io/browse/QTBUG-52633
|
// This line fixes a Qt bug => https://bugreports.qt.io/browse/QTBUG-52633
|
||||||
// Tested in Qt 5.6.0. For more info see:
|
// Tested in Qt 5.6.0. For more info see:
|
||||||
// https://github.com/qbittorrent/qBittorrent/issues/5131
|
// https://github.com/qbittorrent/qBittorrent/issues/5131
|
||||||
|
|
|
@ -107,8 +107,8 @@ void BanListOptionsDialog::on_buttonBanIP_clicked()
|
||||||
|
|
||||||
void BanListOptionsDialog::on_buttonDeleteIP_clicked()
|
void BanListOptionsDialog::on_buttonDeleteIP_clicked()
|
||||||
{
|
{
|
||||||
QModelIndexList selection = m_ui->bannedIPList->selectionModel()->selectedIndexes();
|
const QModelIndexList selection = m_ui->bannedIPList->selectionModel()->selectedIndexes();
|
||||||
for (auto &i : selection)
|
for (const auto &i : selection)
|
||||||
m_sortFilter->removeRow(i.row());
|
m_sortFilter->removeRow(i.row());
|
||||||
|
|
||||||
m_modified = true;
|
m_modified = true;
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
|
#include "base/global.h"
|
||||||
#include "guiiconprovider.h"
|
#include "guiiconprovider.h"
|
||||||
|
|
||||||
class CategoryModelItem
|
class CategoryModelItem
|
||||||
|
@ -407,7 +408,7 @@ void CategoryFilterModel::populate()
|
||||||
const QString &category = i.key();
|
const QString &category = i.key();
|
||||||
if (m_isSubcategoriesEnabled) {
|
if (m_isSubcategoriesEnabled) {
|
||||||
CategoryModelItem *parent = m_rootItem;
|
CategoryModelItem *parent = m_rootItem;
|
||||||
foreach (const QString &subcat, session->expandCategory(category)) {
|
for (const QString &subcat : asConst(session->expandCategory(category))) {
|
||||||
const QString subcatName = shortName(subcat);
|
const QString subcatName = shortName(subcat);
|
||||||
if (!parent->hasChild(subcatName)) {
|
if (!parent->hasChild(subcatName)) {
|
||||||
new CategoryModelItem(
|
new CategoryModelItem(
|
||||||
|
@ -436,7 +437,7 @@ CategoryModelItem *CategoryFilterModel::findItem(const QString &fullName) const
|
||||||
return m_rootItem->child(fullName);
|
return m_rootItem->child(fullName);
|
||||||
|
|
||||||
CategoryModelItem *item = m_rootItem;
|
CategoryModelItem *item = m_rootItem;
|
||||||
foreach (const QString &subcat, BitTorrent::Session::expandCategory(fullName)) {
|
for (const QString &subcat : asConst(BitTorrent::Session::expandCategory(fullName))) {
|
||||||
const QString subcatName = shortName(subcat);
|
const QString subcatName = shortName(subcat);
|
||||||
if (!item->hasChild(subcatName)) return nullptr;
|
if (!item->hasChild(subcatName)) return nullptr;
|
||||||
item = item->child(subcatName);
|
item = item->child(subcatName);
|
||||||
|
|
|
@ -231,7 +231,7 @@ void CategoryFilterWidget::removeCategory()
|
||||||
void CategoryFilterWidget::removeUnusedCategories()
|
void CategoryFilterWidget::removeUnusedCategories()
|
||||||
{
|
{
|
||||||
auto session = BitTorrent::Session::instance();
|
auto session = BitTorrent::Session::instance();
|
||||||
for (const QString &category : copyAsConst(session->categories().keys())) {
|
for (const QString &category : asConst(session->categories().keys())) {
|
||||||
if (model()->data(static_cast<CategoryFilterProxyModel *>(model())->index(category), Qt::UserRole) == 0)
|
if (model()->data(static_cast<CategoryFilterProxyModel *>(model())->index(category), Qt::UserRole) == 0)
|
||||||
session->removeCategory(category);
|
session->removeCategory(category);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/net/downloadmanager.h"
|
#include "base/net/downloadmanager.h"
|
||||||
#include "base/settingsstorage.h"
|
#include "base/settingsstorage.h"
|
||||||
#include "cookiesmodel.h"
|
#include "cookiesmodel.h"
|
||||||
|
@ -100,6 +101,6 @@ void CookiesDialog::onButtonDeleteClicked()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const QModelIndex &idx : idxs)
|
for (const QModelIndex &idx : asConst(idxs))
|
||||||
m_cookiesModel->removeRow(idx.row());
|
m_cookiesModel->removeRow(idx.row());
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
#include "guiiconprovider.h"
|
#include "guiiconprovider.h"
|
||||||
#include "loglistwidget.h"
|
#include "loglistwidget.h"
|
||||||
#include "ui_executionlogwidget.h"
|
#include "ui_executionlogwidget.h"
|
||||||
|
@ -52,9 +53,9 @@ ExecutionLogWidget::ExecutionLogWidget(QWidget *parent, const Log::MsgTypes &typ
|
||||||
m_ui->tabBan->layout()->addWidget(m_peerList);
|
m_ui->tabBan->layout()->addWidget(m_peerList);
|
||||||
|
|
||||||
const Logger *const logger = Logger::instance();
|
const Logger *const logger = Logger::instance();
|
||||||
foreach (const Log::Msg &msg, logger->getMessages())
|
for (const Log::Msg &msg : asConst(logger->getMessages()))
|
||||||
addLogMessage(msg);
|
addLogMessage(msg);
|
||||||
foreach (const Log::Peer &peer, logger->getPeers())
|
for (const Log::Peer &peer : asConst(logger->getPeers()))
|
||||||
addPeerMessage(peer);
|
addPeerMessage(peer);
|
||||||
connect(logger, &Logger::newLogMessage, this, &ExecutionLogWidget::addLogMessage);
|
connect(logger, &Logger::newLogMessage, this, &ExecutionLogWidget::addLogMessage);
|
||||||
connect(logger, &Logger::newLogPeer, this, &ExecutionLogWidget::addPeerMessage);
|
connect(logger, &Logger::newLogPeer, this, &ExecutionLogWidget::addPeerMessage);
|
||||||
|
|
|
@ -350,7 +350,7 @@ void FileSystemPathComboEdit::addItem(const QString &text)
|
||||||
editWidget<WidgetType>()->addItem(Utils::Fs::toNativePath(text));
|
editWidget<WidgetType>()->addItem(Utils::Fs::toNativePath(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSystemPathComboEdit::insertItem(int index, const QString& text)
|
void FileSystemPathComboEdit::insertItem(int index, const QString &text)
|
||||||
{
|
{
|
||||||
editWidget<WidgetType>()->insertItem(index, Utils::Fs::toNativePath(text));
|
editWidget<WidgetType>()->insertItem(index, Utils::Fs::toNativePath(text));
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ IPSubnetWhitelistOptionsDialog::IPSubnetWhitelistOptionsDialog(QWidget *parent)
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
QStringList authSubnetWhitelistStringList;
|
QStringList authSubnetWhitelistStringList;
|
||||||
for (const Utils::Net::Subnet &subnet : copyAsConst(Preferences::instance()->getWebUiAuthSubnetWhitelist()))
|
for (const Utils::Net::Subnet &subnet : asConst(Preferences::instance()->getWebUiAuthSubnetWhitelist()))
|
||||||
authSubnetWhitelistStringList << Utils::Net::subnetToString(subnet);
|
authSubnetWhitelistStringList << Utils::Net::subnetToString(subnet);
|
||||||
m_model = new QStringListModel(authSubnetWhitelistStringList, this);
|
m_model = new QStringListModel(authSubnetWhitelistStringList, this);
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ void IPSubnetWhitelistOptionsDialog::on_buttonWhitelistIPSubnet_clicked()
|
||||||
|
|
||||||
void IPSubnetWhitelistOptionsDialog::on_buttonDeleteIPSubnet_clicked()
|
void IPSubnetWhitelistOptionsDialog::on_buttonDeleteIPSubnet_clicked()
|
||||||
{
|
{
|
||||||
for (const auto &i : copyAsConst(m_ui->whitelistedIPSubnetList->selectionModel()->selectedIndexes()))
|
for (const auto &i : asConst(m_ui->whitelistedIPSubnetList->selectionModel()->selectedIndexes()))
|
||||||
m_sortFilter->removeRow(i.row());
|
m_sortFilter->removeRow(i.row());
|
||||||
|
|
||||||
m_modified = true;
|
m_modified = true;
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
#include "guiiconprovider.h"
|
#include "guiiconprovider.h"
|
||||||
|
|
||||||
LogListWidget::LogListWidget(int maxLines, const Log::MsgTypes &types, QWidget *parent)
|
LogListWidget::LogListWidget(int maxLines, const Log::MsgTypes &types, QWidget *parent)
|
||||||
|
@ -97,7 +98,7 @@ void LogListWidget::copySelection()
|
||||||
{
|
{
|
||||||
static const QRegularExpression htmlTag("<[^>]+>");
|
static const QRegularExpression htmlTag("<[^>]+>");
|
||||||
QStringList strings;
|
QStringList strings;
|
||||||
foreach (QListWidgetItem* it, selectedItems())
|
for (QListWidgetItem* it : asConst(selectedItems()))
|
||||||
strings << static_cast<QLabel*>(itemWidget(it))->text().remove(htmlTag);
|
strings << static_cast<QLabel*>(itemWidget(it))->text().remove(htmlTag);
|
||||||
|
|
||||||
QApplication::clipboard()->setText(strings.join('\n'));
|
QApplication::clipboard()->setText(strings.join('\n'));
|
||||||
|
|
|
@ -284,7 +284,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
m_prioSeparatorMenu = m_ui->menuEdit->insertSeparator(m_ui->actionTopPriority);
|
m_prioSeparatorMenu = m_ui->menuEdit->insertSeparator(m_ui->actionTopPriority);
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
foreach (QAction *action, m_ui->toolBar->actions()) {
|
for (QAction *action : asConst(m_ui->toolBar->actions())) {
|
||||||
if (action->isSeparator()) {
|
if (action->isSeparator()) {
|
||||||
QWidget *spacer = new QWidget(this);
|
QWidget *spacer = new QWidget(this);
|
||||||
spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
|
@ -305,7 +305,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
spacer->setMinimumWidth(8);
|
spacer->setMinimumWidth(8);
|
||||||
m_ui->toolBar->addWidget(spacer);
|
m_ui->toolBar->addWidget(spacer);
|
||||||
}
|
}
|
||||||
#endif
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
// Transfer list slots
|
// Transfer list slots
|
||||||
connect(m_ui->actionStart, &QAction::triggered, m_transferListWidget, &TransferListWidget::startSelectedTorrents);
|
connect(m_ui->actionStart, &QAction::triggered, m_transferListWidget, &TransferListWidget::startSelectedTorrents);
|
||||||
|
@ -1110,7 +1110,7 @@ void MainWindow::toggleVisibility(const QSystemTrayIcon::ActivationReason reason
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
// Display About Dialog
|
// Display About Dialog
|
||||||
void MainWindow::on_actionAbout_triggered()
|
void MainWindow::on_actionAbout_triggered()
|
||||||
|
@ -1239,7 +1239,7 @@ bool MainWindow::event(QEvent *e)
|
||||||
qDebug() << "Has active window:" << (qApp->activeWindow() != nullptr);
|
qDebug() << "Has active window:" << (qApp->activeWindow() != nullptr);
|
||||||
// Check if there is a modal window
|
// Check if there is a modal window
|
||||||
bool hasModalWindow = false;
|
bool hasModalWindow = false;
|
||||||
foreach (QWidget *widget, QApplication::allWidgets()) {
|
for (QWidget *widget : asConst(QApplication::allWidgets())) {
|
||||||
if (widget->isModal()) {
|
if (widget->isModal()) {
|
||||||
hasModalWindow = true;
|
hasModalWindow = true;
|
||||||
break;
|
break;
|
||||||
|
@ -1272,7 +1272,7 @@ bool MainWindow::event(QEvent *e)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
return QMainWindow::event(e);
|
return QMainWindow::event(e);
|
||||||
}
|
}
|
||||||
|
@ -1285,7 +1285,7 @@ void MainWindow::dropEvent(QDropEvent *event)
|
||||||
// remove scheme
|
// remove scheme
|
||||||
QStringList files;
|
QStringList files;
|
||||||
if (event->mimeData()->hasUrls()) {
|
if (event->mimeData()->hasUrls()) {
|
||||||
foreach (const QUrl &url, event->mimeData()->urls()) {
|
for (const QUrl &url : asConst(event->mimeData()->urls())) {
|
||||||
if (url.isEmpty())
|
if (url.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1300,7 +1300,7 @@ void MainWindow::dropEvent(QDropEvent *event)
|
||||||
|
|
||||||
// differentiate ".torrent" files/links & magnet links from others
|
// differentiate ".torrent" files/links & magnet links from others
|
||||||
QStringList torrentFiles, otherFiles;
|
QStringList torrentFiles, otherFiles;
|
||||||
foreach (const QString &file, files) {
|
for (const QString &file : asConst(files)) {
|
||||||
const bool isTorrentLink = (file.startsWith("magnet:", Qt::CaseInsensitive)
|
const bool isTorrentLink = (file.startsWith("magnet:", Qt::CaseInsensitive)
|
||||||
|| file.endsWith(C_TORRENT_FILE_EXTENSION, Qt::CaseInsensitive)
|
|| file.endsWith(C_TORRENT_FILE_EXTENSION, Qt::CaseInsensitive)
|
||||||
|| Utils::Misc::isUrl(file));
|
|| Utils::Misc::isUrl(file));
|
||||||
|
@ -1312,7 +1312,7 @@ void MainWindow::dropEvent(QDropEvent *event)
|
||||||
|
|
||||||
// Download torrents
|
// Download torrents
|
||||||
const bool useTorrentAdditionDialog = AddNewTorrentDialog::isEnabled();
|
const bool useTorrentAdditionDialog = AddNewTorrentDialog::isEnabled();
|
||||||
foreach (const QString &file, torrentFiles) {
|
for (const QString &file : asConst(torrentFiles)) {
|
||||||
if (useTorrentAdditionDialog)
|
if (useTorrentAdditionDialog)
|
||||||
AddNewTorrentDialog::show(file, this);
|
AddNewTorrentDialog::show(file, this);
|
||||||
else
|
else
|
||||||
|
@ -1321,7 +1321,7 @@ void MainWindow::dropEvent(QDropEvent *event)
|
||||||
if (!torrentFiles.isEmpty()) return;
|
if (!torrentFiles.isEmpty()) return;
|
||||||
|
|
||||||
// Create torrent
|
// Create torrent
|
||||||
foreach (const QString &file, otherFiles) {
|
for (const QString &file : asConst(otherFiles)) {
|
||||||
createTorrentTriggered(file);
|
createTorrentTriggered(file);
|
||||||
|
|
||||||
// currently only hande the first entry
|
// currently only hande the first entry
|
||||||
|
@ -1333,7 +1333,7 @@ void MainWindow::dropEvent(QDropEvent *event)
|
||||||
// Decode if we accept drag 'n drop or not
|
// Decode if we accept drag 'n drop or not
|
||||||
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
|
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
|
||||||
{
|
{
|
||||||
foreach (const QString &mime, event->mimeData()->formats())
|
for (const QString &mime : asConst(event->mimeData()->formats()))
|
||||||
qDebug("mimeData: %s", mime.toLocal8Bit().data());
|
qDebug("mimeData: %s", mime.toLocal8Bit().data());
|
||||||
if (event->mimeData()->hasFormat("text/plain") || event->mimeData()->hasFormat("text/uri-list"))
|
if (event->mimeData()->hasFormat("text/plain") || event->mimeData()->hasFormat("text/uri-list"))
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
|
@ -1361,7 +1361,7 @@ void MainWindow::setupDockClickHandler()
|
||||||
MacUtils::overrideDockClickHandler(dockClickHandler);
|
MacUtils::overrideDockClickHandler(dockClickHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
/*****************************************************
|
/*****************************************************
|
||||||
* *
|
* *
|
||||||
|
@ -1382,7 +1382,7 @@ void MainWindow::on_actionOpen_triggered()
|
||||||
|
|
||||||
const bool useTorrentAdditionDialog = AddNewTorrentDialog::isEnabled();
|
const bool useTorrentAdditionDialog = AddNewTorrentDialog::isEnabled();
|
||||||
if (!pathsList.isEmpty()) {
|
if (!pathsList.isEmpty()) {
|
||||||
foreach (QString file, pathsList) {
|
for (const QString &file : pathsList) {
|
||||||
qDebug("Dropped file %s on download list", qUtf8Printable(file));
|
qDebug("Dropped file %s on download list", qUtf8Printable(file));
|
||||||
if (useTorrentAdditionDialog)
|
if (useTorrentAdditionDialog)
|
||||||
AddNewTorrentDialog::show(file, this);
|
AddNewTorrentDialog::show(file, this);
|
||||||
|
@ -1635,7 +1635,7 @@ void MainWindow::showNotificationBaloon(QString title, QString msg) const
|
||||||
void MainWindow::downloadFromURLList(const QStringList &urlList)
|
void MainWindow::downloadFromURLList(const QStringList &urlList)
|
||||||
{
|
{
|
||||||
const bool useTorrentAdditionDialog = AddNewTorrentDialog::isEnabled();
|
const bool useTorrentAdditionDialog = AddNewTorrentDialog::isEnabled();
|
||||||
foreach (QString url, urlList) {
|
for (QString url : urlList) {
|
||||||
if (((url.size() == 40) && !url.contains(QRegularExpression("[^0-9A-Fa-f]")))
|
if (((url.size() == 40) && !url.contains(QRegularExpression("[^0-9A-Fa-f]")))
|
||||||
|| ((url.size() == 32) && !url.contains(QRegularExpression("[^2-7A-Za-z]"))))
|
|| ((url.size() == 32) && !url.contains(QRegularExpression("[^2-7A-Za-z]"))))
|
||||||
url = "magnet:?xt=urn:btih:" + url;
|
url = "magnet:?xt=urn:btih:" + url;
|
||||||
|
|
|
@ -160,10 +160,10 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
||||||
m_ui->hsplitter->setCollapsible(0, false);
|
m_ui->hsplitter->setCollapsible(0, false);
|
||||||
m_ui->hsplitter->setCollapsible(1, false);
|
m_ui->hsplitter->setCollapsible(1, false);
|
||||||
// Get apply button in button box
|
// Get apply button in button box
|
||||||
QList<QAbstractButton *> buttons = m_ui->buttonBox->buttons();
|
const QList<QAbstractButton *> buttons = m_ui->buttonBox->buttons();
|
||||||
foreach (QAbstractButton *button, buttons) {
|
for (QAbstractButton *button : buttons) {
|
||||||
if (m_ui->buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole) {
|
if (m_ui->buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole) {
|
||||||
applyButton = button;
|
m_applyButton = button;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -424,13 +424,13 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
||||||
connect(m_ui->btnEditRules, &QPushButton::clicked, this, [this]() { AutomatedRssDownloader(this).exec(); });
|
connect(m_ui->btnEditRules, &QPushButton::clicked, this, [this]() { AutomatedRssDownloader(this).exec(); });
|
||||||
|
|
||||||
// Disable apply Button
|
// Disable apply Button
|
||||||
applyButton->setEnabled(false);
|
m_applyButton->setEnabled(false);
|
||||||
// Tab selection mechanism
|
// Tab selection mechanism
|
||||||
connect(m_ui->tabSelection, &QListWidget::currentItemChanged, this, &ThisType::changePage);
|
connect(m_ui->tabSelection, &QListWidget::currentItemChanged, this, &ThisType::changePage);
|
||||||
// Load Advanced settings
|
// Load Advanced settings
|
||||||
advancedSettings = new AdvancedSettings(m_ui->tabAdvancedPage);
|
m_advancedSettings = new AdvancedSettings(m_ui->tabAdvancedPage);
|
||||||
m_ui->advPageLayout->addWidget(advancedSettings);
|
m_ui->advPageLayout->addWidget(m_advancedSettings);
|
||||||
connect(advancedSettings, &AdvancedSettings::settingsChanged, this, &ThisType::enableApplyButton);
|
connect(m_advancedSettings, &AdvancedSettings::settingsChanged, this, &ThisType::enableApplyButton);
|
||||||
|
|
||||||
m_ui->textFileLogPath->setDialogCaption(tr("Choose a save directory"));
|
m_ui->textFileLogPath->setDialogCaption(tr("Choose a save directory"));
|
||||||
m_ui->textFileLogPath->setMode(FileSystemPathEdit::Mode::DirectorySave);
|
m_ui->textFileLogPath->setMode(FileSystemPathEdit::Mode::DirectorySave);
|
||||||
|
@ -453,9 +453,9 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
||||||
|
|
||||||
// disable mouse wheel event on widgets to avoid mis-selection
|
// disable mouse wheel event on widgets to avoid mis-selection
|
||||||
WheelEventEater *wheelEventEater = new WheelEventEater(this);
|
WheelEventEater *wheelEventEater = new WheelEventEater(this);
|
||||||
for (QComboBox *widget : copyAsConst(findChildren<QComboBox *>()))
|
for (QComboBox *widget : asConst(findChildren<QComboBox *>()))
|
||||||
widget->installEventFilter(wheelEventEater);
|
widget->installEventFilter(wheelEventEater);
|
||||||
for (QSpinBox *widget : copyAsConst(findChildren<QSpinBox *>()))
|
for (QSpinBox *widget : asConst(findChildren<QSpinBox *>()))
|
||||||
widget->installEventFilter(wheelEventEater);
|
widget->installEventFilter(wheelEventEater);
|
||||||
|
|
||||||
loadWindowState();
|
loadWindowState();
|
||||||
|
@ -469,7 +469,7 @@ void OptionsDialog::initializeLanguageCombo()
|
||||||
// List language files
|
// List language files
|
||||||
const QDir langDir(":/lang");
|
const QDir langDir(":/lang");
|
||||||
const QStringList langFiles = langDir.entryList(QStringList("qbittorrent_*.qm"), QDir::Files);
|
const QStringList langFiles = langDir.entryList(QStringList("qbittorrent_*.qm"), QDir::Files);
|
||||||
foreach (const QString langFile, langFiles) {
|
for (const QString &langFile : langFiles) {
|
||||||
QString localeStr = langFile.mid(12); // remove "qbittorrent_"
|
QString localeStr = langFile.mid(12); // remove "qbittorrent_"
|
||||||
localeStr.chop(3); // Remove ".qm"
|
localeStr.chop(3); // Remove ".qm"
|
||||||
QString languageName;
|
QString languageName;
|
||||||
|
@ -493,7 +493,7 @@ OptionsDialog::~OptionsDialog()
|
||||||
|
|
||||||
saveWindowState();
|
saveWindowState();
|
||||||
|
|
||||||
foreach (const QString &path, addedScanDirs)
|
for (const QString &path : asConst(m_addedScanDirs))
|
||||||
ScanFoldersModel::instance()->removePath(path);
|
ScanFoldersModel::instance()->removePath(path);
|
||||||
ScanFoldersModel::instance()->configure(); // reloads "removed" paths
|
ScanFoldersModel::instance()->configure(); // reloads "removed" paths
|
||||||
delete m_ui;
|
delete m_ui;
|
||||||
|
@ -541,7 +541,7 @@ void OptionsDialog::saveWindowState() const
|
||||||
|
|
||||||
void OptionsDialog::saveOptions()
|
void OptionsDialog::saveOptions()
|
||||||
{
|
{
|
||||||
applyButton->setEnabled(false);
|
m_applyButton->setEnabled(false);
|
||||||
Preferences *const pref = Preferences::instance();
|
Preferences *const pref = Preferences::instance();
|
||||||
// Load the translation
|
// Load the translation
|
||||||
QString locale = getLocale();
|
QString locale = getLocale();
|
||||||
|
@ -625,11 +625,11 @@ void OptionsDialog::saveOptions()
|
||||||
AddNewTorrentDialog::setTopLevel(m_ui->checkAdditionDialogFront->isChecked());
|
AddNewTorrentDialog::setTopLevel(m_ui->checkAdditionDialogFront->isChecked());
|
||||||
session->setAddTorrentPaused(addTorrentsInPause());
|
session->setAddTorrentPaused(addTorrentsInPause());
|
||||||
session->setCreateTorrentSubfolder(m_ui->checkCreateSubfolder->isChecked());
|
session->setCreateTorrentSubfolder(m_ui->checkCreateSubfolder->isChecked());
|
||||||
ScanFoldersModel::instance()->removeFromFSWatcher(removedScanDirs);
|
ScanFoldersModel::instance()->removeFromFSWatcher(m_removedScanDirs);
|
||||||
ScanFoldersModel::instance()->addToFSWatcher(addedScanDirs);
|
ScanFoldersModel::instance()->addToFSWatcher(m_addedScanDirs);
|
||||||
ScanFoldersModel::instance()->makePersistent();
|
ScanFoldersModel::instance()->makePersistent();
|
||||||
removedScanDirs.clear();
|
m_removedScanDirs.clear();
|
||||||
addedScanDirs.clear();
|
m_addedScanDirs.clear();
|
||||||
session->setTorrentExportDirectory(getTorrentExportDir());
|
session->setTorrentExportDirectory(getTorrentExportDir());
|
||||||
session->setFinishedTorrentExportDirectory(getFinishedTorrentExportDir());
|
session->setFinishedTorrentExportDirectory(getFinishedTorrentExportDir());
|
||||||
pref->setMailNotificationEnabled(m_ui->groupMailNotification->isChecked());
|
pref->setMailNotificationEnabled(m_ui->groupMailNotification->isChecked());
|
||||||
|
@ -748,7 +748,7 @@ void OptionsDialog::saveOptions()
|
||||||
// End Web UI
|
// End Web UI
|
||||||
// End preferences
|
// End preferences
|
||||||
// Save advanced settings
|
// Save advanced settings
|
||||||
advancedSettings->saveAdvancedSettings();
|
m_advancedSettings->saveAdvancedSettings();
|
||||||
// Assume that user changed multiple settings
|
// Assume that user changed multiple settings
|
||||||
// so it's best to save immediately
|
// so it's best to save immediately
|
||||||
pref->apply();
|
pref->apply();
|
||||||
|
@ -1240,7 +1240,7 @@ int OptionsDialog::getMaxUploadsPerTorrent() const
|
||||||
|
|
||||||
void OptionsDialog::on_buttonBox_accepted()
|
void OptionsDialog::on_buttonBox_accepted()
|
||||||
{
|
{
|
||||||
if (applyButton->isEnabled()) {
|
if (m_applyButton->isEnabled()) {
|
||||||
if (!schedTimesOk()) {
|
if (!schedTimesOk()) {
|
||||||
m_ui->tabSelection->setCurrentRow(TAB_SPEED);
|
m_ui->tabSelection->setCurrentRow(TAB_SPEED);
|
||||||
return;
|
return;
|
||||||
|
@ -1249,7 +1249,7 @@ void OptionsDialog::on_buttonBox_accepted()
|
||||||
m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
|
m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
applyButton->setEnabled(false);
|
m_applyButton->setEnabled(false);
|
||||||
this->hide();
|
this->hide();
|
||||||
saveOptions();
|
saveOptions();
|
||||||
}
|
}
|
||||||
|
@ -1259,7 +1259,7 @@ void OptionsDialog::on_buttonBox_accepted()
|
||||||
|
|
||||||
void OptionsDialog::applySettings(QAbstractButton *button)
|
void OptionsDialog::applySettings(QAbstractButton *button)
|
||||||
{
|
{
|
||||||
if (button == applyButton) {
|
if (button == m_applyButton) {
|
||||||
if (!schedTimesOk()) {
|
if (!schedTimesOk()) {
|
||||||
m_ui->tabSelection->setCurrentRow(TAB_SPEED);
|
m_ui->tabSelection->setCurrentRow(TAB_SPEED);
|
||||||
return;
|
return;
|
||||||
|
@ -1291,7 +1291,7 @@ bool OptionsDialog::useAdditionDialog() const
|
||||||
|
|
||||||
void OptionsDialog::enableApplyButton()
|
void OptionsDialog::enableApplyButton()
|
||||||
{
|
{
|
||||||
applyButton->setEnabled(true);
|
m_applyButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsDialog::toggleComboRatioLimitAct()
|
void OptionsDialog::toggleComboRatioLimitAct()
|
||||||
|
@ -1486,7 +1486,7 @@ void OptionsDialog::on_addScanFolderButton_clicked()
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pref->setScanDirsLastPath(dir);
|
pref->setScanDirsLastPath(dir);
|
||||||
addedScanDirs << dir;
|
m_addedScanDirs << dir;
|
||||||
for (int i = 0; i < ScanFoldersModel::instance()->columnCount(); ++i)
|
for (int i = 0; i < ScanFoldersModel::instance()->columnCount(); ++i)
|
||||||
m_ui->scanFoldersView->resizeColumnToContents(i);
|
m_ui->scanFoldersView->resizeColumnToContents(i);
|
||||||
enableApplyButton();
|
enableApplyButton();
|
||||||
|
@ -1504,9 +1504,9 @@ void OptionsDialog::on_removeScanFolderButton_clicked()
|
||||||
if (selected.isEmpty())
|
if (selected.isEmpty())
|
||||||
return;
|
return;
|
||||||
Q_ASSERT(selected.count() == ScanFoldersModel::instance()->columnCount());
|
Q_ASSERT(selected.count() == ScanFoldersModel::instance()->columnCount());
|
||||||
foreach (const QModelIndex &index, selected) {
|
for (const QModelIndex &index : selected) {
|
||||||
if (index.column() == ScanFoldersModel::WATCH)
|
if (index.column() == ScanFoldersModel::WATCH)
|
||||||
removedScanDirs << index.data().toString();
|
m_removedScanDirs << index.data().toString();
|
||||||
}
|
}
|
||||||
ScanFoldersModel::instance()->removePath(selected.first().row(), false);
|
ScanFoldersModel::instance()->removePath(selected.first().row(), false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,11 +176,10 @@ private:
|
||||||
QByteArray m_sslCert, m_sslKey;
|
QByteArray m_sslCert, m_sslKey;
|
||||||
|
|
||||||
Ui::OptionsDialog *m_ui;
|
Ui::OptionsDialog *m_ui;
|
||||||
QButtonGroup choiceLanguage;
|
QAbstractButton *m_applyButton;
|
||||||
QAbstractButton *applyButton;
|
AdvancedSettings *m_advancedSettings;
|
||||||
AdvancedSettings *advancedSettings;
|
QList<QString> m_addedScanDirs;
|
||||||
QList<QString> addedScanDirs;
|
QList<QString> m_removedScanDirs;
|
||||||
QList<QString> removedScanDirs;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OPTIONSDIALOG_H
|
#endif // OPTIONSDIALOG_H
|
||||||
|
|
|
@ -141,7 +141,7 @@ bool ProgramUpdater::isVersionMoreRecent(const QString &remoteVersion) const
|
||||||
qDebug() << Q_FUNC_INFO << "local version:" << localVersion << "/" << QBT_VERSION;
|
qDebug() << Q_FUNC_INFO << "local version:" << localVersion << "/" << QBT_VERSION;
|
||||||
QStringList remoteParts = remoteVersion.split('.');
|
QStringList remoteParts = remoteVersion.split('.');
|
||||||
QStringList localParts = localVersion.split('.');
|
QStringList localParts = localVersion.split('.');
|
||||||
for (int i = 0; i<qMin(remoteParts.size(), localParts.size()); ++i) {
|
for (int i = 0; i < qMin(remoteParts.size(), localParts.size()); ++i) {
|
||||||
if (remoteParts[i].toInt() > localParts[i].toInt())
|
if (remoteParts[i].toInt() > localParts[i].toInt())
|
||||||
return true;
|
return true;
|
||||||
if (remoteParts[i].toInt() < localParts[i].toInt())
|
if (remoteParts[i].toInt() < localParts[i].toInt())
|
||||||
|
|
|
@ -103,7 +103,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
|
||||||
hideColumn(PeerListDelegate::COUNTRY);
|
hideColumn(PeerListDelegate::COUNTRY);
|
||||||
// Ensure that at least one column is visible at all times
|
// Ensure that at least one column is visible at all times
|
||||||
bool atLeastOne = false;
|
bool atLeastOne = false;
|
||||||
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) {
|
for (int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) {
|
||||||
if (!isColumnHidden(i)) {
|
if (!isColumnHidden(i)) {
|
||||||
atLeastOne = true;
|
atLeastOne = true;
|
||||||
break;
|
break;
|
||||||
|
@ -114,7 +114,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
|
||||||
// To also mitigate the above issue, we have to resize each column when
|
// To also mitigate the above issue, we have to resize each column when
|
||||||
// its size is 0, because explicitly 'showing' the column isn't enough
|
// its size is 0, because explicitly 'showing' the column isn't enough
|
||||||
// in the above scenario.
|
// in the above scenario.
|
||||||
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i)
|
for (int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i)
|
||||||
if ((columnWidth(i) <= 0) && !isColumnHidden(i))
|
if ((columnWidth(i) <= 0) && !isColumnHidden(i))
|
||||||
resizeColumnToContents(i);
|
resizeColumnToContents(i);
|
||||||
// Context menu
|
// Context menu
|
||||||
|
@ -169,7 +169,7 @@ void PeerListWidget::displayToggleColumnsMenu(const QPoint &)
|
||||||
actions.append(myAct);
|
actions.append(myAct);
|
||||||
}
|
}
|
||||||
int visibleCols = 0;
|
int visibleCols = 0;
|
||||||
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) {
|
for (int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) {
|
||||||
if (!isColumnHidden(i))
|
if (!isColumnHidden(i))
|
||||||
++visibleCols;
|
++visibleCols;
|
||||||
|
|
||||||
|
@ -248,9 +248,9 @@ void PeerListWidget::showPeerListMenu(const QPoint &)
|
||||||
if (!act) return;
|
if (!act) return;
|
||||||
|
|
||||||
if (act == addPeerAct) {
|
if (act == addPeerAct) {
|
||||||
QList<BitTorrent::PeerAddress> peersList = PeersAdditionDialog::askForPeers(this);
|
const QList<BitTorrent::PeerAddress> peersList = PeersAdditionDialog::askForPeers(this);
|
||||||
int peerCount = 0;
|
int peerCount = 0;
|
||||||
foreach (const BitTorrent::PeerAddress &addr, peersList) {
|
for (const BitTorrent::PeerAddress &addr : peersList) {
|
||||||
if (torrent->connectPeer(addr)) {
|
if (torrent->connectPeer(addr)) {
|
||||||
qDebug("Adding peer %s...", qUtf8Printable(addr.ip.toString()));
|
qDebug("Adding peer %s...", qUtf8Printable(addr.ip.toString()));
|
||||||
Logger::instance()->addMessage(tr("Manually adding peer '%1'...").arg(addr.ip.toString()));
|
Logger::instance()->addMessage(tr("Manually adding peer '%1'...").arg(addr.ip.toString()));
|
||||||
|
@ -284,8 +284,8 @@ void PeerListWidget::banSelectedPeers()
|
||||||
QString(), 0, 1);
|
QString(), 0, 1);
|
||||||
if (ret) return;
|
if (ret) return;
|
||||||
|
|
||||||
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
const QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
||||||
foreach (const QModelIndex &index, selectedIndexes) {
|
for (const QModelIndex &index : selectedIndexes) {
|
||||||
int row = m_proxyModel->mapToSource(index).row();
|
int row = m_proxyModel->mapToSource(index).row();
|
||||||
QString ip = m_listModel->data(m_listModel->index(row, PeerListDelegate::IP_HIDDEN)).toString();
|
QString ip = m_listModel->data(m_listModel->index(row, PeerListDelegate::IP_HIDDEN)).toString();
|
||||||
qDebug("Banning peer %s...", ip.toLocal8Bit().data());
|
qDebug("Banning peer %s...", ip.toLocal8Bit().data());
|
||||||
|
@ -298,9 +298,9 @@ void PeerListWidget::banSelectedPeers()
|
||||||
|
|
||||||
void PeerListWidget::copySelectedPeers()
|
void PeerListWidget::copySelectedPeers()
|
||||||
{
|
{
|
||||||
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
const QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
||||||
QStringList selectedPeers;
|
QStringList selectedPeers;
|
||||||
foreach (const QModelIndex &index, selectedIndexes) {
|
for (const QModelIndex &index : selectedIndexes) {
|
||||||
int row = m_proxyModel->mapToSource(index).row();
|
int row = m_proxyModel->mapToSource(index).row();
|
||||||
QString ip = m_listModel->data(m_listModel->index(row, PeerListDelegate::IP_HIDDEN)).toString();
|
QString ip = m_listModel->data(m_listModel->index(row, PeerListDelegate::IP_HIDDEN)).toString();
|
||||||
QString myport = m_listModel->data(m_listModel->index(row, PeerListDelegate::PORT)).toString();
|
QString myport = m_listModel->data(m_listModel->index(row, PeerListDelegate::PORT)).toString();
|
||||||
|
@ -321,7 +321,7 @@ void PeerListWidget::clear()
|
||||||
int nbrows = m_listModel->rowCount();
|
int nbrows = m_listModel->rowCount();
|
||||||
if (nbrows > 0) {
|
if (nbrows > 0) {
|
||||||
qDebug("Cleared %d peers", nbrows);
|
qDebug("Cleared %d peers", nbrows);
|
||||||
m_listModel->removeRows(0, nbrows);
|
m_listModel->removeRows(0, nbrows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,10 +339,10 @@ void PeerListWidget::loadPeers(BitTorrent::TorrentHandle *const torrent, bool fo
|
||||||
{
|
{
|
||||||
if (!torrent) return;
|
if (!torrent) return;
|
||||||
|
|
||||||
QList<BitTorrent::PeerInfo> peers = torrent->peers();
|
const QList<BitTorrent::PeerInfo> peers = torrent->peers();
|
||||||
QSet<QString> oldPeersSet = m_peerItems.keys().toSet();
|
QSet<QString> oldPeersSet = m_peerItems.keys().toSet();
|
||||||
|
|
||||||
foreach (const BitTorrent::PeerInfo &peer, peers) {
|
for (const BitTorrent::PeerInfo &peer : peers) {
|
||||||
BitTorrent::PeerAddress addr = peer.address();
|
BitTorrent::PeerAddress addr = peer.address();
|
||||||
if (addr.ip.isNull()) continue;
|
if (addr.ip.isNull()) continue;
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
#include "ui_peersadditiondialog.h"
|
#include "ui_peersadditiondialog.h"
|
||||||
|
|
||||||
PeersAdditionDialog::PeersAdditionDialog(QWidget *parent)
|
PeersAdditionDialog::PeersAdditionDialog(QWidget *parent)
|
||||||
|
@ -61,7 +62,7 @@ void PeersAdditionDialog::validateInput()
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
foreach (const QString &peer, m_ui->textEditPeers->toPlainText().trimmed().split('\n')) {
|
for (const QString &peer : asConst(m_ui->textEditPeers->toPlainText().trimmed().split('\n'))) {
|
||||||
BitTorrent::PeerAddress addr = parsePeer(peer);
|
BitTorrent::PeerAddress addr = parsePeer(peer);
|
||||||
if (!addr.ip.isNull()) {
|
if (!addr.ip.isNull()) {
|
||||||
m_peersList.append(addr);
|
m_peersList.append(addr);
|
||||||
|
|
|
@ -259,7 +259,7 @@ void PiecesBar::showToolTip(const QHelpEvent *e)
|
||||||
stream << "<html><body>";
|
stream << "<html><body>";
|
||||||
PieceIndexToImagePos transform {m_torrent->info(), m_image};
|
PieceIndexToImagePos transform {m_torrent->info(), m_image};
|
||||||
int pieceIndex = transform.pieceIndex(imagePos);
|
int pieceIndex = transform.pieceIndex(imagePos);
|
||||||
QVector<int> files {m_torrent->info().fileIndicesForPiece(pieceIndex)};
|
const QVector<int> files {m_torrent->info().fileIndicesForPiece(pieceIndex)};
|
||||||
|
|
||||||
QString tooltipTitle;
|
QString tooltipTitle;
|
||||||
if (files.count() > 1) {
|
if (files.count() > 1) {
|
||||||
|
@ -275,7 +275,7 @@ void PiecesBar::showToolTip(const QHelpEvent *e)
|
||||||
DetailedTooltipRenderer renderer(stream, tooltipTitle);
|
DetailedTooltipRenderer renderer(stream, tooltipTitle);
|
||||||
|
|
||||||
const bool isFileNameCorrectionNeeded = this->isFileNameCorrectionNeeded();
|
const bool isFileNameCorrectionNeeded = this->isFileNameCorrectionNeeded();
|
||||||
for (int f: files) {
|
for (int f : files) {
|
||||||
QString filePath {m_torrent->info().filePath(f)};
|
QString filePath {m_torrent->info().filePath(f)};
|
||||||
if (isFileNameCorrectionNeeded)
|
if (isFileNameCorrectionNeeded)
|
||||||
filePath.replace(QLatin1String("/.unwanted"), QString());
|
filePath.replace(QLatin1String("/.unwanted"), QString());
|
||||||
|
|
|
@ -511,7 +511,7 @@ void PropertiesWidget::loadUrlSeeds()
|
||||||
qDebug("Loading URL seeds");
|
qDebug("Loading URL seeds");
|
||||||
const QList<QUrl> hcSeeds = m_torrent->urlSeeds();
|
const QList<QUrl> hcSeeds = m_torrent->urlSeeds();
|
||||||
// Add url seeds
|
// Add url seeds
|
||||||
foreach (const QUrl &hcSeed, hcSeeds) {
|
for (const QUrl &hcSeed : hcSeeds) {
|
||||||
qDebug("Loading URL seed: %s", qUtf8Printable(hcSeed.toString()));
|
qDebug("Loading URL seed: %s", qUtf8Printable(hcSeed.toString()));
|
||||||
new QListWidgetItem(hcSeed.toString(), m_ui->listWebSeeds);
|
new QListWidgetItem(hcSeed.toString(), m_ui->listWebSeeds);
|
||||||
}
|
}
|
||||||
|
@ -582,7 +582,7 @@ void PropertiesWidget::displayFilesListMenu(const QPoint &)
|
||||||
{
|
{
|
||||||
if (!m_torrent) return;
|
if (!m_torrent) return;
|
||||||
|
|
||||||
QModelIndexList selectedRows = m_ui->filesList->selectionModel()->selectedRows(0);
|
const QModelIndexList selectedRows = m_ui->filesList->selectionModel()->selectedRows(0);
|
||||||
if (selectedRows.empty()) return;
|
if (selectedRows.empty()) return;
|
||||||
|
|
||||||
QMenu myFilesLlistMenu;
|
QMenu myFilesLlistMenu;
|
||||||
|
@ -630,7 +630,7 @@ void PropertiesWidget::displayFilesListMenu(const QPoint &)
|
||||||
prio = prio::IGNORED;
|
prio = prio::IGNORED;
|
||||||
|
|
||||||
qDebug("Setting files priority");
|
qDebug("Setting files priority");
|
||||||
foreach (QModelIndex index, selectedRows) {
|
for (const QModelIndex &index : selectedRows) {
|
||||||
qDebug("Setting priority(%d) for file at row %d", prio, index.row());
|
qDebug("Setting priority(%d) for file at row %d", prio, index.row());
|
||||||
m_propListModel->setData(m_propListModel->index(index.row(), PRIORITY, index.parent()), prio);
|
m_propListModel->setData(m_propListModel->index(index.row(), PRIORITY, index.parent()), prio);
|
||||||
}
|
}
|
||||||
|
@ -847,7 +847,7 @@ void PropertiesWidget::deleteSelectedUrlSeeds()
|
||||||
if (selectedItems.isEmpty()) return;
|
if (selectedItems.isEmpty()) return;
|
||||||
|
|
||||||
QList<QUrl> urlSeeds;
|
QList<QUrl> urlSeeds;
|
||||||
foreach (const QListWidgetItem *item, selectedItems)
|
for (const QListWidgetItem *item : selectedItems)
|
||||||
urlSeeds << item->text();
|
urlSeeds << item->text();
|
||||||
|
|
||||||
m_torrent->removeUrlSeeds(urlSeeds);
|
m_torrent->removeUrlSeeds(urlSeeds);
|
||||||
|
@ -861,7 +861,7 @@ void PropertiesWidget::copySelectedWebSeedsToClipboard() const
|
||||||
if (selectedItems.isEmpty()) return;
|
if (selectedItems.isEmpty()) return;
|
||||||
|
|
||||||
QStringList urlsToCopy;
|
QStringList urlsToCopy;
|
||||||
foreach (QListWidgetItem *item, selectedItems)
|
for (const QListWidgetItem *item : selectedItems)
|
||||||
urlsToCopy << item->text();
|
urlsToCopy << item->text();
|
||||||
|
|
||||||
QApplication::clipboard()->setText(urlsToCopy.join('\n'));
|
QApplication::clipboard()->setText(urlsToCopy.join('\n'));
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSpacerItem>
|
#include <QSpacerItem>
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
#include "guiiconprovider.h"
|
#include "guiiconprovider.h"
|
||||||
|
|
||||||
PropTabBar::PropTabBar(QWidget *parent)
|
PropTabBar::PropTabBar(QWidget *parent)
|
||||||
|
@ -102,7 +103,7 @@ PropTabBar::PropTabBar(QWidget *parent)
|
||||||
connect(m_btnGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked)
|
connect(m_btnGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked)
|
||||||
, this, &PropTabBar::setCurrentIndex);
|
, this, &PropTabBar::setCurrentIndex);
|
||||||
// Disable buttons focus
|
// Disable buttons focus
|
||||||
foreach (QAbstractButton *btn, m_btnGroup->buttons())
|
for (QAbstractButton *btn : asConst(m_btnGroup->buttons()))
|
||||||
btn->setFocusPolicy(Qt::NoFocus);
|
btn->setFocusPolicy(Qt::NoFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -274,7 +274,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
|
||||||
rect.adjust(0, fontMetrics.height(), 0, 0); // Add top padding for top speed text
|
rect.adjust(0, fontMetrics.height(), 0, 0); // Add top padding for top speed text
|
||||||
|
|
||||||
// draw Y axis speed labels
|
// draw Y axis speed labels
|
||||||
QVector<QString> speedLabels = {
|
const QVector<QString> speedLabels = {
|
||||||
formatLabel(niceScale.arg, niceScale.unit),
|
formatLabel(niceScale.arg, niceScale.unit),
|
||||||
formatLabel((0.75 * niceScale.arg), niceScale.unit),
|
formatLabel((0.75 * niceScale.arg), niceScale.unit),
|
||||||
formatLabel((0.50 * niceScale.arg), niceScale.unit),
|
formatLabel((0.50 * niceScale.arg), niceScale.unit),
|
||||||
|
@ -348,7 +348,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
double legendHeight = 0;
|
double legendHeight = 0;
|
||||||
int legendWidth = 0;
|
int legendWidth = 0;
|
||||||
for (const auto &property : qAsConst(m_properties)) {
|
for (const auto &property : asConst(m_properties)) {
|
||||||
if (!property.enable)
|
if (!property.enable)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
|
||||||
painter.fillRect(legendBackgroundRect, legendBackgroundColor);
|
painter.fillRect(legendBackgroundRect, legendBackgroundColor);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
for (const auto &property : qAsConst(m_properties)) {
|
for (const auto &property : asConst(m_properties)) {
|
||||||
if (!property.enable)
|
if (!property.enable)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
#include "base/bittorrent/trackerentry.h"
|
#include "base/bittorrent/trackerentry.h"
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
#include "autoexpandabledialog.h"
|
#include "autoexpandabledialog.h"
|
||||||
|
@ -140,7 +141,7 @@ QList<QTreeWidgetItem*> TrackerListWidget::getSelectedTrackerItems() const
|
||||||
{
|
{
|
||||||
const QList<QTreeWidgetItem *> selectedTrackerItems = selectedItems();
|
const QList<QTreeWidgetItem *> selectedTrackerItems = selectedItems();
|
||||||
QList<QTreeWidgetItem *> selectedTrackers;
|
QList<QTreeWidgetItem *> selectedTrackers;
|
||||||
foreach (QTreeWidgetItem *item, selectedTrackerItems) {
|
for (QTreeWidgetItem *item : selectedTrackerItems) {
|
||||||
if (indexOfTopLevelItem(item) >= NB_STICKY_ITEM) // Ignore STICKY ITEMS
|
if (indexOfTopLevelItem(item) >= NB_STICKY_ITEM) // Ignore STICKY ITEMS
|
||||||
selectedTrackers << item;
|
selectedTrackers << item;
|
||||||
}
|
}
|
||||||
|
@ -163,11 +164,11 @@ void TrackerListWidget::moveSelectionUp()
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QList<QTreeWidgetItem *> selectedTrackerItems = getSelectedTrackerItems();
|
const QList<QTreeWidgetItem *> selectedTrackerItems = getSelectedTrackerItems();
|
||||||
if (selectedTrackerItems.isEmpty()) return;
|
if (selectedTrackerItems.isEmpty()) return;
|
||||||
|
|
||||||
bool change = false;
|
bool change = false;
|
||||||
foreach (QTreeWidgetItem *item, selectedTrackerItems) {
|
for (QTreeWidgetItem *item : selectedTrackerItems) {
|
||||||
int index = indexOfTopLevelItem(item);
|
int index = indexOfTopLevelItem(item);
|
||||||
if (index > NB_STICKY_ITEM) {
|
if (index > NB_STICKY_ITEM) {
|
||||||
insertTopLevelItem(index - 1, takeTopLevelItem(index));
|
insertTopLevelItem(index - 1, takeTopLevelItem(index));
|
||||||
|
@ -178,7 +179,7 @@ void TrackerListWidget::moveSelectionUp()
|
||||||
|
|
||||||
// Restore selection
|
// Restore selection
|
||||||
QItemSelectionModel *selection = selectionModel();
|
QItemSelectionModel *selection = selectionModel();
|
||||||
foreach (QTreeWidgetItem *item, selectedTrackerItems)
|
for (QTreeWidgetItem *item : selectedTrackerItems)
|
||||||
selection->select(indexFromItem(item), (QItemSelectionModel::Rows | QItemSelectionModel::Select));
|
selection->select(indexFromItem(item), (QItemSelectionModel::Rows | QItemSelectionModel::Select));
|
||||||
|
|
||||||
setSelectionModel(selection);
|
setSelectionModel(selection);
|
||||||
|
@ -204,7 +205,7 @@ void TrackerListWidget::moveSelectionDown()
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QList<QTreeWidgetItem *> selectedTrackerItems = getSelectedTrackerItems();
|
const QList<QTreeWidgetItem *> selectedTrackerItems = getSelectedTrackerItems();
|
||||||
if (selectedTrackerItems.isEmpty()) return;
|
if (selectedTrackerItems.isEmpty()) return;
|
||||||
|
|
||||||
bool change = false;
|
bool change = false;
|
||||||
|
@ -219,7 +220,7 @@ void TrackerListWidget::moveSelectionDown()
|
||||||
|
|
||||||
// Restore selection
|
// Restore selection
|
||||||
QItemSelectionModel *selection = selectionModel();
|
QItemSelectionModel *selection = selectionModel();
|
||||||
foreach (QTreeWidgetItem *item, selectedTrackerItems)
|
for (QTreeWidgetItem *item : selectedTrackerItems)
|
||||||
selection->select(indexFromItem(item), (QItemSelectionModel::Rows | QItemSelectionModel::Select));
|
selection->select(indexFromItem(item), (QItemSelectionModel::Rows | QItemSelectionModel::Select));
|
||||||
|
|
||||||
setSelectionModel(selection);
|
setSelectionModel(selection);
|
||||||
|
@ -289,7 +290,7 @@ void TrackerListWidget::loadStickyItems(BitTorrent::TorrentHandle *const torrent
|
||||||
// XXX: libtorrent should provide this info...
|
// XXX: libtorrent should provide this info...
|
||||||
// Count peers from DHT, PeX, LSD
|
// Count peers from DHT, PeX, LSD
|
||||||
uint seedsDHT = 0, seedsPeX = 0, seedsLSD = 0, peersDHT = 0, peersPeX = 0, peersLSD = 0;
|
uint seedsDHT = 0, seedsPeX = 0, seedsLSD = 0, peersDHT = 0, peersPeX = 0, peersLSD = 0;
|
||||||
foreach (const BitTorrent::PeerInfo &peer, torrent->peers()) {
|
for (const BitTorrent::PeerInfo &peer : asConst(torrent->peers())) {
|
||||||
if (peer.isConnecting()) continue;
|
if (peer.isConnecting()) continue;
|
||||||
|
|
||||||
if (peer.fromDHT()) {
|
if (peer.fromDHT()) {
|
||||||
|
@ -331,7 +332,7 @@ void TrackerListWidget::loadTrackers()
|
||||||
// Load actual trackers information
|
// Load actual trackers information
|
||||||
QHash<QString, BitTorrent::TrackerInfo> trackerData = torrent->trackerInfos();
|
QHash<QString, BitTorrent::TrackerInfo> trackerData = torrent->trackerInfos();
|
||||||
QStringList oldTrackerURLs = m_trackerItems.keys();
|
QStringList oldTrackerURLs = m_trackerItems.keys();
|
||||||
foreach (const BitTorrent::TrackerEntry &entry, torrent->trackers()) {
|
for (const BitTorrent::TrackerEntry &entry : asConst(torrent->trackers())) {
|
||||||
QString trackerURL = entry.url();
|
QString trackerURL = entry.url();
|
||||||
QTreeWidgetItem *item = m_trackerItems.value(trackerURL, nullptr);
|
QTreeWidgetItem *item = m_trackerItems.value(trackerURL, nullptr);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
|
@ -383,7 +384,7 @@ void TrackerListWidget::loadTrackers()
|
||||||
item->setTextAlignment(COL_DOWNLOADED, (Qt::AlignRight | Qt::AlignVCenter));
|
item->setTextAlignment(COL_DOWNLOADED, (Qt::AlignRight | Qt::AlignVCenter));
|
||||||
}
|
}
|
||||||
// Remove old trackers
|
// Remove old trackers
|
||||||
foreach (const QString &tracker, oldTrackerURLs)
|
for (const QString &tracker : asConst(oldTrackerURLs))
|
||||||
delete m_trackerItems.take(tracker);
|
delete m_trackerItems.take(tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,7 +395,7 @@ void TrackerListWidget::askForTrackers()
|
||||||
if (!torrent) return;
|
if (!torrent) return;
|
||||||
|
|
||||||
QList<BitTorrent::TrackerEntry> trackers;
|
QList<BitTorrent::TrackerEntry> trackers;
|
||||||
foreach (const QString &tracker, TrackersAdditionDialog::askForTrackers(this, torrent))
|
for (const QString &tracker : asConst(TrackersAdditionDialog::askForTrackers(this, torrent)))
|
||||||
trackers << tracker;
|
trackers << tracker;
|
||||||
|
|
||||||
torrent->addTrackers(trackers);
|
torrent->addTrackers(trackers);
|
||||||
|
@ -402,11 +403,11 @@ void TrackerListWidget::askForTrackers()
|
||||||
|
|
||||||
void TrackerListWidget::copyTrackerUrl()
|
void TrackerListWidget::copyTrackerUrl()
|
||||||
{
|
{
|
||||||
QList<QTreeWidgetItem *> selectedTrackerItems = getSelectedTrackerItems();
|
const QList<QTreeWidgetItem *> selectedTrackerItems = getSelectedTrackerItems();
|
||||||
if (selectedTrackerItems.isEmpty()) return;
|
if (selectedTrackerItems.isEmpty()) return;
|
||||||
|
|
||||||
QStringList urlsToCopy;
|
QStringList urlsToCopy;
|
||||||
foreach (QTreeWidgetItem *item, selectedTrackerItems) {
|
for (const QTreeWidgetItem *item : selectedTrackerItems) {
|
||||||
QString trackerURL = item->data(COL_URL, Qt::DisplayRole).toString();
|
QString trackerURL = item->data(COL_URL, Qt::DisplayRole).toString();
|
||||||
qDebug() << QString("Copy: ") + trackerURL;
|
qDebug() << QString("Copy: ") + trackerURL;
|
||||||
urlsToCopy << trackerURL;
|
urlsToCopy << trackerURL;
|
||||||
|
@ -423,11 +424,11 @@ void TrackerListWidget::deleteSelectedTrackers()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QTreeWidgetItem *> selectedTrackerItems = getSelectedTrackerItems();
|
const QList<QTreeWidgetItem *> selectedTrackerItems = getSelectedTrackerItems();
|
||||||
if (selectedTrackerItems.isEmpty()) return;
|
if (selectedTrackerItems.isEmpty()) return;
|
||||||
|
|
||||||
QStringList urlsToRemove;
|
QStringList urlsToRemove;
|
||||||
foreach (QTreeWidgetItem *item, selectedTrackerItems) {
|
for (const QTreeWidgetItem *item : selectedTrackerItems) {
|
||||||
QString trackerURL = item->data(COL_URL, Qt::DisplayRole).toString();
|
QString trackerURL = item->data(COL_URL, Qt::DisplayRole).toString();
|
||||||
urlsToRemove << trackerURL;
|
urlsToRemove << trackerURL;
|
||||||
m_trackerItems.remove(trackerURL);
|
m_trackerItems.remove(trackerURL);
|
||||||
|
@ -436,8 +437,8 @@ void TrackerListWidget::deleteSelectedTrackers()
|
||||||
|
|
||||||
// Iterate over the trackers and remove the selected ones
|
// Iterate over the trackers and remove the selected ones
|
||||||
QList<BitTorrent::TrackerEntry> remainingTrackers;
|
QList<BitTorrent::TrackerEntry> remainingTrackers;
|
||||||
QList<BitTorrent::TrackerEntry> trackers = torrent->trackers();
|
const QList<BitTorrent::TrackerEntry> trackers = torrent->trackers();
|
||||||
foreach (const BitTorrent::TrackerEntry &entry, trackers) {
|
for (const BitTorrent::TrackerEntry &entry : trackers) {
|
||||||
if (!urlsToRemove.contains(entry.url()))
|
if (!urlsToRemove.contains(entry.url()))
|
||||||
remainingTrackers.push_back(entry);
|
remainingTrackers.push_back(entry);
|
||||||
}
|
}
|
||||||
|
@ -493,7 +494,7 @@ void TrackerListWidget::editSelectedTracker()
|
||||||
|
|
||||||
void TrackerListWidget::reannounceSelected()
|
void TrackerListWidget::reannounceSelected()
|
||||||
{
|
{
|
||||||
QList<QTreeWidgetItem *> selItems = selectedItems();
|
const QList<QTreeWidgetItem *> selItems = selectedItems();
|
||||||
if (selItems.isEmpty()) return;
|
if (selItems.isEmpty()) return;
|
||||||
|
|
||||||
BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent();
|
BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent();
|
||||||
|
@ -501,7 +502,7 @@ void TrackerListWidget::reannounceSelected()
|
||||||
|
|
||||||
QList<BitTorrent::TrackerEntry> trackers = torrent->trackers();
|
QList<BitTorrent::TrackerEntry> trackers = torrent->trackers();
|
||||||
|
|
||||||
foreach (QTreeWidgetItem* item, selItems) {
|
for (const QTreeWidgetItem *item : selItems) {
|
||||||
// DHT case
|
// DHT case
|
||||||
if (item == m_DHTItem) {
|
if (item == m_DHTItem) {
|
||||||
torrent->forceDHTAnnounce();
|
torrent->forceDHTAnnounce();
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
#include "base/bittorrent/trackerentry.h"
|
#include "base/bittorrent/trackerentry.h"
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/net/downloadhandler.h"
|
#include "base/net/downloadhandler.h"
|
||||||
#include "base/net/downloadmanager.h"
|
#include "base/net/downloadmanager.h"
|
||||||
#include "base/utils/fs.h"
|
#include "base/utils/fs.h"
|
||||||
|
@ -59,7 +60,7 @@ TrackersAdditionDialog::~TrackersAdditionDialog()
|
||||||
QStringList TrackersAdditionDialog::newTrackers() const
|
QStringList TrackersAdditionDialog::newTrackers() const
|
||||||
{
|
{
|
||||||
QStringList cleanTrackers;
|
QStringList cleanTrackers;
|
||||||
foreach (QString url, m_ui->textEditTrackersList->toPlainText().split('\n')) {
|
for (QString url : asConst(m_ui->textEditTrackersList->toPlainText().split('\n'))) {
|
||||||
url = url.trimmed();
|
url = url.trimmed();
|
||||||
if (!url.isEmpty())
|
if (!url.isEmpty())
|
||||||
cleanTrackers << url;
|
cleanTrackers << url;
|
||||||
|
@ -83,8 +84,8 @@ void TrackersAdditionDialog::parseUTorrentList(const QString &, const QByteArray
|
||||||
// Load from torrent handle
|
// Load from torrent handle
|
||||||
QList<BitTorrent::TrackerEntry> existingTrackers = m_torrent->trackers();
|
QList<BitTorrent::TrackerEntry> existingTrackers = m_torrent->trackers();
|
||||||
// Load from current user list
|
// Load from current user list
|
||||||
QStringList tmp = m_ui->textEditTrackersList->toPlainText().split('\n');
|
const QStringList tmp = m_ui->textEditTrackersList->toPlainText().split('\n');
|
||||||
foreach (const QString &userURL, tmp) {
|
for (const QString &userURL : tmp) {
|
||||||
BitTorrent::TrackerEntry userTracker(userURL);
|
BitTorrent::TrackerEntry userTracker(userURL);
|
||||||
if (!existingTrackers.contains(userTracker))
|
if (!existingTrackers.contains(userTracker))
|
||||||
existingTrackers << userTracker;
|
existingTrackers << userTracker;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/rss/rss_article.h"
|
#include "base/rss/rss_article.h"
|
||||||
#include "base/rss/rss_item.h"
|
#include "base/rss/rss_item.h"
|
||||||
|
|
||||||
|
@ -68,7 +69,7 @@ void ArticleListWidget::setRSSItem(RSS::Item *rssItem, bool unreadOnly)
|
||||||
connect(m_rssItem, &RSS::Item::articleRead, this, &ArticleListWidget::handleArticleRead);
|
connect(m_rssItem, &RSS::Item::articleRead, this, &ArticleListWidget::handleArticleRead);
|
||||||
connect(m_rssItem, &RSS::Item::articleAboutToBeRemoved, this, &ArticleListWidget::handleArticleAboutToBeRemoved);
|
connect(m_rssItem, &RSS::Item::articleAboutToBeRemoved, this, &ArticleListWidget::handleArticleAboutToBeRemoved);
|
||||||
|
|
||||||
foreach (auto article, rssItem->articles()) {
|
for (const auto article : asConst(rssItem->articles())) {
|
||||||
if (!(m_unreadOnly && article->isRead())) {
|
if (!(m_unreadOnly && article->isRead())) {
|
||||||
auto item = createItem(article);
|
auto item = createItem(article);
|
||||||
addItem(item);
|
addItem(item);
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
#include "base/rss/rss_article.h"
|
#include "base/rss/rss_article.h"
|
||||||
#include "base/rss/rss_autodownloader.h"
|
#include "base/rss/rss_autodownloader.h"
|
||||||
|
@ -131,7 +132,7 @@ AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent)
|
||||||
loadFeedList();
|
loadFeedList();
|
||||||
|
|
||||||
m_ui->listRules->blockSignals(true);
|
m_ui->listRules->blockSignals(true);
|
||||||
foreach (const RSS::AutoDownloadRule &rule, RSS::AutoDownloader::instance()->rules())
|
for (const RSS::AutoDownloadRule &rule : asConst(RSS::AutoDownloader::instance()->rules()))
|
||||||
createRuleItem(rule);
|
createRuleItem(rule);
|
||||||
m_ui->listRules->blockSignals(false);
|
m_ui->listRules->blockSignals(false);
|
||||||
|
|
||||||
|
@ -181,7 +182,7 @@ void AutomatedRssDownloader::loadFeedList()
|
||||||
{
|
{
|
||||||
const QSignalBlocker feedListSignalBlocker(m_ui->listFeeds);
|
const QSignalBlocker feedListSignalBlocker(m_ui->listFeeds);
|
||||||
|
|
||||||
foreach (auto feed, RSS::Session::instance()->feeds()) {
|
for (const auto feed : asConst(RSS::Session::instance()->feeds())) {
|
||||||
QListWidgetItem *item = new QListWidgetItem(feed->name(), m_ui->listFeeds);
|
QListWidgetItem *item = new QListWidgetItem(feed->name(), m_ui->listFeeds);
|
||||||
item->setData(Qt::UserRole, feed->url());
|
item->setData(Qt::UserRole, feed->url());
|
||||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsTristate);
|
item->setFlags(item->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsTristate);
|
||||||
|
@ -211,7 +212,7 @@ void AutomatedRssDownloader::updateFeedList()
|
||||||
bool allEnabled = true;
|
bool allEnabled = true;
|
||||||
bool anyEnabled = false;
|
bool anyEnabled = false;
|
||||||
|
|
||||||
foreach (const QListWidgetItem *ruleItem, selection) {
|
for (const QListWidgetItem *ruleItem : asConst(selection)) {
|
||||||
auto rule = RSS::AutoDownloader::instance()->ruleByName(ruleItem->text());
|
auto rule = RSS::AutoDownloader::instance()->ruleByName(ruleItem->text());
|
||||||
if (rule.feedURLs().contains(feedURL))
|
if (rule.feedURLs().contains(feedURL))
|
||||||
anyEnabled = true;
|
anyEnabled = true;
|
||||||
|
@ -384,7 +385,7 @@ void AutomatedRssDownloader::on_removeRuleBtn_clicked()
|
||||||
if (QMessageBox::question(this, tr("Rule deletion confirmation"), confirmText, QMessageBox::Yes, QMessageBox::No) != QMessageBox::Yes)
|
if (QMessageBox::question(this, tr("Rule deletion confirmation"), confirmText, QMessageBox::Yes, QMessageBox::No) != QMessageBox::Yes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (QListWidgetItem *item, selection)
|
for (const QListWidgetItem *item : selection)
|
||||||
RSS::AutoDownloader::instance()->removeRule(item->text());
|
RSS::AutoDownloader::instance()->removeRule(item->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,7 +549,7 @@ void AutomatedRssDownloader::clearSelectedRuleDownloadedEpisodeList()
|
||||||
void AutomatedRssDownloader::handleFeedCheckStateChange(QListWidgetItem *feedItem)
|
void AutomatedRssDownloader::handleFeedCheckStateChange(QListWidgetItem *feedItem)
|
||||||
{
|
{
|
||||||
const QString feedURL = feedItem->data(Qt::UserRole).toString();
|
const QString feedURL = feedItem->data(Qt::UserRole).toString();
|
||||||
foreach (QListWidgetItem *ruleItem, m_ui->listRules->selectedItems()) {
|
for (QListWidgetItem *ruleItem : asConst(m_ui->listRules->selectedItems())) {
|
||||||
RSS::AutoDownloadRule rule = (ruleItem == m_currentRuleItem
|
RSS::AutoDownloadRule rule = (ruleItem == m_currentRuleItem
|
||||||
? m_currentRule
|
? m_currentRule
|
||||||
: RSS::AutoDownloader::instance()->ruleByName(ruleItem->text()));
|
: RSS::AutoDownloader::instance()->ruleByName(ruleItem->text()));
|
||||||
|
@ -572,16 +573,16 @@ void AutomatedRssDownloader::updateMatchingArticles()
|
||||||
{
|
{
|
||||||
m_ui->treeMatchingArticles->clear();
|
m_ui->treeMatchingArticles->clear();
|
||||||
|
|
||||||
foreach (const QListWidgetItem *ruleItem, m_ui->listRules->selectedItems()) {
|
for (const QListWidgetItem *ruleItem : asConst(m_ui->listRules->selectedItems())) {
|
||||||
RSS::AutoDownloadRule rule = (ruleItem == m_currentRuleItem
|
RSS::AutoDownloadRule rule = (ruleItem == m_currentRuleItem
|
||||||
? m_currentRule
|
? m_currentRule
|
||||||
: RSS::AutoDownloader::instance()->ruleByName(ruleItem->text()));
|
: RSS::AutoDownloader::instance()->ruleByName(ruleItem->text()));
|
||||||
foreach (const QString &feedURL, rule.feedURLs()) {
|
for (const QString &feedURL : asConst(rule.feedURLs())) {
|
||||||
auto feed = RSS::Session::instance()->feedByURL(feedURL);
|
auto feed = RSS::Session::instance()->feedByURL(feedURL);
|
||||||
if (!feed) continue; // feed doesn't exist
|
if (!feed) continue; // feed doesn't exist
|
||||||
|
|
||||||
QStringList matchingArticles;
|
QStringList matchingArticles;
|
||||||
foreach (auto article, feed->articles())
|
for (const auto article : asConst(feed->articles()))
|
||||||
if (rule.matches(article->data()))
|
if (rule.matches(article->data()))
|
||||||
matchingArticles << article->title();
|
matchingArticles << article->title();
|
||||||
if (!matchingArticles.isEmpty())
|
if (!matchingArticles.isEmpty())
|
||||||
|
@ -620,7 +621,7 @@ void AutomatedRssDownloader::addFeedArticlesToTree(RSS::Feed *feed, const QStrin
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert the articles
|
// Insert the articles
|
||||||
foreach (const QString &article, articles) {
|
for (const QString &article : articles) {
|
||||||
QPair<QString, QString> key(feed->name(), article);
|
QPair<QString, QString> key(feed->name(), article);
|
||||||
|
|
||||||
if (!m_treeListEntries.contains(key)) {
|
if (!m_treeListEntries.contains(key)) {
|
||||||
|
@ -675,10 +676,10 @@ void AutomatedRssDownloader::updateMustLineValidity()
|
||||||
if (isRegex)
|
if (isRegex)
|
||||||
tokens << text;
|
tokens << text;
|
||||||
else
|
else
|
||||||
foreach (const QString &token, text.split('|'))
|
for (const QString &token : asConst(text.split('|')))
|
||||||
tokens << Utils::String::wildcardToRegex(token);
|
tokens << Utils::String::wildcardToRegex(token);
|
||||||
|
|
||||||
foreach (const QString &token, tokens) {
|
for (const QString &token : asConst(tokens)) {
|
||||||
QRegularExpression reg(token, QRegularExpression::CaseInsensitiveOption);
|
QRegularExpression reg(token, QRegularExpression::CaseInsensitiveOption);
|
||||||
if (!reg.isValid()) {
|
if (!reg.isValid()) {
|
||||||
if (isRegex)
|
if (isRegex)
|
||||||
|
@ -713,10 +714,10 @@ void AutomatedRssDownloader::updateMustNotLineValidity()
|
||||||
if (isRegex)
|
if (isRegex)
|
||||||
tokens << text;
|
tokens << text;
|
||||||
else
|
else
|
||||||
foreach (const QString &token, text.split('|'))
|
for (const QString &token : asConst(text.split('|')))
|
||||||
tokens << Utils::String::wildcardToRegex(token);
|
tokens << Utils::String::wildcardToRegex(token);
|
||||||
|
|
||||||
foreach (const QString &token, tokens) {
|
for (const QString &token : asConst(tokens)) {
|
||||||
QRegularExpression reg(token, QRegularExpression::CaseInsensitiveOption);
|
QRegularExpression reg(token, QRegularExpression::CaseInsensitiveOption);
|
||||||
if (!reg.isValid()) {
|
if (!reg.isValid()) {
|
||||||
if (isRegex)
|
if (isRegex)
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
#include <QTreeWidgetItem>
|
#include <QTreeWidgetItem>
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/rss/rss_article.h"
|
#include "base/rss/rss_article.h"
|
||||||
#include "base/rss/rss_feed.h"
|
#include "base/rss/rss_feed.h"
|
||||||
#include "base/rss/rss_folder.h"
|
#include "base/rss/rss_folder.h"
|
||||||
|
@ -219,7 +220,7 @@ void FeedListWidget::dropEvent(QDropEvent *event)
|
||||||
: RSS::Session::instance()->rootFolder());
|
: RSS::Session::instance()->rootFolder());
|
||||||
|
|
||||||
// move as much items as possible
|
// move as much items as possible
|
||||||
foreach (QTreeWidgetItem *srcItem, selectedItems()) {
|
for (QTreeWidgetItem *srcItem : asConst(selectedItems())) {
|
||||||
auto rssItem = getRSSItem(srcItem);
|
auto rssItem = getRSSItem(srcItem);
|
||||||
RSS::Session::instance()->moveItem(rssItem, RSS::Item::joinPath(destFolder->path(), rssItem->name()));
|
RSS::Session::instance()->moveItem(rssItem, RSS::Item::joinPath(destFolder->path(), rssItem->name()));
|
||||||
}
|
}
|
||||||
|
@ -264,7 +265,7 @@ QTreeWidgetItem *FeedListWidget::createItem(RSS::Item *rssItem, QTreeWidgetItem
|
||||||
|
|
||||||
void FeedListWidget::fill(QTreeWidgetItem *parent, RSS::Folder *rssParent)
|
void FeedListWidget::fill(QTreeWidgetItem *parent, RSS::Folder *rssParent)
|
||||||
{
|
{
|
||||||
foreach (auto rssItem, rssParent->items()) {
|
for (const auto rssItem : asConst(rssParent->items())) {
|
||||||
QTreeWidgetItem *item = createItem(rssItem, parent);
|
QTreeWidgetItem *item = createItem(rssItem, parent);
|
||||||
// Recursive call if this is a folder.
|
// Recursive call if this is a folder.
|
||||||
if (auto folder = qobject_cast<RSS::Folder *>(rssItem))
|
if (auto folder = qobject_cast<RSS::Folder *>(rssItem))
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/net/downloadmanager.h"
|
#include "base/net/downloadmanager.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
#include "base/rss/rss_article.h"
|
#include "base/rss/rss_article.h"
|
||||||
|
@ -186,7 +187,7 @@ void RSSWidget::displayItemsListMenu(const QPoint &)
|
||||||
{
|
{
|
||||||
bool hasTorrent = false;
|
bool hasTorrent = false;
|
||||||
bool hasLink = false;
|
bool hasLink = false;
|
||||||
foreach (const QListWidgetItem *item, m_articleListWidget->selectedItems()) {
|
for (const QListWidgetItem *item : asConst(m_articleListWidget->selectedItems())) {
|
||||||
auto article = reinterpret_cast<RSS::Article *>(item->data(Qt::UserRole).value<quintptr>());
|
auto article = reinterpret_cast<RSS::Article *>(item->data(Qt::UserRole).value<quintptr>());
|
||||||
Q_ASSERT(article);
|
Q_ASSERT(article);
|
||||||
|
|
||||||
|
@ -286,7 +287,7 @@ void RSSWidget::on_newFeedButton_clicked()
|
||||||
|
|
||||||
void RSSWidget::deleteSelectedItems()
|
void RSSWidget::deleteSelectedItems()
|
||||||
{
|
{
|
||||||
QList<QTreeWidgetItem *> selectedItems = m_feedListWidget->selectedItems();
|
const QList<QTreeWidgetItem *> selectedItems = m_feedListWidget->selectedItems();
|
||||||
if (selectedItems.isEmpty())
|
if (selectedItems.isEmpty())
|
||||||
return;
|
return;
|
||||||
if ((selectedItems.size() == 1) && (selectedItems.first() == m_feedListWidget->stickyUnreadItem()))
|
if ((selectedItems.size() == 1) && (selectedItems.first() == m_feedListWidget->stickyUnreadItem()))
|
||||||
|
@ -298,7 +299,7 @@ void RSSWidget::deleteSelectedItems()
|
||||||
if (answer == QMessageBox::No)
|
if (answer == QMessageBox::No)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (QTreeWidgetItem *item, selectedItems)
|
for (QTreeWidgetItem *item : selectedItems)
|
||||||
if (item != m_feedListWidget->stickyUnreadItem())
|
if (item != m_feedListWidget->stickyUnreadItem())
|
||||||
RSS::Session::instance()->removeItem(m_feedListWidget->itemPath(item));
|
RSS::Session::instance()->removeItem(m_feedListWidget->itemPath(item));
|
||||||
}
|
}
|
||||||
|
@ -306,9 +307,9 @@ void RSSWidget::deleteSelectedItems()
|
||||||
void RSSWidget::loadFoldersOpenState()
|
void RSSWidget::loadFoldersOpenState()
|
||||||
{
|
{
|
||||||
const QStringList openedFolders = Preferences::instance()->getRssOpenFolders();
|
const QStringList openedFolders = Preferences::instance()->getRssOpenFolders();
|
||||||
foreach (const QString &varPath, openedFolders) {
|
for (const QString &varPath : openedFolders) {
|
||||||
QTreeWidgetItem *parent = nullptr;
|
QTreeWidgetItem *parent = nullptr;
|
||||||
foreach (const QString &name, varPath.split('\\')) {
|
for (const QString &name : asConst(varPath.split('\\'))) {
|
||||||
int nbChildren = (parent ? parent->childCount() : m_feedListWidget->topLevelItemCount());
|
int nbChildren = (parent ? parent->childCount() : m_feedListWidget->topLevelItemCount());
|
||||||
for (int i = 0; i < nbChildren; ++i) {
|
for (int i = 0; i < nbChildren; ++i) {
|
||||||
QTreeWidgetItem *child = (parent ? parent->child(i) : m_feedListWidget->topLevelItem(i));
|
QTreeWidgetItem *child = (parent ? parent->child(i) : m_feedListWidget->topLevelItem(i));
|
||||||
|
@ -325,7 +326,7 @@ void RSSWidget::loadFoldersOpenState()
|
||||||
void RSSWidget::saveFoldersOpenState()
|
void RSSWidget::saveFoldersOpenState()
|
||||||
{
|
{
|
||||||
QStringList openedFolders;
|
QStringList openedFolders;
|
||||||
foreach (QTreeWidgetItem *item, m_feedListWidget->getAllOpenedFolders())
|
for (QTreeWidgetItem *item : asConst(m_feedListWidget->getAllOpenedFolders()))
|
||||||
openedFolders << m_feedListWidget->itemPath(item);
|
openedFolders << m_feedListWidget->itemPath(item);
|
||||||
Preferences::instance()->setRssOpenFolders(openedFolders);
|
Preferences::instance()->setRssOpenFolders(openedFolders);
|
||||||
}
|
}
|
||||||
|
@ -337,7 +338,7 @@ void RSSWidget::refreshAllFeeds()
|
||||||
|
|
||||||
void RSSWidget::downloadSelectedTorrents()
|
void RSSWidget::downloadSelectedTorrents()
|
||||||
{
|
{
|
||||||
foreach (QListWidgetItem *item, m_articleListWidget->selectedItems()) {
|
for (QListWidgetItem *item : asConst(m_articleListWidget->selectedItems())) {
|
||||||
auto article = reinterpret_cast<RSS::Article *>(item->data(Qt::UserRole).value<quintptr>());
|
auto article = reinterpret_cast<RSS::Article *>(item->data(Qt::UserRole).value<quintptr>());
|
||||||
Q_ASSERT(article);
|
Q_ASSERT(article);
|
||||||
|
|
||||||
|
@ -356,7 +357,7 @@ void RSSWidget::downloadSelectedTorrents()
|
||||||
// open the url of the selected RSS articles in the Web browser
|
// open the url of the selected RSS articles in the Web browser
|
||||||
void RSSWidget::openSelectedArticlesUrls()
|
void RSSWidget::openSelectedArticlesUrls()
|
||||||
{
|
{
|
||||||
foreach (QListWidgetItem *item, m_articleListWidget->selectedItems()) {
|
for (QListWidgetItem *item : asConst(m_articleListWidget->selectedItems())) {
|
||||||
auto article = reinterpret_cast<RSS::Article *>(item->data(Qt::UserRole).value<quintptr>());
|
auto article = reinterpret_cast<RSS::Article *>(item->data(Qt::UserRole).value<quintptr>());
|
||||||
Q_ASSERT(article);
|
Q_ASSERT(article);
|
||||||
|
|
||||||
|
@ -397,7 +398,7 @@ void RSSWidget::renameSelectedRSSItem()
|
||||||
|
|
||||||
void RSSWidget::refreshSelectedItems()
|
void RSSWidget::refreshSelectedItems()
|
||||||
{
|
{
|
||||||
foreach (QTreeWidgetItem *item, m_feedListWidget->selectedItems()) {
|
for (QTreeWidgetItem *item : asConst(m_feedListWidget->selectedItems())) {
|
||||||
if (item == m_feedListWidget->stickyUnreadItem()) {
|
if (item == m_feedListWidget->stickyUnreadItem()) {
|
||||||
refreshAllFeeds();
|
refreshAllFeeds();
|
||||||
return;
|
return;
|
||||||
|
@ -410,7 +411,7 @@ void RSSWidget::refreshSelectedItems()
|
||||||
void RSSWidget::copySelectedFeedsURL()
|
void RSSWidget::copySelectedFeedsURL()
|
||||||
{
|
{
|
||||||
QStringList URLs;
|
QStringList URLs;
|
||||||
foreach (QTreeWidgetItem *item, m_feedListWidget->selectedItems()) {
|
for (QTreeWidgetItem *item : asConst(m_feedListWidget->selectedItems())) {
|
||||||
if (auto feed = qobject_cast<RSS::Feed *>(m_feedListWidget->getRSSItem(item)))
|
if (auto feed = qobject_cast<RSS::Feed *>(m_feedListWidget->getRSSItem(item)))
|
||||||
URLs << feed->url();
|
URLs << feed->url();
|
||||||
}
|
}
|
||||||
|
@ -425,7 +426,7 @@ void RSSWidget::handleCurrentFeedItemChanged(QTreeWidgetItem *currentItem)
|
||||||
|
|
||||||
void RSSWidget::on_markReadButton_clicked()
|
void RSSWidget::on_markReadButton_clicked()
|
||||||
{
|
{
|
||||||
foreach (QTreeWidgetItem *item, m_feedListWidget->selectedItems()) {
|
for (QTreeWidgetItem *item : asConst(m_feedListWidget->selectedItems())) {
|
||||||
m_feedListWidget->getRSSItem(item)->markAsRead();
|
m_feedListWidget->getRSSItem(item)->markAsRead();
|
||||||
if (item == m_feedListWidget->stickyUnreadItem())
|
if (item == m_feedListWidget->stickyUnreadItem())
|
||||||
break; // all items was read
|
break; // all items was read
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/net/downloadhandler.h"
|
#include "base/net/downloadhandler.h"
|
||||||
#include "base/net/downloadmanager.h"
|
#include "base/net/downloadmanager.h"
|
||||||
#include "base/utils/fs.h"
|
#include "base/utils/fs.h"
|
||||||
|
@ -110,7 +111,7 @@ void PluginSelectDialog::dropEvent(QDropEvent *event)
|
||||||
|
|
||||||
QStringList files;
|
QStringList files;
|
||||||
if (event->mimeData()->hasUrls()) {
|
if (event->mimeData()->hasUrls()) {
|
||||||
foreach (const QUrl &url, event->mimeData()->urls()) {
|
for (const QUrl &url : asConst(event->mimeData()->urls())) {
|
||||||
if (!url.isEmpty()) {
|
if (!url.isEmpty()) {
|
||||||
if (url.scheme().compare("file", Qt::CaseInsensitive) == 0)
|
if (url.scheme().compare("file", Qt::CaseInsensitive) == 0)
|
||||||
files << url.toLocalFile();
|
files << url.toLocalFile();
|
||||||
|
@ -125,7 +126,7 @@ void PluginSelectDialog::dropEvent(QDropEvent *event)
|
||||||
|
|
||||||
if (files.isEmpty()) return;
|
if (files.isEmpty()) return;
|
||||||
|
|
||||||
foreach (QString file, files) {
|
for (const QString &file : asConst(files)) {
|
||||||
qDebug("dropped %s", qUtf8Printable(file));
|
qDebug("dropped %s", qUtf8Printable(file));
|
||||||
startAsyncOp();
|
startAsyncOp();
|
||||||
m_pluginManager->installPlugin(file);
|
m_pluginManager->installPlugin(file);
|
||||||
|
@ -135,8 +136,7 @@ void PluginSelectDialog::dropEvent(QDropEvent *event)
|
||||||
// Decode if we accept drag 'n drop or not
|
// Decode if we accept drag 'n drop or not
|
||||||
void PluginSelectDialog::dragEnterEvent(QDragEnterEvent *event)
|
void PluginSelectDialog::dragEnterEvent(QDragEnterEvent *event)
|
||||||
{
|
{
|
||||||
QString mime;
|
for (const QString &mime : asConst(event->mimeData()->formats())) {
|
||||||
foreach (mime, event->mimeData()->formats()) {
|
|
||||||
qDebug("mimeData: %s", qUtf8Printable(mime));
|
qDebug("mimeData: %s", qUtf8Printable(mime));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ void PluginSelectDialog::on_closeButton_clicked()
|
||||||
void PluginSelectDialog::on_actionUninstall_triggered()
|
void PluginSelectDialog::on_actionUninstall_triggered()
|
||||||
{
|
{
|
||||||
bool error = false;
|
bool error = false;
|
||||||
foreach (QTreeWidgetItem *item, m_ui->pluginsTree->selectedItems()) {
|
for (QTreeWidgetItem *item : asConst(m_ui->pluginsTree->selectedItems())) {
|
||||||
int index = m_ui->pluginsTree->indexOfTopLevelItem(item);
|
int index = m_ui->pluginsTree->indexOfTopLevelItem(item);
|
||||||
Q_ASSERT(index != -1);
|
Q_ASSERT(index != -1);
|
||||||
QString id = item->text(PLUGIN_ID);
|
QString id = item->text(PLUGIN_ID);
|
||||||
|
@ -212,7 +212,7 @@ void PluginSelectDialog::on_actionUninstall_triggered()
|
||||||
|
|
||||||
void PluginSelectDialog::enableSelection(bool enable)
|
void PluginSelectDialog::enableSelection(bool enable)
|
||||||
{
|
{
|
||||||
foreach (QTreeWidgetItem *item, m_ui->pluginsTree->selectedItems()) {
|
for (QTreeWidgetItem *item : asConst(m_ui->pluginsTree->selectedItems())) {
|
||||||
int index = m_ui->pluginsTree->indexOfTopLevelItem(item);
|
int index = m_ui->pluginsTree->indexOfTopLevelItem(item);
|
||||||
Q_ASSERT(index != -1);
|
Q_ASSERT(index != -1);
|
||||||
QString id = item->text(PLUGIN_ID);
|
QString id = item->text(PLUGIN_ID);
|
||||||
|
@ -265,7 +265,7 @@ void PluginSelectDialog::loadSupportedSearchPlugins()
|
||||||
{
|
{
|
||||||
// Some clean up first
|
// Some clean up first
|
||||||
m_ui->pluginsTree->clear();
|
m_ui->pluginsTree->clear();
|
||||||
foreach (QString name, m_pluginManager->allPlugins())
|
for (const QString &name : asConst(m_pluginManager->allPlugins()))
|
||||||
addNewPlugin(name);
|
addNewPlugin(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,11 +360,11 @@ void PluginSelectDialog::askForPluginUrl()
|
||||||
|
|
||||||
void PluginSelectDialog::askForLocalPlugin()
|
void PluginSelectDialog::askForLocalPlugin()
|
||||||
{
|
{
|
||||||
QStringList pathsList = QFileDialog::getOpenFileNames(
|
const QStringList pathsList = QFileDialog::getOpenFileNames(
|
||||||
nullptr, tr("Select search plugins"), QDir::homePath(),
|
nullptr, tr("Select search plugins"), QDir::homePath(),
|
||||||
tr("qBittorrent search plugin") + QLatin1String(" (*.py)")
|
tr("qBittorrent search plugin") + QLatin1String(" (*.py)")
|
||||||
);
|
);
|
||||||
foreach (QString path, pathsList) {
|
for (const QString &path : pathsList) {
|
||||||
startAsyncOp();
|
startAsyncOp();
|
||||||
m_pluginManager->installPlugin(path);
|
m_pluginManager->installPlugin(path);
|
||||||
}
|
}
|
||||||
|
@ -380,7 +380,7 @@ void PluginSelectDialog::iconDownloaded(const QString &url, QString filePath)
|
||||||
QList<QSize> sizes = icon.availableSizes();
|
QList<QSize> sizes = icon.availableSizes();
|
||||||
bool invalid = (sizes.isEmpty() || icon.pixmap(sizes.first()).isNull());
|
bool invalid = (sizes.isEmpty() || icon.pixmap(sizes.first()).isNull());
|
||||||
if (!invalid) {
|
if (!invalid) {
|
||||||
foreach (QTreeWidgetItem *item, findItemsWithUrl(url)) {
|
for (QTreeWidgetItem *item : asConst(findItemsWithUrl(url))) {
|
||||||
QString id = item->text(PLUGIN_ID);
|
QString id = item->text(PLUGIN_ID);
|
||||||
PluginInfo *plugin = m_pluginManager->pluginInfo(id);
|
PluginInfo *plugin = m_pluginManager->pluginInfo(id);
|
||||||
if (!plugin) continue;
|
if (!plugin) continue;
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include "searchsortmodel.h"
|
#include "searchsortmodel.h"
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
|
|
||||||
SearchSortModel::SearchSortModel(QObject *parent)
|
SearchSortModel::SearchSortModel(QObject *parent)
|
||||||
: base(parent)
|
: base(parent)
|
||||||
, m_isNameFilterEnabled(false)
|
, m_isNameFilterEnabled(false)
|
||||||
|
@ -126,7 +128,7 @@ bool SearchSortModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceP
|
||||||
const QAbstractItemModel *const sourceModel = this->sourceModel();
|
const QAbstractItemModel *const sourceModel = this->sourceModel();
|
||||||
if (m_isNameFilterEnabled && !m_searchTerm.isEmpty()) {
|
if (m_isNameFilterEnabled && !m_searchTerm.isEmpty()) {
|
||||||
QString name = sourceModel->data(sourceModel->index(sourceRow, NAME, sourceParent)).toString();
|
QString name = sourceModel->data(sourceModel->index(sourceRow, NAME, sourceParent)).toString();
|
||||||
for (const QString &word: m_searchTermWords) {
|
for (const QString &word : asConst(m_searchTermWords)) {
|
||||||
int i = name.indexOf(word, 0, Qt::CaseInsensitive);
|
int i = name.indexOf(word, 0, Qt::CaseInsensitive);
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
#include "base/search/searchpluginmanager.h"
|
#include "base/search/searchpluginmanager.h"
|
||||||
#include "base/search/searchhandler.h"
|
#include "base/search/searchhandler.h"
|
||||||
|
@ -166,11 +167,11 @@ void SearchWidget::fillCatCombobox()
|
||||||
|
|
||||||
using QStrPair = QPair<QString, QString>;
|
using QStrPair = QPair<QString, QString>;
|
||||||
QList<QStrPair> tmpList;
|
QList<QStrPair> tmpList;
|
||||||
foreach (const QString &cat, SearchPluginManager::instance()->getPluginCategories(selectedPlugin()))
|
for (const QString &cat : asConst(SearchPluginManager::instance()->getPluginCategories(selectedPlugin())))
|
||||||
tmpList << qMakePair(SearchPluginManager::categoryFullName(cat), cat);
|
tmpList << qMakePair(SearchPluginManager::categoryFullName(cat), cat);
|
||||||
std::sort(tmpList.begin(), tmpList.end(), [](const QStrPair &l, const QStrPair &r) { return (QString::localeAwareCompare(l.first, r.first) < 0); });
|
std::sort(tmpList.begin(), tmpList.end(), [](const QStrPair &l, const QStrPair &r) { return (QString::localeAwareCompare(l.first, r.first) < 0); });
|
||||||
|
|
||||||
foreach (const QStrPair &p, tmpList) {
|
for (const QStrPair &p : asConst(tmpList)) {
|
||||||
qDebug("Supported category: %s", qUtf8Printable(p.second));
|
qDebug("Supported category: %s", qUtf8Printable(p.second));
|
||||||
m_ui->comboCategory->addItem(p.first, QVariant(p.second));
|
m_ui->comboCategory->addItem(p.first, QVariant(p.second));
|
||||||
}
|
}
|
||||||
|
@ -188,11 +189,11 @@ void SearchWidget::fillPluginComboBox()
|
||||||
|
|
||||||
using QStrPair = QPair<QString, QString>;
|
using QStrPair = QPair<QString, QString>;
|
||||||
QList<QStrPair> tmpList;
|
QList<QStrPair> tmpList;
|
||||||
foreach (const QString &name, SearchPluginManager::instance()->enabledPlugins())
|
for (const QString &name : asConst(SearchPluginManager::instance()->enabledPlugins()))
|
||||||
tmpList << qMakePair(SearchPluginManager::instance()->pluginFullName(name), name);
|
tmpList << qMakePair(SearchPluginManager::instance()->pluginFullName(name), name);
|
||||||
std::sort(tmpList.begin(), tmpList.end(), [](const QStrPair &l, const QStrPair &r) { return (l.first < r.first); } );
|
std::sort(tmpList.begin(), tmpList.end(), [](const QStrPair &l, const QStrPair &r) { return (l.first < r.first); } );
|
||||||
|
|
||||||
foreach (const QStrPair &p, tmpList)
|
for (const QStrPair &p : asConst(tmpList))
|
||||||
m_ui->selectPlugin->addItem(p.first, QVariant(p.second));
|
m_ui->selectPlugin->addItem(p.first, QVariant(p.second));
|
||||||
|
|
||||||
if (m_ui->selectPlugin->count() > 3)
|
if (m_ui->selectPlugin->count() > 3)
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
#include "base/bittorrent/sessionstatus.h"
|
#include "base/bittorrent/sessionstatus.h"
|
||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
#include "base/utils/string.h"
|
#include "base/utils/string.h"
|
||||||
#include "ui_statsdialog.h"
|
#include "ui_statsdialog.h"
|
||||||
|
@ -89,7 +90,7 @@ void StatsDialog::update()
|
||||||
|
|
||||||
// num_peers is not reliable (adds up peers, which didn't even overcome tcp handshake)
|
// num_peers is not reliable (adds up peers, which didn't even overcome tcp handshake)
|
||||||
quint32 peers = 0;
|
quint32 peers = 0;
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, BitTorrent::Session::instance()->torrents())
|
for (BitTorrent::TorrentHandle *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
|
||||||
peers += torrent->peersCount();
|
peers += torrent->peersCount();
|
||||||
|
|
||||||
m_ui->labelWriteStarve->setText(QString("%1%")
|
m_ui->labelWriteStarve->setText(QString("%1%")
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
|
#include "base/global.h"
|
||||||
#include "guiiconprovider.h"
|
#include "guiiconprovider.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
@ -236,7 +237,7 @@ void TagFilterModel::torrentAdded(BitTorrent::TorrentHandle *const torrent)
|
||||||
if (items.isEmpty())
|
if (items.isEmpty())
|
||||||
untaggedItem()->increaseTorrentsCount();
|
untaggedItem()->increaseTorrentsCount();
|
||||||
|
|
||||||
foreach (TagModelItem *item, items)
|
for (TagModelItem *item : items)
|
||||||
item->increaseTorrentsCount();
|
item->increaseTorrentsCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +248,7 @@ void TagFilterModel::torrentAboutToBeRemoved(BitTorrent::TorrentHandle *const to
|
||||||
if (torrent->tags().isEmpty())
|
if (torrent->tags().isEmpty())
|
||||||
untaggedItem()->decreaseTorrentsCount();
|
untaggedItem()->decreaseTorrentsCount();
|
||||||
|
|
||||||
foreach (TagModelItem *item, findItems(torrent->tags()))
|
for (TagModelItem *item : asConst(findItems(torrent->tags())))
|
||||||
item->decreaseTorrentsCount();
|
item->decreaseTorrentsCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +275,7 @@ void TagFilterModel::populate()
|
||||||
[](Torrent *torrent) { return torrent->tags().isEmpty(); });
|
[](Torrent *torrent) { return torrent->tags().isEmpty(); });
|
||||||
addToModel(getSpecialUntaggedTag(), untaggedCount);
|
addToModel(getSpecialUntaggedTag(), untaggedCount);
|
||||||
|
|
||||||
foreach (const QString &tag, session->tags()) {
|
for (const QString &tag : asConst(session->tags())) {
|
||||||
const int count = std::count_if(torrents.begin(), torrents.end(),
|
const int count = std::count_if(torrents.begin(), torrents.end(),
|
||||||
[tag](Torrent *torrent) { return torrent->hasTag(tag); });
|
[tag](Torrent *torrent) { return torrent->hasTag(tag); });
|
||||||
addToModel(tag, count);
|
addToModel(tag, count);
|
||||||
|
@ -313,7 +314,7 @@ QVector<TagModelItem *> TagFilterModel::findItems(const QSet<QString> &tags)
|
||||||
{
|
{
|
||||||
QVector<TagModelItem *> items;
|
QVector<TagModelItem *> items;
|
||||||
items.reserve(tags.size());
|
items.reserve(tags.size());
|
||||||
foreach (const QString &tag, tags) {
|
for (const QString &tag : tags) {
|
||||||
TagModelItem *item = findItem(tag);
|
TagModelItem *item = findItem(tag);
|
||||||
if (item)
|
if (item)
|
||||||
items.push_back(item);
|
items.push_back(item);
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
|
#include "base/global.h"
|
||||||
#include "autoexpandabledialog.h"
|
#include "autoexpandabledialog.h"
|
||||||
#include "guiiconprovider.h"
|
#include "guiiconprovider.h"
|
||||||
#include "tagfiltermodel.h"
|
#include "tagfiltermodel.h"
|
||||||
|
@ -222,7 +223,7 @@ void TagFilterWidget::removeTag()
|
||||||
void TagFilterWidget::removeUnusedTags()
|
void TagFilterWidget::removeUnusedTags()
|
||||||
{
|
{
|
||||||
auto session = BitTorrent::Session::instance();
|
auto session = BitTorrent::Session::instance();
|
||||||
foreach (const QString &tag, session->tags())
|
for (const QString &tag : asConst(session->tags()))
|
||||||
if (model()->data(static_cast<TagFilterProxyModel *>(model())->index(tag), Qt::UserRole) == 0)
|
if (model()->data(static_cast<TagFilterProxyModel *>(model())->index(tag), Qt::UserRole) == 0)
|
||||||
session->removeTag(tag);
|
session->removeTag(tag);
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
#include "base/utils/fs.h"
|
#include "base/utils/fs.h"
|
||||||
#include "guiiconprovider.h"
|
#include "guiiconprovider.h"
|
||||||
|
@ -146,7 +147,7 @@ namespace
|
||||||
#elif defined(Q_OS_MAC)
|
#elif defined(Q_OS_MAC)
|
||||||
// There is a similar bug on macOS, to be reported to Qt
|
// There is a similar bug on macOS, to be reported to Qt
|
||||||
// https://github.com/qbittorrent/qBittorrent/pull/6156#issuecomment-316302615
|
// https://github.com/qbittorrent/qBittorrent/pull/6156#issuecomment-316302615
|
||||||
class MacFileIconProvider final: public CachingFileIconProvider
|
class MacFileIconProvider final : public CachingFileIconProvider
|
||||||
{
|
{
|
||||||
QPixmap pixmapForExtension(const QString &ext) const override
|
QPixmap pixmapForExtension(const QString &ext) const override
|
||||||
{
|
{
|
||||||
|
@ -266,14 +267,14 @@ QVector<int> TorrentContentModel::getFilePriorities() const
|
||||||
{
|
{
|
||||||
QVector<int> prio;
|
QVector<int> prio;
|
||||||
prio.reserve(m_filesIndex.size());
|
prio.reserve(m_filesIndex.size());
|
||||||
foreach (const TorrentContentModelFile *file, m_filesIndex)
|
for (const TorrentContentModelFile *file : asConst(m_filesIndex))
|
||||||
prio.push_back(file->priority());
|
prio.push_back(file->priority());
|
||||||
return prio;
|
return prio;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TorrentContentModel::allFiltered() const
|
bool TorrentContentModel::allFiltered() const
|
||||||
{
|
{
|
||||||
foreach (const TorrentContentModelFile *fileItem, m_filesIndex)
|
for (const TorrentContentModelFile *fileItem : asConst(m_filesIndex))
|
||||||
if (fileItem->priority() != prio::IGNORED)
|
if (fileItem->priority() != prio::IGNORED)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -346,7 +347,7 @@ int TorrentContentModel::getFileIndex(const QModelIndex &index)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant TorrentContentModel::data(const QModelIndex& index, int role) const
|
QVariant TorrentContentModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -476,7 +477,7 @@ void TorrentContentModel::setupModelData(const BitTorrent::TorrentInfo &info)
|
||||||
// Iterate of parts of the path to create necessary folders
|
// Iterate of parts of the path to create necessary folders
|
||||||
QStringList pathFolders = path.split('/', QString::SkipEmptyParts);
|
QStringList pathFolders = path.split('/', QString::SkipEmptyParts);
|
||||||
pathFolders.removeLast();
|
pathFolders.removeLast();
|
||||||
foreach (const QString &pathPart, pathFolders) {
|
for (const QString &pathPart : asConst(pathFolders)) {
|
||||||
if (pathPart == ".unwanted")
|
if (pathPart == ".unwanted")
|
||||||
continue;
|
continue;
|
||||||
TorrentContentModelFolder* newParent = currentParent->childFolderWithName(pathPart);
|
TorrentContentModelFolder* newParent = currentParent->childFolderWithName(pathPart);
|
||||||
|
|
|
@ -54,13 +54,13 @@ public:
|
||||||
QVector<int> getFilePriorities() const;
|
QVector<int> getFilePriorities() const;
|
||||||
bool allFiltered() const;
|
bool allFiltered() const;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
bool setData(const QModelIndex &index, const QVariant& value, int role = Qt::EditRole) override;
|
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||||
TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const;
|
TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const;
|
||||||
int getFileIndex(const QModelIndex &index);
|
int getFileIndex(const QModelIndex &index);
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||||
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||||
QModelIndex parent(const QModelIndex &index) const override;
|
QModelIndex parent(const QModelIndex &index) const override;
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
void clear();
|
void clear();
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "torrentcontentmodelfolder.h"
|
#include "torrentcontentmodelfolder.h"
|
||||||
|
|
||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
|
#include "base/global.h"
|
||||||
|
|
||||||
TorrentContentModelFolder::TorrentContentModelFolder(const QString &name, TorrentContentModelFolder *parent)
|
TorrentContentModelFolder::TorrentContentModelFolder(const QString &name, TorrentContentModelFolder *parent)
|
||||||
: TorrentContentModelItem(parent)
|
: TorrentContentModelItem(parent)
|
||||||
|
@ -85,7 +86,7 @@ TorrentContentModelItem *TorrentContentModelFolder::child(int row) const
|
||||||
|
|
||||||
TorrentContentModelFolder *TorrentContentModelFolder::childFolderWithName(const QString &name) const
|
TorrentContentModelFolder *TorrentContentModelFolder::childFolderWithName(const QString &name) const
|
||||||
{
|
{
|
||||||
foreach (TorrentContentModelItem *child, m_childItems)
|
for (TorrentContentModelItem *child : asConst(m_childItems))
|
||||||
if ((child->itemType() == FolderType) && (child->name() == name))
|
if ((child->itemType() == FolderType) && (child->name() == name))
|
||||||
return static_cast<TorrentContentModelFolder *>(child);
|
return static_cast<TorrentContentModelFolder *>(child);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -132,7 +133,7 @@ void TorrentContentModelFolder::setPriority(int newPriority, bool updateParent)
|
||||||
|
|
||||||
// Update children
|
// Update children
|
||||||
if (m_priority != prio::MIXED)
|
if (m_priority != prio::MIXED)
|
||||||
foreach (TorrentContentModelItem *child, m_childItems)
|
for (TorrentContentModelItem *child : asConst(m_childItems))
|
||||||
child->setPriority(m_priority, false);
|
child->setPriority(m_priority, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +142,7 @@ void TorrentContentModelFolder::recalculateProgress()
|
||||||
qreal tProgress = 0;
|
qreal tProgress = 0;
|
||||||
qulonglong tSize = 0;
|
qulonglong tSize = 0;
|
||||||
qulonglong tRemaining = 0;
|
qulonglong tRemaining = 0;
|
||||||
foreach (TorrentContentModelItem *child, m_childItems) {
|
for (TorrentContentModelItem *child : asConst(m_childItems)) {
|
||||||
if (child->priority() == prio::IGNORED)
|
if (child->priority() == prio::IGNORED)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -164,7 +165,7 @@ void TorrentContentModelFolder::recalculateAvailability()
|
||||||
qreal tAvailability = 0;
|
qreal tAvailability = 0;
|
||||||
qulonglong tSize = 0;
|
qulonglong tSize = 0;
|
||||||
bool foundAnyData = false;
|
bool foundAnyData = false;
|
||||||
foreach (TorrentContentModelItem *child, m_childItems) {
|
for (TorrentContentModelItem *child : asConst(m_childItems)) {
|
||||||
if (child->priority() == prio::IGNORED)
|
if (child->priority() == prio::IGNORED)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
#include "base/bittorrent/trackerentry.h"
|
#include "base/bittorrent/trackerentry.h"
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/logger.h"
|
#include "base/logger.h"
|
||||||
#include "base/net/downloadhandler.h"
|
#include "base/net/downloadhandler.h"
|
||||||
#include "base/net/downloadmanager.h"
|
#include "base/net/downloadmanager.h"
|
||||||
|
@ -219,7 +220,7 @@ TrackerFiltersList::TrackerFiltersList(QWidget *parent, TransferListWidget *tran
|
||||||
|
|
||||||
TrackerFiltersList::~TrackerFiltersList()
|
TrackerFiltersList::~TrackerFiltersList()
|
||||||
{
|
{
|
||||||
foreach (const QString &iconPath, m_iconPaths)
|
for (const QString &iconPath : asConst(m_iconPaths))
|
||||||
Utils::Fs::forceRemove(iconPath);
|
Utils::Fs::forceRemove(iconPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,7 +405,7 @@ void TrackerFiltersList::trackerWarning(const QString &hash, const QString &trac
|
||||||
applyFilter(3);
|
applyFilter(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackerFiltersList::downloadFavicon(const QString& url)
|
void TrackerFiltersList::downloadFavicon(const QString &url)
|
||||||
{
|
{
|
||||||
if (!m_downloadTrackerFavicon) return;
|
if (!m_downloadTrackerFavicon) return;
|
||||||
Net::DownloadHandler *h = Net::DownloadManager::instance()->download(
|
Net::DownloadHandler *h = Net::DownloadManager::instance()->download(
|
||||||
|
@ -416,7 +417,7 @@ void TrackerFiltersList::downloadFavicon(const QString& url)
|
||||||
, &TrackerFiltersList::handleFavicoFailure);
|
, &TrackerFiltersList::handleFavicoFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackerFiltersList::handleFavicoDownload(const QString& url, const QString& filePath)
|
void TrackerFiltersList::handleFavicoDownload(const QString &url, const QString &filePath)
|
||||||
{
|
{
|
||||||
QString host = url.startsWith(GOOGLE_FAVICON_URL)
|
QString host = url.startsWith(GOOGLE_FAVICON_URL)
|
||||||
? url.mid(GOOGLE_FAVICON_URL.size())
|
? url.mid(GOOGLE_FAVICON_URL.size())
|
||||||
|
@ -487,8 +488,8 @@ void TrackerFiltersList::applyFilter(int row)
|
||||||
void TrackerFiltersList::handleNewTorrent(BitTorrent::TorrentHandle *const torrent)
|
void TrackerFiltersList::handleNewTorrent(BitTorrent::TorrentHandle *const torrent)
|
||||||
{
|
{
|
||||||
QString hash = torrent->hash();
|
QString hash = torrent->hash();
|
||||||
QList<BitTorrent::TrackerEntry> trackers = torrent->trackers();
|
const QList<BitTorrent::TrackerEntry> trackers = torrent->trackers();
|
||||||
foreach (const BitTorrent::TrackerEntry &tracker, trackers)
|
for (const BitTorrent::TrackerEntry &tracker : trackers)
|
||||||
addItem(tracker.url(), hash);
|
addItem(tracker.url(), hash);
|
||||||
|
|
||||||
//Check for trackerless torrent
|
//Check for trackerless torrent
|
||||||
|
@ -501,8 +502,8 @@ void TrackerFiltersList::handleNewTorrent(BitTorrent::TorrentHandle *const torre
|
||||||
void TrackerFiltersList::torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const torrent)
|
void TrackerFiltersList::torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const torrent)
|
||||||
{
|
{
|
||||||
QString hash = torrent->hash();
|
QString hash = torrent->hash();
|
||||||
QList<BitTorrent::TrackerEntry> trackers = torrent->trackers();
|
const QList<BitTorrent::TrackerEntry> trackers = torrent->trackers();
|
||||||
foreach (const BitTorrent::TrackerEntry &tracker, trackers)
|
for (const BitTorrent::TrackerEntry &tracker : trackers)
|
||||||
removeItem(tracker.url(), hash);
|
removeItem(tracker.url(), hash);
|
||||||
|
|
||||||
//Check for trackerless torrent
|
//Check for trackerless torrent
|
||||||
|
@ -662,13 +663,13 @@ void TransferListFiltersWidget::setDownloadTrackerFavicon(bool value)
|
||||||
|
|
||||||
void TransferListFiltersWidget::addTrackers(BitTorrent::TorrentHandle *const torrent, const QList<BitTorrent::TrackerEntry> &trackers)
|
void TransferListFiltersWidget::addTrackers(BitTorrent::TorrentHandle *const torrent, const QList<BitTorrent::TrackerEntry> &trackers)
|
||||||
{
|
{
|
||||||
foreach (const BitTorrent::TrackerEntry &tracker, trackers)
|
for (const BitTorrent::TrackerEntry &tracker : trackers)
|
||||||
m_trackerFilters->addItem(tracker.url(), torrent->hash());
|
m_trackerFilters->addItem(tracker.url(), torrent->hash());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::removeTrackers(BitTorrent::TorrentHandle *const torrent, const QList<BitTorrent::TrackerEntry> &trackers)
|
void TransferListFiltersWidget::removeTrackers(BitTorrent::TorrentHandle *const torrent, const QList<BitTorrent::TrackerEntry> &trackers)
|
||||||
{
|
{
|
||||||
foreach (const BitTorrent::TrackerEntry &tracker, trackers)
|
for (const BitTorrent::TrackerEntry &tracker : trackers)
|
||||||
m_trackerFilters->removeItem(tracker.url(), torrent->hash());
|
m_trackerFilters->removeItem(tracker.url(), torrent->hash());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/torrentfilter.h"
|
#include "base/torrentfilter.h"
|
||||||
#include "base/utils/fs.h"
|
#include "base/utils/fs.h"
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ TransferListModel::TransferListModel(QObject *parent)
|
||||||
{
|
{
|
||||||
// Load the torrents
|
// Load the torrents
|
||||||
using namespace BitTorrent;
|
using namespace BitTorrent;
|
||||||
foreach (TorrentHandle *const torrent, Session::instance()->torrents())
|
for (TorrentHandle *const torrent : asConst(Session::instance()->torrents()))
|
||||||
addTorrent(torrent);
|
addTorrent(torrent);
|
||||||
|
|
||||||
// Listen for torrent changes
|
// Listen for torrent changes
|
||||||
|
|
|
@ -83,7 +83,7 @@ public:
|
||||||
|
|
||||||
explicit TransferListModel(QObject *parent = nullptr);
|
explicit TransferListModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
int rowCount(const QModelIndex& index = QModelIndex()) const override;
|
int rowCount(const QModelIndex &index = QModelIndex()) const override;
|
||||||
int columnCount(const QModelIndex &parent=QModelIndex()) const override;
|
int columnCount(const QModelIndex &parent=QModelIndex()) const override;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
|
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/logger.h"
|
#include "base/logger.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
#include "base/torrentfilter.h"
|
#include "base/torrentfilter.h"
|
||||||
|
@ -72,7 +73,7 @@ namespace
|
||||||
QStringList extractHashes(const QList<BitTorrent::TorrentHandle *> &torrents)
|
QStringList extractHashes(const QList<BitTorrent::TorrentHandle *> &torrents)
|
||||||
{
|
{
|
||||||
QStringList hashes;
|
QStringList hashes;
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, torrents)
|
for (BitTorrent::TorrentHandle *const torrent : torrents)
|
||||||
hashes << torrent->hash();
|
hashes << torrent->hash();
|
||||||
|
|
||||||
return hashes;
|
return hashes;
|
||||||
|
@ -381,7 +382,7 @@ void TransferListWidget::torrentDoubleClicked()
|
||||||
QList<BitTorrent::TorrentHandle *> TransferListWidget::getSelectedTorrents() const
|
QList<BitTorrent::TorrentHandle *> TransferListWidget::getSelectedTorrents() const
|
||||||
{
|
{
|
||||||
QList<BitTorrent::TorrentHandle *> torrents;
|
QList<BitTorrent::TorrentHandle *> torrents;
|
||||||
foreach (const QModelIndex &index, selectionModel()->selectedRows())
|
for (const QModelIndex &index : asConst(selectionModel()->selectedRows()))
|
||||||
torrents << m_listModel->torrentHandle(mapToSource(index));
|
torrents << m_listModel->torrentHandle(mapToSource(index));
|
||||||
|
|
||||||
return torrents;
|
return torrents;
|
||||||
|
@ -401,7 +402,7 @@ void TransferListWidget::setSelectedTorrentsLocation()
|
||||||
qDebug("New location is %s", qUtf8Printable(newLocation));
|
qDebug("New location is %s", qUtf8Printable(newLocation));
|
||||||
|
|
||||||
// Actually move storage
|
// Actually move storage
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, torrents) {
|
for (BitTorrent::TorrentHandle *const torrent : torrents) {
|
||||||
Logger::instance()->addMessage(tr("Set location: moving \"%1\", from \"%2\" to \"%3\""
|
Logger::instance()->addMessage(tr("Set location: moving \"%1\", from \"%2\" to \"%3\""
|
||||||
, "Set location: moving \"ubuntu_16_04.iso\", from \"/home/dir1\" to \"/home/dir2\"")
|
, "Set location: moving \"ubuntu_16_04.iso\", from \"/home/dir1\" to \"/home/dir2\"")
|
||||||
.arg(torrent->name(), Utils::Fs::toNativePath(torrent->savePath())
|
.arg(torrent->name(), Utils::Fs::toNativePath(torrent->savePath())
|
||||||
|
@ -412,25 +413,25 @@ void TransferListWidget::setSelectedTorrentsLocation()
|
||||||
|
|
||||||
void TransferListWidget::pauseAllTorrents()
|
void TransferListWidget::pauseAllTorrents()
|
||||||
{
|
{
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, BitTorrent::Session::instance()->torrents())
|
for (BitTorrent::TorrentHandle *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
|
||||||
torrent->pause();
|
torrent->pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::resumeAllTorrents()
|
void TransferListWidget::resumeAllTorrents()
|
||||||
{
|
{
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, BitTorrent::Session::instance()->torrents())
|
for (BitTorrent::TorrentHandle *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
|
||||||
torrent->resume();
|
torrent->resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::startSelectedTorrents()
|
void TransferListWidget::startSelectedTorrents()
|
||||||
{
|
{
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents())
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
|
||||||
torrent->resume();
|
torrent->resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::forceStartSelectedTorrents()
|
void TransferListWidget::forceStartSelectedTorrents()
|
||||||
{
|
{
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents())
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
|
||||||
torrent->resume(true);
|
torrent->resume(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +446,7 @@ void TransferListWidget::startVisibleTorrents()
|
||||||
|
|
||||||
void TransferListWidget::pauseSelectedTorrents()
|
void TransferListWidget::pauseSelectedTorrents()
|
||||||
{
|
{
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents())
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
|
||||||
torrent->pause();
|
torrent->pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,7 +479,7 @@ void TransferListWidget::deleteSelectedTorrents(bool deleteLocalFiles)
|
||||||
if (Preferences::instance()->confirmTorrentDeletion()
|
if (Preferences::instance()->confirmTorrentDeletion()
|
||||||
&& !DeletionConfirmationDialog::askForDeletionConfirmation(this, deleteLocalFiles, torrents.size(), torrents[0]->name()))
|
&& !DeletionConfirmationDialog::askForDeletionConfirmation(this, deleteLocalFiles, torrents.size(), torrents[0]->name()))
|
||||||
return;
|
return;
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, torrents)
|
for (BitTorrent::TorrentHandle *const torrent : torrents)
|
||||||
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles);
|
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,7 +496,7 @@ void TransferListWidget::deleteVisibleTorrents()
|
||||||
&& !DeletionConfirmationDialog::askForDeletionConfirmation(this, deleteLocalFiles, torrents.size(), torrents[0]->name()))
|
&& !DeletionConfirmationDialog::askForDeletionConfirmation(this, deleteLocalFiles, torrents.size(), torrents[0]->name()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, torrents)
|
for (BitTorrent::TorrentHandle *const torrent : asConst(torrents))
|
||||||
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles);
|
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,7 +529,7 @@ void TransferListWidget::bottomPrioSelectedTorrents()
|
||||||
void TransferListWidget::copySelectedMagnetURIs() const
|
void TransferListWidget::copySelectedMagnetURIs() const
|
||||||
{
|
{
|
||||||
QStringList magnetUris;
|
QStringList magnetUris;
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents())
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
|
||||||
magnetUris << torrent->toMagnetUri();
|
magnetUris << torrent->toMagnetUri();
|
||||||
|
|
||||||
qApp->clipboard()->setText(magnetUris.join('\n'));
|
qApp->clipboard()->setText(magnetUris.join('\n'));
|
||||||
|
@ -537,7 +538,7 @@ void TransferListWidget::copySelectedMagnetURIs() const
|
||||||
void TransferListWidget::copySelectedNames() const
|
void TransferListWidget::copySelectedNames() const
|
||||||
{
|
{
|
||||||
QStringList torrentNames;
|
QStringList torrentNames;
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents())
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
|
||||||
torrentNames << torrent->name();
|
torrentNames << torrent->name();
|
||||||
|
|
||||||
qApp->clipboard()->setText(torrentNames.join('\n'));
|
qApp->clipboard()->setText(torrentNames.join('\n'));
|
||||||
|
@ -546,7 +547,7 @@ void TransferListWidget::copySelectedNames() const
|
||||||
void TransferListWidget::copySelectedHashes() const
|
void TransferListWidget::copySelectedHashes() const
|
||||||
{
|
{
|
||||||
QStringList torrentHashes;
|
QStringList torrentHashes;
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents())
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
|
||||||
torrentHashes << torrent->hash();
|
torrentHashes << torrent->hash();
|
||||||
|
|
||||||
qApp->clipboard()->setText(torrentHashes.join('\n'));
|
qApp->clipboard()->setText(torrentHashes.join('\n'));
|
||||||
|
@ -566,13 +567,13 @@ void TransferListWidget::openSelectedTorrentsFolder() const
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
// On macOS you expect both the files and folders to be opened in their parent
|
// On macOS you expect both the files and folders to be opened in their parent
|
||||||
// folders prehilighted for opening, so we use a custom method.
|
// folders prehilighted for opening, so we use a custom method.
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents()) {
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) {
|
||||||
QString path = torrent->contentPath(true);
|
QString path = torrent->contentPath(true);
|
||||||
pathsList.insert(path);
|
pathsList.insert(path);
|
||||||
}
|
}
|
||||||
MacUtils::openFiles(pathsList);
|
MacUtils::openFiles(pathsList);
|
||||||
#else
|
#else
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents()) {
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) {
|
||||||
QString path = torrent->contentPath(true);
|
QString path = torrent->contentPath(true);
|
||||||
if (!pathsList.contains(path)) {
|
if (!pathsList.contains(path)) {
|
||||||
if (torrent->filesCount() == 1)
|
if (torrent->filesCount() == 1)
|
||||||
|
@ -582,12 +583,12 @@ void TransferListWidget::openSelectedTorrentsFolder() const
|
||||||
}
|
}
|
||||||
pathsList.insert(path);
|
pathsList.insert(path);
|
||||||
}
|
}
|
||||||
#endif
|
#endif // Q_OS_MAC
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::previewSelectedTorrents()
|
void TransferListWidget::previewSelectedTorrents()
|
||||||
{
|
{
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents()) {
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) {
|
||||||
if (torrent->hasMetadata())
|
if (torrent->hasMetadata())
|
||||||
new PreviewSelectDialog(this, torrent);
|
new PreviewSelectDialog(this, torrent);
|
||||||
}
|
}
|
||||||
|
@ -595,16 +596,16 @@ void TransferListWidget::previewSelectedTorrents()
|
||||||
|
|
||||||
void TransferListWidget::setDlLimitSelectedTorrents()
|
void TransferListWidget::setDlLimitSelectedTorrents()
|
||||||
{
|
{
|
||||||
QList<BitTorrent::TorrentHandle *> TorrentsList;
|
QList<BitTorrent::TorrentHandle *> torrentsList;
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents()) {
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) {
|
||||||
if (torrent->isSeed())
|
if (torrent->isSeed())
|
||||||
continue;
|
continue;
|
||||||
TorrentsList += torrent;
|
torrentsList += torrent;
|
||||||
}
|
}
|
||||||
if (TorrentsList.empty()) return;
|
if (torrentsList.empty()) return;
|
||||||
|
|
||||||
int oldLimit = TorrentsList.first()->downloadLimit();
|
int oldLimit = torrentsList.first()->downloadLimit();
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
|
for (BitTorrent::TorrentHandle *const torrent : asConst(torrentsList)) {
|
||||||
if (torrent->downloadLimit() != oldLimit) {
|
if (torrent->downloadLimit() != oldLimit) {
|
||||||
oldLimit = -1;
|
oldLimit = -1;
|
||||||
break;
|
break;
|
||||||
|
@ -617,7 +618,7 @@ void TransferListWidget::setDlLimitSelectedTorrents()
|
||||||
, BitTorrent::Session::instance()->globalDownloadSpeedLimit());
|
, BitTorrent::Session::instance()->globalDownloadSpeedLimit());
|
||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
|
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
|
for (BitTorrent::TorrentHandle *const torrent : asConst(torrentsList)) {
|
||||||
qDebug("Applying download speed limit of %ld Kb/s to torrent %s", (newLimit / 1024l), qUtf8Printable(torrent->hash()));
|
qDebug("Applying download speed limit of %ld Kb/s to torrent %s", (newLimit / 1024l), qUtf8Printable(torrent->hash()));
|
||||||
torrent->setDownloadLimit(newLimit);
|
torrent->setDownloadLimit(newLimit);
|
||||||
}
|
}
|
||||||
|
@ -625,11 +626,11 @@ void TransferListWidget::setDlLimitSelectedTorrents()
|
||||||
|
|
||||||
void TransferListWidget::setUpLimitSelectedTorrents()
|
void TransferListWidget::setUpLimitSelectedTorrents()
|
||||||
{
|
{
|
||||||
QList<BitTorrent::TorrentHandle *> TorrentsList = getSelectedTorrents();
|
QList<BitTorrent::TorrentHandle *> torrentsList = getSelectedTorrents();
|
||||||
if (TorrentsList.empty()) return;
|
if (torrentsList.empty()) return;
|
||||||
|
|
||||||
int oldLimit = TorrentsList.first()->uploadLimit();
|
int oldLimit = torrentsList.first()->uploadLimit();
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
|
for (BitTorrent::TorrentHandle *const torrent : asConst(torrentsList)) {
|
||||||
if (torrent->uploadLimit() != oldLimit) {
|
if (torrent->uploadLimit() != oldLimit) {
|
||||||
oldLimit = -1;
|
oldLimit = -1;
|
||||||
break;
|
break;
|
||||||
|
@ -642,7 +643,7 @@ void TransferListWidget::setUpLimitSelectedTorrents()
|
||||||
, BitTorrent::Session::instance()->globalUploadSpeedLimit());
|
, BitTorrent::Session::instance()->globalUploadSpeedLimit());
|
||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
|
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
|
for (BitTorrent::TorrentHandle *const torrent : asConst(torrentsList)) {
|
||||||
qDebug("Applying upload speed limit of %ld Kb/s to torrent %s", (newLimit / 1024l), qUtf8Printable(torrent->hash()));
|
qDebug("Applying upload speed limit of %ld Kb/s to torrent %s", (newLimit / 1024l), qUtf8Printable(torrent->hash()));
|
||||||
torrent->setUploadLimit(newLimit);
|
torrent->setUploadLimit(newLimit);
|
||||||
}
|
}
|
||||||
|
@ -670,7 +671,7 @@ void TransferListWidget::setMaxRatioSelectedTorrents()
|
||||||
currentMaxSeedingTime, BitTorrent::TorrentHandle::MAX_SEEDING_TIME, this);
|
currentMaxSeedingTime, BitTorrent::TorrentHandle::MAX_SEEDING_TIME, this);
|
||||||
if (dlg.exec() != QDialog::Accepted) return;
|
if (dlg.exec() != QDialog::Accepted) return;
|
||||||
|
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, torrents) {
|
for (BitTorrent::TorrentHandle *const torrent : torrents) {
|
||||||
qreal ratio = (dlg.useDefault() ? BitTorrent::TorrentHandle::USE_GLOBAL_RATIO : dlg.ratio());
|
qreal ratio = (dlg.useDefault() ? BitTorrent::TorrentHandle::USE_GLOBAL_RATIO : dlg.ratio());
|
||||||
torrent->setRatioLimit(ratio);
|
torrent->setRatioLimit(ratio);
|
||||||
|
|
||||||
|
@ -686,13 +687,13 @@ void TransferListWidget::recheckSelectedTorrents()
|
||||||
if (ret != QMessageBox::Yes) return;
|
if (ret != QMessageBox::Yes) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents())
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
|
||||||
torrent->forceRecheck();
|
torrent->forceRecheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::reannounceSelectedTorrents()
|
void TransferListWidget::reannounceSelectedTorrents()
|
||||||
{
|
{
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents())
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
|
||||||
torrent->forceReannounce();
|
torrent->forceReannounce();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -738,7 +739,7 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&)
|
||||||
|
|
||||||
void TransferListWidget::toggleSelectedTorrentsSuperSeeding() const
|
void TransferListWidget::toggleSelectedTorrentsSuperSeeding() const
|
||||||
{
|
{
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents()) {
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) {
|
||||||
if (torrent->hasMetadata())
|
if (torrent->hasMetadata())
|
||||||
torrent->setSuperSeeding(!torrent->superSeeding());
|
torrent->setSuperSeeding(!torrent->superSeeding());
|
||||||
}
|
}
|
||||||
|
@ -746,19 +747,19 @@ void TransferListWidget::toggleSelectedTorrentsSuperSeeding() const
|
||||||
|
|
||||||
void TransferListWidget::toggleSelectedTorrentsSequentialDownload() const
|
void TransferListWidget::toggleSelectedTorrentsSequentialDownload() const
|
||||||
{
|
{
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents())
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
|
||||||
torrent->toggleSequentialDownload();
|
torrent->toggleSequentialDownload();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::toggleSelectedFirstLastPiecePrio() const
|
void TransferListWidget::toggleSelectedFirstLastPiecePrio() const
|
||||||
{
|
{
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents())
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
|
||||||
torrent->toggleFirstLastPiecePriority();
|
torrent->toggleFirstLastPiecePriority();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::setSelectedAutoTMMEnabled(bool enabled) const
|
void TransferListWidget::setSelectedAutoTMMEnabled(bool enabled) const
|
||||||
{
|
{
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents())
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
|
||||||
torrent->setAutoTMMEnabled(enabled);
|
torrent->setAutoTMMEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -772,7 +773,7 @@ void TransferListWidget::askNewCategoryForSelection()
|
||||||
void TransferListWidget::askAddTagsForSelection()
|
void TransferListWidget::askAddTagsForSelection()
|
||||||
{
|
{
|
||||||
const QStringList tags = askTagsForSelection(tr("Add Tags"));
|
const QStringList tags = askTagsForSelection(tr("Add Tags"));
|
||||||
foreach (const QString &tag, tags)
|
for (const QString &tag : tags)
|
||||||
addSelectionTag(tag);
|
addSelectionTag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -811,7 +812,7 @@ QStringList TransferListWidget::askTagsForSelection(const QString &dialogTitle)
|
||||||
|
|
||||||
void TransferListWidget::applyToSelectedTorrents(const std::function<void (BitTorrent::TorrentHandle *const)> &fn)
|
void TransferListWidget::applyToSelectedTorrents(const std::function<void (BitTorrent::TorrentHandle *const)> &fn)
|
||||||
{
|
{
|
||||||
foreach (const QModelIndex &index, selectionModel()->selectedRows()) {
|
for (const QModelIndex &index : asConst(selectionModel()->selectedRows())) {
|
||||||
BitTorrent::TorrentHandle *const torrent = m_listModel->torrentHandle(mapToSource(index));
|
BitTorrent::TorrentHandle *const torrent = m_listModel->torrentHandle(mapToSource(index));
|
||||||
Q_ASSERT(torrent);
|
Q_ASSERT(torrent);
|
||||||
fn(torrent);
|
fn(torrent);
|
||||||
|
@ -839,7 +840,7 @@ void TransferListWidget::renameSelectedTorrent()
|
||||||
|
|
||||||
void TransferListWidget::setSelectionCategory(QString category)
|
void TransferListWidget::setSelectionCategory(QString category)
|
||||||
{
|
{
|
||||||
foreach (const QModelIndex &index, selectionModel()->selectedRows())
|
for (const QModelIndex &index : asConst(selectionModel()->selectedRows()))
|
||||||
m_listModel->setData(m_listModel->index(mapToSource(index).row(), TransferListModel::TR_CATEGORY), category, Qt::DisplayRole);
|
m_listModel->setData(m_listModel->index(mapToSource(index).row(), TransferListModel::TR_CATEGORY), category, Qt::DisplayRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -860,7 +861,7 @@ void TransferListWidget::clearSelectionTags()
|
||||||
|
|
||||||
void TransferListWidget::displayListMenu(const QPoint&)
|
void TransferListWidget::displayListMenu(const QPoint&)
|
||||||
{
|
{
|
||||||
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
const QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
||||||
if (selectedIndexes.size() == 0) return;
|
if (selectedIndexes.size() == 0) return;
|
||||||
|
|
||||||
// Create actions
|
// Create actions
|
||||||
|
@ -936,7 +937,7 @@ void TransferListWidget::displayListMenu(const QPoint&)
|
||||||
|
|
||||||
BitTorrent::TorrentHandle *torrent;
|
BitTorrent::TorrentHandle *torrent;
|
||||||
qDebug("Displaying menu");
|
qDebug("Displaying menu");
|
||||||
foreach (const QModelIndex &index, selectedIndexes) {
|
for (const QModelIndex &index : selectedIndexes) {
|
||||||
// Get the file name
|
// Get the file name
|
||||||
// Get handle and pause the torrent
|
// Get handle and pause the torrent
|
||||||
torrent = m_listModel->torrentHandle(mapToSource(index));
|
torrent = m_listModel->torrentHandle(mapToSource(index));
|
||||||
|
@ -1022,7 +1023,7 @@ void TransferListWidget::displayListMenu(const QPoint&)
|
||||||
categoryActions << categoryMenu->addAction(GuiIconProvider::instance()->getIcon("list-add"), tr("New...", "New category..."));
|
categoryActions << categoryMenu->addAction(GuiIconProvider::instance()->getIcon("list-add"), tr("New...", "New category..."));
|
||||||
categoryActions << categoryMenu->addAction(GuiIconProvider::instance()->getIcon("edit-clear"), tr("Reset", "Reset category"));
|
categoryActions << categoryMenu->addAction(GuiIconProvider::instance()->getIcon("edit-clear"), tr("Reset", "Reset category"));
|
||||||
categoryMenu->addSeparator();
|
categoryMenu->addSeparator();
|
||||||
foreach (QString category, categories) {
|
for (QString category : asConst(categories)) {
|
||||||
category.replace('&', "&&"); // avoid '&' becomes accelerator key
|
category.replace('&', "&&"); // avoid '&' becomes accelerator key
|
||||||
QAction *cat = new QAction(GuiIconProvider::instance()->getIcon("inode-directory"), category, categoryMenu);
|
QAction *cat = new QAction(GuiIconProvider::instance()->getIcon("inode-directory"), category, categoryMenu);
|
||||||
if (allSameCategory && (category == firstCategory)) {
|
if (allSameCategory && (category == firstCategory)) {
|
||||||
|
@ -1041,7 +1042,7 @@ void TransferListWidget::displayListMenu(const QPoint&)
|
||||||
tagsActions << tagsMenu->addAction(GuiIconProvider::instance()->getIcon("list-add"), tr("Add...", "Add / assign multiple tags..."));
|
tagsActions << tagsMenu->addAction(GuiIconProvider::instance()->getIcon("list-add"), tr("Add...", "Add / assign multiple tags..."));
|
||||||
tagsActions << tagsMenu->addAction(GuiIconProvider::instance()->getIcon("edit-clear"), tr("Remove All", "Remove all tags"));
|
tagsActions << tagsMenu->addAction(GuiIconProvider::instance()->getIcon("edit-clear"), tr("Remove All", "Remove all tags"));
|
||||||
tagsMenu->addSeparator();
|
tagsMenu->addSeparator();
|
||||||
foreach (QString tag, tags) {
|
for (const QString &tag : asConst(tags)) {
|
||||||
const Qt::CheckState initialState = tagsInAll.contains(tag) ? Qt::Checked
|
const Qt::CheckState initialState = tagsInAll.contains(tag) ? Qt::Checked
|
||||||
: tagsInAny.contains(tag) ? Qt::PartiallyChecked
|
: tagsInAny.contains(tag) ? Qt::PartiallyChecked
|
||||||
: Qt::Unchecked;
|
: Qt::Unchecked;
|
||||||
|
@ -1144,7 +1145,7 @@ void TransferListWidget::displayListMenu(const QPoint&)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::currentChanged(const QModelIndex& current, const QModelIndex&)
|
void TransferListWidget::currentChanged(const QModelIndex ¤t, const QModelIndex&)
|
||||||
{
|
{
|
||||||
qDebug("CURRENT CHANGED");
|
qDebug("CURRENT CHANGED");
|
||||||
BitTorrent::TorrentHandle *torrent = nullptr;
|
BitTorrent::TorrentHandle *torrent = nullptr;
|
||||||
|
|
|
@ -106,7 +106,7 @@ protected:
|
||||||
protected slots:
|
protected slots:
|
||||||
void torrentDoubleClicked();
|
void torrentDoubleClicked();
|
||||||
void displayListMenu(const QPoint&);
|
void displayListMenu(const QPoint&);
|
||||||
void currentChanged(const QModelIndex& current, const QModelIndex&) override;
|
void currentChanged(const QModelIndex ¤t, const QModelIndex&) override;
|
||||||
void toggleSelectedTorrentsSuperSeeding() const;
|
void toggleSelectedTorrentsSuperSeeding() const;
|
||||||
void toggleSelectedTorrentsSequentialDownload() const;
|
void toggleSelectedTorrentsSequentialDownload() const;
|
||||||
void toggleSelectedFirstLastPiecePrio() const;
|
void toggleSelectedFirstLastPiecePrio() const;
|
||||||
|
|
|
@ -202,7 +202,7 @@ void AppController::preferencesAction()
|
||||||
data["bypass_local_auth"] = !pref->isWebUiLocalAuthEnabled();
|
data["bypass_local_auth"] = !pref->isWebUiLocalAuthEnabled();
|
||||||
data["bypass_auth_subnet_whitelist_enabled"] = pref->isWebUiAuthSubnetWhitelistEnabled();
|
data["bypass_auth_subnet_whitelist_enabled"] = pref->isWebUiAuthSubnetWhitelistEnabled();
|
||||||
QStringList authSubnetWhitelistStringList;
|
QStringList authSubnetWhitelistStringList;
|
||||||
for (const Utils::Net::Subnet &subnet : copyAsConst(pref->getWebUiAuthSubnetWhitelist()))
|
for (const Utils::Net::Subnet &subnet : asConst(pref->getWebUiAuthSubnetWhitelist()))
|
||||||
authSubnetWhitelistStringList << Utils::Net::subnetToString(subnet);
|
authSubnetWhitelistStringList << Utils::Net::subnetToString(subnet);
|
||||||
data["bypass_auth_subnet_whitelist"] = authSubnetWhitelistStringList.join("\n");
|
data["bypass_auth_subnet_whitelist"] = authSubnetWhitelistStringList.join("\n");
|
||||||
// Security
|
// Security
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/logger.h"
|
#include "base/logger.h"
|
||||||
#include "base/utils/string.h"
|
#include "base/utils/string.h"
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ void LogController::mainAction()
|
||||||
Logger *const logger = Logger::instance();
|
Logger *const logger = Logger::instance();
|
||||||
QVariantList msgList;
|
QVariantList msgList;
|
||||||
|
|
||||||
foreach (const Log::Msg &msg, logger->getMessages(lastKnownId)) {
|
for (const Log::Msg &msg : asConst(logger->getMessages(lastKnownId))) {
|
||||||
if (!((msg.type == Log::NORMAL && isNormal)
|
if (!((msg.type == Log::NORMAL && isNormal)
|
||||||
|| (msg.type == Log::INFO && isInfo)
|
|| (msg.type == Log::INFO && isInfo)
|
||||||
|| (msg.type == Log::WARNING && isWarning)
|
|| (msg.type == Log::WARNING && isWarning)
|
||||||
|
@ -110,7 +111,7 @@ void LogController::peersAction()
|
||||||
Logger *const logger = Logger::instance();
|
Logger *const logger = Logger::instance();
|
||||||
QVariantList peerList;
|
QVariantList peerList;
|
||||||
|
|
||||||
foreach (const Log::Peer &peer, logger->getPeers(lastKnownId)) {
|
for (const Log::Peer &peer : asConst(logger->getPeers(lastKnownId))) {
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
map[KEY_LOG_ID] = peer.id;
|
map[KEY_LOG_ID] = peer.id;
|
||||||
map[KEY_LOG_TIMESTAMP] = peer.timestamp;
|
map[KEY_LOG_TIMESTAMP] = peer.timestamp;
|
||||||
|
|
|
@ -202,7 +202,7 @@ void SearchController::categoriesAction()
|
||||||
const QString name = params()["pluginName"].trimmed();
|
const QString name = params()["pluginName"].trimmed();
|
||||||
|
|
||||||
categories << SearchPluginManager::categoryFullName("all");
|
categories << SearchPluginManager::categoryFullName("all");
|
||||||
for (const QString &category : copyAsConst(SearchPluginManager::instance()->getPluginCategories(name)))
|
for (const QString &category : asConst(SearchPluginManager::instance()->getPluginCategories(name)))
|
||||||
categories << SearchPluginManager::categoryFullName(category);
|
categories << SearchPluginManager::categoryFullName(category);
|
||||||
|
|
||||||
const QJsonArray result = QJsonArray::fromStringList(categories);
|
const QJsonArray result = QJsonArray::fromStringList(categories);
|
||||||
|
@ -263,7 +263,7 @@ void SearchController::checkForUpdatesFinished(const QHash<QString, PluginVersio
|
||||||
LogMsg(tr("Updating %1 plugins").arg(updateInfo.size()), Log::INFO);
|
LogMsg(tr("Updating %1 plugins").arg(updateInfo.size()), Log::INFO);
|
||||||
|
|
||||||
SearchPluginManager *const pluginManager = SearchPluginManager::instance();
|
SearchPluginManager *const pluginManager = SearchPluginManager::instance();
|
||||||
for (const QString &pluginName : updateInfo.keys()) {
|
for (const QString &pluginName : asConst(updateInfo.keys())) {
|
||||||
LogMsg(tr("Updating plugin %1").arg(pluginName), Log::INFO);
|
LogMsg(tr("Updating plugin %1").arg(pluginName), Log::INFO);
|
||||||
pluginManager->updatePlugin(pluginName);
|
pluginManager->updatePlugin(pluginName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "base/bittorrent/peerinfo.h"
|
#include "base/bittorrent/peerinfo.h"
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/net/geoipmanager.h"
|
#include "base/net/geoipmanager.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
#include "base/utils/fs.h"
|
#include "base/utils/fs.h"
|
||||||
|
@ -133,7 +134,7 @@ namespace
|
||||||
|
|
||||||
// num_peers is not reliable (adds up peers, which didn't even overcome tcp handshake)
|
// num_peers is not reliable (adds up peers, which didn't even overcome tcp handshake)
|
||||||
quint32 peers = 0;
|
quint32 peers = 0;
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, BitTorrent::Session::instance()->torrents())
|
for (BitTorrent::TorrentHandle *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
|
||||||
peers += torrent->peersCount();
|
peers += torrent->peersCount();
|
||||||
map[KEY_TRANSFER_WRITE_CACHE_OVERLOAD] = ((sessionStatus.diskWriteQueue > 0) && (peers > 0)) ? Utils::String::fromDouble((100. * sessionStatus.diskWriteQueue) / peers, 2) : "0";
|
map[KEY_TRANSFER_WRITE_CACHE_OVERLOAD] = ((sessionStatus.diskWriteQueue > 0) && (peers > 0)) ? Utils::String::fromDouble((100. * sessionStatus.diskWriteQueue) / peers, 2) : "0";
|
||||||
map[KEY_TRANSFER_READ_CACHE_OVERLOAD] = ((sessionStatus.diskReadQueue > 0) && (peers > 0)) ? Utils::String::fromDouble((100. * sessionStatus.diskReadQueue) / peers, 2) : "0";
|
map[KEY_TRANSFER_READ_CACHE_OVERLOAD] = ((sessionStatus.diskReadQueue > 0) && (peers > 0)) ? Utils::String::fromDouble((100. * sessionStatus.diskReadQueue) / peers, 2) : "0";
|
||||||
|
@ -268,7 +269,7 @@ namespace
|
||||||
syncData = data;
|
syncData = data;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
foreach (QVariant item, data) {
|
for (const QVariant &item : data) {
|
||||||
if (!prevData.contains(item))
|
if (!prevData.contains(item))
|
||||||
// new list item found - append it to syncData
|
// new list item found - append it to syncData
|
||||||
syncData.append(item);
|
syncData.append(item);
|
||||||
|
@ -409,7 +410,7 @@ void SyncController::maindataAction()
|
||||||
|
|
||||||
BitTorrent::Session *const session = BitTorrent::Session::instance();
|
BitTorrent::Session *const session = BitTorrent::Session::instance();
|
||||||
|
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, session->torrents()) {
|
for (BitTorrent::TorrentHandle *const torrent : asConst(session->torrents())) {
|
||||||
QVariantMap map = serialize(*torrent);
|
QVariantMap map = serialize(*torrent);
|
||||||
map.remove(KEY_TORRENT_HASH);
|
map.remove(KEY_TORRENT_HASH);
|
||||||
|
|
||||||
|
@ -468,7 +469,7 @@ void SyncController::torrentPeersAction()
|
||||||
|
|
||||||
QVariantMap data;
|
QVariantMap data;
|
||||||
QVariantHash peers;
|
QVariantHash peers;
|
||||||
QList<BitTorrent::PeerInfo> peersList = torrent->peers();
|
const QList<BitTorrent::PeerInfo> peersList = torrent->peers();
|
||||||
#ifndef DISABLE_COUNTRIES_RESOLUTION
|
#ifndef DISABLE_COUNTRIES_RESOLUTION
|
||||||
bool resolvePeerCountries = Preferences::instance()->resolvePeerCountries();
|
bool resolvePeerCountries = Preferences::instance()->resolvePeerCountries();
|
||||||
#else
|
#else
|
||||||
|
@ -477,7 +478,7 @@ void SyncController::torrentPeersAction()
|
||||||
|
|
||||||
data[KEY_SYNC_TORRENT_PEERS_SHOW_FLAGS] = resolvePeerCountries;
|
data[KEY_SYNC_TORRENT_PEERS_SHOW_FLAGS] = resolvePeerCountries;
|
||||||
|
|
||||||
foreach (const BitTorrent::PeerInfo &pi, peersList) {
|
for (const BitTorrent::PeerInfo &pi : peersList) {
|
||||||
if (pi.address().ip.isNull()) continue;
|
if (pi.address().ip.isNull()) continue;
|
||||||
QVariantMap peer;
|
QVariantMap peer;
|
||||||
#ifndef DISABLE_COUNTRIES_RESOLUTION
|
#ifndef DISABLE_COUNTRIES_RESOLUTION
|
||||||
|
|
|
@ -113,7 +113,7 @@ namespace
|
||||||
void applyToTorrents(const QStringList &hashes, const std::function<void (BitTorrent::TorrentHandle *torrent)> &func)
|
void applyToTorrents(const QStringList &hashes, const std::function<void (BitTorrent::TorrentHandle *torrent)> &func)
|
||||||
{
|
{
|
||||||
if ((hashes.size() == 1) && (hashes[0] == QLatin1String("all"))) {
|
if ((hashes.size() == 1) && (hashes[0] == QLatin1String("all"))) {
|
||||||
foreach (BitTorrent::TorrentHandle *torrent, BitTorrent::Session::instance()->torrents())
|
for (BitTorrent::TorrentHandle *torrent : asConst(BitTorrent::Session::instance()->torrents()))
|
||||||
func(torrent);
|
func(torrent);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -167,7 +167,7 @@ void TorrentsController::infoAction()
|
||||||
|
|
||||||
QVariantList torrentList;
|
QVariantList torrentList;
|
||||||
TorrentFilter torrentFilter(filter, (hashSet.isEmpty() ? TorrentFilter::AnyHash : hashSet), category);
|
TorrentFilter torrentFilter(filter, (hashSet.isEmpty() ? TorrentFilter::AnyHash : hashSet), category);
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, BitTorrent::Session::instance()->torrents()) {
|
for (BitTorrent::TorrentHandle *const torrent : asConst(BitTorrent::Session::instance()->torrents())) {
|
||||||
if (torrentFilter.match(torrent))
|
if (torrentFilter.match(torrent))
|
||||||
torrentList.append(serialize(*torrent));
|
torrentList.append(serialize(*torrent));
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ void TorrentsController::trackersAction()
|
||||||
throw APIError(APIErrorType::NotFound);
|
throw APIError(APIErrorType::NotFound);
|
||||||
|
|
||||||
QHash<QString, BitTorrent::TrackerInfo> trackersData = torrent->trackerInfos();
|
QHash<QString, BitTorrent::TrackerInfo> trackersData = torrent->trackerInfos();
|
||||||
foreach (const BitTorrent::TrackerEntry &tracker, torrent->trackers()) {
|
for (const BitTorrent::TrackerEntry &tracker : asConst(torrent->trackers())) {
|
||||||
QVariantMap trackerDict;
|
QVariantMap trackerDict;
|
||||||
trackerDict[KEY_TRACKER_URL] = tracker.url();
|
trackerDict[KEY_TRACKER_URL] = tracker.url();
|
||||||
const BitTorrent::TrackerInfo data = trackersData.value(tracker.url());
|
const BitTorrent::TrackerInfo data = trackersData.value(tracker.url());
|
||||||
|
@ -346,7 +346,7 @@ void TorrentsController::webseedsAction()
|
||||||
if (!torrent)
|
if (!torrent)
|
||||||
throw APIError(APIErrorType::NotFound);
|
throw APIError(APIErrorType::NotFound);
|
||||||
|
|
||||||
foreach (const QUrl &webseed, torrent->urlSeeds()) {
|
for (const QUrl &webseed : asConst(torrent->urlSeeds())) {
|
||||||
QVariantMap webSeedDict;
|
QVariantMap webSeedDict;
|
||||||
webSeedDict[KEY_WEBSEED_URL] = webseed.toString();
|
webSeedDict[KEY_WEBSEED_URL] = webseed.toString();
|
||||||
webSeedList.append(webSeedDict);
|
webSeedList.append(webSeedDict);
|
||||||
|
@ -419,7 +419,7 @@ void TorrentsController::pieceHashesAction()
|
||||||
|
|
||||||
const QVector<QByteArray> hashes = torrent->info().pieceHashes();
|
const QVector<QByteArray> hashes = torrent->info().pieceHashes();
|
||||||
pieceHashes.reserve(hashes.size());
|
pieceHashes.reserve(hashes.size());
|
||||||
foreach (const QByteArray &hash, hashes)
|
for (const QByteArray &hash : hashes)
|
||||||
pieceHashes.append(hash.toHex());
|
pieceHashes.append(hash.toHex());
|
||||||
|
|
||||||
setResult(QJsonArray::fromVariantList(pieceHashes));
|
setResult(QJsonArray::fromVariantList(pieceHashes));
|
||||||
|
@ -498,7 +498,7 @@ void TorrentsController::addAction()
|
||||||
params.downloadLimit = (dlLimit > 0) ? dlLimit : -1;
|
params.downloadLimit = (dlLimit > 0) ? dlLimit : -1;
|
||||||
|
|
||||||
bool partialSuccess = false;
|
bool partialSuccess = false;
|
||||||
for (QString url : copyAsConst(urls.split('\n'))) {
|
for (QString url : asConst(urls.split('\n'))) {
|
||||||
url = url.trimmed();
|
url = url.trimmed();
|
||||||
if (!url.isEmpty()) {
|
if (!url.isEmpty()) {
|
||||||
Net::DownloadManager::instance()->setCookiesFromUrl(cookies, QUrl::fromEncoded(url.toUtf8()));
|
Net::DownloadManager::instance()->setCookiesFromUrl(cookies, QUrl::fromEncoded(url.toUtf8()));
|
||||||
|
@ -531,7 +531,7 @@ void TorrentsController::addTrackersAction()
|
||||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
||||||
if (torrent) {
|
if (torrent) {
|
||||||
QList<BitTorrent::TrackerEntry> trackers;
|
QList<BitTorrent::TrackerEntry> trackers;
|
||||||
foreach (QString url, params()["urls"].split('\n')) {
|
for (QString url : asConst(params()["urls"].split('\n'))) {
|
||||||
url = url.trimmed();
|
url = url.trimmed();
|
||||||
if (!url.isEmpty())
|
if (!url.isEmpty())
|
||||||
trackers << url;
|
trackers << url;
|
||||||
|
@ -575,7 +575,7 @@ void TorrentsController::uploadLimitAction()
|
||||||
|
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
foreach (const QString &hash, hashes) {
|
for (const QString &hash : hashes) {
|
||||||
int limit = -1;
|
int limit = -1;
|
||||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
||||||
if (torrent)
|
if (torrent)
|
||||||
|
@ -592,7 +592,7 @@ void TorrentsController::downloadLimitAction()
|
||||||
|
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
foreach (const QString &hash, hashes) {
|
for (const QString &hash : hashes) {
|
||||||
int limit = -1;
|
int limit = -1;
|
||||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
||||||
if (torrent)
|
if (torrent)
|
||||||
|
|
|
@ -525,7 +525,7 @@ Http::Response WebApplication::processRequest(const Http::Request &request, cons
|
||||||
if (m_request.method == Http::METHOD_GET) {
|
if (m_request.method == Http::METHOD_GET) {
|
||||||
// Parse GET parameters
|
// Parse GET parameters
|
||||||
using namespace Utils::ByteArray;
|
using namespace Utils::ByteArray;
|
||||||
for (const QByteArray ¶m : copyAsConst(splitToViews(m_request.query, "&"))) {
|
for (const QByteArray ¶m : asConst(splitToViews(m_request.query, "&"))) {
|
||||||
const int sepPos = param.indexOf('=');
|
const int sepPos = param.indexOf('=');
|
||||||
if (sepPos <= 0) continue; // ignores params without name
|
if (sepPos <= 0) continue; // ignores params without name
|
||||||
|
|
||||||
|
@ -649,7 +649,8 @@ void WebApplication::sessionStart()
|
||||||
|
|
||||||
// remove outdated sessions
|
// remove outdated sessions
|
||||||
const qint64 now = QDateTime::currentMSecsSinceEpoch() / 1000;
|
const qint64 now = QDateTime::currentMSecsSinceEpoch() / 1000;
|
||||||
foreach (const auto session, m_sessions) {
|
const QMap<QString, WebSession *> sessionsCopy {m_sessions};
|
||||||
|
for (const auto session : sessionsCopy) {
|
||||||
if ((now - session->timestamp()) > INACTIVE_TIME)
|
if ((now - session->timestamp()) > INACTIVE_TIME)
|
||||||
delete m_sessions.take(session->id());
|
delete m_sessions.take(session->id());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue