Fix coding style

This commit is contained in:
thalieht 2018-04-14 22:53:45 +03:00
parent 6c6e23910d
commit 20ca90800d
60 changed files with 308 additions and 346 deletions

View file

@ -34,14 +34,14 @@
#include <QFile> #include <QFile>
#include <QObject> #include <QObject>
class AsyncFileStorageError: public std::runtime_error class AsyncFileStorageError : public std::runtime_error
{ {
public: public:
explicit AsyncFileStorageError(const QString &message); explicit AsyncFileStorageError(const QString &message);
QString message() const; QString message() const;
}; };
class AsyncFileStorage: public QObject class AsyncFileStorage : public QObject
{ {
Q_OBJECT Q_OBJECT

View file

@ -55,7 +55,7 @@ void BandwidthScheduler::start()
bool BandwidthScheduler::isTimeForAlternative() const bool BandwidthScheduler::isTimeForAlternative() const
{ {
const Preferences* const pref = Preferences::instance(); const Preferences *const pref = Preferences::instance();
QTime start = pref->getSchedulerStartTime(); QTime start = pref->getSchedulerStartTime();
QTime end = pref->getSchedulerEndTime(); QTime end = pref->getSchedulerEndTime();

View file

@ -33,7 +33,7 @@
#include <QObject> #include <QObject>
#include <QTimer> #include <QTimer>
class BandwidthScheduler: public QObject class BandwidthScheduler : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(BandwidthScheduler) Q_DISABLE_COPY(BandwidthScheduler)

View file

@ -1,5 +1,5 @@
/* /*
* Bittorrent Client using Qt and libt. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org> * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -147,13 +147,13 @@ int FilterParserThread::parseDATFilterFile()
if (bytesRead < 0) if (bytesRead < 0)
break; break;
int dataSize = bytesRead + offset; int dataSize = bytesRead + offset;
if (bytesRead == 0 && dataSize == 0) if ((bytesRead == 0) && (dataSize == 0))
break; break;
for (start = 0; start < dataSize; ++start) { for (start = 0; start < dataSize; ++start) {
endOfLine = -1; endOfLine = -1;
// The file might have ended without the last line having a newline // The file might have ended without the last line having a newline
if (!(bytesRead == 0 && dataSize > 0)) { if (!((bytesRead == 0) && (dataSize > 0))) {
for (int i = start; i < dataSize; ++i) { for (int i = start; i < dataSize; ++i) {
if (buffer[i] == '\n') { if (buffer[i] == '\n') {
endOfLine = i; endOfLine = i;
@ -295,13 +295,13 @@ int FilterParserThread::parseP2PFilterFile()
if (bytesRead < 0) if (bytesRead < 0)
break; break;
int dataSize = bytesRead + offset; int dataSize = bytesRead + offset;
if (bytesRead == 0 && dataSize == 0) if ((bytesRead == 0) && (dataSize == 0))
break; break;
for (start = 0; start < dataSize; ++start) { for (start = 0; start < dataSize; ++start) {
endOfLine = -1; endOfLine = -1;
// The file might have ended without the last line having a newline // The file might have ended without the last line having a newline
if (!(bytesRead == 0 && dataSize > 0)) { if (!((bytesRead == 0) && (dataSize > 0))) {
for (int i = start; i < dataSize; ++i) { for (int i = start; i < dataSize; ++i) {
if (buffer[i] == '\n') { if (buffer[i] == '\n') {
endOfLine = i; endOfLine = i;
@ -610,7 +610,7 @@ int FilterParserThread::findAndNullDelimiter(char *const data, char delimiter, i
return -1; return -1;
} }
int FilterParserThread::trim(char* const data, int start, int end) int FilterParserThread::trim(char *const data, int start, int end)
{ {
if (start >= end) return start; if (start >= end) return start;
int newStart = start; int newStart = start;

View file

@ -370,7 +370,7 @@ Session::Session(QObject *parent)
, m_extraLimit(0) , m_extraLimit(0)
, m_useProxy(false) , m_useProxy(false)
{ {
Logger* const logger = Logger::instance(); Logger *const logger = Logger::instance();
initResumeFolder(); initResumeFolder();
@ -940,7 +940,7 @@ qreal Session::globalMaxRatio() const
return m_globalMaxRatio; return m_globalMaxRatio;
} }
// Torrents will a ratio superior to the given value will // Torrents with a ratio superior to the given value will
// be automatically deleted // be automatically deleted
void Session::setGlobalMaxRatio(qreal ratio) void Session::setGlobalMaxRatio(qreal ratio)
{ {
@ -1083,7 +1083,7 @@ void Session::processBannedIPs(libt::ip_filter &filter)
#if LIBTORRENT_VERSION_NUM >= 10100 #if LIBTORRENT_VERSION_NUM >= 10100
void Session::adjustLimits(libt::settings_pack &settingsPack) void Session::adjustLimits(libt::settings_pack &settingsPack)
{ {
//Internally increase the queue limits to ensure that the magnet is started // Internally increase the queue limits to ensure that the magnet is started
int maxDownloads = maxActiveDownloads(); int maxDownloads = maxActiveDownloads();
int maxActive = maxActiveTorrents(); int maxActive = maxActiveTorrents();
@ -1180,7 +1180,7 @@ void Session::initMetrics()
void Session::configure(libtorrent::settings_pack &settingsPack) void Session::configure(libtorrent::settings_pack &settingsPack)
{ {
Logger* const logger = Logger::instance(); Logger *const logger = Logger::instance();
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
QString chosenIP; QString chosenIP;
@ -1249,7 +1249,7 @@ void Session::configure(libtorrent::settings_pack &settingsPack)
settingsPack.set_int(libt::settings_pack::allowed_enc_level, libt::settings_pack::pe_rc4); settingsPack.set_int(libt::settings_pack::allowed_enc_level, libt::settings_pack::pe_rc4);
settingsPack.set_bool(libt::settings_pack::prefer_rc4, true); settingsPack.set_bool(libt::settings_pack::prefer_rc4, true);
switch (encryption()) { switch (encryption()) {
case 0: //Enabled case 0: // Enabled
settingsPack.set_int(libt::settings_pack::out_enc_policy, libt::settings_pack::pe_enabled); settingsPack.set_int(libt::settings_pack::out_enc_policy, libt::settings_pack::pe_enabled);
settingsPack.set_int(libt::settings_pack::in_enc_policy, libt::settings_pack::pe_enabled); settingsPack.set_int(libt::settings_pack::in_enc_policy, libt::settings_pack::pe_enabled);
break; break;
@ -1302,7 +1302,7 @@ void Session::configure(libtorrent::settings_pack &settingsPack)
settingsPack.set_bool(libt::settings_pack::announce_to_all_trackers, announceToAllTrackers()); settingsPack.set_bool(libt::settings_pack::announce_to_all_trackers, announceToAllTrackers());
settingsPack.set_bool(libt::settings_pack::announce_to_all_tiers, announceToAllTiers()); settingsPack.set_bool(libt::settings_pack::announce_to_all_tiers, announceToAllTiers());
const int cacheSize = (diskCacheSize() > -1) ? diskCacheSize() * 64 : -1; const int cacheSize = (diskCacheSize() > -1) ? (diskCacheSize() * 64) : -1;
settingsPack.set_int(libt::settings_pack::cache_size, cacheSize); settingsPack.set_int(libt::settings_pack::cache_size, cacheSize);
settingsPack.set_int(libt::settings_pack::cache_expiry, diskCacheTTL()); settingsPack.set_int(libt::settings_pack::cache_expiry, diskCacheTTL());
qDebug() << "Using a disk cache size of" << cacheSize << "MiB"; qDebug() << "Using a disk cache size of" << cacheSize << "MiB";
@ -1510,12 +1510,12 @@ void Session::configurePeerClasses()
void Session::adjustLimits(libt::session_settings &sessionSettings) void Session::adjustLimits(libt::session_settings &sessionSettings)
{ {
//Internally increase the queue limits to ensure that the magnet is started // Internally increase the queue limits to ensure that the magnet is started
int maxDownloads = maxActiveDownloads(); int maxDownloads = maxActiveDownloads();
int maxActive = maxActiveTorrents(); int maxActive = maxActiveTorrents();
sessionSettings.active_downloads = maxDownloads > -1 ? maxDownloads + m_extraLimit : maxDownloads; sessionSettings.active_downloads = (maxDownloads > -1) ? (maxDownloads + m_extraLimit) : maxDownloads;
sessionSettings.active_limit = maxActive > -1 ? maxActive + m_extraLimit : maxActive; sessionSettings.active_limit = (maxActive > -1) ? (maxActive + m_extraLimit) : maxActive;
} }
void Session::applyBandwidthLimits(libt::session_settings &sessionSettings) void Session::applyBandwidthLimits(libt::session_settings &sessionSettings)
@ -1534,7 +1534,7 @@ void Session::configure(libtorrent::session_settings &sessionSettings)
encryptionSettings.allowed_enc_level = libt::pe_settings::rc4; encryptionSettings.allowed_enc_level = libt::pe_settings::rc4;
encryptionSettings.prefer_rc4 = true; encryptionSettings.prefer_rc4 = true;
switch (encryption()) { switch (encryption()) {
case 0: //Enabled case 0: // Enabled
encryptionSettings.out_enc_policy = libt::pe_settings::enabled; encryptionSettings.out_enc_policy = libt::pe_settings::enabled;
encryptionSettings.in_enc_policy = libt::pe_settings::enabled; encryptionSettings.in_enc_policy = libt::pe_settings::enabled;
break; break;
@ -1589,7 +1589,7 @@ void Session::configure(libtorrent::session_settings &sessionSettings)
sessionSettings.announce_to_all_trackers = announceToAllTrackers(); sessionSettings.announce_to_all_trackers = announceToAllTrackers();
sessionSettings.announce_to_all_tiers = announceToAllTiers(); sessionSettings.announce_to_all_tiers = announceToAllTiers();
const int cacheSize = (diskCacheSize() > -1) ? diskCacheSize() * 64 : -1; const int cacheSize = (diskCacheSize() > -1) ? (diskCacheSize() * 64) : -1;
sessionSettings.cache_size = cacheSize; sessionSettings.cache_size = cacheSize;
sessionSettings.cache_expiry = diskCacheTTL(); sessionSettings.cache_expiry = diskCacheTTL();
qDebug() << "Using a disk cache size of" << cacheSize << "MiB"; qDebug() << "Using a disk cache size of" << cacheSize << "MiB";
@ -1762,7 +1762,7 @@ void Session::enableBandwidthScheduler()
void Session::populateAdditionalTrackers() void Session::populateAdditionalTrackers()
{ {
m_additionalTrackerList.clear(); m_additionalTrackerList.clear();
foreach (QString tracker, additionalTrackers().split("\n")) { foreach (QString tracker, additionalTrackers().split('\n')) {
tracker = tracker.trimmed(); tracker = tracker.trimmed();
if (!tracker.isEmpty()) if (!tracker.isEmpty())
m_additionalTrackerList << tracker; m_additionalTrackerList << tracker;
@ -1786,7 +1786,7 @@ void Session::processShareLimits()
qDebug("Ratio: %f (limit: %f)", ratio, ratioLimit); qDebug("Ratio: %f (limit: %f)", ratio, ratioLimit);
if ((ratio <= TorrentHandle::MAX_RATIO) && (ratio >= ratioLimit)) { if ((ratio <= TorrentHandle::MAX_RATIO) && (ratio >= ratioLimit)) {
Logger* const logger = Logger::instance(); Logger *const logger = Logger::instance();
if (m_maxRatioAction == Remove) { if (m_maxRatioAction == Remove) {
logger->addMessage(tr("'%1' reached the maximum ratio you set. Removed.").arg(torrent->name())); logger->addMessage(tr("'%1' reached the maximum ratio you set. Removed.").arg(torrent->name()));
deleteTorrent(torrent->hash()); deleteTorrent(torrent->hash());
@ -1811,7 +1811,7 @@ void Session::processShareLimits()
qDebug("Seeding Time: %d (limit: %d)", seedingTimeInMinutes, seedingTimeLimit); qDebug("Seeding Time: %d (limit: %d)", seedingTimeInMinutes, seedingTimeLimit);
if ((seedingTimeInMinutes <= TorrentHandle::MAX_SEEDING_TIME) && (seedingTimeInMinutes >= seedingTimeLimit)) { if ((seedingTimeInMinutes <= TorrentHandle::MAX_SEEDING_TIME) && (seedingTimeInMinutes >= seedingTimeLimit)) {
Logger* const logger = Logger::instance(); Logger *const logger = Logger::instance();
if (m_maxRatioAction == Remove) { if (m_maxRatioAction == Remove) {
logger->addMessage(tr("'%1' reached the maximum seeding time you set. Removed.").arg(torrent->name())); logger->addMessage(tr("'%1' reached the maximum seeding time you set. Removed.").arg(torrent->name()));
deleteTorrent(torrent->hash()); deleteTorrent(torrent->hash());
@ -2259,7 +2259,7 @@ bool Session::loadMetadata(const MagnetUri &magnetUri)
InfoHash hash = magnetUri.hash(); InfoHash hash = magnetUri.hash();
QString name = magnetUri.name(); QString name = magnetUri.name();
// We should not add torrent if it already // We should not add torrent if it's already
// processed or adding to session // processed or adding to session
if (m_torrents.contains(hash)) return false; if (m_torrents.contains(hash)) return false;
if (m_addingTorrents.contains(hash)) return false; if (m_addingTorrents.contains(hash)) return false;
@ -2404,7 +2404,7 @@ void Session::networkOnlineStateChanged(const bool online)
Logger::instance()->addMessage(tr("System network status changed to %1", "e.g: System network status changed to ONLINE").arg(online ? tr("ONLINE") : tr("OFFLINE")), Log::INFO); Logger::instance()->addMessage(tr("System network status changed to %1", "e.g: System network status changed to ONLINE").arg(online ? tr("ONLINE") : tr("OFFLINE")), Log::INFO);
} }
void Session::networkConfigurationChange(const QNetworkConfiguration& cfg) void Session::networkConfigurationChange(const QNetworkConfiguration &cfg)
{ {
const QString configuredInterfaceName = networkInterface(); const QString configuredInterfaceName = networkInterface();
// Empty means "Any Interface". In this case libtorrent has binded to 0.0.0.0 so any change to any interface will // Empty means "Any Interface". In this case libtorrent has binded to 0.0.0.0 so any change to any interface will
@ -2430,7 +2430,7 @@ void Session::networkConfigurationChange(const QNetworkConfiguration& cfg)
const QStringList Session::getListeningIPs() const QStringList Session::getListeningIPs()
{ {
Logger* const logger = Logger::instance(); Logger *const logger = Logger::instance();
QStringList IPs; QStringList IPs;
const QString ifaceName = networkInterface(); const QString ifaceName = networkInterface();
@ -2473,12 +2473,12 @@ const QStringList Session::getListeningIPs()
ip = entry.ip(); ip = entry.ip();
ipString = ip.toString(); ipString = ip.toString();
protocol = ip.protocol(); protocol = ip.protocol();
Q_ASSERT(protocol == QAbstractSocket::IPv4Protocol || protocol == QAbstractSocket::IPv6Protocol); Q_ASSERT((protocol == QAbstractSocket::IPv4Protocol) || (protocol == QAbstractSocket::IPv6Protocol));
if ((!listenIPv6 && (protocol == QAbstractSocket::IPv6Protocol)) if ((!listenIPv6 && (protocol == QAbstractSocket::IPv6Protocol))
|| (listenIPv6 && (protocol == QAbstractSocket::IPv4Protocol))) || (listenIPv6 && (protocol == QAbstractSocket::IPv4Protocol)))
continue; continue;
//If an iface address has been defined only allow ip's that match it to go through // If an iface address has been defined to only allow ip's that match it to go through
if (!ifaceAddr.isEmpty()) { if (!ifaceAddr.isEmpty()) {
if (ifaceAddr == ipString) { if (ifaceAddr == ipString) {
IPs.append(ipString); IPs.append(ipString);
@ -2509,7 +2509,7 @@ void Session::configureListeningInterface()
const ushort port = this->port(); const ushort port = this->port();
qDebug() << Q_FUNC_INFO << port; qDebug() << Q_FUNC_INFO << port;
Logger* const logger = Logger::instance(); Logger *const logger = Logger::instance();
std::pair<int, int> ports(port, port); std::pair<int, int> ports(port, port);
libt::error_code ec; libt::error_code ec;
@ -3512,7 +3512,7 @@ void Session::handleTorrentTagRemoved(TorrentHandle *const torrent, const QStrin
emit torrentTagRemoved(torrent, tag); emit torrentTagRemoved(torrent, tag);
} }
void Session::handleTorrentSavingModeChanged(TorrentHandle * const torrent) void Session::handleTorrentSavingModeChanged(TorrentHandle *const torrent)
{ {
emit torrentSavingModeChanged(torrent); emit torrentSavingModeChanged(torrent);
} }
@ -3798,7 +3798,7 @@ void Session::startUpTorrents()
.arg(params.hash), Log::CRITICAL); .arg(params.hash), Log::CRITICAL);
// process add torrent messages before message queue overflow // process add torrent messages before message queue overflow
if (resumedTorrentsCount % 100 == 0) readAlerts(); if ((resumedTorrentsCount % 100) == 0) readAlerts();
++resumedTorrentsCount; ++resumedTorrentsCount;
}; };
@ -3833,12 +3833,12 @@ void Session::startUpTorrents()
} }
else { else {
int q = queuePosition; int q = queuePosition;
for(; queuedResumeData.contains(q); ++q) { for (; queuedResumeData.contains(q); ++q) {
} }
if (q != queuePosition) { if (q != queuePosition) {
++numOfRemappedFiles; ++numOfRemappedFiles;
} }
queuedResumeData[q] = { hash, magnetUri, resumeData, data }; queuedResumeData[q] = {hash, magnetUri, resumeData, data};
} }
} }
} }

View file

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2010 Christophe Dumez * Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#include "torrentcreatorthread.h" #include "torrentcreatorthread.h"

View file

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2010 Christophe Dumez * Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#ifndef BITTORRENT_TORRENTCREATORTHREAD_H #ifndef BITTORRENT_TORRENTCREATORTHREAD_H

View file

@ -30,13 +30,13 @@
#include <libtorrent/error_code.hpp> #include <libtorrent/error_code.hpp>
#include <QDateTime>
#include <QDebug> #include <QDebug>
#include <QString> #include <QString>
#include <QUrl> #include <QUrl>
#include <QDateTime>
#include "base/utils/misc.h"
#include "base/utils/fs.h" #include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "base/utils/string.h" #include "base/utils/string.h"
#include "infohash.h" #include "infohash.h"
#include "trackerentry.h" #include "trackerentry.h"
@ -315,7 +315,7 @@ QVector<QByteArray> TorrentInfo::pieceHashes() const
return hashes; return hashes;
} }
TorrentInfo::PieceRange TorrentInfo::filePieces(const QString& file) const TorrentInfo::PieceRange TorrentInfo::filePieces(const QString &file) const
{ {
if (!isValid()) // if we do not check here the debug message will be printed, which would be not correct if (!isValid()) // if we do not check here the debug message will be printed, which would be not correct
return {}; return {};
@ -353,8 +353,8 @@ void TorrentInfo::renameFile(uint index, const QString &newPath)
int BitTorrent::TorrentInfo::fileIndex(const QString& fileName) const int BitTorrent::TorrentInfo::fileIndex(const QString& fileName) const
{ {
// the check whether the object valid is not needed here // the check whether the object is valid is not needed here
// because filesCount() returns -1 in that case and the loop exits immediately // because if filesCount() returns -1 the loop exits immediately
for (int i = 0; i < filesCount(); ++i) for (int i = 0; i < filesCount(); ++i)
if (fileName == filePath(i)) if (fileName == filePath(i))
return i; return i;

View file

@ -39,11 +39,11 @@
#include "base/indexrange.h" #include "base/indexrange.h"
class QString;
class QUrl;
class QDateTime;
class QStringList;
class QByteArray; class QByteArray;
class QDateTime;
class QString;
class QStringList;
class QUrl;
namespace BitTorrent namespace BitTorrent
{ {

View file

@ -1,5 +1,5 @@
/* /*
* Bittorrent Client using Qt4 and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru> * Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org> * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
@ -27,6 +27,8 @@
* exception statement from your version. * exception statement from your version.
*/ */
#include "tracker.h"
#include <vector> #include <vector>
#include <libtorrent/bencode.hpp> #include <libtorrent/bencode.hpp>
@ -37,7 +39,6 @@
#include "base/preferences.h" #include "base/preferences.h"
#include "base/utils/bytearray.h" #include "base/utils/bytearray.h"
#include "base/utils/string.h" #include "base/utils/string.h"
#include "tracker.h"
// static limits // static limits
static const int MAX_TORRENTS = 100; static const int MAX_TORRENTS = 100;
@ -277,5 +278,3 @@ void Tracker::replyWithPeerList(const TrackerAnnounceRequest &annonceReq)
// HTTP reply // HTTP reply
print(reply, Http::CONTENT_TYPE_TXT); print(reply, Http::CONTENT_TYPE_TXT);
} }

View file

@ -28,14 +28,14 @@
#include "filesystemwatcher.h" #include "filesystemwatcher.h"
#include <QtGlobal>
#if defined(Q_OS_MAC) || defined(Q_OS_FREEBSD) #if defined(Q_OS_MAC) || defined(Q_OS_FREEBSD)
#include <cstring> #include <cstring>
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/param.h> #include <sys/param.h>
#endif #endif
#include <QtGlobal>
#include "base/algorithm.h" #include "base/algorithm.h"
#include "base/bittorrent/magneturi.h" #include "base/bittorrent/magneturi.h"
#include "base/bittorrent/torrentinfo.h" #include "base/bittorrent/torrentinfo.h"

View file

@ -2,7 +2,7 @@
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2018 Mike Tzou (Chocobo1) * Copyright (C) 2018 Mike Tzou (Chocobo1)
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru> * Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Ishan Arora and Christophe Dumez * Copyright (C) 2006 Ishan Arora and Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -26,8 +26,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#include "connection.h" #include "connection.h"

View file

@ -1,7 +1,7 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru> * Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Ishan Arora and Christophe Dumez * Copyright (C) 2006 Ishan Arora and Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -25,8 +25,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */

View file

@ -3,12 +3,12 @@
#include <QDateTime> #include <QDateTime>
#include "base/utils/string.h" #include "base/utils/string.h"
Logger* Logger::m_instance = nullptr; Logger *Logger::m_instance = nullptr;
Logger::Logger() Logger::Logger()
: lock(QReadWriteLock::Recursive) : m_lock(QReadWriteLock::Recursive)
, msgCounter(0) , m_msgCounter(0)
, peerCounter(0) , m_peerCounter(0)
{ {
} }
@ -35,9 +35,9 @@ void Logger::freeInstance()
void Logger::addMessage(const QString &message, const Log::MsgType &type) void Logger::addMessage(const QString &message, const Log::MsgType &type)
{ {
QWriteLocker locker(&lock); QWriteLocker locker(&m_lock);
Log::Msg temp = { msgCounter++, QDateTime::currentMSecsSinceEpoch(), type, message.toHtmlEscaped() }; Log::Msg temp = {m_msgCounter++, QDateTime::currentMSecsSinceEpoch(), type, message.toHtmlEscaped()};
m_messages.push_back(temp); m_messages.push_back(temp);
if (m_messages.size() >= MAX_LOG_MESSAGES) if (m_messages.size() >= MAX_LOG_MESSAGES)
@ -48,9 +48,9 @@ void Logger::addMessage(const QString &message, const Log::MsgType &type)
void Logger::addPeer(const QString &ip, bool blocked, const QString &reason) void Logger::addPeer(const QString &ip, bool blocked, const QString &reason)
{ {
QWriteLocker locker(&lock); QWriteLocker locker(&m_lock);
Log::Peer temp = { peerCounter++, QDateTime::currentMSecsSinceEpoch(), ip.toHtmlEscaped(), blocked, reason.toHtmlEscaped() }; Log::Peer temp = {m_peerCounter++, QDateTime::currentMSecsSinceEpoch(), ip.toHtmlEscaped(), blocked, reason.toHtmlEscaped()};
m_peers.push_back(temp); m_peers.push_back(temp);
if (m_peers.size() >= MAX_LOG_MESSAGES) if (m_peers.size() >= MAX_LOG_MESSAGES)
@ -61,9 +61,9 @@ void Logger::addPeer(const QString &ip, bool blocked, const QString &reason)
QVector<Log::Msg> Logger::getMessages(int lastKnownId) const QVector<Log::Msg> Logger::getMessages(int lastKnownId) const
{ {
QReadLocker locker(&lock); QReadLocker locker(&m_lock);
int diff = msgCounter - lastKnownId - 1; int diff = m_msgCounter - lastKnownId - 1;
int size = m_messages.size(); int size = m_messages.size();
if ((lastKnownId == -1) || (diff >= size)) if ((lastKnownId == -1) || (diff >= size))
@ -77,9 +77,9 @@ QVector<Log::Msg> Logger::getMessages(int lastKnownId) const
QVector<Log::Peer> Logger::getPeers(int lastKnownId) const QVector<Log::Peer> Logger::getPeers(int lastKnownId) const
{ {
QReadLocker locker(&lock); QReadLocker locker(&m_lock);
int diff = peerCounter - lastKnownId - 1; int diff = m_peerCounter - lastKnownId - 1;
int size = m_peers.size(); int size = m_peers.size();
if ((lastKnownId == -1) || (diff >= size)) if ((lastKnownId == -1) || (diff >= size))

View file

@ -1,10 +1,10 @@
#ifndef LOGGER_H #ifndef LOGGER_H
#define LOGGER_H #define LOGGER_H
#include <QObject>
#include <QReadWriteLock>
#include <QString> #include <QString>
#include <QVector> #include <QVector>
#include <QReadWriteLock>
#include <QObject>
const int MAX_LOG_MESSAGES = 20000; const int MAX_LOG_MESSAGES = 20000;
@ -16,7 +16,7 @@ namespace Log
NORMAL = 0x1, NORMAL = 0x1,
INFO = 0x2, INFO = 0x2,
WARNING = 0x4, WARNING = 0x4,
CRITICAL = 0x8 //ERROR is defined by libtorrent and results in compiler error CRITICAL = 0x8 // ERROR is defined by libtorrent and results in compiler error
}; };
Q_DECLARE_FLAGS(MsgTypes, MsgType) Q_DECLARE_FLAGS(MsgTypes, MsgType)
@ -63,12 +63,12 @@ private:
Logger(); Logger();
~Logger(); ~Logger();
static Logger* m_instance; static Logger *m_instance;
QVector<Log::Msg> m_messages; QVector<Log::Msg> m_messages;
QVector<Log::Peer> m_peers; QVector<Log::Peer> m_peers;
mutable QReadWriteLock lock; mutable QReadWriteLock m_lock;
int msgCounter; int m_msgCounter;
int peerCounter; int m_peerCounter;
}; };
// Helper function // Helper function

View file

@ -48,7 +48,7 @@ const char DEFAULT_USER_AGENT[] = "Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/
namespace namespace
{ {
class NetworkCookieJar: public QNetworkCookieJar class NetworkCookieJar : public QNetworkCookieJar
{ {
public: public:
explicit NetworkCookieJar(QObject *parent = nullptr) explicit NetworkCookieJar(QObject *parent = nullptr)

View file

@ -26,12 +26,12 @@
* exception statement from your version. * exception statement from your version.
*/ */
#include <QDateTime>
#include <QDebug> #include <QDebug>
#include <QVariant> #include <QFile>
#include <QHash> #include <QHash>
#include <QHostAddress> #include <QHostAddress>
#include <QDateTime> #include <QVariant>
#include <QFile>
#include "base/types.h" #include "base/types.h"
#include "geoipdatabase.h" #include "geoipdatabase.h"
@ -44,7 +44,7 @@ namespace
const char DB_TYPE[] = "GeoLite2-Country"; const char DB_TYPE[] = "GeoLite2-Country";
const quint32 MAX_METADATA_SIZE = 131072; // 128KB const quint32 MAX_METADATA_SIZE = 131072; // 128KB
const char METADATA_BEGIN_MARK[] = "\xab\xcd\xefMaxMind.com"; const char METADATA_BEGIN_MARK[] = "\xab\xcd\xefMaxMind.com";
const char DATA_SECTION_SEPARATOR[16] = { 0 }; const char DATA_SECTION_SEPARATOR[16] = {0};
enum class DataType enum class DataType
{ {

View file

@ -29,13 +29,13 @@
#ifndef GEOIPDATABASE_H #ifndef GEOIPDATABASE_H
#define GEOIPDATABASE_H #define GEOIPDATABASE_H
#include <QtGlobal>
#include <QCoreApplication> #include <QCoreApplication>
#include <QtGlobal>
class QHostAddress;
class QString;
class QByteArray; class QByteArray;
class QDateTime; class QDateTime;
class QHostAddress;
class QString;
struct DataFieldDescriptor; struct DataFieldDescriptor;

View file

@ -27,6 +27,7 @@
*/ */
#include "proxyconfigurationmanager.h" #include "proxyconfigurationmanager.h"
#include "base/settingsstorage.h" #include "base/settingsstorage.h"
#define SETTINGS_KEY(name) "Network/Proxy/" name #define SETTINGS_KEY(name) "Network/Proxy/" name

View file

@ -52,7 +52,7 @@ namespace Net
QString password; QString password;
}; };
class ProxyConfigurationManager: public QObject class ProxyConfigurationManager : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(ProxyConfigurationManager) Q_DISABLE_COPY(ProxyConfigurationManager)

View file

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,26 +24,24 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#include "reverseresolution.h"
#include <boost/asio/ip/tcp.hpp>
#include <boost/version.hpp>
#include <QDebug> #include <QDebug>
#include <QHostInfo> #include <QHostInfo>
#include <QString> #include <QString>
#include <boost/version.hpp>
#include <boost/asio/ip/tcp.hpp>
#include "reverseresolution.h"
const int CACHE_SIZE = 500; const int CACHE_SIZE = 500;
using namespace Net; using namespace Net;
static inline bool isUsefulHostName(const QString &hostname, const QString &ip) static inline bool isUsefulHostName(const QString &hostname, const QString &ip)
{ {
return (!hostname.isEmpty() && hostname != ip); return (!hostname.isEmpty() && (hostname != ip));
} }
ReverseResolution::ReverseResolution(QObject *parent) ReverseResolution::ReverseResolution(QObject *parent)

View file

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#ifndef NET_REVERSERESOLUTION_H #ifndef NET_REVERSERESOLUTION_H
@ -34,10 +32,8 @@
#include <QCache> #include <QCache>
#include <QObject> #include <QObject>
QT_BEGIN_NAMESPACE
class QHostInfo; class QHostInfo;
class QString; class QString;
QT_END_NAMESPACE
namespace Net namespace Net
{ {

View file

@ -130,8 +130,8 @@ Smtp::~Smtp()
void Smtp::sendMail(const QString &from, const QString &to, const QString &subject, const QString &body) void Smtp::sendMail(const QString &from, const QString &to, const QString &subject, const QString &body)
{ {
const Preferences* const pref = Preferences::instance(); const Preferences *const pref = Preferences::instance();
QTextCodec* latin1 = QTextCodec::codecForName("latin1"); QTextCodec *latin1 = QTextCodec::codecForName("latin1");
m_message = "Date: " + getCurrentDateTime().toLatin1() + "\r\n" m_message = "Date: " + getCurrentDateTime().toLatin1() + "\r\n"
+ encodeMimeHeader("From", from, latin1) + encodeMimeHeader("From", from, latin1)
+ encodeMimeHeader("Subject", subject, latin1) + encodeMimeHeader("Subject", subject, latin1)
@ -141,8 +141,8 @@ void Smtp::sendMail(const QString &from, const QString &to, const QString &subje
+ "Content-Transfer-Encoding: base64\r\n" + "Content-Transfer-Encoding: base64\r\n"
+ "\r\n"; + "\r\n";
// Encode the body in base64 // Encode the body in base64
QString crlf_body = body; QString crlfBody = body;
QByteArray b = crlf_body.replace("\n", "\r\n").toUtf8().toBase64(); QByteArray b = crlfBody.replace("\n", "\r\n").toUtf8().toBase64();
int ct = b.length(); int ct = b.length();
for (int i = 0; i < ct; i += 78) for (int i = 0; i < ct; i += 78)
m_message += b.mid(i, 78); m_message += b.mid(i, 78);
@ -165,7 +165,7 @@ void Smtp::sendMail(const QString &from, const QString &to, const QString &subje
m_socket->connectToHost(pref->getMailNotificationSMTP(), DEFAULT_PORT); m_socket->connectToHost(pref->getMailNotificationSMTP(), DEFAULT_PORT);
m_useSsl = false; m_useSsl = false;
#ifndef QT_NO_OPENSSL #ifndef QT_NO_OPENSSL
} }
#endif #endif
} }
@ -184,7 +184,7 @@ void Smtp::readyRead()
QByteArray code = line.left(3); QByteArray code = line.left(3);
switch (m_state) { switch (m_state) {
case Init: { case Init:
if (code[0] == '2') { if (code[0] == '2') {
// The server may send a multiline greeting/INIT/220 response. // The server may send a multiline greeting/INIT/220 response.
// We wait until it finishes. // We wait until it finishes.
@ -198,7 +198,6 @@ void Smtp::readyRead()
m_state = Close; m_state = Close;
} }
break; break;
}
case EhloSent: case EhloSent:
case HeloSent: case HeloSent:
case EhloGreetReceived: case EhloGreetReceived:
@ -448,7 +447,7 @@ void Smtp::startTLS()
#endif #endif
} }
void Smtp::authCramMD5(const QByteArray& challenge) void Smtp::authCramMD5(const QByteArray &challenge)
{ {
if (m_state != AuthRequestSent) { if (m_state != AuthRequestSent) {
m_socket->write("auth cram-md5\r\n"); m_socket->write("auth cram-md5\r\n");

View file

@ -1,7 +1,7 @@
/* /*
* Bittorrent Client using Qt4 and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2014 sledgehammer999 <sledgehammer999@qbittorrent.org>
* Copyright (C) 2014 sledgehammer999 * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -25,9 +25,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
* Contact : hammered999@gmail.com
*/ */
#include "preferences.h" #include "preferences.h"
@ -420,12 +417,12 @@ void Preferences::setSchedulerEndTime(const QTime &time)
setValue("Preferences/Scheduler/end_time", time); setValue("Preferences/Scheduler/end_time", time);
} }
scheduler_days Preferences::getSchedulerDays() const SchedulerDays Preferences::getSchedulerDays() const
{ {
return static_cast<scheduler_days>(value("Preferences/Scheduler/days", EVERY_DAY).toInt()); return static_cast<SchedulerDays>(value("Preferences/Scheduler/days", EVERY_DAY).toInt());
} }
void Preferences::setSchedulerDays(scheduler_days days) void Preferences::setSchedulerDays(SchedulerDays days)
{ {
setValue("Preferences/Scheduler/days", static_cast<int>(days)); setValue("Preferences/Scheduler/days", static_cast<int>(days));
} }
@ -690,12 +687,12 @@ QString Preferences::getUILockPasswordMD5() const
return value("Locking/password").toString(); return value("Locking/password").toString();
} }
void Preferences::setUILockPassword(const QString &clear_password) void Preferences::setUILockPassword(const QString &clearPassword)
{ {
QCryptographicHash md5(QCryptographicHash::Md5); QCryptographicHash md5(QCryptographicHash::Md5);
md5.addData(clear_password.toLocal8Bit()); md5.addData(clearPassword.toLocal8Bit());
QString md5_password = md5.result().toHex(); QString md5Password = md5.result().toHex();
setValue("Locking/password", md5_password); setValue("Locking/password", md5Password);
} }
bool Preferences::isUILocked() const bool Preferences::isUILocked() const

View file

@ -1,7 +1,7 @@
/* /*
* Bittorrent Client using Qt4 and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2014 sledgehammer999 <sledgehammer999@qbittorrent.org>
* Copyright (C) 2014 sledgehammer999 * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -25,9 +25,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
* Contact : hammered999@gmail.com
*/ */
#ifndef PREFERENCES_H #ifndef PREFERENCES_H
@ -47,7 +44,7 @@
#include "base/utils/net.h" #include "base/utils/net.h"
#include "types.h" #include "types.h"
enum scheduler_days enum SchedulerDays
{ {
EVERY_DAY, EVERY_DAY,
WEEK_DAYS, WEEK_DAYS,
@ -83,7 +80,7 @@ namespace DNS
class SettingsStorage; class SettingsStorage;
class Preferences: public QObject class Preferences : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(Preferences) Q_DISABLE_COPY(Preferences)
@ -166,8 +163,8 @@ public:
void setSchedulerStartTime(const QTime &time); void setSchedulerStartTime(const QTime &time);
QTime getSchedulerEndTime() const; QTime getSchedulerEndTime() const;
void setSchedulerEndTime(const QTime &time); void setSchedulerEndTime(const QTime &time);
scheduler_days getSchedulerDays() const; SchedulerDays getSchedulerDays() const;
void setSchedulerDays(scheduler_days days); void setSchedulerDays(SchedulerDays days);
// Search // Search
bool isSearchEnabled() const; bool isSearchEnabled() const;
@ -222,7 +219,7 @@ public:
void setDynDNSPassword(const QString &password); void setDynDNSPassword(const QString &password);
// Advanced settings // Advanced settings
void setUILockPassword(const QString &clear_password); void setUILockPassword(const QString &clearPassword);
void clearUILockPassword(); void clearUILockPassword();
QString getUILockPasswordMD5() const; QString getUILockPasswordMD5() const;
bool isUILocked() const; bool isUILocked() const;

View file

@ -25,7 +25,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
*/ */
#ifndef QBT_PROFILE_P_H #ifndef QBT_PROFILE_P_H
@ -33,6 +32,7 @@
#include <QDir> #include <QDir>
#include <QStandardPaths> #include <QStandardPaths>
#include "base/profile.h" #include "base/profile.h"
namespace Private namespace Private
@ -63,7 +63,7 @@ namespace Private
}; };
/// Default implementation. Takes paths from system /// Default implementation. Takes paths from system
class DefaultProfile: public Profile class DefaultProfile : public Profile
{ {
public: public:
DefaultProfile(const QString &configurationName); DefaultProfile(const QString &configurationName);
@ -86,7 +86,7 @@ namespace Private
}; };
/// Custom tree: creates directories under the specified root directory /// Custom tree: creates directories under the specified root directory
class CustomProfile: public Profile class CustomProfile : public Profile
{ {
public: public:
CustomProfile(const QString &rootPath, const QString &configurationName); CustomProfile(const QString &rootPath, const QString &configurationName);
@ -114,14 +114,14 @@ namespace Private
virtual ~PathConverter() = default; virtual ~PathConverter() = default;
}; };
class NoConvertConverter: public PathConverter class NoConvertConverter : public PathConverter
{ {
public: public:
QString toPortablePath(const QString &path) const override; QString toPortablePath(const QString &path) const override;
QString fromPortablePath(const QString &portablePath) const override; QString fromPortablePath(const QString &portablePath) const override;
}; };
class Converter: public PathConverter class Converter : public PathConverter
{ {
public: public:
Converter(const QString &basePath); Converter(const QString &basePath);
@ -132,4 +132,5 @@ namespace Private
QDir m_baseDir; QDir m_baseDir;
}; };
} }
#endif // QBT_PROFILE_P_H #endif // QBT_PROFILE_P_H

View file

@ -25,7 +25,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
*/ */
#include "profile.h" #include "profile.h"

View file

@ -33,9 +33,9 @@
#include <memory> #include <memory>
#include <QString>
#include <QScopedPointer> #include <QScopedPointer>
#include <QSettings> #include <QSettings>
#include <QString>
class Application; class Application;

View file

@ -29,8 +29,8 @@
#include "rss_parser.h" #include "rss_parser.h"
#include <QDebug>
#include <QDateTime> #include <QDateTime>
#include <QDebug>
#include <QGlobalStatic> #include <QGlobalStatic>
#include <QHash> #include <QHash>
#include <QMetaObject> #include <QMetaObject>

View file

@ -48,7 +48,7 @@ namespace RSS
QList<QVariantHash> articles; QList<QVariantHash> articles;
}; };
class Parser: public QObject class Parser : public QObject
{ {
Q_OBJECT Q_OBJECT

View file

@ -39,7 +39,7 @@ namespace RSS
{ {
class Feed; class Feed;
class Article: public QObject class Article : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(Article) Q_DISABLE_COPY(Article)

View file

@ -59,7 +59,7 @@ namespace RSS
QString message() const; QString message() const;
}; };
class AutoDownloader final: public QObject class AutoDownloader final : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(AutoDownloader) Q_DISABLE_COPY(AutoDownloader)

View file

@ -43,9 +43,9 @@
#include "../tristatebool.h" #include "../tristatebool.h"
#include "../utils/fs.h" #include "../utils/fs.h"
#include "../utils/string.h" #include "../utils/string.h"
#include "rss_feed.h"
#include "rss_article.h" #include "rss_article.h"
#include "rss_autodownloader.h" #include "rss_autodownloader.h"
#include "rss_feed.h"
namespace namespace
{ {
@ -105,7 +105,7 @@ const QString Str_PreviouslyMatched(QStringLiteral("previouslyMatchedEpisodes"))
namespace RSS namespace RSS
{ {
struct AutoDownloadRuleData: public QSharedData struct AutoDownloadRuleData : public QSharedData
{ {
QString name; QString name;
bool enabled = true; bool enabled = true;

View file

@ -49,7 +49,7 @@ namespace RSS
struct ParsingResult; struct ParsingResult;
} }
class Feed final: public Item class Feed final : public Item
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(Feed) Q_DISABLE_COPY(Feed)

View file

@ -37,7 +37,7 @@ namespace RSS
{ {
class Session; class Session;
class Folder final: public Item class Folder final : public Item
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(Folder) Q_DISABLE_COPY(Folder)

View file

@ -39,7 +39,7 @@ namespace RSS
class Folder; class Folder;
class Session; class Session;
class Item: public QObject class Item : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(Item) Q_DISABLE_COPY(Item)

View file

@ -47,8 +47,8 @@
#include "../utils/fs.h" #include "../utils/fs.h"
#include "rss_article.h" #include "rss_article.h"
#include "rss_feed.h" #include "rss_feed.h"
#include "rss_item.h"
#include "rss_folder.h" #include "rss_folder.h"
#include "rss_item.h"
const int MsecsPerMin = 60000; const int MsecsPerMin = 60000;
const QString ConfFolderName(QStringLiteral("rss")); const QString ConfFolderName(QStringLiteral("rss"));

View file

@ -69,11 +69,11 @@ class AsyncFileStorage;
namespace RSS namespace RSS
{ {
class Item;
class Feed; class Feed;
class Folder; class Folder;
class Item;
class Session: public QObject class Session : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(Session) Q_DISABLE_COPY(Session)

View file

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2010 Christian Kandeler, Christophe Dumez * Copyright (C) 2010 Christian Kandeler, Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#include "scanfoldersmodel.h" #include "scanfoldersmodel.h"
@ -235,7 +233,7 @@ ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath,
return Ok; return Ok;
} }
ScanFoldersModel::PathStatus ScanFoldersModel::updatePath(const QString &watchPath, const PathType& downloadType, const QString &downloadPath) ScanFoldersModel::PathStatus ScanFoldersModel::updatePath(const QString &watchPath, const PathType &downloadType, const QString &downloadPath)
{ {
QDir watchDir(watchPath); QDir watchDir(watchPath);
const QString &canonicalWatchPath = watchDir.canonicalPath(); const QString &canonicalWatchPath = watchDir.canonicalPath();

View file

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2010 Christian Kandeler, Christophe Dumez * Copyright (C) 2010 Christian Kandeler, Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#ifndef SCANFOLDERSMODEL_H #ifndef SCANFOLDERSMODEL_H
@ -37,7 +35,7 @@
class QStringList; class QStringList;
class FileSystemWatcher; class FileSystemWatcher;
class ScanFoldersModel: public QAbstractListModel class ScanFoldersModel : public QAbstractListModel
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(ScanFoldersModel) Q_DISABLE_COPY(ScanFoldersModel)
@ -68,7 +66,7 @@ public:
static bool initInstance(QObject *parent = nullptr); static bool initInstance(QObject *parent = nullptr);
static void freeInstance(); static void freeInstance();
static ScanFoldersModel* instance(); static ScanFoldersModel *instance();
static QString pathTypeDisplayName(const PathType type); static QString pathTypeDisplayName(const PathType type);

View file

@ -42,8 +42,8 @@
#include "base/global.h" #include "base/global.h"
#include "base/logger.h" #include "base/logger.h"
#include "base/net/downloadmanager.h"
#include "base/net/downloadhandler.h" #include "base/net/downloadhandler.h"
#include "base/net/downloadmanager.h"
#include "base/preferences.h" #include "base/preferences.h"
#include "base/profile.h" #include "base/profile.h"
#include "base/utils/fs.h" #include "base/utils/fs.h"
@ -256,7 +256,7 @@ bool SearchPluginManager::uninstallPlugin(const QString &name)
return true; return true;
} }
void SearchPluginManager::updateIconPath(PluginInfo * const plugin) void SearchPluginManager::updateIconPath(PluginInfo *const plugin)
{ {
if (!plugin) return; if (!plugin) return;
QString iconPath = QString("%1/%2.png").arg(pluginsLocation(), plugin->name); QString iconPath = QString("%1/%2.png").arg(pluginsLocation(), plugin->name);

View file

@ -73,7 +73,7 @@ public:
void updatePlugin(const QString &name); void updatePlugin(const QString &name);
void installPlugin(const QString &source); void installPlugin(const QString &source);
bool uninstallPlugin(const QString &name); bool uninstallPlugin(const QString &name);
static void updateIconPath(PluginInfo * const plugin); static void updateIconPath(PluginInfo *const plugin);
void checkForUpdates(); void checkForUpdates();
SearchHandler *startSearch(const QString &pattern, const QString &category, const QStringList &usedPlugins); SearchHandler *startSearch(const QString &pattern, const QString &category, const QStringList &usedPlugins);

View file

@ -1,7 +1,7 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2016 Vladimir Golovnev <glassez@yandex.ru> * Copyright (C) 2016 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2014 sledgehammer999 <hammered999@gmail.com> * Copyright (C) 2014 sledgehammer999 <sledgehammer999@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -258,7 +258,7 @@ QVariantHash TransactionalSettings::read()
bool TransactionalSettings::write(const QVariantHash &data) bool TransactionalSettings::write(const QVariantHash &data)
{ {
// QSettings delete the file before writing it out. This can result in problems // QSettings deletes the file before writing it out. This can result in problems
// if the disk is full or a power outage occurs. Those events might occur // if the disk is full or a power outage occurs. Those events might occur
// between deleting the file and recreating it. This is a safety measure. // between deleting the file and recreating it. This is a safety measure.
// Write everything to qBittorrent_new.ini/qBittorrent_new.conf and if it succeeds // Write everything to qBittorrent_new.ini/qBittorrent_new.conf and if it succeeds

View file

@ -1,7 +1,7 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2016 Vladimir Golovnev <glassez@yandex.ru> * Copyright (C) 2016 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2014 sledgehammer999 <hammered999@gmail.com> * Copyright (C) 2014 sledgehammer999 <sledgehammer999@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -31,11 +31,11 @@
#define SETTINGSSTORAGE_H #define SETTINGSSTORAGE_H
#include <QObject> #include <QObject>
#include <QVariantHash>
#include <QTimer>
#include <QReadWriteLock> #include <QReadWriteLock>
#include <QTimer>
#include <QVariantHash>
class SettingsStorage: public QObject class SettingsStorage : public QObject
{ {
Q_OBJECT Q_OBJECT
SettingsStorage(); SettingsStorage();
@ -44,7 +44,7 @@ class SettingsStorage: public QObject
public: public:
static void initInstance(); static void initInstance();
static void freeInstance(); static void freeInstance();
static SettingsStorage* instance(); static SettingsStorage *instance();
QVariant loadValue(const QString &key, const QVariant &defaultValue = QVariant()) const; QVariant loadValue(const QString &key, const QVariant &defaultValue = QVariant()) const;
void storeValue(const QString &key, const QVariant &value); void storeValue(const QString &key, const QVariant &value);

View file

@ -31,6 +31,7 @@
#include <functional> #include <functional>
#include <type_traits> #include <type_traits>
#include <QMetaEnum> #include <QMetaEnum>
#include <QString> #include <QString>
#include <QVariant> #include <QVariant>

View file

@ -51,7 +51,7 @@ private:
/// Reads settings for .torrent files from preferences /// Reads settings for .torrent files from preferences
/// and sets the file guard up accordingly /// and sets the file guard up accordingly
class TorrentFileGuard: private FileGuard class TorrentFileGuard : private FileGuard
{ {
Q_GADGET Q_GADGET

View file

@ -29,8 +29,8 @@
#ifndef TORRENTFILTER_H #ifndef TORRENTFILTER_H
#define TORRENTFILTER_H #define TORRENTFILTER_H
#include <QString>
#include <QSet> #include <QSet>
#include <QString>
typedef QSet<QString> QStringSet; typedef QSet<QString> QStringSet;

View file

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2012 Christophe Dumez * Copyright (C) 2012 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,20 +24,18 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#include "fs.h" #include "fs.h"
#include <cstring> #include <cstring>
#include <QCoreApplication>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QDirIterator>
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
#include <QDirIterator>
#include <QCoreApplication>
#include <QStorageInfo> #include <QStorageInfo>
#include <sys/stat.h> #include <sys/stat.h>
@ -152,7 +150,7 @@ bool Utils::Fs::smartRemoveEmptyFolderTree(const QString &path)
} }
/** /**
* Removes the file with the given file_path. * Removes the file with the given filePath.
* *
* This function will try to fix the file permissions before removing it. * This function will try to fix the file permissions before removing it.
*/ */
@ -169,7 +167,6 @@ bool Utils::Fs::forceRemove(const QString &filePath)
/** /**
* Removes directory and its content recursively. * Removes directory and its content recursively.
*
*/ */
void Utils::Fs::removeDirRecursive(const QString &path) void Utils::Fs::removeDirRecursive(const QString &path)
{ {

View file

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2012 Christophe Dumez * Copyright (C) 2012 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#ifndef UTILS_FS_H #ifndef UTILS_FS_H

View file

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#include "misc.h" #include "misc.h"
@ -70,9 +68,9 @@
#endif #endif
#endif #endif
#include "base/utils/string.h"
#include "base/unicodestrings.h"
#include "base/logger.h" #include "base/logger.h"
#include "base/unicodestrings.h"
#include "base/utils/string.h"
#include "fs.h" #include "fs.h"
namespace namespace
@ -141,7 +139,7 @@ void Utils::Misc::shutdownComputer(const ShutdownDialogAction &action)
else else
EventToSend = kAEShutDown; EventToSend = kAEShutDown;
AEAddressDesc targetDesc; AEAddressDesc targetDesc;
static const ProcessSerialNumber kPSNOfSystemProcess = { 0, kSystemProcess }; static const ProcessSerialNumber kPSNOfSystemProcess = {0, kSystemProcess};
AppleEvent eventReply = {typeNull, NULL}; AppleEvent eventReply = {typeNull, NULL};
AppleEvent appleEventToSend = {typeNull, NULL}; AppleEvent appleEventToSend = {typeNull, NULL};
@ -525,9 +523,9 @@ bool Utils::Misc::isUrl(const QString &s)
return reURLScheme.match(QUrl(s).scheme()).hasMatch(); return reURLScheme.match(QUrl(s).scheme()).hasMatch();
} }
QString Utils::Misc::parseHtmlLinks(const QString &raw_text) QString Utils::Misc::parseHtmlLinks(const QString &rawText)
{ {
QString result = raw_text; QString result = rawText;
static QRegExp reURL( static QRegExp reURL(
"(\\s|^)" // start with whitespace or beginning of line "(\\s|^)" // start with whitespace or beginning of line
"(" "("

View file

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#ifndef UTILS_MISC_H #ifndef UTILS_MISC_H
@ -73,7 +71,7 @@ namespace Utils
// YobiByte, // 1024^8 // YobiByte, // 1024^8
}; };
QString parseHtmlLinks(const QString &raw_text); QString parseHtmlLinks(const QString &rawText);
bool isUrl(const QString &s); bool isUrl(const QString &s);
void shutdownComputer(const ShutdownDialogAction &action); void shutdownComputer(const ShutdownDialogAction &action);
@ -88,16 +86,16 @@ namespace Utils
QString unitString(SizeUnit unit); QString unitString(SizeUnit unit);
// return best user friendly storage unit (B, KiB, MiB, GiB, TiB) // return the best user friendly storage unit (B, KiB, MiB, GiB, TiB)
// value must be given in bytes // value must be given in bytes
bool friendlyUnit(qint64 sizeInBytes, qreal& val, SizeUnit& unit); bool friendlyUnit(qint64 sizeInBytes, qreal &val, SizeUnit &unit);
QString friendlyUnit(qint64 bytesValue, bool isSpeed = false); QString friendlyUnit(qint64 bytesValue, bool isSpeed = false);
int friendlyUnitPrecision(SizeUnit unit); int friendlyUnitPrecision(SizeUnit unit);
qint64 sizeInBytes(qreal size, SizeUnit unit); qint64 sizeInBytes(qreal size, SizeUnit unit);
bool isPreviewable(const QString& extension); bool isPreviewable(const QString &extension);
// Take a number of seconds and return an user-friendly // Take a number of seconds and return a user-friendly
// time duration like "1d 2h 10m". // time duration like "1d 2h 10m".
QString userFriendlyDuration(qlonglong seconds); QString userFriendlyDuration(qlonglong seconds);
QString getUserIDString(); QString getUserIDString();
@ -108,8 +106,8 @@ namespace Utils
QList<bool> boolListfromStringList(const QStringList &l); QList<bool> boolListfromStringList(const QStringList &l);
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
void openPath(const QString& absolutePath); void openPath(const QString &absolutePath);
void openFolderSelect(const QString& absolutePath); void openFolderSelect(const QString &absolutePath);
QPoint screenCenter(const QWidget *w); QPoint screenCenter(const QWidget *w);
#endif #endif
@ -136,4 +134,4 @@ namespace Utils
} }
} }
#endif #endif // UTILS_MISC_H

View file

@ -27,6 +27,7 @@
*/ */
#include "net.h" #include "net.h"
#include <QHostAddress> #include <QHostAddress>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>

View file

@ -24,7 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
*/ */
#include "random.h" #include "random.h"

View file

@ -24,7 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
*/ */
#ifndef UTILS_RANDOM_H #ifndef UTILS_RANDOM_H

View file

@ -117,7 +117,7 @@ namespace Utils
{ {
// find the last one non-zero component // find the last one non-zero component
std::size_t lastSignificantIndex = N - 1; std::size_t lastSignificantIndex = N - 1;
while (lastSignificantIndex > 0 && (*this)[lastSignificantIndex] == 0) while ((lastSignificantIndex > 0) && ((*this)[lastSignificantIndex] == 0))
--lastSignificantIndex; --lastSignificantIndex;
if (lastSignificantIndex + 1 < Mandatory) // lastSignificantIndex >= 0 if (lastSignificantIndex + 1 < Mandatory) // lastSignificantIndex >= 0

View file

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2012 Christophe Dumez * Copyright (C) 2012 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#include "addnewtorrentdialog.h" #include "addnewtorrentdialog.h"
@ -38,7 +36,6 @@
#include <QString> #include <QString>
#include <QUrl> #include <QUrl>
#include "autoexpandabledialog.h"
#include "base/bittorrent/magneturi.h" #include "base/bittorrent/magneturi.h"
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h" #include "base/bittorrent/torrenthandle.h"
@ -53,6 +50,7 @@
#include "base/utils/fs.h" #include "base/utils/fs.h"
#include "base/utils/misc.h" #include "base/utils/misc.h"
#include "base/utils/string.h" #include "base/utils/string.h"
#include "autoexpandabledialog.h"
#include "guiiconprovider.h" #include "guiiconprovider.h"
#include "messageboxraised.h" #include "messageboxraised.h"
#include "proplistdelegate.h" #include "proplistdelegate.h"
@ -85,7 +83,7 @@ constexpr int AddNewTorrentDialog::maxPathHistoryLength;
AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inParams, QWidget *parent) AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inParams, QWidget *parent)
: QDialog(parent) : QDialog(parent)
, ui(new Ui::AddNewTorrentDialog) , m_ui(new Ui::AddNewTorrentDialog)
, m_contentModel(nullptr) , m_contentModel(nullptr)
, m_contentDelegate(nullptr) , m_contentDelegate(nullptr)
, m_hasMetadata(false) , m_hasMetadata(false)
@ -93,40 +91,40 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
, m_torrentParams(inParams) , m_torrentParams(inParams)
{ {
// TODO: set dialog file properties using m_torrentParams.filePriorities // TODO: set dialog file properties using m_torrentParams.filePriorities
ui->setupUi(this); m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
ui->lblMetaLoading->setVisible(false); m_ui->lblMetaLoading->setVisible(false);
ui->progMetaLoading->setVisible(false); m_ui->progMetaLoading->setVisible(false);
ui->savePath->setMode(FileSystemPathEdit::Mode::DirectorySave); m_ui->savePath->setMode(FileSystemPathEdit::Mode::DirectorySave);
ui->savePath->setDialogCaption(tr("Choose save path")); m_ui->savePath->setDialogCaption(tr("Choose save path"));
ui->savePath->setMaxVisibleItems(20); m_ui->savePath->setMaxVisibleItems(20);
auto session = BitTorrent::Session::instance(); auto session = BitTorrent::Session::instance();
if (m_torrentParams.addPaused == TriStateBool::True) if (m_torrentParams.addPaused == TriStateBool::True)
ui->startTorrentCheckBox->setChecked(false); m_ui->startTorrentCheckBox->setChecked(false);
else if (m_torrentParams.addPaused == TriStateBool::False) else if (m_torrentParams.addPaused == TriStateBool::False)
ui->startTorrentCheckBox->setChecked(true); m_ui->startTorrentCheckBox->setChecked(true);
else else
ui->startTorrentCheckBox->setChecked(!session->isAddTorrentPaused()); m_ui->startTorrentCheckBox->setChecked(!session->isAddTorrentPaused());
ui->comboTTM->blockSignals(true); // the TreeView size isn't correct if the slot does it job at this point m_ui->comboTTM->blockSignals(true); // the TreeView size isn't correct if the slot does it job at this point
ui->comboTTM->setCurrentIndex(!session->isAutoTMMDisabledByDefault()); m_ui->comboTTM->setCurrentIndex(!session->isAutoTMMDisabledByDefault());
ui->comboTTM->blockSignals(false); m_ui->comboTTM->blockSignals(false);
populateSavePathComboBox(); populateSavePathComboBox();
connect(ui->savePath, &FileSystemPathEdit::selectedPathChanged, this, &AddNewTorrentDialog::onSavePathChanged); connect(m_ui->savePath, &FileSystemPathEdit::selectedPathChanged, this, &AddNewTorrentDialog::onSavePathChanged);
ui->defaultSavePathCheckBox->setVisible(false); // Default path is selected by default m_ui->defaultSavePathCheckBox->setVisible(false); // Default path is selected by default
if (m_torrentParams.createSubfolder == TriStateBool::True) if (m_torrentParams.createSubfolder == TriStateBool::True)
ui->createSubfolderCheckBox->setChecked(true); m_ui->createSubfolderCheckBox->setChecked(true);
else if (m_torrentParams.createSubfolder == TriStateBool::False) else if (m_torrentParams.createSubfolder == TriStateBool::False)
ui->createSubfolderCheckBox->setChecked(false); m_ui->createSubfolderCheckBox->setChecked(false);
else else
ui->createSubfolderCheckBox->setChecked(session->isCreateTorrentSubfolder()); m_ui->createSubfolderCheckBox->setChecked(session->isCreateTorrentSubfolder());
ui->skipCheckingCheckBox->setChecked(m_torrentParams.skipChecking); m_ui->skipCheckingCheckBox->setChecked(m_torrentParams.skipChecking);
ui->doNotDeleteTorrentCheckBox->setVisible(TorrentFileGuard::autoDeleteMode() != TorrentFileGuard::Never); m_ui->doNotDeleteTorrentCheckBox->setVisible(TorrentFileGuard::autoDeleteMode() != TorrentFileGuard::Never);
// Load categories // Load categories
QStringList categories = session->categories().keys(); QStringList categories = session->categories().keys();
@ -134,25 +132,25 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
QString defaultCategory = settings()->loadValue(KEY_DEFAULTCATEGORY).toString(); QString defaultCategory = settings()->loadValue(KEY_DEFAULTCATEGORY).toString();
if (!m_torrentParams.category.isEmpty()) if (!m_torrentParams.category.isEmpty())
ui->categoryComboBox->addItem(m_torrentParams.category); m_ui->categoryComboBox->addItem(m_torrentParams.category);
if (!defaultCategory.isEmpty()) if (!defaultCategory.isEmpty())
ui->categoryComboBox->addItem(defaultCategory); m_ui->categoryComboBox->addItem(defaultCategory);
ui->categoryComboBox->addItem(""); m_ui->categoryComboBox->addItem("");
foreach (const QString &category, categories) foreach (const QString &category, categories)
if (category != defaultCategory && category != m_torrentParams.category) if (category != defaultCategory && category != m_torrentParams.category)
ui->categoryComboBox->addItem(category); m_ui->categoryComboBox->addItem(category);
ui->contentTreeView->header()->setSortIndicator(0, Qt::AscendingOrder); m_ui->contentTreeView->header()->setSortIndicator(0, Qt::AscendingOrder);
loadState(); loadState();
// Signal / slots // Signal / slots
connect(ui->adv_button, &QToolButton::clicked, this, &AddNewTorrentDialog::showAdvancedSettings); connect(m_ui->adv_button, &QToolButton::clicked, this, &AddNewTorrentDialog::showAdvancedSettings);
connect(ui->doNotDeleteTorrentCheckBox, &QCheckBox::clicked, this, &AddNewTorrentDialog::doNotDeleteTorrentClicked); connect(m_ui->doNotDeleteTorrentCheckBox, &QCheckBox::clicked, this, &AddNewTorrentDialog::doNotDeleteTorrentClicked);
QShortcut *editHotkey = new QShortcut(Qt::Key_F2, ui->contentTreeView, nullptr, nullptr, Qt::WidgetShortcut); QShortcut *editHotkey = new QShortcut(Qt::Key_F2, m_ui->contentTreeView, nullptr, nullptr, Qt::WidgetShortcut);
connect(editHotkey, &QShortcut::activated, this, &AddNewTorrentDialog::renameSelectedFile); connect(editHotkey, &QShortcut::activated, this, &AddNewTorrentDialog::renameSelectedFile);
connect(ui->contentTreeView, &QAbstractItemView::doubleClicked, this, &AddNewTorrentDialog::renameSelectedFile); connect(m_ui->contentTreeView, &QAbstractItemView::doubleClicked, this, &AddNewTorrentDialog::renameSelectedFile);
ui->buttonBox->button(QDialogButtonBox::Ok)->setFocus(); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setFocus();
} }
AddNewTorrentDialog::~AddNewTorrentDialog() AddNewTorrentDialog::~AddNewTorrentDialog()
@ -160,7 +158,7 @@ AddNewTorrentDialog::~AddNewTorrentDialog()
saveState(); saveState();
delete m_contentDelegate; delete m_contentDelegate;
delete ui; delete m_ui;
} }
bool AddNewTorrentDialog::isEnabled() bool AddNewTorrentDialog::isEnabled()
@ -220,15 +218,15 @@ void AddNewTorrentDialog::loadState()
const int height = newSize.height(); const int height = newSize.height();
resize(width, height); resize(width, height);
ui->adv_button->setChecked(settings()->loadValue(KEY_EXPANDED).toBool()); m_ui->adv_button->setChecked(settings()->loadValue(KEY_EXPANDED).toBool());
} }
void AddNewTorrentDialog::saveState() void AddNewTorrentDialog::saveState()
{ {
if (m_contentModel) if (m_contentModel)
settings()->storeValue(KEY_TREEHEADERSTATE, ui->contentTreeView->header()->saveState()); settings()->storeValue(KEY_TREEHEADERSTATE, m_ui->contentTreeView->header()->saveState());
settings()->storeValue(KEY_WIDTH, width()); settings()->storeValue(KEY_WIDTH, width());
settings()->storeValue(KEY_EXPANDED, ui->adv_button->isChecked()); settings()->storeValue(KEY_EXPANDED, m_ui->adv_button->isChecked());
} }
void AddNewTorrentDialog::show(QString source, const BitTorrent::AddTorrentParams &inParams, QWidget *parent) void AddNewTorrentDialog::show(QString source, const BitTorrent::AddTorrentParams &inParams, QWidget *parent)
@ -316,9 +314,9 @@ bool AddNewTorrentDialog::loadTorrent(const QString &torrentPath)
return false; return false;
} }
ui->lblhash->setText(m_hash); m_ui->lblhash->setText(m_hash);
setupTreeview(); setupTreeview();
TMMChanged(ui->comboTTM->currentIndex()); TMMChanged(m_ui->comboTTM->currentIndex());
return true; return true;
} }
@ -353,15 +351,15 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
connect(BitTorrent::Session::instance(), &BitTorrent::Session::metadataLoaded, this, &AddNewTorrentDialog::updateMetadata); connect(BitTorrent::Session::instance(), &BitTorrent::Session::metadataLoaded, this, &AddNewTorrentDialog::updateMetadata);
// Set dialog title // Set dialog title
QString torrent_name = magnetUri.name(); QString torrentName = magnetUri.name();
setWindowTitle(torrent_name.isEmpty() ? tr("Magnet link") : torrent_name); setWindowTitle(torrentName.isEmpty() ? tr("Magnet link") : torrentName);
setupTreeview(); setupTreeview();
TMMChanged(ui->comboTTM->currentIndex()); TMMChanged(m_ui->comboTTM->currentIndex());
BitTorrent::Session::instance()->loadMetadata(magnetUri); BitTorrent::Session::instance()->loadMetadata(magnetUri);
setMetadataProgressIndicator(true, tr("Retrieving metadata...")); setMetadataProgressIndicator(true, tr("Retrieving metadata..."));
ui->lblhash->setText(m_hash); m_ui->lblhash->setText(m_hash);
return true; return true;
} }
@ -378,19 +376,19 @@ void AddNewTorrentDialog::showEvent(QShowEvent *event)
void AddNewTorrentDialog::showAdvancedSettings(bool show) void AddNewTorrentDialog::showAdvancedSettings(bool show)
{ {
const int minimumW = minimumWidth(); const int minimumW = minimumWidth();
setMinimumWidth(width()); // to remain the same width setMinimumWidth(width()); // to remain the same width
if (show) { if (show) {
ui->adv_button->setText(QString::fromUtf8(C_UP)); m_ui->adv_button->setText(QString::fromUtf8(C_UP));
ui->settings_group->setVisible(true); m_ui->settings_group->setVisible(true);
ui->infoGroup->setVisible(true); m_ui->infoGroup->setVisible(true);
ui->contentTreeView->setVisible(m_hasMetadata); m_ui->contentTreeView->setVisible(m_hasMetadata);
static_cast<QVBoxLayout *>(layout())->insertWidget(layout()->indexOf(ui->never_show_cb) + 1, ui->adv_button); static_cast<QVBoxLayout *>(layout())->insertWidget(layout()->indexOf(m_ui->never_show_cb) + 1, m_ui->adv_button);
} }
else { else {
ui->adv_button->setText(QString::fromUtf8(C_DOWN)); m_ui->adv_button->setText(QString::fromUtf8(C_DOWN));
ui->settings_group->setVisible(false); m_ui->settings_group->setVisible(false);
ui->infoGroup->setVisible(false); m_ui->infoGroup->setVisible(false);
ui->buttonsHLayout->insertWidget(0, layout()->takeAt(layout()->indexOf(ui->never_show_cb) + 1)->widget()); m_ui->buttonsHLayout->insertWidget(0, layout()->takeAt(layout()->indexOf(m_ui->never_show_cb) + 1)->widget());
} }
adjustSize(); adjustSize();
setMinimumWidth(minimumW); setMinimumWidth(minimumW);
@ -398,7 +396,7 @@ void AddNewTorrentDialog::showAdvancedSettings(bool show)
void AddNewTorrentDialog::saveSavePathHistory() const void AddNewTorrentDialog::saveSavePathHistory() const
{ {
QDir selectedSavePath(ui->savePath->selectedPath()); QDir selectedSavePath(m_ui->savePath->selectedPath());
// Get current history // Get current history
QStringList history = settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList(); QStringList history = settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList();
if (history.size() > savePathHistoryLength()) if (history.size() > savePathHistoryLength())
@ -417,12 +415,12 @@ void AddNewTorrentDialog::saveSavePathHistory() const
} }
} }
// save_path is a folder, not an absolute file path // savePath is a folder, not an absolute file path
int AddNewTorrentDialog::indexOfSavePath(const QString &save_path) int AddNewTorrentDialog::indexOfSavePath(const QString &savePath)
{ {
QDir saveDir(save_path); QDir saveDir(savePath);
for (int i = 0; i < ui->savePath->count(); ++i) for (int i = 0; i < m_ui->savePath->count(); ++i)
if (QDir(ui->savePath->item(i)) == saveDir) if (QDir(m_ui->savePath->item(i)) == saveDir)
return i; return i;
return -1; return -1;
} }
@ -430,7 +428,7 @@ int AddNewTorrentDialog::indexOfSavePath(const QString &save_path)
void AddNewTorrentDialog::updateDiskSpaceLabel() void AddNewTorrentDialog::updateDiskSpaceLabel()
{ {
// Determine torrent size // Determine torrent size
qulonglong torrent_size = 0; qulonglong torrentSize = 0;
if (m_hasMetadata) { if (m_hasMetadata) {
if (m_contentModel) { if (m_contentModel) {
@ -438,28 +436,28 @@ void AddNewTorrentDialog::updateDiskSpaceLabel()
Q_ASSERT(priorities.size() == m_torrentInfo.filesCount()); Q_ASSERT(priorities.size() == m_torrentInfo.filesCount());
for (int i = 0; i < priorities.size(); ++i) for (int i = 0; i < priorities.size(); ++i)
if (priorities[i] > 0) if (priorities[i] > 0)
torrent_size += m_torrentInfo.fileSize(i); torrentSize += m_torrentInfo.fileSize(i);
} }
else { else {
torrent_size = m_torrentInfo.totalSize(); torrentSize = m_torrentInfo.totalSize();
} }
} }
QString size_string = torrent_size ? Utils::Misc::friendlyUnit(torrent_size) : QString(tr("Not Available", "This size is unavailable.")); QString sizeString = torrentSize ? Utils::Misc::friendlyUnit(torrentSize) : QString(tr("Not Available", "This size is unavailable."));
size_string += " ("; sizeString += " (";
size_string += tr("Free space on disk: %1").arg(Utils::Misc::friendlyUnit(Utils::Fs::freeDiskSpaceOnPath( sizeString += tr("Free space on disk: %1").arg(Utils::Misc::friendlyUnit(Utils::Fs::freeDiskSpaceOnPath(
ui->savePath->selectedPath()))); m_ui->savePath->selectedPath())));
size_string += ")"; sizeString += ")";
ui->size_lbl->setText(size_string); m_ui->size_lbl->setText(sizeString);
} }
void AddNewTorrentDialog::onSavePathChanged(const QString &newPath) void AddNewTorrentDialog::onSavePathChanged(const QString &newPath)
{ {
// Toggle default save path setting checkbox visibility // Toggle default save path setting checkbox visibility
ui->defaultSavePathCheckBox->setChecked(false); m_ui->defaultSavePathCheckBox->setChecked(false);
ui->defaultSavePathCheckBox->setVisible(QDir(newPath) != QDir(BitTorrent::Session::instance()->defaultSavePath())); m_ui->defaultSavePathCheckBox->setVisible(QDir(newPath) != QDir(BitTorrent::Session::instance()->defaultSavePath()));
// Remember index // Remember index
m_oldIndex = ui->savePath->currentIndex(); m_oldIndex = m_ui->savePath->currentIndex();
updateDiskSpaceLabel(); updateDiskSpaceLabel();
} }
@ -467,9 +465,9 @@ void AddNewTorrentDialog::categoryChanged(int index)
{ {
Q_UNUSED(index); Q_UNUSED(index);
if (ui->comboTTM->currentIndex() == 1) { if (m_ui->comboTTM->currentIndex() == 1) {
QString savePath = BitTorrent::Session::instance()->categorySavePath(ui->categoryComboBox->currentText()); QString savePath = BitTorrent::Session::instance()->categorySavePath(m_ui->categoryComboBox->currentText());
ui->savePath->setSelectedPath(Utils::Fs::toNativePath(savePath)); m_ui->savePath->setSelectedPath(Utils::Fs::toNativePath(savePath));
} }
} }
@ -478,16 +476,16 @@ void AddNewTorrentDialog::setSavePath(const QString &newPath)
int existingIndex = indexOfSavePath(newPath); int existingIndex = indexOfSavePath(newPath);
if (existingIndex < 0) { if (existingIndex < 0) {
// New path, prepend to combo box // New path, prepend to combo box
ui->savePath->insertItem(0, newPath); m_ui->savePath->insertItem(0, newPath);
existingIndex = 0; existingIndex = 0;
} }
ui->savePath->setCurrentIndex(existingIndex); m_ui->savePath->setCurrentIndex(existingIndex);
onSavePathChanged(newPath); onSavePathChanged(newPath);
} }
void AddNewTorrentDialog::renameSelectedFile() void AddNewTorrentDialog::renameSelectedFile()
{ {
const QModelIndexList selectedIndexes = ui->contentTreeView->selectionModel()->selectedRows(0); const QModelIndexList selectedIndexes = m_ui->contentTreeView->selectionModel()->selectedRows(0);
if (selectedIndexes.size() != 1) return; if (selectedIndexes.size() != 1) return;
const QModelIndex modelIndex = selectedIndexes.first(); const QModelIndex modelIndex = selectedIndexes.first();
@ -590,13 +588,13 @@ void AddNewTorrentDialog::populateSavePathComboBox()
{ {
QString defSavePath = BitTorrent::Session::instance()->defaultSavePath(); QString defSavePath = BitTorrent::Session::instance()->defaultSavePath();
ui->savePath->clear(); m_ui->savePath->clear();
ui->savePath->addItem(defSavePath); m_ui->savePath->addItem(defSavePath);
QDir defaultSaveDir(defSavePath); QDir defaultSaveDir(defSavePath);
// Load save path history // Load save path history
foreach (const QString &savePath, settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList()) foreach (const QString &savePath, settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList())
if (QDir(savePath) != defaultSaveDir) if (QDir(savePath) != defaultSaveDir)
ui->savePath->addItem(savePath); m_ui->savePath->addItem(savePath);
if (!m_torrentParams.savePath.isEmpty()) if (!m_torrentParams.savePath.isEmpty())
setSavePath(m_torrentParams.savePath); setSavePath(m_torrentParams.savePath);
@ -605,7 +603,7 @@ void AddNewTorrentDialog::populateSavePathComboBox()
void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &) void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
{ {
QMenu myFilesLlistMenu; QMenu myFilesLlistMenu;
const QModelIndexList selectedRows = ui->contentTreeView->selectionModel()->selectedRows(0); const QModelIndexList selectedRows = m_ui->contentTreeView->selectionModel()->selectedRows(0);
QAction *actRename = nullptr; QAction *actRename = nullptr;
if (selectedRows.size() == 1) { if (selectedRows.size() == 1) {
actRename = myFilesLlistMenu.addAction(GuiIconProvider::instance()->getIcon("edit-rename"), tr("Rename...")); actRename = myFilesLlistMenu.addAction(GuiIconProvider::instance()->getIcon("edit-rename"), tr("Rename..."));
@ -613,10 +611,10 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
} }
QMenu subMenu; QMenu subMenu;
subMenu.setTitle(tr("Priority")); subMenu.setTitle(tr("Priority"));
subMenu.addAction(ui->actionNot_downloaded); subMenu.addAction(m_ui->actionNot_downloaded);
subMenu.addAction(ui->actionNormal); subMenu.addAction(m_ui->actionNormal);
subMenu.addAction(ui->actionHigh); subMenu.addAction(m_ui->actionHigh);
subMenu.addAction(ui->actionMaximum); subMenu.addAction(m_ui->actionMaximum);
myFilesLlistMenu.addMenu(&subMenu); myFilesLlistMenu.addMenu(&subMenu);
// Call menu // Call menu
QAction *act = myFilesLlistMenu.exec(QCursor::pos()); QAction *act = myFilesLlistMenu.exec(QCursor::pos());
@ -626,11 +624,11 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
} }
else { else {
int prio = prio::NORMAL; int prio = prio::NORMAL;
if (act == ui->actionHigh) if (act == m_ui->actionHigh)
prio = prio::HIGH; prio = prio::HIGH;
else if (act == ui->actionMaximum) else if (act == m_ui->actionMaximum)
prio = prio::MAXIMUM; prio = prio::MAXIMUM;
else if (act == ui->actionNot_downloaded) else if (act == m_ui->actionNot_downloaded)
prio = prio::IGNORED; prio = prio::IGNORED;
qDebug("Setting files priority"); qDebug("Setting files priority");
@ -648,34 +646,34 @@ void AddNewTorrentDialog::accept()
disconnect(this, SLOT(updateMetadata(const BitTorrent::TorrentInfo&))); disconnect(this, SLOT(updateMetadata(const BitTorrent::TorrentInfo&)));
// TODO: Check if destination actually exists // TODO: Check if destination actually exists
m_torrentParams.skipChecking = ui->skipCheckingCheckBox->isChecked(); m_torrentParams.skipChecking = m_ui->skipCheckingCheckBox->isChecked();
// Category // Category
m_torrentParams.category = ui->categoryComboBox->currentText(); m_torrentParams.category = m_ui->categoryComboBox->currentText();
if (ui->defaultCategoryCheckbox->isChecked()) if (m_ui->defaultCategoryCheckbox->isChecked())
settings()->storeValue(KEY_DEFAULTCATEGORY, m_torrentParams.category); settings()->storeValue(KEY_DEFAULTCATEGORY, m_torrentParams.category);
// Save file priorities // Save file priorities
if (m_contentModel) if (m_contentModel)
m_torrentParams.filePriorities = m_contentModel->model()->getFilePriorities(); m_torrentParams.filePriorities = m_contentModel->model()->getFilePriorities();
m_torrentParams.addPaused = TriStateBool(!ui->startTorrentCheckBox->isChecked()); m_torrentParams.addPaused = TriStateBool(!m_ui->startTorrentCheckBox->isChecked());
m_torrentParams.createSubfolder = TriStateBool(ui->createSubfolderCheckBox->isChecked()); m_torrentParams.createSubfolder = TriStateBool(m_ui->createSubfolderCheckBox->isChecked());
QString savePath = ui->savePath->selectedPath(); QString savePath = m_ui->savePath->selectedPath();
if (ui->comboTTM->currentIndex() != 1) { // 0 is Manual mode and 1 is Automatic mode. Handle all non 1 values as manual mode. if (m_ui->comboTTM->currentIndex() != 1) { // 0 is Manual mode and 1 is Automatic mode. Handle all non 1 values as manual mode.
m_torrentParams.useAutoTMM = TriStateBool::False; m_torrentParams.useAutoTMM = TriStateBool::False;
m_torrentParams.savePath = savePath; m_torrentParams.savePath = savePath;
saveSavePathHistory(); saveSavePathHistory();
if (ui->defaultSavePathCheckBox->isChecked()) if (m_ui->defaultSavePathCheckBox->isChecked())
BitTorrent::Session::instance()->setDefaultSavePath(savePath); BitTorrent::Session::instance()->setDefaultSavePath(savePath);
} }
else { else {
m_torrentParams.useAutoTMM = TriStateBool::True; m_torrentParams.useAutoTMM = TriStateBool::True;
} }
setEnabled(!ui->never_show_cb->isChecked()); setEnabled(!m_ui->never_show_cb->isChecked());
// Add torrent // Add torrent
if (!m_hasMetadata) if (!m_hasMetadata)
@ -722,16 +720,16 @@ void AddNewTorrentDialog::updateMetadata(const BitTorrent::TorrentInfo &info)
void AddNewTorrentDialog::setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText) void AddNewTorrentDialog::setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText)
{ {
// Always show info label when waiting for metadata // Always show info label when waiting for metadata
ui->lblMetaLoading->setVisible(true); m_ui->lblMetaLoading->setVisible(true);
ui->lblMetaLoading->setText(labelText); m_ui->lblMetaLoading->setText(labelText);
ui->progMetaLoading->setVisible(visibleIndicator); m_ui->progMetaLoading->setVisible(visibleIndicator);
} }
void AddNewTorrentDialog::setupTreeview() void AddNewTorrentDialog::setupTreeview()
{ {
if (!m_hasMetadata) { if (!m_hasMetadata) {
setCommentText(tr("Not Available", "This comment is unavailable")); setCommentText(tr("Not Available", "This comment is unavailable"));
ui->date_lbl->setText(tr("Not Available", "This date is unavailable")); m_ui->date_lbl->setText(tr("Not Available", "This date is unavailable"));
} }
else { else {
// Set dialog title // Set dialog title
@ -739,30 +737,30 @@ void AddNewTorrentDialog::setupTreeview()
// Set torrent information // Set torrent information
setCommentText(Utils::Misc::parseHtmlLinks(m_torrentInfo.comment())); setCommentText(Utils::Misc::parseHtmlLinks(m_torrentInfo.comment()));
ui->date_lbl->setText(!m_torrentInfo.creationDate().isNull() ? m_torrentInfo.creationDate().toString(Qt::DefaultLocaleShortDate) : tr("Not available")); m_ui->date_lbl->setText(!m_torrentInfo.creationDate().isNull() ? m_torrentInfo.creationDate().toString(Qt::DefaultLocaleShortDate) : tr("Not available"));
// Prepare content tree // Prepare content tree
m_contentModel = new TorrentContentFilterModel(this); m_contentModel = new TorrentContentFilterModel(this);
connect(m_contentModel->model(), &TorrentContentModel::filteredFilesChanged, this, &AddNewTorrentDialog::updateDiskSpaceLabel); connect(m_contentModel->model(), &TorrentContentModel::filteredFilesChanged, this, &AddNewTorrentDialog::updateDiskSpaceLabel);
ui->contentTreeView->setModel(m_contentModel); m_ui->contentTreeView->setModel(m_contentModel);
m_contentDelegate = new PropListDelegate(nullptr); m_contentDelegate = new PropListDelegate(nullptr);
ui->contentTreeView->setItemDelegate(m_contentDelegate); m_ui->contentTreeView->setItemDelegate(m_contentDelegate);
connect(ui->contentTreeView, &QAbstractItemView::clicked, ui->contentTreeView connect(m_ui->contentTreeView, &QAbstractItemView::clicked, m_ui->contentTreeView
, static_cast<void (QAbstractItemView::*)(const QModelIndex &)>(&QAbstractItemView::edit)); , static_cast<void (QAbstractItemView::*)(const QModelIndex &)>(&QAbstractItemView::edit));
connect(ui->contentTreeView, &QWidget::customContextMenuRequested, this, &AddNewTorrentDialog::displayContentTreeMenu); connect(m_ui->contentTreeView, &QWidget::customContextMenuRequested, this, &AddNewTorrentDialog::displayContentTreeMenu);
// List files in torrent // List files in torrent
m_contentModel->model()->setupModelData(m_torrentInfo); m_contentModel->model()->setupModelData(m_torrentInfo);
if (!m_headerState.isEmpty()) if (!m_headerState.isEmpty())
ui->contentTreeView->header()->restoreState(m_headerState); m_ui->contentTreeView->header()->restoreState(m_headerState);
// Hide useless columns after loading the header state // Hide useless columns after loading the header state
ui->contentTreeView->hideColumn(PROGRESS); m_ui->contentTreeView->hideColumn(PROGRESS);
ui->contentTreeView->hideColumn(REMAINING); m_ui->contentTreeView->hideColumn(REMAINING);
ui->contentTreeView->hideColumn(AVAILABILITY); m_ui->contentTreeView->hideColumn(AVAILABILITY);
// Expand root folder // Expand root folder
ui->contentTreeView->setExpanded(m_contentModel->index(0, 0), true); m_ui->contentTreeView->setExpanded(m_contentModel->index(0, 0), true);
} }
updateDiskSpaceLabel(); updateDiskSpaceLabel();
@ -798,33 +796,33 @@ void AddNewTorrentDialog::TMMChanged(int index)
{ {
if (index != 1) { // 0 is Manual mode and 1 is Automatic mode. Handle all non 1 values as manual mode. if (index != 1) { // 0 is Manual mode and 1 is Automatic mode. Handle all non 1 values as manual mode.
populateSavePathComboBox(); populateSavePathComboBox();
ui->groupBoxSavePath->setEnabled(true); m_ui->groupBoxSavePath->setEnabled(true);
ui->savePath->blockSignals(false); m_ui->savePath->blockSignals(false);
ui->savePath->setCurrentIndex(m_oldIndex < ui->savePath->count() ? m_oldIndex : ui->savePath->count() - 1); m_ui->savePath->setCurrentIndex(m_oldIndex < m_ui->savePath->count() ? m_oldIndex : m_ui->savePath->count() - 1);
ui->adv_button->setEnabled(true); m_ui->adv_button->setEnabled(true);
} }
else { else {
ui->groupBoxSavePath->setEnabled(false); m_ui->groupBoxSavePath->setEnabled(false);
ui->savePath->blockSignals(true); m_ui->savePath->blockSignals(true);
ui->savePath->clear(); m_ui->savePath->clear();
QString savePath = BitTorrent::Session::instance()->categorySavePath(ui->categoryComboBox->currentText()); QString savePath = BitTorrent::Session::instance()->categorySavePath(m_ui->categoryComboBox->currentText());
ui->savePath->addItem(savePath); m_ui->savePath->addItem(savePath);
ui->defaultSavePathCheckBox->setVisible(false); m_ui->defaultSavePathCheckBox->setVisible(false);
ui->adv_button->setChecked(true); m_ui->adv_button->setChecked(true);
ui->adv_button->setEnabled(false); m_ui->adv_button->setEnabled(false);
showAdvancedSettings(true); showAdvancedSettings(true);
} }
} }
void AddNewTorrentDialog::setCommentText(const QString &str) const void AddNewTorrentDialog::setCommentText(const QString &str) const
{ {
ui->commentLabel->setText(str); m_ui->commentLabel->setText(str);
// workaround for the additional space introduced by QScrollArea // workaround for the additional space introduced by QScrollArea
int lineHeight = ui->commentLabel->fontMetrics().lineSpacing(); int lineHeight = m_ui->commentLabel->fontMetrics().lineSpacing();
int lines = 1 + str.count("\n"); int lines = 1 + str.count("\n");
int height = lineHeight * lines; int height = lineHeight * lines;
ui->scrollArea->setMaximumHeight(height); m_ui->scrollArea->setMaximumHeight(height);
} }
void AddNewTorrentDialog::doNotDeleteTorrentClicked(bool checked) void AddNewTorrentDialog::doNotDeleteTorrentClicked(bool checked)

View file

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt4 and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2012 Christophe Dumez * Copyright (C) 2012 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#ifndef ADDNEWTORRENTDIALOG_H #ifndef ADDNEWTORRENTDIALOG_H
@ -36,9 +34,9 @@
#include <QShortcut> #include <QShortcut>
#include <QUrl> #include <QUrl>
#include "base/bittorrent/addtorrentparams.h"
#include "base/bittorrent/infohash.h" #include "base/bittorrent/infohash.h"
#include "base/bittorrent/torrentinfo.h" #include "base/bittorrent/torrentinfo.h"
#include "base/bittorrent/addtorrentparams.h"
namespace BitTorrent namespace BitTorrent
{ {
@ -50,12 +48,12 @@ namespace Ui
class AddNewTorrentDialog; class AddNewTorrentDialog;
} }
class PropListDelegate;
class TorrentContentFilterModel; class TorrentContentFilterModel;
class TorrentFileGuard; class TorrentFileGuard;
class PropListDelegate;
template <typename T> class CachedSettingValue; template <typename T> class CachedSettingValue;
class AddNewTorrentDialog: public QDialog class AddNewTorrentDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
@ -98,7 +96,7 @@ private:
bool loadMagnet(const BitTorrent::MagnetUri &magnetUri); bool loadMagnet(const BitTorrent::MagnetUri &magnetUri);
void populateSavePathComboBox(); void populateSavePathComboBox();
void saveSavePathHistory() const; void saveSavePathHistory() const;
int indexOfSavePath(const QString &save_path); int indexOfSavePath(const QString &savePath);
void loadState(); void loadState();
void saveState(); void saveState();
void setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText = QString()); void setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText = QString());
@ -109,7 +107,7 @@ private:
void showEvent(QShowEvent *event) override; void showEvent(QShowEvent *event) override;
Ui::AddNewTorrentDialog *ui; Ui::AddNewTorrentDialog *m_ui;
TorrentContentFilterModel *m_contentModel; TorrentContentFilterModel *m_contentModel;
PropListDelegate *m_contentDelegate; PropListDelegate *m_contentDelegate;
bool m_hasMetadata; bool m_hasMetadata;

View file

@ -115,7 +115,7 @@ AdvancedSettings::AdvancedSettings(QWidget *parent)
{ {
// column // column
setColumnCount(COL_COUNT); setColumnCount(COL_COUNT);
QStringList header = { tr("Setting"), tr("Value", "Value set for this setting") }; QStringList header = {tr("Setting"), tr("Value", "Value set for this setting")};
setHorizontalHeaderLabels(header); setHorizontalHeaderLabels(header);
// row // row
setRowCount(ROW_COUNT); setRowCount(ROW_COUNT);

View file

@ -626,7 +626,7 @@ void OptionsDialog::saveOptions()
session->setAltGlobalUploadSpeedLimit(alt_down_up_limit.second); session->setAltGlobalUploadSpeedLimit(alt_down_up_limit.second);
pref->setSchedulerStartTime(m_ui->schedule_from->time()); pref->setSchedulerStartTime(m_ui->schedule_from->time());
pref->setSchedulerEndTime(m_ui->schedule_to->time()); pref->setSchedulerEndTime(m_ui->schedule_to->time());
pref->setSchedulerDays(static_cast<scheduler_days>(m_ui->schedule_days->currentIndex())); pref->setSchedulerDays(static_cast<SchedulerDays>(m_ui->schedule_days->currentIndex()));
session->setBandwidthSchedulerEnabled(m_ui->check_schedule->isChecked()); session->setBandwidthSchedulerEnabled(m_ui->check_schedule->isChecked());
auto proxyConfigManager = Net::ProxyConfigurationManager::instance(); auto proxyConfigManager = Net::ProxyConfigurationManager::instance();

View file

@ -383,7 +383,7 @@ void AppController::setPreferencesAction()
if (m.contains("schedule_to_hour") && m.contains("schedule_to_min")) if (m.contains("schedule_to_hour") && m.contains("schedule_to_min"))
pref->setSchedulerEndTime(QTime(m["schedule_to_hour"].toInt(), m["schedule_to_min"].toInt())); pref->setSchedulerEndTime(QTime(m["schedule_to_hour"].toInt(), m["schedule_to_min"].toInt()));
if (m.contains("scheduler_days")) if (m.contains("scheduler_days"))
pref->setSchedulerDays(scheduler_days(m["scheduler_days"].toInt())); pref->setSchedulerDays(SchedulerDays(m["scheduler_days"].toInt()));
// Bittorrent // Bittorrent
// Privacy // Privacy