diff --git a/src/base/asyncfilestorage.h b/src/base/asyncfilestorage.h index 79e53faf7..383b5b555 100644 --- a/src/base/asyncfilestorage.h +++ b/src/base/asyncfilestorage.h @@ -34,14 +34,14 @@ #include #include -class AsyncFileStorageError: public std::runtime_error +class AsyncFileStorageError : public std::runtime_error { public: explicit AsyncFileStorageError(const QString &message); QString message() const; }; -class AsyncFileStorage: public QObject +class AsyncFileStorage : public QObject { Q_OBJECT diff --git a/src/base/bittorrent/private/bandwidthscheduler.cpp b/src/base/bittorrent/private/bandwidthscheduler.cpp index 9e5126668..b65cf62c3 100644 --- a/src/base/bittorrent/private/bandwidthscheduler.cpp +++ b/src/base/bittorrent/private/bandwidthscheduler.cpp @@ -55,7 +55,7 @@ void BandwidthScheduler::start() bool BandwidthScheduler::isTimeForAlternative() const { - const Preferences* const pref = Preferences::instance(); + const Preferences *const pref = Preferences::instance(); QTime start = pref->getSchedulerStartTime(); QTime end = pref->getSchedulerEndTime(); diff --git a/src/base/bittorrent/private/bandwidthscheduler.h b/src/base/bittorrent/private/bandwidthscheduler.h index 602bcade5..bf3e76263 100644 --- a/src/base/bittorrent/private/bandwidthscheduler.h +++ b/src/base/bittorrent/private/bandwidthscheduler.h @@ -33,7 +33,7 @@ #include #include -class BandwidthScheduler: public QObject +class BandwidthScheduler : public QObject { Q_OBJECT Q_DISABLE_COPY(BandwidthScheduler) diff --git a/src/base/bittorrent/private/filterparserthread.cpp b/src/base/bittorrent/private/filterparserthread.cpp index fa90b428c..eeb3b5fc9 100644 --- a/src/base/bittorrent/private/filterparserthread.cpp +++ b/src/base/bittorrent/private/filterparserthread.cpp @@ -1,5 +1,5 @@ /* - * Bittorrent Client using Qt and libt. + * Bittorrent Client using Qt and libtorrent. * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or @@ -147,13 +147,13 @@ int FilterParserThread::parseDATFilterFile() if (bytesRead < 0) break; int dataSize = bytesRead + offset; - if (bytesRead == 0 && dataSize == 0) + if ((bytesRead == 0) && (dataSize == 0)) break; for (start = 0; start < dataSize; ++start) { endOfLine = -1; // 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) { if (buffer[i] == '\n') { endOfLine = i; @@ -295,13 +295,13 @@ int FilterParserThread::parseP2PFilterFile() if (bytesRead < 0) break; int dataSize = bytesRead + offset; - if (bytesRead == 0 && dataSize == 0) + if ((bytesRead == 0) && (dataSize == 0)) break; for (start = 0; start < dataSize; ++start) { endOfLine = -1; // 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) { if (buffer[i] == '\n') { endOfLine = i; @@ -610,7 +610,7 @@ int FilterParserThread::findAndNullDelimiter(char *const data, char delimiter, i 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; int newStart = start; diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index dd70aab54..f4f6b13e0 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -370,7 +370,7 @@ Session::Session(QObject *parent) , m_extraLimit(0) , m_useProxy(false) { - Logger* const logger = Logger::instance(); + Logger *const logger = Logger::instance(); initResumeFolder(); @@ -940,7 +940,7 @@ qreal Session::globalMaxRatio() const 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 void Session::setGlobalMaxRatio(qreal ratio) { @@ -1083,7 +1083,7 @@ void Session::processBannedIPs(libt::ip_filter &filter) #if LIBTORRENT_VERSION_NUM >= 10100 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 maxActive = maxActiveTorrents(); @@ -1180,7 +1180,7 @@ void Session::initMetrics() void Session::configure(libtorrent::settings_pack &settingsPack) { - Logger* const logger = Logger::instance(); + Logger *const logger = Logger::instance(); #ifdef Q_OS_WIN 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_bool(libt::settings_pack::prefer_rc4, true); 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::in_enc_policy, libt::settings_pack::pe_enabled); 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_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_expiry, diskCacheTTL()); qDebug() << "Using a disk cache size of" << cacheSize << "MiB"; @@ -1510,12 +1510,12 @@ void Session::configurePeerClasses() 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 maxActive = maxActiveTorrents(); - sessionSettings.active_downloads = maxDownloads > -1 ? maxDownloads + m_extraLimit : maxDownloads; - sessionSettings.active_limit = maxActive > -1 ? maxActive + m_extraLimit : maxActive; + sessionSettings.active_downloads = (maxDownloads > -1) ? (maxDownloads + m_extraLimit) : maxDownloads; + sessionSettings.active_limit = (maxActive > -1) ? (maxActive + m_extraLimit) : maxActive; } 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.prefer_rc4 = true; switch (encryption()) { - case 0: //Enabled + case 0: // Enabled encryptionSettings.out_enc_policy = libt::pe_settings::enabled; encryptionSettings.in_enc_policy = libt::pe_settings::enabled; break; @@ -1589,7 +1589,7 @@ void Session::configure(libtorrent::session_settings &sessionSettings) sessionSettings.announce_to_all_trackers = announceToAllTrackers(); 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_expiry = diskCacheTTL(); qDebug() << "Using a disk cache size of" << cacheSize << "MiB"; @@ -1762,7 +1762,7 @@ void Session::enableBandwidthScheduler() void Session::populateAdditionalTrackers() { m_additionalTrackerList.clear(); - foreach (QString tracker, additionalTrackers().split("\n")) { + foreach (QString tracker, additionalTrackers().split('\n')) { tracker = tracker.trimmed(); if (!tracker.isEmpty()) m_additionalTrackerList << tracker; @@ -1786,7 +1786,7 @@ void Session::processShareLimits() qDebug("Ratio: %f (limit: %f)", ratio, ratioLimit); if ((ratio <= TorrentHandle::MAX_RATIO) && (ratio >= ratioLimit)) { - Logger* const logger = Logger::instance(); + Logger *const logger = Logger::instance(); if (m_maxRatioAction == Remove) { logger->addMessage(tr("'%1' reached the maximum ratio you set. Removed.").arg(torrent->name())); deleteTorrent(torrent->hash()); @@ -1811,7 +1811,7 @@ void Session::processShareLimits() qDebug("Seeding Time: %d (limit: %d)", seedingTimeInMinutes, seedingTimeLimit); if ((seedingTimeInMinutes <= TorrentHandle::MAX_SEEDING_TIME) && (seedingTimeInMinutes >= seedingTimeLimit)) { - Logger* const logger = Logger::instance(); + Logger *const logger = Logger::instance(); if (m_maxRatioAction == Remove) { logger->addMessage(tr("'%1' reached the maximum seeding time you set. Removed.").arg(torrent->name())); deleteTorrent(torrent->hash()); @@ -2259,7 +2259,7 @@ bool Session::loadMetadata(const MagnetUri &magnetUri) InfoHash hash = magnetUri.hash(); 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 if (m_torrents.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); } -void Session::networkConfigurationChange(const QNetworkConfiguration& cfg) +void Session::networkConfigurationChange(const QNetworkConfiguration &cfg) { 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 @@ -2430,7 +2430,7 @@ void Session::networkConfigurationChange(const QNetworkConfiguration& cfg) const QStringList Session::getListeningIPs() { - Logger* const logger = Logger::instance(); + Logger *const logger = Logger::instance(); QStringList IPs; const QString ifaceName = networkInterface(); @@ -2473,12 +2473,12 @@ const QStringList Session::getListeningIPs() ip = entry.ip(); ipString = ip.toString(); protocol = ip.protocol(); - Q_ASSERT(protocol == QAbstractSocket::IPv4Protocol || protocol == QAbstractSocket::IPv6Protocol); + Q_ASSERT((protocol == QAbstractSocket::IPv4Protocol) || (protocol == QAbstractSocket::IPv6Protocol)); if ((!listenIPv6 && (protocol == QAbstractSocket::IPv6Protocol)) || (listenIPv6 && (protocol == QAbstractSocket::IPv4Protocol))) 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 == ipString) { IPs.append(ipString); @@ -2509,7 +2509,7 @@ void Session::configureListeningInterface() const ushort port = this->port(); qDebug() << Q_FUNC_INFO << port; - Logger* const logger = Logger::instance(); + Logger *const logger = Logger::instance(); std::pair ports(port, port); libt::error_code ec; @@ -3512,7 +3512,7 @@ void Session::handleTorrentTagRemoved(TorrentHandle *const torrent, const QStrin emit torrentTagRemoved(torrent, tag); } -void Session::handleTorrentSavingModeChanged(TorrentHandle * const torrent) +void Session::handleTorrentSavingModeChanged(TorrentHandle *const torrent) { emit torrentSavingModeChanged(torrent); } @@ -3798,7 +3798,7 @@ void Session::startUpTorrents() .arg(params.hash), Log::CRITICAL); // process add torrent messages before message queue overflow - if (resumedTorrentsCount % 100 == 0) readAlerts(); + if ((resumedTorrentsCount % 100) == 0) readAlerts(); ++resumedTorrentsCount; }; @@ -3833,12 +3833,12 @@ void Session::startUpTorrents() } else { int q = queuePosition; - for(; queuedResumeData.contains(q); ++q) { + for (; queuedResumeData.contains(q); ++q) { } if (q != queuePosition) { ++numOfRemappedFiles; } - queuedResumeData[q] = { hash, magnetUri, resumeData, data }; + queuedResumeData[q] = {hash, magnetUri, resumeData, data}; } } } diff --git a/src/base/bittorrent/torrentcreatorthread.cpp b/src/base/bittorrent/torrentcreatorthread.cpp index a85661f66..85b2b3150 100644 --- a/src/base/bittorrent/torrentcreatorthread.cpp +++ b/src/base/bittorrent/torrentcreatorthread.cpp @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2010 Christophe Dumez + * Copyright (C) 2010 Christophe Dumez * * This program is free software; you can redistribute it and/or * 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), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #include "torrentcreatorthread.h" diff --git a/src/base/bittorrent/torrentcreatorthread.h b/src/base/bittorrent/torrentcreatorthread.h index 5704315be..41c991517 100644 --- a/src/base/bittorrent/torrentcreatorthread.h +++ b/src/base/bittorrent/torrentcreatorthread.h @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2010 Christophe Dumez + * Copyright (C) 2010 Christophe Dumez * * This program is free software; you can redistribute it and/or * 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), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef BITTORRENT_TORRENTCREATORTHREAD_H diff --git a/src/base/bittorrent/torrentinfo.cpp b/src/base/bittorrent/torrentinfo.cpp index 823002c01..08eb401ed 100644 --- a/src/base/bittorrent/torrentinfo.cpp +++ b/src/base/bittorrent/torrentinfo.cpp @@ -30,13 +30,13 @@ #include +#include #include #include #include -#include -#include "base/utils/misc.h" #include "base/utils/fs.h" +#include "base/utils/misc.h" #include "base/utils/string.h" #include "infohash.h" #include "trackerentry.h" @@ -315,7 +315,7 @@ QVector TorrentInfo::pieceHashes() const 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 return {}; @@ -353,8 +353,8 @@ void TorrentInfo::renameFile(uint index, const QString &newPath) int BitTorrent::TorrentInfo::fileIndex(const QString& fileName) const { - // the check whether the object valid is not needed here - // because filesCount() returns -1 in that case and the loop exits immediately + // the check whether the object is valid is not needed here + // because if filesCount() returns -1 the loop exits immediately for (int i = 0; i < filesCount(); ++i) if (fileName == filePath(i)) return i; diff --git a/src/base/bittorrent/torrentinfo.h b/src/base/bittorrent/torrentinfo.h index 71c75939b..2523c868b 100644 --- a/src/base/bittorrent/torrentinfo.h +++ b/src/base/bittorrent/torrentinfo.h @@ -39,11 +39,11 @@ #include "base/indexrange.h" -class QString; -class QUrl; -class QDateTime; -class QStringList; class QByteArray; +class QDateTime; +class QString; +class QStringList; +class QUrl; namespace BitTorrent { diff --git a/src/base/bittorrent/tracker.cpp b/src/base/bittorrent/tracker.cpp index ccaa6e127..c95f24e56 100644 --- a/src/base/bittorrent/tracker.cpp +++ b/src/base/bittorrent/tracker.cpp @@ -1,5 +1,5 @@ /* - * Bittorrent Client using Qt4 and libtorrent. + * Bittorrent Client using Qt and libtorrent. * Copyright (C) 2015 Vladimir Golovnev * Copyright (C) 2006 Christophe Dumez * @@ -27,6 +27,8 @@ * exception statement from your version. */ +#include "tracker.h" + #include #include @@ -37,7 +39,6 @@ #include "base/preferences.h" #include "base/utils/bytearray.h" #include "base/utils/string.h" -#include "tracker.h" // static limits static const int MAX_TORRENTS = 100; @@ -277,5 +278,3 @@ void Tracker::replyWithPeerList(const TrackerAnnounceRequest &annonceReq) // HTTP reply print(reply, Http::CONTENT_TYPE_TXT); } - - diff --git a/src/base/filesystemwatcher.cpp b/src/base/filesystemwatcher.cpp index 78efa4693..58a3c14af 100644 --- a/src/base/filesystemwatcher.cpp +++ b/src/base/filesystemwatcher.cpp @@ -28,14 +28,14 @@ #include "filesystemwatcher.h" +#include + #if defined(Q_OS_MAC) || defined(Q_OS_FREEBSD) #include #include #include #endif -#include - #include "base/algorithm.h" #include "base/bittorrent/magneturi.h" #include "base/bittorrent/torrentinfo.h" diff --git a/src/base/http/connection.cpp b/src/base/http/connection.cpp index 4ade26155..a90cae331 100644 --- a/src/base/http/connection.cpp +++ b/src/base/http/connection.cpp @@ -2,7 +2,7 @@ * Bittorrent Client using Qt and libtorrent. * Copyright (C) 2018 Mike Tzou (Chocobo1) * Copyright (C) 2014 Vladimir Golovnev - * Copyright (C) 2006 Ishan Arora and Christophe Dumez + * Copyright (C) 2006 Ishan Arora and Christophe Dumez * * This program is free software; you can redistribute it and/or * 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), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #include "connection.h" diff --git a/src/base/http/connection.h b/src/base/http/connection.h index 1eb8297aa..4304a9ee5 100644 --- a/src/base/http/connection.h +++ b/src/base/http/connection.h @@ -1,7 +1,7 @@ /* * Bittorrent Client using Qt and libtorrent. * Copyright (C) 2014 Vladimir Golovnev - * Copyright (C) 2006 Ishan Arora and Christophe Dumez + * Copyright (C) 2006 Ishan Arora and Christophe Dumez * * This program is free software; you can redistribute it and/or * 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), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ diff --git a/src/base/logger.cpp b/src/base/logger.cpp index faa7aeb53..1b62c1b7c 100644 --- a/src/base/logger.cpp +++ b/src/base/logger.cpp @@ -3,12 +3,12 @@ #include #include "base/utils/string.h" -Logger* Logger::m_instance = nullptr; +Logger *Logger::m_instance = nullptr; Logger::Logger() - : lock(QReadWriteLock::Recursive) - , msgCounter(0) - , peerCounter(0) + : m_lock(QReadWriteLock::Recursive) + , m_msgCounter(0) + , m_peerCounter(0) { } @@ -35,9 +35,9 @@ void Logger::freeInstance() 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); 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) { - 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); if (m_peers.size() >= MAX_LOG_MESSAGES) @@ -61,9 +61,9 @@ void Logger::addPeer(const QString &ip, bool blocked, const QString &reason) QVector 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(); if ((lastKnownId == -1) || (diff >= size)) @@ -77,9 +77,9 @@ QVector Logger::getMessages(int lastKnownId) const QVector 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(); if ((lastKnownId == -1) || (diff >= size)) diff --git a/src/base/logger.h b/src/base/logger.h index 441a7408b..37d706c64 100644 --- a/src/base/logger.h +++ b/src/base/logger.h @@ -1,10 +1,10 @@ #ifndef LOGGER_H #define LOGGER_H +#include +#include #include #include -#include -#include const int MAX_LOG_MESSAGES = 20000; @@ -16,7 +16,7 @@ namespace Log NORMAL = 0x1, INFO = 0x2, 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) @@ -63,12 +63,12 @@ private: Logger(); ~Logger(); - static Logger* m_instance; + static Logger *m_instance; QVector m_messages; QVector m_peers; - mutable QReadWriteLock lock; - int msgCounter; - int peerCounter; + mutable QReadWriteLock m_lock; + int m_msgCounter; + int m_peerCounter; }; // Helper function diff --git a/src/base/net/downloadmanager.cpp b/src/base/net/downloadmanager.cpp index c2b37b39f..5194deaae 100644 --- a/src/base/net/downloadmanager.cpp +++ b/src/base/net/downloadmanager.cpp @@ -48,7 +48,7 @@ const char DEFAULT_USER_AGENT[] = "Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/ namespace { - class NetworkCookieJar: public QNetworkCookieJar + class NetworkCookieJar : public QNetworkCookieJar { public: explicit NetworkCookieJar(QObject *parent = nullptr) diff --git a/src/base/net/private/geoipdatabase.cpp b/src/base/net/private/geoipdatabase.cpp index 1a29fab71..b0480c98c 100644 --- a/src/base/net/private/geoipdatabase.cpp +++ b/src/base/net/private/geoipdatabase.cpp @@ -26,12 +26,12 @@ * exception statement from your version. */ +#include #include -#include +#include #include #include -#include -#include +#include #include "base/types.h" #include "geoipdatabase.h" @@ -44,7 +44,7 @@ namespace const char DB_TYPE[] = "GeoLite2-Country"; const quint32 MAX_METADATA_SIZE = 131072; // 128KB 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 { diff --git a/src/base/net/private/geoipdatabase.h b/src/base/net/private/geoipdatabase.h index 329e28453..dc702d4df 100644 --- a/src/base/net/private/geoipdatabase.h +++ b/src/base/net/private/geoipdatabase.h @@ -29,13 +29,13 @@ #ifndef GEOIPDATABASE_H #define GEOIPDATABASE_H -#include #include +#include -class QHostAddress; -class QString; class QByteArray; class QDateTime; +class QHostAddress; +class QString; struct DataFieldDescriptor; diff --git a/src/base/net/proxyconfigurationmanager.cpp b/src/base/net/proxyconfigurationmanager.cpp index e792df651..da55cc929 100644 --- a/src/base/net/proxyconfigurationmanager.cpp +++ b/src/base/net/proxyconfigurationmanager.cpp @@ -27,6 +27,7 @@ */ #include "proxyconfigurationmanager.h" + #include "base/settingsstorage.h" #define SETTINGS_KEY(name) "Network/Proxy/" name diff --git a/src/base/net/proxyconfigurationmanager.h b/src/base/net/proxyconfigurationmanager.h index 3f21632c1..87f1f88e9 100644 --- a/src/base/net/proxyconfigurationmanager.h +++ b/src/base/net/proxyconfigurationmanager.h @@ -52,7 +52,7 @@ namespace Net QString password; }; - class ProxyConfigurationManager: public QObject + class ProxyConfigurationManager : public QObject { Q_OBJECT Q_DISABLE_COPY(ProxyConfigurationManager) diff --git a/src/base/net/reverseresolution.cpp b/src/base/net/reverseresolution.cpp index e3b9b706d..c639e9cbc 100644 --- a/src/base/net/reverseresolution.cpp +++ b/src/base/net/reverseresolution.cpp @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * 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), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ +#include "reverseresolution.h" + +#include +#include + #include #include #include -#include -#include - -#include "reverseresolution.h" - const int CACHE_SIZE = 500; using namespace Net; static inline bool isUsefulHostName(const QString &hostname, const QString &ip) { - return (!hostname.isEmpty() && hostname != ip); + return (!hostname.isEmpty() && (hostname != ip)); } ReverseResolution::ReverseResolution(QObject *parent) diff --git a/src/base/net/reverseresolution.h b/src/base/net/reverseresolution.h index c0a39dede..30ffbe14b 100644 --- a/src/base/net/reverseresolution.h +++ b/src/base/net/reverseresolution.h @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * 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), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef NET_REVERSERESOLUTION_H @@ -34,10 +32,8 @@ #include #include -QT_BEGIN_NAMESPACE class QHostInfo; class QString; -QT_END_NAMESPACE namespace Net { diff --git a/src/base/net/smtp.cpp b/src/base/net/smtp.cpp index 605b631dc..467afcad6 100644 --- a/src/base/net/smtp.cpp +++ b/src/base/net/smtp.cpp @@ -130,8 +130,8 @@ Smtp::~Smtp() void Smtp::sendMail(const QString &from, const QString &to, const QString &subject, const QString &body) { - const Preferences* const pref = Preferences::instance(); - QTextCodec* latin1 = QTextCodec::codecForName("latin1"); + const Preferences *const pref = Preferences::instance(); + QTextCodec *latin1 = QTextCodec::codecForName("latin1"); m_message = "Date: " + getCurrentDateTime().toLatin1() + "\r\n" + encodeMimeHeader("From", from, 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" + "\r\n"; // Encode the body in base64 - QString crlf_body = body; - QByteArray b = crlf_body.replace("\n", "\r\n").toUtf8().toBase64(); + QString crlfBody = body; + QByteArray b = crlfBody.replace("\n", "\r\n").toUtf8().toBase64(); int ct = b.length(); for (int i = 0; i < ct; 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_useSsl = false; #ifndef QT_NO_OPENSSL -} + } #endif } @@ -184,7 +184,7 @@ void Smtp::readyRead() QByteArray code = line.left(3); switch (m_state) { - case Init: { + case Init: if (code[0] == '2') { // The server may send a multiline greeting/INIT/220 response. // We wait until it finishes. @@ -198,7 +198,6 @@ void Smtp::readyRead() m_state = Close; } break; - } case EhloSent: case HeloSent: case EhloGreetReceived: @@ -448,7 +447,7 @@ void Smtp::startTLS() #endif } -void Smtp::authCramMD5(const QByteArray& challenge) +void Smtp::authCramMD5(const QByteArray &challenge) { if (m_state != AuthRequestSent) { m_socket->write("auth cram-md5\r\n"); diff --git a/src/base/preferences.cpp b/src/base/preferences.cpp index efb0e75d8..076a73773 100644 --- a/src/base/preferences.cpp +++ b/src/base/preferences.cpp @@ -1,7 +1,7 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006 Christophe Dumez - * Copyright (C) 2014 sledgehammer999 + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2014 sledgehammer999 + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * 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), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org - * Contact : hammered999@gmail.com */ #include "preferences.h" @@ -420,12 +417,12 @@ void Preferences::setSchedulerEndTime(const QTime &time) setValue("Preferences/Scheduler/end_time", time); } -scheduler_days Preferences::getSchedulerDays() const +SchedulerDays Preferences::getSchedulerDays() const { - return static_cast(value("Preferences/Scheduler/days", EVERY_DAY).toInt()); + return static_cast(value("Preferences/Scheduler/days", EVERY_DAY).toInt()); } -void Preferences::setSchedulerDays(scheduler_days days) +void Preferences::setSchedulerDays(SchedulerDays days) { setValue("Preferences/Scheduler/days", static_cast(days)); } @@ -690,12 +687,12 @@ QString Preferences::getUILockPasswordMD5() const return value("Locking/password").toString(); } -void Preferences::setUILockPassword(const QString &clear_password) +void Preferences::setUILockPassword(const QString &clearPassword) { QCryptographicHash md5(QCryptographicHash::Md5); - md5.addData(clear_password.toLocal8Bit()); - QString md5_password = md5.result().toHex(); - setValue("Locking/password", md5_password); + md5.addData(clearPassword.toLocal8Bit()); + QString md5Password = md5.result().toHex(); + setValue("Locking/password", md5Password); } bool Preferences::isUILocked() const diff --git a/src/base/preferences.h b/src/base/preferences.h index e01127d7f..c9a0188d2 100644 --- a/src/base/preferences.h +++ b/src/base/preferences.h @@ -1,7 +1,7 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006 Christophe Dumez - * Copyright (C) 2014 sledgehammer999 + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2014 sledgehammer999 + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * 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), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org - * Contact : hammered999@gmail.com */ #ifndef PREFERENCES_H @@ -47,7 +44,7 @@ #include "base/utils/net.h" #include "types.h" -enum scheduler_days +enum SchedulerDays { EVERY_DAY, WEEK_DAYS, @@ -83,7 +80,7 @@ namespace DNS class SettingsStorage; -class Preferences: public QObject +class Preferences : public QObject { Q_OBJECT Q_DISABLE_COPY(Preferences) @@ -166,8 +163,8 @@ public: void setSchedulerStartTime(const QTime &time); QTime getSchedulerEndTime() const; void setSchedulerEndTime(const QTime &time); - scheduler_days getSchedulerDays() const; - void setSchedulerDays(scheduler_days days); + SchedulerDays getSchedulerDays() const; + void setSchedulerDays(SchedulerDays days); // Search bool isSearchEnabled() const; @@ -222,7 +219,7 @@ public: void setDynDNSPassword(const QString &password); // Advanced settings - void setUILockPassword(const QString &clear_password); + void setUILockPassword(const QString &clearPassword); void clearUILockPassword(); QString getUILockPasswordMD5() const; bool isUILocked() const; diff --git a/src/base/private/profile_p.h b/src/base/private/profile_p.h index 7e6d9a7ea..80fca303e 100644 --- a/src/base/private/profile_p.h +++ b/src/base/private/profile_p.h @@ -25,7 +25,6 @@ * 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 * exception statement from your version. - * */ #ifndef QBT_PROFILE_P_H @@ -33,6 +32,7 @@ #include #include + #include "base/profile.h" namespace Private @@ -63,7 +63,7 @@ namespace Private }; /// Default implementation. Takes paths from system - class DefaultProfile: public Profile + class DefaultProfile : public Profile { public: DefaultProfile(const QString &configurationName); @@ -86,7 +86,7 @@ namespace Private }; /// Custom tree: creates directories under the specified root directory - class CustomProfile: public Profile + class CustomProfile : public Profile { public: CustomProfile(const QString &rootPath, const QString &configurationName); @@ -114,14 +114,14 @@ namespace Private virtual ~PathConverter() = default; }; - class NoConvertConverter: public PathConverter + class NoConvertConverter : public PathConverter { public: QString toPortablePath(const QString &path) const override; QString fromPortablePath(const QString &portablePath) const override; }; - class Converter: public PathConverter + class Converter : public PathConverter { public: Converter(const QString &basePath); @@ -132,4 +132,5 @@ namespace Private QDir m_baseDir; }; } + #endif // QBT_PROFILE_P_H diff --git a/src/base/profile.cpp b/src/base/profile.cpp index 4eabc2f37..a63e7833e 100644 --- a/src/base/profile.cpp +++ b/src/base/profile.cpp @@ -25,7 +25,6 @@ * 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 * exception statement from your version. - * */ #include "profile.h" diff --git a/src/base/profile.h b/src/base/profile.h index 85557633a..e8fe2fc5d 100644 --- a/src/base/profile.h +++ b/src/base/profile.h @@ -33,9 +33,9 @@ #include -#include #include #include +#include class Application; diff --git a/src/base/rss/private/rss_parser.cpp b/src/base/rss/private/rss_parser.cpp index c0a3cc3c4..51be081fe 100644 --- a/src/base/rss/private/rss_parser.cpp +++ b/src/base/rss/private/rss_parser.cpp @@ -29,8 +29,8 @@ #include "rss_parser.h" -#include #include +#include #include #include #include diff --git a/src/base/rss/private/rss_parser.h b/src/base/rss/private/rss_parser.h index e58237786..aeab57e3f 100644 --- a/src/base/rss/private/rss_parser.h +++ b/src/base/rss/private/rss_parser.h @@ -48,7 +48,7 @@ namespace RSS QList articles; }; - class Parser: public QObject + class Parser : public QObject { Q_OBJECT diff --git a/src/base/rss/rss_article.h b/src/base/rss/rss_article.h index a77967551..681b1dfa2 100644 --- a/src/base/rss/rss_article.h +++ b/src/base/rss/rss_article.h @@ -39,7 +39,7 @@ namespace RSS { class Feed; - class Article: public QObject + class Article : public QObject { Q_OBJECT Q_DISABLE_COPY(Article) diff --git a/src/base/rss/rss_autodownloader.h b/src/base/rss/rss_autodownloader.h index 5a56b488e..5b61741a4 100644 --- a/src/base/rss/rss_autodownloader.h +++ b/src/base/rss/rss_autodownloader.h @@ -59,7 +59,7 @@ namespace RSS QString message() const; }; - class AutoDownloader final: public QObject + class AutoDownloader final : public QObject { Q_OBJECT Q_DISABLE_COPY(AutoDownloader) diff --git a/src/base/rss/rss_autodownloadrule.cpp b/src/base/rss/rss_autodownloadrule.cpp index d34bf8366..2c5530695 100644 --- a/src/base/rss/rss_autodownloadrule.cpp +++ b/src/base/rss/rss_autodownloadrule.cpp @@ -43,9 +43,9 @@ #include "../tristatebool.h" #include "../utils/fs.h" #include "../utils/string.h" -#include "rss_feed.h" #include "rss_article.h" #include "rss_autodownloader.h" +#include "rss_feed.h" namespace { @@ -105,7 +105,7 @@ const QString Str_PreviouslyMatched(QStringLiteral("previouslyMatchedEpisodes")) namespace RSS { - struct AutoDownloadRuleData: public QSharedData + struct AutoDownloadRuleData : public QSharedData { QString name; bool enabled = true; diff --git a/src/base/rss/rss_feed.h b/src/base/rss/rss_feed.h index 248095d9d..6b83a6eb1 100644 --- a/src/base/rss/rss_feed.h +++ b/src/base/rss/rss_feed.h @@ -49,7 +49,7 @@ namespace RSS struct ParsingResult; } - class Feed final: public Item + class Feed final : public Item { Q_OBJECT Q_DISABLE_COPY(Feed) diff --git a/src/base/rss/rss_folder.h b/src/base/rss/rss_folder.h index 6317f4ea5..f26b8a178 100644 --- a/src/base/rss/rss_folder.h +++ b/src/base/rss/rss_folder.h @@ -37,7 +37,7 @@ namespace RSS { class Session; - class Folder final: public Item + class Folder final : public Item { Q_OBJECT Q_DISABLE_COPY(Folder) diff --git a/src/base/rss/rss_item.h b/src/base/rss/rss_item.h index 9ba1db692..273857257 100644 --- a/src/base/rss/rss_item.h +++ b/src/base/rss/rss_item.h @@ -39,7 +39,7 @@ namespace RSS class Folder; class Session; - class Item: public QObject + class Item : public QObject { Q_OBJECT Q_DISABLE_COPY(Item) diff --git a/src/base/rss/rss_session.cpp b/src/base/rss/rss_session.cpp index 33c273bee..7ab988e43 100644 --- a/src/base/rss/rss_session.cpp +++ b/src/base/rss/rss_session.cpp @@ -47,8 +47,8 @@ #include "../utils/fs.h" #include "rss_article.h" #include "rss_feed.h" -#include "rss_item.h" #include "rss_folder.h" +#include "rss_item.h" const int MsecsPerMin = 60000; const QString ConfFolderName(QStringLiteral("rss")); diff --git a/src/base/rss/rss_session.h b/src/base/rss/rss_session.h index 648e167bf..ee39e59f2 100644 --- a/src/base/rss/rss_session.h +++ b/src/base/rss/rss_session.h @@ -69,11 +69,11 @@ class AsyncFileStorage; namespace RSS { - class Item; class Feed; class Folder; + class Item; - class Session: public QObject + class Session : public QObject { Q_OBJECT Q_DISABLE_COPY(Session) diff --git a/src/base/scanfoldersmodel.cpp b/src/base/scanfoldersmodel.cpp index 429d02de4..b271c1590 100644 --- a/src/base/scanfoldersmodel.cpp +++ b/src/base/scanfoldersmodel.cpp @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2010 Christian Kandeler, Christophe Dumez + * Copyright (C) 2010 Christian Kandeler, Christophe Dumez * * This program is free software; you can redistribute it and/or * 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), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #include "scanfoldersmodel.h" @@ -235,7 +233,7 @@ ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath, 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); const QString &canonicalWatchPath = watchDir.canonicalPath(); diff --git a/src/base/scanfoldersmodel.h b/src/base/scanfoldersmodel.h index 171996b1a..0ba4a8e17 100644 --- a/src/base/scanfoldersmodel.h +++ b/src/base/scanfoldersmodel.h @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2010 Christian Kandeler, Christophe Dumez + * Copyright (C) 2010 Christian Kandeler, Christophe Dumez * * This program is free software; you can redistribute it and/or * 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), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef SCANFOLDERSMODEL_H @@ -37,7 +35,7 @@ class QStringList; class FileSystemWatcher; -class ScanFoldersModel: public QAbstractListModel +class ScanFoldersModel : public QAbstractListModel { Q_OBJECT Q_DISABLE_COPY(ScanFoldersModel) @@ -68,7 +66,7 @@ public: static bool initInstance(QObject *parent = nullptr); static void freeInstance(); - static ScanFoldersModel* instance(); + static ScanFoldersModel *instance(); static QString pathTypeDisplayName(const PathType type); diff --git a/src/base/search/searchpluginmanager.cpp b/src/base/search/searchpluginmanager.cpp index b1df35c92..b1f23bd3e 100644 --- a/src/base/search/searchpluginmanager.cpp +++ b/src/base/search/searchpluginmanager.cpp @@ -42,8 +42,8 @@ #include "base/global.h" #include "base/logger.h" -#include "base/net/downloadmanager.h" #include "base/net/downloadhandler.h" +#include "base/net/downloadmanager.h" #include "base/preferences.h" #include "base/profile.h" #include "base/utils/fs.h" @@ -256,7 +256,7 @@ bool SearchPluginManager::uninstallPlugin(const QString &name) return true; } -void SearchPluginManager::updateIconPath(PluginInfo * const plugin) +void SearchPluginManager::updateIconPath(PluginInfo *const plugin) { if (!plugin) return; QString iconPath = QString("%1/%2.png").arg(pluginsLocation(), plugin->name); diff --git a/src/base/search/searchpluginmanager.h b/src/base/search/searchpluginmanager.h index 89294af83..7f2b93ab3 100644 --- a/src/base/search/searchpluginmanager.h +++ b/src/base/search/searchpluginmanager.h @@ -73,7 +73,7 @@ public: void updatePlugin(const QString &name); void installPlugin(const QString &source); bool uninstallPlugin(const QString &name); - static void updateIconPath(PluginInfo * const plugin); + static void updateIconPath(PluginInfo *const plugin); void checkForUpdates(); SearchHandler *startSearch(const QString &pattern, const QString &category, const QStringList &usedPlugins); diff --git a/src/base/settingsstorage.cpp b/src/base/settingsstorage.cpp index a184c29db..8616461fd 100644 --- a/src/base/settingsstorage.cpp +++ b/src/base/settingsstorage.cpp @@ -1,7 +1,7 @@ /* * Bittorrent Client using Qt and libtorrent. * Copyright (C) 2016 Vladimir Golovnev - * Copyright (C) 2014 sledgehammer999 + * Copyright (C) 2014 sledgehammer999 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -258,7 +258,7 @@ QVariantHash TransactionalSettings::read() 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 // 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 diff --git a/src/base/settingsstorage.h b/src/base/settingsstorage.h index 1f035fad4..bae38550a 100644 --- a/src/base/settingsstorage.h +++ b/src/base/settingsstorage.h @@ -1,7 +1,7 @@ /* * Bittorrent Client using Qt and libtorrent. * Copyright (C) 2016 Vladimir Golovnev - * Copyright (C) 2014 sledgehammer999 + * Copyright (C) 2014 sledgehammer999 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -31,11 +31,11 @@ #define SETTINGSSTORAGE_H #include -#include -#include #include +#include +#include -class SettingsStorage: public QObject +class SettingsStorage : public QObject { Q_OBJECT SettingsStorage(); @@ -44,7 +44,7 @@ class SettingsStorage: public QObject public: static void initInstance(); static void freeInstance(); - static SettingsStorage* instance(); + static SettingsStorage *instance(); QVariant loadValue(const QString &key, const QVariant &defaultValue = QVariant()) const; void storeValue(const QString &key, const QVariant &value); diff --git a/src/base/settingvalue.h b/src/base/settingvalue.h index ec0ba71a1..5ce8f3d8a 100644 --- a/src/base/settingvalue.h +++ b/src/base/settingvalue.h @@ -31,6 +31,7 @@ #include #include + #include #include #include diff --git a/src/base/torrentfileguard.h b/src/base/torrentfileguard.h index 30ec3138d..57fc765d2 100644 --- a/src/base/torrentfileguard.h +++ b/src/base/torrentfileguard.h @@ -51,7 +51,7 @@ private: /// Reads settings for .torrent files from preferences /// and sets the file guard up accordingly -class TorrentFileGuard: private FileGuard +class TorrentFileGuard : private FileGuard { Q_GADGET diff --git a/src/base/torrentfilter.h b/src/base/torrentfilter.h index 335ec1868..378bb7a6f 100644 --- a/src/base/torrentfilter.h +++ b/src/base/torrentfilter.h @@ -29,8 +29,8 @@ #ifndef TORRENTFILTER_H #define TORRENTFILTER_H -#include #include +#include typedef QSet QStringSet; diff --git a/src/base/utils/fs.cpp b/src/base/utils/fs.cpp index eee398a57..1e86f548b 100644 --- a/src/base/utils/fs.cpp +++ b/src/base/utils/fs.cpp @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2012 Christophe Dumez + * Copyright (C) 2012 Christophe Dumez * * This program is free software; you can redistribute it and/or * 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), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #include "fs.h" #include +#include #include #include +#include #include #include -#include -#include #include #include @@ -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. */ @@ -169,7 +167,6 @@ bool Utils::Fs::forceRemove(const QString &filePath) /** * Removes directory and its content recursively. - * */ void Utils::Fs::removeDirRecursive(const QString &path) { diff --git a/src/base/utils/fs.h b/src/base/utils/fs.h index 8561bb23a..08cdc29db 100644 --- a/src/base/utils/fs.h +++ b/src/base/utils/fs.h @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2012 Christophe Dumez + * Copyright (C) 2012 Christophe Dumez * * This program is free software; you can redistribute it and/or * 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), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef UTILS_FS_H diff --git a/src/base/utils/misc.cpp b/src/base/utils/misc.cpp index b09ab07c1..1d3ec29fb 100644 --- a/src/base/utils/misc.cpp +++ b/src/base/utils/misc.cpp @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * 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), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #include "misc.h" @@ -70,9 +68,9 @@ #endif #endif -#include "base/utils/string.h" -#include "base/unicodestrings.h" #include "base/logger.h" +#include "base/unicodestrings.h" +#include "base/utils/string.h" #include "fs.h" namespace @@ -141,7 +139,7 @@ void Utils::Misc::shutdownComputer(const ShutdownDialogAction &action) else EventToSend = kAEShutDown; AEAddressDesc targetDesc; - static const ProcessSerialNumber kPSNOfSystemProcess = { 0, kSystemProcess }; + static const ProcessSerialNumber kPSNOfSystemProcess = {0, kSystemProcess}; AppleEvent eventReply = {typeNull, NULL}; AppleEvent appleEventToSend = {typeNull, NULL}; @@ -525,9 +523,9 @@ bool Utils::Misc::isUrl(const QString &s) 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( "(\\s|^)" // start with whitespace or beginning of line "(" diff --git a/src/base/utils/misc.h b/src/base/utils/misc.h index db9617ce3..8af5c54fc 100644 --- a/src/base/utils/misc.h +++ b/src/base/utils/misc.h @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * 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), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef UTILS_MISC_H @@ -73,7 +71,7 @@ namespace Utils // YobiByte, // 1024^8 }; - QString parseHtmlLinks(const QString &raw_text); + QString parseHtmlLinks(const QString &rawText); bool isUrl(const QString &s); void shutdownComputer(const ShutdownDialogAction &action); @@ -88,16 +86,16 @@ namespace Utils 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 - bool friendlyUnit(qint64 sizeInBytes, qreal& val, SizeUnit& unit); + bool friendlyUnit(qint64 sizeInBytes, qreal &val, SizeUnit &unit); QString friendlyUnit(qint64 bytesValue, bool isSpeed = false); int friendlyUnitPrecision(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". QString userFriendlyDuration(qlonglong seconds); QString getUserIDString(); @@ -108,8 +106,8 @@ namespace Utils QList boolListfromStringList(const QStringList &l); #ifndef DISABLE_GUI - void openPath(const QString& absolutePath); - void openFolderSelect(const QString& absolutePath); + void openPath(const QString &absolutePath); + void openFolderSelect(const QString &absolutePath); QPoint screenCenter(const QWidget *w); #endif @@ -136,4 +134,4 @@ namespace Utils } } -#endif +#endif // UTILS_MISC_H diff --git a/src/base/utils/net.cpp b/src/base/utils/net.cpp index 8acaabb77..47b89ce37 100644 --- a/src/base/utils/net.cpp +++ b/src/base/utils/net.cpp @@ -27,6 +27,7 @@ */ #include "net.h" + #include #include #include diff --git a/src/base/utils/random.cpp b/src/base/utils/random.cpp index fac913227..fde12462e 100644 --- a/src/base/utils/random.cpp +++ b/src/base/utils/random.cpp @@ -24,7 +24,6 @@ * 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 * exception statement from your version. - * */ #include "random.h" diff --git a/src/base/utils/random.h b/src/base/utils/random.h index 106d0b90f..6e3a30c0e 100644 --- a/src/base/utils/random.h +++ b/src/base/utils/random.h @@ -24,7 +24,6 @@ * 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 * exception statement from your version. - * */ #ifndef UTILS_RANDOM_H diff --git a/src/base/utils/version.h b/src/base/utils/version.h index 5f2e17ea4..e8a169007 100644 --- a/src/base/utils/version.h +++ b/src/base/utils/version.h @@ -117,7 +117,7 @@ namespace Utils { // find the last one non-zero component std::size_t lastSignificantIndex = N - 1; - while (lastSignificantIndex > 0 && (*this)[lastSignificantIndex] == 0) + while ((lastSignificantIndex > 0) && ((*this)[lastSignificantIndex] == 0)) --lastSignificantIndex; if (lastSignificantIndex + 1 < Mandatory) // lastSignificantIndex >= 0 diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index 59190a5e9..6f392d84e 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2012 Christophe Dumez + * Copyright (C) 2012 Christophe Dumez * * This program is free software; you can redistribute it and/or * 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), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #include "addnewtorrentdialog.h" @@ -38,7 +36,6 @@ #include #include -#include "autoexpandabledialog.h" #include "base/bittorrent/magneturi.h" #include "base/bittorrent/session.h" #include "base/bittorrent/torrenthandle.h" @@ -53,6 +50,7 @@ #include "base/utils/fs.h" #include "base/utils/misc.h" #include "base/utils/string.h" +#include "autoexpandabledialog.h" #include "guiiconprovider.h" #include "messageboxraised.h" #include "proplistdelegate.h" @@ -85,7 +83,7 @@ constexpr int AddNewTorrentDialog::maxPathHistoryLength; AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inParams, QWidget *parent) : QDialog(parent) - , ui(new Ui::AddNewTorrentDialog) + , m_ui(new Ui::AddNewTorrentDialog) , m_contentModel(nullptr) , m_contentDelegate(nullptr) , m_hasMetadata(false) @@ -93,40 +91,40 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP , m_torrentParams(inParams) { // TODO: set dialog file properties using m_torrentParams.filePriorities - ui->setupUi(this); + m_ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); - ui->lblMetaLoading->setVisible(false); - ui->progMetaLoading->setVisible(false); + m_ui->lblMetaLoading->setVisible(false); + m_ui->progMetaLoading->setVisible(false); - ui->savePath->setMode(FileSystemPathEdit::Mode::DirectorySave); - ui->savePath->setDialogCaption(tr("Choose save path")); - ui->savePath->setMaxVisibleItems(20); + m_ui->savePath->setMode(FileSystemPathEdit::Mode::DirectorySave); + m_ui->savePath->setDialogCaption(tr("Choose save path")); + m_ui->savePath->setMaxVisibleItems(20); auto session = BitTorrent::Session::instance(); if (m_torrentParams.addPaused == TriStateBool::True) - ui->startTorrentCheckBox->setChecked(false); + m_ui->startTorrentCheckBox->setChecked(false); else if (m_torrentParams.addPaused == TriStateBool::False) - ui->startTorrentCheckBox->setChecked(true); + m_ui->startTorrentCheckBox->setChecked(true); 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 - ui->comboTTM->setCurrentIndex(!session->isAutoTMMDisabledByDefault()); - ui->comboTTM->blockSignals(false); + m_ui->comboTTM->blockSignals(true); // the TreeView size isn't correct if the slot does it job at this point + m_ui->comboTTM->setCurrentIndex(!session->isAutoTMMDisabledByDefault()); + m_ui->comboTTM->blockSignals(false); populateSavePathComboBox(); - connect(ui->savePath, &FileSystemPathEdit::selectedPathChanged, this, &AddNewTorrentDialog::onSavePathChanged); - ui->defaultSavePathCheckBox->setVisible(false); // Default path is selected by default + connect(m_ui->savePath, &FileSystemPathEdit::selectedPathChanged, this, &AddNewTorrentDialog::onSavePathChanged); + m_ui->defaultSavePathCheckBox->setVisible(false); // Default path is selected by default if (m_torrentParams.createSubfolder == TriStateBool::True) - ui->createSubfolderCheckBox->setChecked(true); + m_ui->createSubfolderCheckBox->setChecked(true); else if (m_torrentParams.createSubfolder == TriStateBool::False) - ui->createSubfolderCheckBox->setChecked(false); + m_ui->createSubfolderCheckBox->setChecked(false); else - ui->createSubfolderCheckBox->setChecked(session->isCreateTorrentSubfolder()); + m_ui->createSubfolderCheckBox->setChecked(session->isCreateTorrentSubfolder()); - ui->skipCheckingCheckBox->setChecked(m_torrentParams.skipChecking); - ui->doNotDeleteTorrentCheckBox->setVisible(TorrentFileGuard::autoDeleteMode() != TorrentFileGuard::Never); + m_ui->skipCheckingCheckBox->setChecked(m_torrentParams.skipChecking); + m_ui->doNotDeleteTorrentCheckBox->setVisible(TorrentFileGuard::autoDeleteMode() != TorrentFileGuard::Never); // Load categories QStringList categories = session->categories().keys(); @@ -134,25 +132,25 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP QString defaultCategory = settings()->loadValue(KEY_DEFAULTCATEGORY).toString(); if (!m_torrentParams.category.isEmpty()) - ui->categoryComboBox->addItem(m_torrentParams.category); + m_ui->categoryComboBox->addItem(m_torrentParams.category); if (!defaultCategory.isEmpty()) - ui->categoryComboBox->addItem(defaultCategory); - ui->categoryComboBox->addItem(""); + m_ui->categoryComboBox->addItem(defaultCategory); + m_ui->categoryComboBox->addItem(""); foreach (const QString &category, categories) 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(); // Signal / slots - connect(ui->adv_button, &QToolButton::clicked, this, &AddNewTorrentDialog::showAdvancedSettings); - connect(ui->doNotDeleteTorrentCheckBox, &QCheckBox::clicked, this, &AddNewTorrentDialog::doNotDeleteTorrentClicked); - QShortcut *editHotkey = new QShortcut(Qt::Key_F2, ui->contentTreeView, nullptr, nullptr, Qt::WidgetShortcut); + connect(m_ui->adv_button, &QToolButton::clicked, this, &AddNewTorrentDialog::showAdvancedSettings); + connect(m_ui->doNotDeleteTorrentCheckBox, &QCheckBox::clicked, this, &AddNewTorrentDialog::doNotDeleteTorrentClicked); + QShortcut *editHotkey = new QShortcut(Qt::Key_F2, m_ui->contentTreeView, nullptr, nullptr, Qt::WidgetShortcut); 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() @@ -160,7 +158,7 @@ AddNewTorrentDialog::~AddNewTorrentDialog() saveState(); delete m_contentDelegate; - delete ui; + delete m_ui; } bool AddNewTorrentDialog::isEnabled() @@ -220,15 +218,15 @@ void AddNewTorrentDialog::loadState() const int height = newSize.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() { 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_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) @@ -316,9 +314,9 @@ bool AddNewTorrentDialog::loadTorrent(const QString &torrentPath) return false; } - ui->lblhash->setText(m_hash); + m_ui->lblhash->setText(m_hash); setupTreeview(); - TMMChanged(ui->comboTTM->currentIndex()); + TMMChanged(m_ui->comboTTM->currentIndex()); return true; } @@ -353,15 +351,15 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri) connect(BitTorrent::Session::instance(), &BitTorrent::Session::metadataLoaded, this, &AddNewTorrentDialog::updateMetadata); // Set dialog title - QString torrent_name = magnetUri.name(); - setWindowTitle(torrent_name.isEmpty() ? tr("Magnet link") : torrent_name); + QString torrentName = magnetUri.name(); + setWindowTitle(torrentName.isEmpty() ? tr("Magnet link") : torrentName); setupTreeview(); - TMMChanged(ui->comboTTM->currentIndex()); + TMMChanged(m_ui->comboTTM->currentIndex()); BitTorrent::Session::instance()->loadMetadata(magnetUri); setMetadataProgressIndicator(true, tr("Retrieving metadata...")); - ui->lblhash->setText(m_hash); + m_ui->lblhash->setText(m_hash); return true; } @@ -378,19 +376,19 @@ void AddNewTorrentDialog::showEvent(QShowEvent *event) void AddNewTorrentDialog::showAdvancedSettings(bool show) { const int minimumW = minimumWidth(); - setMinimumWidth(width()); // to remain the same width + setMinimumWidth(width()); // to remain the same width if (show) { - ui->adv_button->setText(QString::fromUtf8(C_UP)); - ui->settings_group->setVisible(true); - ui->infoGroup->setVisible(true); - ui->contentTreeView->setVisible(m_hasMetadata); - static_cast(layout())->insertWidget(layout()->indexOf(ui->never_show_cb) + 1, ui->adv_button); + m_ui->adv_button->setText(QString::fromUtf8(C_UP)); + m_ui->settings_group->setVisible(true); + m_ui->infoGroup->setVisible(true); + m_ui->contentTreeView->setVisible(m_hasMetadata); + static_cast(layout())->insertWidget(layout()->indexOf(m_ui->never_show_cb) + 1, m_ui->adv_button); } else { - ui->adv_button->setText(QString::fromUtf8(C_DOWN)); - ui->settings_group->setVisible(false); - ui->infoGroup->setVisible(false); - ui->buttonsHLayout->insertWidget(0, layout()->takeAt(layout()->indexOf(ui->never_show_cb) + 1)->widget()); + m_ui->adv_button->setText(QString::fromUtf8(C_DOWN)); + m_ui->settings_group->setVisible(false); + m_ui->infoGroup->setVisible(false); + m_ui->buttonsHLayout->insertWidget(0, layout()->takeAt(layout()->indexOf(m_ui->never_show_cb) + 1)->widget()); } adjustSize(); setMinimumWidth(minimumW); @@ -398,7 +396,7 @@ void AddNewTorrentDialog::showAdvancedSettings(bool show) void AddNewTorrentDialog::saveSavePathHistory() const { - QDir selectedSavePath(ui->savePath->selectedPath()); + QDir selectedSavePath(m_ui->savePath->selectedPath()); // Get current history QStringList history = settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList(); if (history.size() > savePathHistoryLength()) @@ -417,12 +415,12 @@ void AddNewTorrentDialog::saveSavePathHistory() const } } -// save_path is a folder, not an absolute file path -int AddNewTorrentDialog::indexOfSavePath(const QString &save_path) +// savePath is a folder, not an absolute file path +int AddNewTorrentDialog::indexOfSavePath(const QString &savePath) { - QDir saveDir(save_path); - for (int i = 0; i < ui->savePath->count(); ++i) - if (QDir(ui->savePath->item(i)) == saveDir) + QDir saveDir(savePath); + for (int i = 0; i < m_ui->savePath->count(); ++i) + if (QDir(m_ui->savePath->item(i)) == saveDir) return i; return -1; } @@ -430,7 +428,7 @@ int AddNewTorrentDialog::indexOfSavePath(const QString &save_path) void AddNewTorrentDialog::updateDiskSpaceLabel() { // Determine torrent size - qulonglong torrent_size = 0; + qulonglong torrentSize = 0; if (m_hasMetadata) { if (m_contentModel) { @@ -438,28 +436,28 @@ void AddNewTorrentDialog::updateDiskSpaceLabel() Q_ASSERT(priorities.size() == m_torrentInfo.filesCount()); for (int i = 0; i < priorities.size(); ++i) if (priorities[i] > 0) - torrent_size += m_torrentInfo.fileSize(i); + torrentSize += m_torrentInfo.fileSize(i); } 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.")); - size_string += " ("; - size_string += tr("Free space on disk: %1").arg(Utils::Misc::friendlyUnit(Utils::Fs::freeDiskSpaceOnPath( - ui->savePath->selectedPath()))); - size_string += ")"; - ui->size_lbl->setText(size_string); + QString sizeString = torrentSize ? Utils::Misc::friendlyUnit(torrentSize) : QString(tr("Not Available", "This size is unavailable.")); + sizeString += " ("; + sizeString += tr("Free space on disk: %1").arg(Utils::Misc::friendlyUnit(Utils::Fs::freeDiskSpaceOnPath( + m_ui->savePath->selectedPath()))); + sizeString += ")"; + m_ui->size_lbl->setText(sizeString); } void AddNewTorrentDialog::onSavePathChanged(const QString &newPath) { // Toggle default save path setting checkbox visibility - ui->defaultSavePathCheckBox->setChecked(false); - ui->defaultSavePathCheckBox->setVisible(QDir(newPath) != QDir(BitTorrent::Session::instance()->defaultSavePath())); + m_ui->defaultSavePathCheckBox->setChecked(false); + m_ui->defaultSavePathCheckBox->setVisible(QDir(newPath) != QDir(BitTorrent::Session::instance()->defaultSavePath())); // Remember index - m_oldIndex = ui->savePath->currentIndex(); + m_oldIndex = m_ui->savePath->currentIndex(); updateDiskSpaceLabel(); } @@ -467,9 +465,9 @@ void AddNewTorrentDialog::categoryChanged(int index) { Q_UNUSED(index); - if (ui->comboTTM->currentIndex() == 1) { - QString savePath = BitTorrent::Session::instance()->categorySavePath(ui->categoryComboBox->currentText()); - ui->savePath->setSelectedPath(Utils::Fs::toNativePath(savePath)); + if (m_ui->comboTTM->currentIndex() == 1) { + QString savePath = BitTorrent::Session::instance()->categorySavePath(m_ui->categoryComboBox->currentText()); + m_ui->savePath->setSelectedPath(Utils::Fs::toNativePath(savePath)); } } @@ -478,16 +476,16 @@ void AddNewTorrentDialog::setSavePath(const QString &newPath) int existingIndex = indexOfSavePath(newPath); if (existingIndex < 0) { // New path, prepend to combo box - ui->savePath->insertItem(0, newPath); + m_ui->savePath->insertItem(0, newPath); existingIndex = 0; } - ui->savePath->setCurrentIndex(existingIndex); + m_ui->savePath->setCurrentIndex(existingIndex); onSavePathChanged(newPath); } 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; const QModelIndex modelIndex = selectedIndexes.first(); @@ -590,13 +588,13 @@ void AddNewTorrentDialog::populateSavePathComboBox() { QString defSavePath = BitTorrent::Session::instance()->defaultSavePath(); - ui->savePath->clear(); - ui->savePath->addItem(defSavePath); + m_ui->savePath->clear(); + m_ui->savePath->addItem(defSavePath); QDir defaultSaveDir(defSavePath); // Load save path history foreach (const QString &savePath, settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList()) if (QDir(savePath) != defaultSaveDir) - ui->savePath->addItem(savePath); + m_ui->savePath->addItem(savePath); if (!m_torrentParams.savePath.isEmpty()) setSavePath(m_torrentParams.savePath); @@ -605,7 +603,7 @@ void AddNewTorrentDialog::populateSavePathComboBox() void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &) { QMenu myFilesLlistMenu; - const QModelIndexList selectedRows = ui->contentTreeView->selectionModel()->selectedRows(0); + const QModelIndexList selectedRows = m_ui->contentTreeView->selectionModel()->selectedRows(0); QAction *actRename = nullptr; if (selectedRows.size() == 1) { actRename = myFilesLlistMenu.addAction(GuiIconProvider::instance()->getIcon("edit-rename"), tr("Rename...")); @@ -613,10 +611,10 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &) } QMenu subMenu; subMenu.setTitle(tr("Priority")); - subMenu.addAction(ui->actionNot_downloaded); - subMenu.addAction(ui->actionNormal); - subMenu.addAction(ui->actionHigh); - subMenu.addAction(ui->actionMaximum); + subMenu.addAction(m_ui->actionNot_downloaded); + subMenu.addAction(m_ui->actionNormal); + subMenu.addAction(m_ui->actionHigh); + subMenu.addAction(m_ui->actionMaximum); myFilesLlistMenu.addMenu(&subMenu); // Call menu QAction *act = myFilesLlistMenu.exec(QCursor::pos()); @@ -626,11 +624,11 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &) } else { int prio = prio::NORMAL; - if (act == ui->actionHigh) + if (act == m_ui->actionHigh) prio = prio::HIGH; - else if (act == ui->actionMaximum) + else if (act == m_ui->actionMaximum) prio = prio::MAXIMUM; - else if (act == ui->actionNot_downloaded) + else if (act == m_ui->actionNot_downloaded) prio = prio::IGNORED; qDebug("Setting files priority"); @@ -648,34 +646,34 @@ void AddNewTorrentDialog::accept() disconnect(this, SLOT(updateMetadata(const BitTorrent::TorrentInfo&))); // TODO: Check if destination actually exists - m_torrentParams.skipChecking = ui->skipCheckingCheckBox->isChecked(); + m_torrentParams.skipChecking = m_ui->skipCheckingCheckBox->isChecked(); // 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); // Save file priorities if (m_contentModel) m_torrentParams.filePriorities = m_contentModel->model()->getFilePriorities(); - m_torrentParams.addPaused = TriStateBool(!ui->startTorrentCheckBox->isChecked()); - m_torrentParams.createSubfolder = TriStateBool(ui->createSubfolderCheckBox->isChecked()); + m_torrentParams.addPaused = TriStateBool(!m_ui->startTorrentCheckBox->isChecked()); + m_torrentParams.createSubfolder = TriStateBool(m_ui->createSubfolderCheckBox->isChecked()); - QString savePath = 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. + QString savePath = m_ui->savePath->selectedPath(); + 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.savePath = savePath; saveSavePathHistory(); - if (ui->defaultSavePathCheckBox->isChecked()) + if (m_ui->defaultSavePathCheckBox->isChecked()) BitTorrent::Session::instance()->setDefaultSavePath(savePath); } else { m_torrentParams.useAutoTMM = TriStateBool::True; } - setEnabled(!ui->never_show_cb->isChecked()); + setEnabled(!m_ui->never_show_cb->isChecked()); // Add torrent if (!m_hasMetadata) @@ -722,16 +720,16 @@ void AddNewTorrentDialog::updateMetadata(const BitTorrent::TorrentInfo &info) void AddNewTorrentDialog::setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText) { // Always show info label when waiting for metadata - ui->lblMetaLoading->setVisible(true); - ui->lblMetaLoading->setText(labelText); - ui->progMetaLoading->setVisible(visibleIndicator); + m_ui->lblMetaLoading->setVisible(true); + m_ui->lblMetaLoading->setText(labelText); + m_ui->progMetaLoading->setVisible(visibleIndicator); } void AddNewTorrentDialog::setupTreeview() { if (!m_hasMetadata) { 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 { // Set dialog title @@ -739,30 +737,30 @@ void AddNewTorrentDialog::setupTreeview() // Set torrent information 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 m_contentModel = new TorrentContentFilterModel(this); 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); - ui->contentTreeView->setItemDelegate(m_contentDelegate); - connect(ui->contentTreeView, &QAbstractItemView::clicked, ui->contentTreeView + m_ui->contentTreeView->setItemDelegate(m_contentDelegate); + connect(m_ui->contentTreeView, &QAbstractItemView::clicked, m_ui->contentTreeView , static_cast(&QAbstractItemView::edit)); - connect(ui->contentTreeView, &QWidget::customContextMenuRequested, this, &AddNewTorrentDialog::displayContentTreeMenu); + connect(m_ui->contentTreeView, &QWidget::customContextMenuRequested, this, &AddNewTorrentDialog::displayContentTreeMenu); // List files in torrent m_contentModel->model()->setupModelData(m_torrentInfo); 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 - ui->contentTreeView->hideColumn(PROGRESS); - ui->contentTreeView->hideColumn(REMAINING); - ui->contentTreeView->hideColumn(AVAILABILITY); + m_ui->contentTreeView->hideColumn(PROGRESS); + m_ui->contentTreeView->hideColumn(REMAINING); + m_ui->contentTreeView->hideColumn(AVAILABILITY); // Expand root folder - ui->contentTreeView->setExpanded(m_contentModel->index(0, 0), true); + m_ui->contentTreeView->setExpanded(m_contentModel->index(0, 0), true); } 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. populateSavePathComboBox(); - ui->groupBoxSavePath->setEnabled(true); - ui->savePath->blockSignals(false); - ui->savePath->setCurrentIndex(m_oldIndex < ui->savePath->count() ? m_oldIndex : ui->savePath->count() - 1); - ui->adv_button->setEnabled(true); + m_ui->groupBoxSavePath->setEnabled(true); + m_ui->savePath->blockSignals(false); + m_ui->savePath->setCurrentIndex(m_oldIndex < m_ui->savePath->count() ? m_oldIndex : m_ui->savePath->count() - 1); + m_ui->adv_button->setEnabled(true); } else { - ui->groupBoxSavePath->setEnabled(false); - ui->savePath->blockSignals(true); - ui->savePath->clear(); - QString savePath = BitTorrent::Session::instance()->categorySavePath(ui->categoryComboBox->currentText()); - ui->savePath->addItem(savePath); - ui->defaultSavePathCheckBox->setVisible(false); - ui->adv_button->setChecked(true); - ui->adv_button->setEnabled(false); + m_ui->groupBoxSavePath->setEnabled(false); + m_ui->savePath->blockSignals(true); + m_ui->savePath->clear(); + QString savePath = BitTorrent::Session::instance()->categorySavePath(m_ui->categoryComboBox->currentText()); + m_ui->savePath->addItem(savePath); + m_ui->defaultSavePathCheckBox->setVisible(false); + m_ui->adv_button->setChecked(true); + m_ui->adv_button->setEnabled(false); showAdvancedSettings(true); } } void AddNewTorrentDialog::setCommentText(const QString &str) const { - ui->commentLabel->setText(str); + m_ui->commentLabel->setText(str); // 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 height = lineHeight * lines; - ui->scrollArea->setMaximumHeight(height); + m_ui->scrollArea->setMaximumHeight(height); } void AddNewTorrentDialog::doNotDeleteTorrentClicked(bool checked) diff --git a/src/gui/addnewtorrentdialog.h b/src/gui/addnewtorrentdialog.h index f698d81c6..b52504232 100644 --- a/src/gui/addnewtorrentdialog.h +++ b/src/gui/addnewtorrentdialog.h @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2012 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2012 Christophe Dumez * * This program is free software; you can redistribute it and/or * 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), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef ADDNEWTORRENTDIALOG_H @@ -36,9 +34,9 @@ #include #include +#include "base/bittorrent/addtorrentparams.h" #include "base/bittorrent/infohash.h" #include "base/bittorrent/torrentinfo.h" -#include "base/bittorrent/addtorrentparams.h" namespace BitTorrent { @@ -50,12 +48,12 @@ namespace Ui class AddNewTorrentDialog; } +class PropListDelegate; class TorrentContentFilterModel; class TorrentFileGuard; -class PropListDelegate; template class CachedSettingValue; -class AddNewTorrentDialog: public QDialog +class AddNewTorrentDialog : public QDialog { Q_OBJECT @@ -98,7 +96,7 @@ private: bool loadMagnet(const BitTorrent::MagnetUri &magnetUri); void populateSavePathComboBox(); void saveSavePathHistory() const; - int indexOfSavePath(const QString &save_path); + int indexOfSavePath(const QString &savePath); void loadState(); void saveState(); void setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText = QString()); @@ -109,7 +107,7 @@ private: void showEvent(QShowEvent *event) override; - Ui::AddNewTorrentDialog *ui; + Ui::AddNewTorrentDialog *m_ui; TorrentContentFilterModel *m_contentModel; PropListDelegate *m_contentDelegate; bool m_hasMetadata; diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 192958089..20dc66591 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -115,7 +115,7 @@ AdvancedSettings::AdvancedSettings(QWidget *parent) { // column 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); // row setRowCount(ROW_COUNT); diff --git a/src/gui/optionsdlg.cpp b/src/gui/optionsdlg.cpp index ab2ae662e..dac450aaf 100644 --- a/src/gui/optionsdlg.cpp +++ b/src/gui/optionsdlg.cpp @@ -626,7 +626,7 @@ void OptionsDialog::saveOptions() session->setAltGlobalUploadSpeedLimit(alt_down_up_limit.second); pref->setSchedulerStartTime(m_ui->schedule_from->time()); pref->setSchedulerEndTime(m_ui->schedule_to->time()); - pref->setSchedulerDays(static_cast(m_ui->schedule_days->currentIndex())); + pref->setSchedulerDays(static_cast(m_ui->schedule_days->currentIndex())); session->setBandwidthSchedulerEnabled(m_ui->check_schedule->isChecked()); auto proxyConfigManager = Net::ProxyConfigurationManager::instance(); diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index 694cd59bd..297929c19 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -383,7 +383,7 @@ void AppController::setPreferencesAction() if (m.contains("schedule_to_hour") && m.contains("schedule_to_min")) pref->setSchedulerEndTime(QTime(m["schedule_to_hour"].toInt(), m["schedule_to_min"].toInt())); if (m.contains("scheduler_days")) - pref->setSchedulerDays(scheduler_days(m["scheduler_days"].toInt())); + pref->setSchedulerDays(SchedulerDays(m["scheduler_days"].toInt())); // Bittorrent // Privacy