Browse Source

Merge pull request #10314 from thalieht/const2

More const
adaptive-webui-19844
Mike Tzou 6 years ago committed by GitHub
parent
commit
46bc1d12b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/app/cmdoptions.cpp
  2. 2
      src/base/bittorrent/magneturi.h
  3. 2
      src/base/bittorrent/session.h
  4. 2
      src/base/bittorrent/torrentinfo.h
  5. 2
      src/base/http/responsebuilder.cpp
  6. 4
      src/base/http/server.cpp
  7. 18
      src/base/logger.cpp
  8. 2
      src/base/logger.h
  9. 4
      src/base/net/dnsupdater.cpp
  10. 2
      src/base/net/downloadhandler.cpp
  11. 22
      src/base/net/downloadmanager.cpp
  12. 2
      src/base/net/downloadmanager.h
  13. 6
      src/base/net/geoipmanager.cpp
  14. 6
      src/base/net/portforwarder.cpp
  15. 28
      src/base/net/private/geoipdatabase.cpp
  16. 48
      src/base/net/smtp.cpp
  17. 4
      src/base/net/smtp.h
  18. 150
      src/base/preferences.cpp
  19. 18
      src/base/preferences.h
  20. 8
      src/base/private/profile_p.cpp
  21. 6
      src/base/profile.cpp
  22. 28
      src/base/rss/private/rss_parser.cpp
  23. 2
      src/base/rss/rss_article.cpp
  24. 2
      src/base/rss/rss_article.h
  25. 18
      src/base/rss/rss_autodownloader.cpp
  26. 4
      src/base/rss/rss_autodownloader.h
  27. 18
      src/base/rss/rss_autodownloadrule.cpp
  28. 20
      src/base/rss/rss_feed.cpp
  29. 6
      src/base/rss/rss_session.cpp
  30. 28
      src/base/scanfoldersmodel.cpp
  31. 6
      src/base/scanfoldersmodel.h
  32. 2
      src/base/search/searchhandler.cpp
  33. 24
      src/base/search/searchpluginmanager.cpp
  34. 2
      src/base/settingsstorage.h
  35. 4
      src/base/torrentfileguard.cpp
  36. 4
      src/base/torrentfileguard.h
  37. 2
      src/base/torrentfilter.h
  38. 2
      src/base/utils/bytearray.h
  39. 2
      src/base/utils/foreignapps.cpp
  40. 16
      src/base/utils/fs.cpp
  41. 16
      src/base/utils/misc.cpp
  42. 2
      src/base/utils/random.h
  43. 4
      src/base/utils/string.cpp
  44. 2
      src/base/utils/string.h
  45. 4
      src/gui/addnewtorrentdialog.cpp
  46. 2
      src/gui/addnewtorrentdialog.h
  47. 2
      src/gui/autoexpandabledialog.h
  48. 10
      src/gui/categoryfiltermodel.cpp
  49. 6
      src/gui/categoryfiltermodel.h
  50. 6
      src/gui/categoryfilterwidget.cpp
  51. 10
      src/gui/cookiesmodel.h
  52. 4
      src/gui/mainwindow.h
  53. 4
      src/gui/optionsdialog.cpp
  54. 2
      src/gui/properties/piecesbar.cpp
  55. 2
      src/gui/properties/piecesbar.h
  56. 2
      src/gui/rss/automatedrssdownloader.cpp
  57. 2
      src/gui/search/searchsortmodel.h
  58. 2
      src/gui/search/searchwidget.cpp
  59. 10
      src/gui/tagfiltermodel.cpp
  60. 4
      src/gui/tagfiltermodel.h
  61. 6
      src/gui/tagfilterwidget.cpp
  62. 2
      src/gui/torrentcategorydialog.h
  63. 6
      src/gui/torrentcontentmodel.h
  64. 2
      src/gui/torrentcreatordialog.h
  65. 2
      src/gui/transferlistmodel.cpp
  66. 2
      src/gui/transferlistmodel.h
  67. 2
      src/gui/transferlistsortmodel.h
  68. 6
      src/gui/utils.h
  69. 4
      src/webui/api/appcontroller.cpp
  70. 2
      src/webui/api/searchcontroller.cpp
  71. 4
      src/webui/api/searchcontroller.h
  72. 2
      src/webui/api/torrentscontroller.cpp

2
src/app/cmdoptions.cpp

@ -159,7 +159,7 @@ namespace @@ -159,7 +159,7 @@ namespace
.arg(fullParameter()).arg(QLatin1String("<value>")));
}
QString value(const QProcessEnvironment &env, const QString &defaultValue = QString()) const
QString value(const QProcessEnvironment &env, const QString &defaultValue = {}) const
{
QString val = env.value(envVarName());
return val.isEmpty() ? defaultValue : Utils::String::unquote(val, QLatin1String("'\""));

2
src/base/bittorrent/magneturi.h

@ -43,7 +43,7 @@ namespace BitTorrent @@ -43,7 +43,7 @@ namespace BitTorrent
class MagnetUri
{
public:
explicit MagnetUri(const QString &source = QString());
explicit MagnetUri(const QString &source = {});
bool isValid() const;
InfoHash hash() const;

2
src/base/bittorrent/session.h

@ -581,7 +581,7 @@ namespace BitTorrent @@ -581,7 +581,7 @@ namespace BitTorrent
bool addTorrent_impl(CreateTorrentParams params, const MagnetUri &magnetUri,
TorrentInfo torrentInfo = TorrentInfo(),
const QByteArray &fastresumeData = QByteArray());
const QByteArray &fastresumeData = {});
bool findIncompleteFiles(TorrentInfo &torrentInfo, QString &savePath) const;
void updateSeedingLimitTimer();

2
src/base/bittorrent/torrentinfo.h

@ -57,7 +57,7 @@ namespace BitTorrent @@ -57,7 +57,7 @@ namespace BitTorrent
typedef boost::shared_ptr<const libtorrent::torrent_info> NativeConstPtr;
typedef boost::shared_ptr<libtorrent::torrent_info> NativePtr;
explicit TorrentInfo(NativeConstPtr nativeInfo = NativeConstPtr());
explicit TorrentInfo(NativeConstPtr nativeInfo = {});
TorrentInfo(const TorrentInfo &other);
static TorrentInfo load(const QByteArray &data, QString *error = nullptr) noexcept;

2
src/base/http/responsebuilder.cpp

@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
using namespace Http;
void ResponseBuilder::status(uint code, const QString &text)
void ResponseBuilder::status(const uint code, const QString &text)
{
m_response.status = ResponseStatus(code, text);
}

4
src/base/http/server.cpp

@ -79,7 +79,7 @@ Server::Server(IRequestHandler *requestHandler, QObject *parent) @@ -79,7 +79,7 @@ Server::Server(IRequestHandler *requestHandler, QObject *parent)
dropConnectionTimer->start(CONNECTIONS_SCAN_INTERVAL * 1000);
}
void Server::incomingConnection(qintptr socketDescriptor)
void Server::incomingConnection(const qintptr socketDescriptor)
{
if (m_connections.size() >= CONNECTIONS_LIMIT) return;
@ -110,7 +110,7 @@ void Server::dropTimedOutConnection() @@ -110,7 +110,7 @@ void Server::dropTimedOutConnection()
{
QMutableListIterator<Connection *> i(m_connections);
while (i.hasNext()) {
auto connection = i.next();
const auto *connection = i.next();
if (connection->isClosed() || connection->hasExpired(KEEP_ALIVE_DURATION)) {
delete connection;
i.remove();

18
src/base/logger.cpp

@ -65,7 +65,7 @@ void Logger::addMessage(const QString &message, const Log::MsgType &type) @@ -65,7 +65,7 @@ void Logger::addMessage(const QString &message, const Log::MsgType &type)
{
QWriteLocker locker(&m_lock);
Log::Msg temp = {m_msgCounter++, QDateTime::currentMSecsSinceEpoch(), type, message.toHtmlEscaped()};
const Log::Msg temp = {m_msgCounter++, QDateTime::currentMSecsSinceEpoch(), type, message.toHtmlEscaped()};
m_messages.push_back(temp);
if (m_messages.size() >= MAX_LOG_MESSAGES)
@ -74,11 +74,11 @@ void Logger::addMessage(const QString &message, const Log::MsgType &type) @@ -74,11 +74,11 @@ void Logger::addMessage(const QString &message, const Log::MsgType &type)
emit newLogMessage(temp);
}
void Logger::addPeer(const QString &ip, bool blocked, const QString &reason)
void Logger::addPeer(const QString &ip, const bool blocked, const QString &reason)
{
QWriteLocker locker(&m_lock);
Log::Peer temp = {m_peerCounter++, QDateTime::currentMSecsSinceEpoch(), ip.toHtmlEscaped(), blocked, reason.toHtmlEscaped()};
const Log::Peer temp = {m_peerCounter++, QDateTime::currentMSecsSinceEpoch(), ip.toHtmlEscaped(), blocked, reason.toHtmlEscaped()};
m_peers.push_back(temp);
if (m_peers.size() >= MAX_LOG_MESSAGES)
@ -87,12 +87,12 @@ void Logger::addPeer(const QString &ip, bool blocked, const QString &reason) @@ -87,12 +87,12 @@ void Logger::addPeer(const QString &ip, bool blocked, const QString &reason)
emit newLogPeer(temp);
}
QVector<Log::Msg> Logger::getMessages(int lastKnownId) const
QVector<Log::Msg> Logger::getMessages(const int lastKnownId) const
{
QReadLocker locker(&m_lock);
int diff = m_msgCounter - lastKnownId - 1;
int size = m_messages.size();
const int diff = m_msgCounter - lastKnownId - 1;
const int size = m_messages.size();
if ((lastKnownId == -1) || (diff >= size))
return m_messages;
@ -103,12 +103,12 @@ QVector<Log::Msg> Logger::getMessages(int lastKnownId) const @@ -103,12 +103,12 @@ QVector<Log::Msg> Logger::getMessages(int lastKnownId) const
return m_messages.mid(size - diff);
}
QVector<Log::Peer> Logger::getPeers(int lastKnownId) const
QVector<Log::Peer> Logger::getPeers(const int lastKnownId) const
{
QReadLocker locker(&m_lock);
int diff = m_peerCounter - lastKnownId - 1;
int size = m_peers.size();
const int diff = m_peerCounter - lastKnownId - 1;
const int size = m_peers.size();
if ((lastKnownId == -1) || (diff >= size))
return m_peers;

2
src/base/logger.h

@ -79,7 +79,7 @@ public: @@ -79,7 +79,7 @@ public:
static Logger *instance();
void addMessage(const QString &message, const Log::MsgType &type = Log::NORMAL);
void addPeer(const QString &ip, bool blocked, const QString &reason = QString());
void addPeer(const QString &ip, bool blocked, const QString &reason = {});
QVector<Log::Msg> getMessages(int lastKnownId = -1) const;
QVector<Log::Peer> getPeers(int lastKnownId = -1) const;

4
src/base/net/dnsupdater.cpp

@ -181,7 +181,7 @@ void DNSUpdater::processIPUpdateReply(const QString &reply) @@ -181,7 +181,7 @@ void DNSUpdater::processIPUpdateReply(const QString &reply)
{
Logger *const logger = Logger::instance();
qDebug() << Q_FUNC_INFO << reply;
QString code = reply.split(' ').first();
const QString code = reply.split(' ').first();
qDebug() << Q_FUNC_INFO << "Code:" << code;
if ((code == "good") || (code == "nochg")) {
@ -284,7 +284,7 @@ void DNSUpdater::updateCredentials() @@ -284,7 +284,7 @@ void DNSUpdater::updateCredentials()
}
}
QUrl DNSUpdater::getRegistrationUrl(int service)
QUrl DNSUpdater::getRegistrationUrl(const int service)
{
switch (service) {
case DNS::DYNDNS:

2
src/base/net/downloadhandler.cpp

@ -135,7 +135,7 @@ void Net::DownloadHandler::processFinishedDownload() @@ -135,7 +135,7 @@ void Net::DownloadHandler::processFinishedDownload()
this->deleteLater();
}
void Net::DownloadHandler::checkDownloadSize(qint64 bytesReceived, qint64 bytesTotal)
void Net::DownloadHandler::checkDownloadSize(const qint64 bytesReceived, const qint64 bytesTotal)
{
QString msg = tr("The file size is %1. It exceeds the download limit of %2.");

22
src/base/net/downloadmanager.cpp

@ -58,7 +58,7 @@ namespace @@ -58,7 +58,7 @@ namespace
explicit NetworkCookieJar(QObject *parent = nullptr)
: QNetworkCookieJar(parent)
{
QDateTime now = QDateTime::currentDateTime();
const QDateTime now = QDateTime::currentDateTime();
QList<QNetworkCookie> cookies = Preferences::instance()->getNetworkCookies();
for (const QNetworkCookie &cookie : asConst(Preferences::instance()->getNetworkCookies())) {
if (cookie.isSessionCookie() || (cookie.expirationDate() <= now))
@ -70,7 +70,7 @@ namespace @@ -70,7 +70,7 @@ namespace
~NetworkCookieJar() override
{
QDateTime now = QDateTime::currentDateTime();
const QDateTime now = QDateTime::currentDateTime();
QList<QNetworkCookie> cookies = allCookies();
for (const QNetworkCookie &cookie : asConst(allCookies())) {
if (cookie.isSessionCookie() || (cookie.expirationDate() <= now))
@ -85,7 +85,7 @@ namespace @@ -85,7 +85,7 @@ namespace
QList<QNetworkCookie> cookiesForUrl(const QUrl &url) const override
{
QDateTime now = QDateTime::currentDateTime();
const QDateTime now = QDateTime::currentDateTime();
QList<QNetworkCookie> cookies = QNetworkCookieJar::cookiesForUrl(url);
for (const QNetworkCookie &cookie : asConst(QNetworkCookieJar::cookiesForUrl(url))) {
if (!cookie.isSessionCookie() && (cookie.expirationDate() <= now))
@ -97,7 +97,7 @@ namespace @@ -97,7 +97,7 @@ namespace
bool setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const QUrl &url) override
{
QDateTime now = QDateTime::currentDateTime();
const QDateTime now = QDateTime::currentDateTime();
QList<QNetworkCookie> cookies = cookieList;
for (const QNetworkCookie &cookie : cookieList) {
if (!cookie.isSessionCookie() && (cookie.expirationDate() <= now))
@ -222,8 +222,8 @@ bool Net::DownloadManager::hasSupportedScheme(const QString &url) @@ -222,8 +222,8 @@ bool Net::DownloadManager::hasSupportedScheme(const QString &url)
void Net::DownloadManager::applyProxySettings()
{
auto proxyManager = ProxyConfigurationManager::instance();
ProxyConfiguration proxyConfig = proxyManager->proxyConfiguration();
const auto *proxyManager = ProxyConfigurationManager::instance();
const ProxyConfiguration proxyConfig = proxyManager->proxyConfiguration();
QNetworkProxy proxy;
if (!proxyManager->isProxyOnlyForTorrents() && (proxyConfig.type != ProxyType::None)) {
@ -253,10 +253,10 @@ void Net::DownloadManager::applyProxySettings() @@ -253,10 +253,10 @@ void Net::DownloadManager::applyProxySettings()
m_networkManager.setProxy(proxy);
}
void Net::DownloadManager::handleReplyFinished(QNetworkReply *reply)
void Net::DownloadManager::handleReplyFinished(const QNetworkReply *reply)
{
const ServiceID id = ServiceID::fromURL(reply->url());
auto waitingJobsIter = m_waitingJobs.find(id);
const auto waitingJobsIter = m_waitingJobs.find(id);
if ((waitingJobsIter == m_waitingJobs.end()) || waitingJobsIter.value().isEmpty()) {
m_busyServices.remove(id);
return;
@ -311,7 +311,7 @@ qint64 Net::DownloadRequest::limit() const @@ -311,7 +311,7 @@ qint64 Net::DownloadRequest::limit() const
return m_limit;
}
Net::DownloadRequest &Net::DownloadRequest::limit(qint64 value)
Net::DownloadRequest &Net::DownloadRequest::limit(const qint64 value)
{
m_limit = value;
return *this;
@ -322,7 +322,7 @@ bool Net::DownloadRequest::saveToFile() const @@ -322,7 +322,7 @@ bool Net::DownloadRequest::saveToFile() const
return m_saveToFile;
}
Net::DownloadRequest &Net::DownloadRequest::saveToFile(bool value)
Net::DownloadRequest &Net::DownloadRequest::saveToFile(const bool value)
{
m_saveToFile = value;
return *this;
@ -333,7 +333,7 @@ bool Net::DownloadRequest::handleRedirectToMagnet() const @@ -333,7 +333,7 @@ bool Net::DownloadRequest::handleRedirectToMagnet() const
return m_handleRedirectToMagnet;
}
Net::DownloadRequest &Net::DownloadRequest::handleRedirectToMagnet(bool value)
Net::DownloadRequest &Net::DownloadRequest::handleRedirectToMagnet(const bool value)
{
m_handleRedirectToMagnet = value;
return *this;

2
src/base/net/downloadmanager.h

@ -115,7 +115,7 @@ namespace Net @@ -115,7 +115,7 @@ namespace Net
explicit DownloadManager(QObject *parent = nullptr);
void applyProxySettings();
void handleReplyFinished(QNetworkReply *reply);
void handleReplyFinished(const QNetworkReply *reply);
static DownloadManager *m_instance;
QNetworkAccessManager m_networkManager;

6
src/base/net/geoipmanager.cpp

@ -95,7 +95,7 @@ void GeoIPManager::loadDatabase() @@ -95,7 +95,7 @@ void GeoIPManager::loadDatabase()
m_geoIPDatabase = nullptr;
}
QString filepath = Utils::Fs::expandPathAbs(
const QString filepath = Utils::Fs::expandPathAbs(
QString("%1%2/%3").arg(specialFolderLocation(SpecialFolder::Data), GEOIP_FOLDER, GEOIP_FILENAME));
QString error;
@ -118,7 +118,7 @@ void GeoIPManager::manageDatabaseUpdate() @@ -118,7 +118,7 @@ void GeoIPManager::manageDatabaseUpdate()
void GeoIPManager::downloadDatabaseFile()
{
DownloadHandler *handler = DownloadManager::instance()->download({DATABASE_URL});
const DownloadHandler *handler = DownloadManager::instance()->download({DATABASE_URL});
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QByteArray &)>(&Net::DownloadHandler::downloadFinished)
, this, &GeoIPManager::downloadFinished);
connect(handler, &Net::DownloadHandler::downloadFailed, this, &GeoIPManager::downloadFailed);
@ -434,7 +434,7 @@ void GeoIPManager::downloadFinished(const QString &url, QByteArray data) @@ -434,7 +434,7 @@ void GeoIPManager::downloadFinished(const QString &url, QByteArray data)
Logger::instance()->addMessage(tr("GeoIP database loaded. Type: %1. Build time: %2.")
.arg(m_geoIPDatabase->type(), m_geoIPDatabase->buildEpoch().toString()),
Log::INFO);
QString targetPath = Utils::Fs::expandPathAbs(
const QString targetPath = Utils::Fs::expandPathAbs(
specialFolderLocation(SpecialFolder::Data) + GEOIP_FOLDER);
if (!QDir(targetPath).exists())
QDir().mkpath(targetPath);

6
src/base/net/portforwarder.cpp

@ -78,7 +78,7 @@ bool PortForwarder::isEnabled() const @@ -78,7 +78,7 @@ bool PortForwarder::isEnabled() const
return m_active;
}
void PortForwarder::setEnabled(bool enabled)
void PortForwarder::setEnabled(const bool enabled)
{
if (m_active != enabled) {
if (enabled)
@ -90,7 +90,7 @@ void PortForwarder::setEnabled(bool enabled) @@ -90,7 +90,7 @@ void PortForwarder::setEnabled(bool enabled)
}
}
void PortForwarder::addPort(quint16 port)
void PortForwarder::addPort(const quint16 port)
{
if (!m_mappedPorts.contains(port)) {
m_mappedPorts.insert(port, 0);
@ -99,7 +99,7 @@ void PortForwarder::addPort(quint16 port) @@ -99,7 +99,7 @@ void PortForwarder::addPort(quint16 port)
}
}
void PortForwarder::deletePort(quint16 port)
void PortForwarder::deletePort(const quint16 port)
{
if (m_mappedPorts.contains(port)) {
if (m_active)

28
src/base/net/private/geoipdatabase.cpp

@ -74,7 +74,7 @@ struct DataFieldDescriptor @@ -74,7 +74,7 @@ struct DataFieldDescriptor
};
};
GeoIPDatabase::GeoIPDatabase(quint32 size)
GeoIPDatabase::GeoIPDatabase(const quint32 size)
: m_ipVersion(0)
, m_recordSize(0)
, m_nodeCount(0)
@ -165,7 +165,7 @@ QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const @@ -165,7 +165,7 @@ QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const
for (int i = 0; i < 16; ++i) {
for (int j = 0; j < 8; ++j) {
bool right = static_cast<bool>((addr[i] >> (7 - j)) & 1);
const bool right = static_cast<bool>((addr[i] >> (7 - j)) & 1);
// Interpret the left/right record as number
if (right)
ptr += m_recordBytes;
@ -183,7 +183,7 @@ QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const @@ -183,7 +183,7 @@ QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const
if (country.isEmpty()) {
const quint32 offset = id - m_nodeCount - sizeof(DATA_SECTION_SEPARATOR);
quint32 tmp = offset + m_indexSize + sizeof(DATA_SECTION_SEPARATOR);
QVariant val = readDataField(tmp);
const QVariant val = readDataField(tmp);
if (val.userType() == QMetaType::QVariantHash) {
country = val.toHash()["country"].toHash()["iso_code"].toString();
m_countries[id] = country;
@ -226,8 +226,8 @@ bool GeoIPDatabase::parseMetadata(const QVariantHash &metadata, QString &error) @@ -226,8 +226,8 @@ bool GeoIPDatabase::parseMetadata(const QVariantHash &metadata, QString &error)
CHECK_METADATA_REQ(binary_format_major_version, UShort);
CHECK_METADATA_REQ(binary_format_minor_version, UShort);
uint versionMajor = metadata.value("binary_format_major_version").toUInt();
uint versionMinor = metadata.value("binary_format_minor_version").toUInt();
const uint versionMajor = metadata.value("binary_format_major_version").toUInt();
const uint versionMinor = metadata.value("binary_format_minor_version").toUInt();
if (versionMajor != 2) {
error = tr("Unsupported database version: %1.%2").arg(versionMajor).arg(versionMinor);
return false;
@ -254,7 +254,7 @@ bool GeoIPDatabase::parseMetadata(const QVariantHash &metadata, QString &error) @@ -254,7 +254,7 @@ bool GeoIPDatabase::parseMetadata(const QVariantHash &metadata, QString &error)
m_indexSize = m_nodeCount * m_nodeSize;
CHECK_METADATA_REQ(database_type, QString);
QString dbType = metadata.value("database_type").toString();
const QString dbType = metadata.value("database_type").toString();
if (dbType != DB_TYPE) {
error = tr("Invalid database type: %1").arg(dbType);
return false;
@ -299,7 +299,7 @@ QVariantHash GeoIPDatabase::readMetadata() const @@ -299,7 +299,7 @@ QVariantHash GeoIPDatabase::readMetadata() const
if (m_size > MAX_METADATA_SIZE)
index += (m_size - MAX_METADATA_SIZE); // from begin of all data
auto offset = static_cast<quint32>(index + strlen(METADATA_BEGIN_MARK));
QVariant metadata = readDataField(offset);
const QVariant metadata = readDataField(offset);
if (metadata.userType() == QMetaType::QVariantHash)
return metadata.toHash();
}
@ -390,12 +390,12 @@ QVariant GeoIPDatabase::readDataField(quint32 &offset) const @@ -390,12 +390,12 @@ QVariant GeoIPDatabase::readDataField(quint32 &offset) const
bool GeoIPDatabase::readDataFieldDescriptor(quint32 &offset, DataFieldDescriptor &out) const
{
const uchar *dataPtr = m_data + offset;
int availSize = m_size - offset;
const int availSize = m_size - offset;
if (availSize < 1) return false;
out.fieldType = static_cast<DataType>((dataPtr[0] & 0xE0) >> 5);
if (out.fieldType == DataType::Pointer) {
int size = ((dataPtr[0] & 0x18) >> 3);
const int size = ((dataPtr[0] & 0x18) >> 3);
if (availSize < (size + 2)) return false;
if (size == 0)
@ -442,7 +442,7 @@ bool GeoIPDatabase::readDataFieldDescriptor(quint32 &offset, DataFieldDescriptor @@ -442,7 +442,7 @@ bool GeoIPDatabase::readDataFieldDescriptor(quint32 &offset, DataFieldDescriptor
return true;
}
void GeoIPDatabase::fromBigEndian(uchar *buf, quint32 len) const
void GeoIPDatabase::fromBigEndian(uchar *buf, const quint32 len) const
{
#if (Q_BYTE_ORDER == Q_LITTLE_ENDIAN)
std::reverse(buf, buf + len);
@ -452,7 +452,7 @@ void GeoIPDatabase::fromBigEndian(uchar *buf, quint32 len) const @@ -452,7 +452,7 @@ void GeoIPDatabase::fromBigEndian(uchar *buf, quint32 len) const
#endif
}
QVariant GeoIPDatabase::readMapValue(quint32 &offset, quint32 count) const
QVariant GeoIPDatabase::readMapValue(quint32 &offset, const quint32 count) const
{
QVariantHash map;
@ -461,7 +461,7 @@ QVariant GeoIPDatabase::readMapValue(quint32 &offset, quint32 count) const @@ -461,7 +461,7 @@ QVariant GeoIPDatabase::readMapValue(quint32 &offset, quint32 count) const
if (field.userType() != QMetaType::QString)
return {};
QString key = field.toString();
const QString key = field.toString();
field = readDataField(offset);
if (field.userType() == QVariant::Invalid)
return {};
@ -472,12 +472,12 @@ QVariant GeoIPDatabase::readMapValue(quint32 &offset, quint32 count) const @@ -472,12 +472,12 @@ QVariant GeoIPDatabase::readMapValue(quint32 &offset, quint32 count) const
return map;
}
QVariant GeoIPDatabase::readArrayValue(quint32 &offset, quint32 count) const
QVariant GeoIPDatabase::readArrayValue(quint32 &offset, const quint32 count) const
{
QVariantList array;
for (quint32 i = 0; i < count; ++i) {
QVariant field = readDataField(offset);
const QVariant field = readDataField(offset);
if (field.userType() == QVariant::Invalid)
return {};

48
src/base/net/smtp.cpp

@ -140,8 +140,8 @@ void Smtp::sendMail(const QString &from, const QString &to, const QString &subje @@ -140,8 +140,8 @@ void Smtp::sendMail(const QString &from, const QString &to, const QString &subje
+ "\r\n";
// Encode the body in base64
QString crlfBody = body;
QByteArray b = crlfBody.replace("\n", "\r\n").toUtf8().toBase64();
int ct = b.length();
const QByteArray b = crlfBody.replace("\n", "\r\n").toUtf8().toBase64();
const int ct = b.length();
for (int i = 0; i < ct; i += 78)
m_message += b.mid(i, 78);
m_from = from;
@ -173,13 +173,13 @@ void Smtp::readyRead() @@ -173,13 +173,13 @@ void Smtp::readyRead()
// SMTP is line-oriented
m_buffer += m_socket->readAll();
while (true) {
int pos = m_buffer.indexOf("\r\n");
const int pos = m_buffer.indexOf("\r\n");
if (pos < 0) return; // Loop exit condition
QByteArray line = m_buffer.left(pos);
const QByteArray line = m_buffer.left(pos);
m_buffer = m_buffer.mid(pos + 2);
qDebug() << "Response line:" << line;
// Extract response code
QByteArray code = line.left(3);
const QByteArray code = line.left(3);
switch (m_state) {
case Init:
@ -285,7 +285,7 @@ void Smtp::readyRead() @@ -285,7 +285,7 @@ void Smtp::readyRead()
}
}
QByteArray Smtp::encodeMimeHeader(const QString &key, const QString &value, QTextCodec *latin1, const QByteArray &prefix)
QByteArray Smtp::encodeMimeHeader(const QString &key, const QString &value, const QTextCodec *latin1, const QByteArray &prefix)
{
QByteArray rv = "";
QByteArray line = key.toLatin1() + ": ";
@ -307,10 +307,10 @@ QByteArray Smtp::encodeMimeHeader(const QString &key, const QString &value, QTex @@ -307,10 +307,10 @@ QByteArray Smtp::encodeMimeHeader(const QString &key, const QString &value, QTex
else {
// The text cannot be losslessly encoded as Latin-1. Therefore, we
// must use base64 encoding.
QByteArray utf8 = value.toUtf8();
const QByteArray utf8 = value.toUtf8();
// Use base64 encoding
QByteArray base64 = utf8.toBase64();
int ct = base64.length();
const QByteArray base64 = utf8.toBase64();
const int ct = base64.length();
line += "=?utf-8?b?";
for (int i = 0; i < ct; i += 4) {
/*if (line.length() > 72) {
@ -326,7 +326,7 @@ QByteArray Smtp::encodeMimeHeader(const QString &key, const QString &value, QTex @@ -326,7 +326,7 @@ QByteArray Smtp::encodeMimeHeader(const QString &key, const QString &value, QTex
void Smtp::ehlo()
{
QByteArray address = determineFQDN();
const QByteArray address = determineFQDN();
m_socket->write("ehlo " + address + "\r\n");
m_socket->flush();
m_state = EhloSent;
@ -334,13 +334,13 @@ void Smtp::ehlo() @@ -334,13 +334,13 @@ void Smtp::ehlo()
void Smtp::helo()
{
QByteArray address = determineFQDN();
const QByteArray address = determineFQDN();
m_socket->write("helo " + address + "\r\n");
m_socket->flush();
m_state = HeloSent;
}
void Smtp::parseEhloResponse(const QByteArray &code, bool continued, const QString &line)
void Smtp::parseEhloResponse(const QByteArray &code, const bool continued, const QString &line)
{
if (code != "250") {
// Error
@ -407,7 +407,7 @@ void Smtp::authenticate() @@ -407,7 +407,7 @@ void Smtp::authenticate()
// AUTH extension is supported, check which
// authentication modes are supported by
// the server
QStringList auth = m_extensions["AUTH"].toUpper().split(' ', QString::SkipEmptyParts);
const QStringList auth = m_extensions["AUTH"].toUpper().split(' ', QString::SkipEmptyParts);
if (auth.contains("CRAM-MD5")) {
qDebug() << "Using CRAM-MD5 authentication...";
authCramMD5();
@ -454,7 +454,7 @@ void Smtp::authCramMD5(const QByteArray &challenge) @@ -454,7 +454,7 @@ void Smtp::authCramMD5(const QByteArray &challenge)
m_state = AuthRequestSent;
}
else {
QByteArray response = m_username.toLatin1() + ' '
const QByteArray response = m_username.toLatin1() + ' '
+ hmacMD5(m_password.toLatin1(), QByteArray::fromBase64(challenge)).toHex();
m_socket->write(response.toBase64() + "\r\n");
m_socket->flush();
@ -514,23 +514,23 @@ QString Smtp::getCurrentDateTime() const @@ -514,23 +514,23 @@ QString Smtp::getCurrentDateTime() const
const QDate nowDate = nowDateTime.date();
const QLocale eng(QLocale::English);
QString timeStr = nowDateTime.time().toString("HH:mm:ss");
QString weekDayStr = eng.dayName(nowDate.dayOfWeek(), QLocale::ShortFormat);
QString dayStr = QString::number(nowDate.day());
QString monthStr = eng.monthName(nowDate.month(), QLocale::ShortFormat);
QString yearStr = QString::number(nowDate.year());
const QString timeStr = nowDateTime.time().toString("HH:mm:ss");
const QString weekDayStr = eng.dayName(nowDate.dayOfWeek(), QLocale::ShortFormat);
const QString dayStr = QString::number(nowDate.day());
const QString monthStr = eng.monthName(nowDate.month(), QLocale::ShortFormat);
const QString yearStr = QString::number(nowDate.year());
QDateTime tmp = nowDateTime;
tmp.setTimeSpec(Qt::UTC);
int timeOffsetHour = nowDateTime.secsTo(tmp) / 3600;
int timeOffsetMin = nowDateTime.secsTo(tmp) / 60 - (60 * timeOffsetHour);
int timeOffset = timeOffsetHour * 100 + timeOffsetMin;
const int timeOffsetHour = nowDateTime.secsTo(tmp) / 3600;
const int timeOffsetMin = nowDateTime.secsTo(tmp) / 60 - (60 * timeOffsetHour);
const int timeOffset = timeOffsetHour * 100 + timeOffsetMin;
// buf size = 11 to avoid format truncation warnings from snprintf
char buf[11] = {0};
std::snprintf(buf, sizeof(buf), "%+05d", timeOffset);
QString timeOffsetStr = buf;
const QString timeOffsetStr = buf;
QString ret = weekDayStr + ", " + dayStr + ' ' + monthStr + ' ' + yearStr + ' ' + timeStr + ' ' + timeOffsetStr;
const QString ret = weekDayStr + ", " + dayStr + ' ' + monthStr + ' ' + yearStr + ' ' + timeStr + ' ' + timeOffsetStr;
return ret;
}

4
src/base/net/smtp.h

@ -90,13 +90,13 @@ namespace Net @@ -90,13 +90,13 @@ namespace Net
AuthCramMD5
};
QByteArray encodeMimeHeader(const QString &key, const QString &value, QTextCodec *latin1, const QByteArray &prefix = QByteArray());
QByteArray encodeMimeHeader(const QString &key, const QString &value, const QTextCodec *latin1, const QByteArray &prefix = {});
void ehlo();
void helo();
void parseEhloResponse(const QByteArray &code, bool continued, const QString &line);
void authenticate();
void startTLS();
void authCramMD5(const QByteArray &challenge = QByteArray());
void authCramMD5(const QByteArray &challenge = {});
void authPlain();
void authLogin();
void logError(const QString &msg);

150
src/base/preferences.cpp

@ -104,7 +104,7 @@ bool Preferences::deleteTorrentFilesAsDefault() const @@ -104,7 +104,7 @@ bool Preferences::deleteTorrentFilesAsDefault() const
return value("Preferences/General/DeleteTorrentsFilesAsDefault", false).toBool();
}
void Preferences::setDeleteTorrentFilesAsDefault(bool del)
void Preferences::setDeleteTorrentFilesAsDefault(const bool del)
{
setValue("Preferences/General/DeleteTorrentsFilesAsDefault", del);
}
@ -114,7 +114,7 @@ bool Preferences::confirmOnExit() const @@ -114,7 +114,7 @@ bool Preferences::confirmOnExit() const
return value("Preferences/General/ExitConfirm", true).toBool();
}
void Preferences::setConfirmOnExit(bool confirm)
void Preferences::setConfirmOnExit(const bool confirm)
{
setValue("Preferences/General/ExitConfirm", confirm);
}
@ -124,7 +124,7 @@ bool Preferences::speedInTitleBar() const @@ -124,7 +124,7 @@ bool Preferences::speedInTitleBar() const
return value("Preferences/General/SpeedInTitleBar", false).toBool();
}
void Preferences::showSpeedInTitleBar(bool show)
void Preferences::showSpeedInTitleBar(const bool show)
{
setValue("Preferences/General/SpeedInTitleBar", show);
}
@ -134,7 +134,7 @@ bool Preferences::useAlternatingRowColors() const @@ -134,7 +134,7 @@ bool Preferences::useAlternatingRowColors() const
return value("Preferences/General/AlternatingRowColors", true).toBool();
}
void Preferences::setAlternatingRowColors(bool b)
void Preferences::setAlternatingRowColors(const bool b)
{
setValue("Preferences/General/AlternatingRowColors", b);
}
@ -144,7 +144,7 @@ bool Preferences::getHideZeroValues() const @@ -144,7 +144,7 @@ bool Preferences::getHideZeroValues() const
return value("Preferences/General/HideZeroValues", false).toBool();
}
void Preferences::setHideZeroValues(bool b)
void Preferences::setHideZeroValues(const bool b)
{
setValue("Preferences/General/HideZeroValues", b);
}
@ -154,7 +154,7 @@ int Preferences::getHideZeroComboValues() const @@ -154,7 +154,7 @@ int Preferences::getHideZeroComboValues() const
return value("Preferences/General/HideZeroComboValues", 0).toInt();
}
void Preferences::setHideZeroComboValues(int n)
void Preferences::setHideZeroComboValues(const int n)
{
setValue("Preferences/General/HideZeroComboValues", n);
}
@ -167,7 +167,7 @@ bool Preferences::systrayIntegration() const @@ -167,7 +167,7 @@ bool Preferences::systrayIntegration() const
return value("Preferences/General/SystrayEnabled", true).toBool();
}
void Preferences::setSystrayIntegration(bool enabled)
void Preferences::setSystrayIntegration(const bool enabled)
{
setValue("Preferences/General/SystrayEnabled", enabled);
}
@ -177,7 +177,7 @@ bool Preferences::minimizeToTray() const @@ -177,7 +177,7 @@ bool Preferences::minimizeToTray() const
return value("Preferences/General/MinimizeToTray", false).toBool();
}
void Preferences::setMinimizeToTray(bool b)
void Preferences::setMinimizeToTray(const bool b)
{
setValue("Preferences/General/MinimizeToTray", b);
}
@ -187,7 +187,7 @@ bool Preferences::minimizeToTrayNotified() const @@ -187,7 +187,7 @@ bool Preferences::minimizeToTrayNotified() const
return value("Preferences/General/MinimizeToTrayNotified", false).toBool();
}
void Preferences::setMinimizeToTrayNotified(bool b)
void Preferences::setMinimizeToTrayNotified(const bool b)
{
setValue("Preferences/General/MinimizeToTrayNotified", b);
}
@ -197,7 +197,7 @@ bool Preferences::closeToTray() const @@ -197,7 +197,7 @@ bool Preferences::closeToTray() const
return value("Preferences/General/CloseToTray", true).toBool();
}
void Preferences::setCloseToTray(bool b)
void Preferences::setCloseToTray(const bool b)
{
setValue("Preferences/General/CloseToTray", b);
}
@ -207,7 +207,7 @@ bool Preferences::closeToTrayNotified() const @@ -207,7 +207,7 @@ bool Preferences::closeToTrayNotified() const
return value("Preferences/General/CloseToTrayNotified", false).toBool();
}
void Preferences::setCloseToTrayNotified(bool b)
void Preferences::setCloseToTrayNotified(const bool b)
{
setValue("Preferences/General/CloseToTrayNotified", b);
}
@ -218,7 +218,7 @@ bool Preferences::isToolbarDisplayed() const @@ -218,7 +218,7 @@ bool Preferences::isToolbarDisplayed() const
return value("Preferences/General/ToolbarDisplayed", true).toBool();
}
void Preferences::setToolbarDisplayed(bool displayed)
void Preferences::setToolbarDisplayed(const bool displayed)
{
setValue("Preferences/General/ToolbarDisplayed", displayed);
}
@ -228,7 +228,7 @@ bool Preferences::isStatusbarDisplayed() const @@ -228,7 +228,7 @@ bool Preferences::isStatusbarDisplayed() const
return value("Preferences/General/StatusbarDisplayed", true).toBool();
}
void Preferences::setStatusbarDisplayed(bool displayed)
void Preferences::setStatusbarDisplayed(const bool displayed)
{
setValue("Preferences/General/StatusbarDisplayed", displayed);
}
@ -238,7 +238,7 @@ bool Preferences::startMinimized() const @@ -238,7 +238,7 @@ bool Preferences::startMinimized() const
return value("Preferences/General/StartMinimized", false).toBool();
}
void Preferences::setStartMinimized(bool b)
void Preferences::setStartMinimized(const bool b)
{
setValue("Preferences/General/StartMinimized", b);
}
@ -248,7 +248,7 @@ bool Preferences::isSplashScreenDisabled() const @@ -248,7 +248,7 @@ bool Preferences::isSplashScreenDisabled() const
return value("Preferences/General/NoSplashScreen", true).toBool();
}
void Preferences::setSplashScreenDisabled(bool b)
void Preferences::setSplashScreenDisabled(const bool b)
{
setValue("Preferences/General/NoSplashScreen", b);
}
@ -259,7 +259,7 @@ bool Preferences::preventFromSuspendWhenDownloading() const @@ -259,7 +259,7 @@ bool Preferences::preventFromSuspendWhenDownloading() const
return value("Preferences/General/PreventFromSuspendWhenDownloading", false).toBool();
}
void Preferences::setPreventFromSuspendWhenDownloading(bool b)
void Preferences::setPreventFromSuspendWhenDownloading(const bool b)
{
setValue("Preferences/General/PreventFromSuspendWhenDownloading", b);
}
@ -269,7 +269,7 @@ bool Preferences::preventFromSuspendWhenSeeding() const @@ -269,7 +269,7 @@ bool Preferences::preventFromSuspendWhenSeeding() const
return value("Preferences/General/PreventFromSuspendWhenSeeding", false).toBool();
}
void Preferences::setPreventFromSuspendWhenSeeding(bool b)
void Preferences::setPreventFromSuspendWhenSeeding(const bool b)
{
setValue("Preferences/General/PreventFromSuspendWhenSeeding", b);
}
@ -281,7 +281,7 @@ bool Preferences::WinStartup() const @@ -281,7 +281,7 @@ bool Preferences::WinStartup() const
return settings.contains("qBittorrent");
}
void Preferences::setWinStartup(bool b)
void Preferences::setWinStartup(const bool b)
{
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
if (b) {
@ -331,7 +331,7 @@ bool Preferences::isMailNotificationEnabled() const @@ -331,7 +331,7 @@ bool Preferences::isMailNotificationEnabled() const
return value("Preferences/MailNotification/enabled", false).toBool();
}
void Preferences::setMailNotificationEnabled(bool enabled)
void Preferences::setMailNotificationEnabled(const bool enabled)
{
setValue("Preferences/MailNotification/enabled", enabled);
}
@ -371,7 +371,7 @@ bool Preferences::getMailNotificationSMTPSSL() const @@ -371,7 +371,7 @@ bool Preferences::getMailNotificationSMTPSSL() const
return value("Preferences/MailNotification/req_ssl", false).toBool();
}
void Preferences::setMailNotificationSMTPSSL(bool use)
void Preferences::setMailNotificationSMTPSSL(const bool use)
{
setValue("Preferences/MailNotification/req_ssl", use);
}
@ -381,7 +381,7 @@ bool Preferences::getMailNotificationSMTPAuth() const @@ -381,7 +381,7 @@ bool Preferences::getMailNotificationSMTPAuth() const
return value("Preferences/MailNotification/req_auth", false).toBool();
}
void Preferences::setMailNotificationSMTPAuth(bool use)
void Preferences::setMailNotificationSMTPAuth(const bool use)
{
setValue("Preferences/MailNotification/req_auth", use);
}
@ -411,7 +411,7 @@ int Preferences::getActionOnDblClOnTorrentDl() const @@ -411,7 +411,7 @@ int Preferences::getActionOnDblClOnTorrentDl() const
return value("Preferences/Downloads/DblClOnTorDl", 0).toInt();
}
void Preferences::setActionOnDblClOnTorrentDl(int act)
void Preferences::setActionOnDblClOnTorrentDl(const int act)
{
setValue("Preferences/Downloads/DblClOnTorDl", act);
}
@ -421,7 +421,7 @@ int Preferences::getActionOnDblClOnTorrentFn() const @@ -421,7 +421,7 @@ int Preferences::getActionOnDblClOnTorrentFn() const
return value("Preferences/Downloads/DblClOnTorFn", 1).toInt();
}
void Preferences::setActionOnDblClOnTorrentFn(int act)
void Preferences::setActionOnDblClOnTorrentFn(const int act)
{
setValue("Preferences/Downloads/DblClOnTorFn", act);
}
@ -451,7 +451,7 @@ SchedulerDays Preferences::getSchedulerDays() const @@ -451,7 +451,7 @@ SchedulerDays Preferences::getSchedulerDays() const
return static_cast<SchedulerDays>(value("Preferences/Scheduler/days", EVERY_DAY).toInt());
}
void Preferences::setSchedulerDays(SchedulerDays days)
void Preferences::setSchedulerDays(const SchedulerDays days)
{
setValue("Preferences/Scheduler/days", static_cast<int>(days));
}
@ -462,7 +462,7 @@ bool Preferences::isSearchEnabled() const @@ -462,7 +462,7 @@ bool Preferences::isSearchEnabled() const
return value("Preferences/Search/SearchEnabled", false).toBool();
}
void Preferences::setSearchEnabled(bool enabled)
void Preferences::setSearchEnabled(const bool enabled)
{
setValue("Preferences/Search/SearchEnabled", enabled);
}
@ -476,7 +476,7 @@ bool Preferences::isWebUiEnabled() const @@ -476,7 +476,7 @@ bool Preferences::isWebUiEnabled() const
#endif
}
void Preferences::setWebUiEnabled(bool enabled)
void Preferences::setWebUiEnabled(const bool enabled)
{
setValue("Preferences/WebUI/Enabled", enabled);
}
@ -486,7 +486,7 @@ bool Preferences::isWebUiLocalAuthEnabled() const @@ -486,7 +486,7 @@ bool Preferences::isWebUiLocalAuthEnabled() const
return value("Preferences/WebUI/LocalHostAuth", true).toBool();
}
void Preferences::setWebUiLocalAuthEnabled(bool enabled)
void Preferences::setWebUiLocalAuthEnabled(const bool enabled)
{
setValue("Preferences/WebUI/LocalHostAuth", enabled);
}
@ -496,7 +496,7 @@ bool Preferences::isWebUiAuthSubnetWhitelistEnabled() const @@ -496,7 +496,7 @@ bool Preferences::isWebUiAuthSubnetWhitelistEnabled() const
return value("Preferences/WebUI/AuthSubnetWhitelistEnabled", false).toBool();
}
void Preferences::setWebUiAuthSubnetWhitelistEnabled(bool enabled)
void Preferences::setWebUiAuthSubnetWhitelistEnabled(const bool enabled)
{
setValue("Preferences/WebUI/AuthSubnetWhitelistEnabled", enabled);
}
@ -552,7 +552,7 @@ quint16 Preferences::getWebUiPort() const @@ -552,7 +552,7 @@ quint16 Preferences::getWebUiPort() const
return value("Preferences/WebUI/Port", 8080).toInt();
}
void Preferences::setWebUiPort(quint16 port)
void Preferences::setWebUiPort(const quint16 port)
{
setValue("Preferences/WebUI/Port", port);
}
@ -566,7 +566,7 @@ bool Preferences::useUPnPForWebUIPort() const @@ -566,7 +566,7 @@ bool Preferences::useUPnPForWebUIPort() const
#endif
}
void Preferences::setUPnPForWebUIPort(bool enabled)
void Preferences::setUPnPForWebUIPort(const bool enabled)
{
setValue("Preferences/WebUI/UseUPnP", enabled);
}
@ -598,7 +598,7 @@ bool Preferences::isWebUiClickjackingProtectionEnabled() const @@ -598,7 +598,7 @@ bool Preferences::isWebUiClickjackingProtectionEnabled() const
return value("Preferences/WebUI/ClickjackingProtection", true).toBool();
}
void Preferences::setWebUiClickjackingProtectionEnabled(bool enabled)
void Preferences::setWebUiClickjackingProtectionEnabled(const bool enabled)
{
setValue("Preferences/WebUI/ClickjackingProtection", enabled);
}
@ -608,7 +608,7 @@ bool Preferences::isWebUiCSRFProtectionEnabled() const @@ -608,7 +608,7 @@ bool Preferences::isWebUiCSRFProtectionEnabled() const
return value("Preferences/WebUI/CSRFProtection", true).toBool();
}
void Preferences::setWebUiCSRFProtectionEnabled(bool enabled)
void Preferences::setWebUiCSRFProtectionEnabled(const bool enabled)
{
setValue("Preferences/WebUI/CSRFProtection", enabled);
}
@ -628,7 +628,7 @@ bool Preferences::isWebUiHttpsEnabled() const @@ -628,7 +628,7 @@ bool Preferences::isWebUiHttpsEnabled() const
return value("Preferences/WebUI/HTTPS/Enabled", false).toBool();
}
void Preferences::setWebUiHttpsEnabled(bool enabled)
void Preferences::setWebUiHttpsEnabled(const bool enabled)
{
setValue("Preferences/WebUI/HTTPS/Enabled", enabled);
}
@ -658,7 +658,7 @@ bool Preferences::isAltWebUiEnabled() const @@ -658,7 +658,7 @@ bool Preferences::isAltWebUiEnabled() const
return value("Preferences/WebUI/AlternativeUIEnabled", false).toBool();
}
void Preferences::setAltWebUiEnabled(bool enabled)
void Preferences::setAltWebUiEnabled(const bool enabled)
{
setValue("Preferences/WebUI/AlternativeUIEnabled", enabled);
}
@ -678,7 +678,7 @@ bool Preferences::isDynDNSEnabled() const @@ -678,7 +678,7 @@ bool Preferences::isDynDNSEnabled() const
return value("Preferences/DynDNS/Enabled", false).toBool();
}
void Preferences::setDynDNSEnabled(bool enabled)
void Preferences::setDynDNSEnabled(const bool enabled)
{
setValue("Preferences/DynDNS/Enabled", enabled);
}
@ -688,7 +688,7 @@ DNS::Service Preferences::getDynDNSService() const @@ -688,7 +688,7 @@ DNS::Service Preferences::getDynDNSService() const
return DNS::Service(value("Preferences/DynDNS/Service", DNS::DYNDNS).toInt());
}
void Preferences::setDynDNSService(int service)
void Preferences::setDynDNSService(const int service)
{
setValue("Preferences/DynDNS/Service", service);
}
@ -739,7 +739,7 @@ bool Preferences::isUILocked() const @@ -739,7 +739,7 @@ bool Preferences::isUILocked() const
return value("Locking/locked", false).toBool();
}
void Preferences::setUILocked(bool locked)
void Preferences::setUILocked(const bool locked)
{
return setValue("Locking/locked", locked);
}
@ -749,7 +749,7 @@ bool Preferences::isAutoRunEnabled() const @@ -749,7 +749,7 @@ bool Preferences::isAutoRunEnabled() const
return value("AutoRun/enabled", false).toBool();
}
void Preferences::setAutoRunEnabled(bool enabled)
void Preferences::setAutoRunEnabled(const bool enabled)
{
return setValue("AutoRun/enabled", enabled);
}
@ -769,7 +769,7 @@ bool Preferences::shutdownWhenDownloadsComplete() const @@ -769,7 +769,7 @@ bool Preferences::shutdownWhenDownloadsComplete() const
return value("Preferences/Downloads/AutoShutDownOnCompletion", false).toBool();
}
void Preferences::setShutdownWhenDownloadsComplete(bool shutdown)
void Preferences::setShutdownWhenDownloadsComplete(const bool shutdown)
{
setValue("Preferences/Downloads/AutoShutDownOnCompletion", shutdown);
}
@ -779,7 +779,7 @@ bool Preferences::suspendWhenDownloadsComplete() const @@ -779,7 +779,7 @@ bool Preferences::suspendWhenDownloadsComplete() const
return value("Preferences/Downloads/AutoSuspendOnCompletion", false).toBool();
}
void Preferences::setSuspendWhenDownloadsComplete(bool suspend)
void Preferences::setSuspendWhenDownloadsComplete(const bool suspend)
{
setValue("Preferences/Downloads/AutoSuspendOnCompletion", suspend);
}
@ -789,7 +789,7 @@ bool Preferences::hibernateWhenDownloadsComplete() const @@ -789,7 +789,7 @@ bool Preferences::hibernateWhenDownloadsComplete() const
return value("Preferences/Downloads/AutoHibernateOnCompletion", false).toBool();
}
void Preferences::setHibernateWhenDownloadsComplete(bool hibernate)
void Preferences::setHibernateWhenDownloadsComplete(const bool hibernate)
{
setValue("Preferences/Downloads/AutoHibernateOnCompletion", hibernate);
}
@ -799,7 +799,7 @@ bool Preferences::shutdownqBTWhenDownloadsComplete() const @@ -799,7 +799,7 @@ bool Preferences::shutdownqBTWhenDownloadsComplete() const
return value("Preferences/Downloads/AutoShutDownqBTOnCompletion", false).toBool();
}
void Preferences::setShutdownqBTWhenDownloadsComplete(bool shutdown)
void Preferences::setShutdownqBTWhenDownloadsComplete(const bool shutdown)
{
setValue("Preferences/Downloads/AutoShutDownqBTOnCompletion", shutdown);
}
@ -809,7 +809,7 @@ bool Preferences::dontConfirmAutoExit() const @@ -809,7 +809,7 @@ bool Preferences::dontConfirmAutoExit() const
return value("ShutdownConfirmDlg/DontConfirmAutoExit", false).toBool();
}
void Preferences::setDontConfirmAutoExit(bool dontConfirmAutoExit)
void Preferences::setDontConfirmAutoExit(const bool dontConfirmAutoExit)
{
setValue("ShutdownConfirmDlg/DontConfirmAutoExit", dontConfirmAutoExit);
}
@ -819,7 +819,7 @@ bool Preferences::recheckTorrentsOnCompletion() const @@ -819,7 +819,7 @@ bool Preferences::recheckTorrentsOnCompletion() const
return value("Preferences/Advanced/RecheckOnCompletion", false).toBool();
}
void Preferences::recheckTorrentsOnCompletion(bool recheck)
void Preferences::recheckTorrentsOnCompletion(const bool recheck)
{
setValue("Preferences/Advanced/RecheckOnCompletion", recheck);
}
@ -829,7 +829,7 @@ bool Preferences::resolvePeerCountries() const @@ -829,7 +829,7 @@ bool Preferences::resolvePeerCountries() const
return value("Preferences/Connection/ResolvePeerCountries", true).toBool();
}
void Preferences::resolvePeerCountries(bool resolve)
void Preferences::resolvePeerCountries(const bool resolve)
{
setValue("Preferences/Connection/ResolvePeerCountries", resolve);
}
@ -839,7 +839,7 @@ bool Preferences::resolvePeerHostNames() const @@ -839,7 +839,7 @@ bool Preferences::resolvePeerHostNames() const
return value("Preferences/Connection/ResolvePeerHostNames", false).toBool();
}
void Preferences::resolvePeerHostNames(bool resolve)
void Preferences::resolvePeerHostNames(const bool resolve)
{
setValue("Preferences/Connection/ResolvePeerHostNames", resolve);
}
@ -850,7 +850,7 @@ bool Preferences::useSystemIconTheme() const @@ -850,7 +850,7 @@ bool Preferences::useSystemIconTheme() const
return value("Preferences/Advanced/useSystemIconTheme", true).toBool();
}
void Preferences::useSystemIconTheme(bool enabled)
void Preferences::useSystemIconTheme(const bool enabled)
{
setValue("Preferences/Advanced/useSystemIconTheme", enabled);
}
@ -861,7 +861,7 @@ bool Preferences::recursiveDownloadDisabled() const @@ -861,7 +861,7 @@ bool Preferences::recursiveDownloadDisabled() const
return value("Preferences/Advanced/DisableRecursiveDownload", false).toBool();
}
void Preferences::disableRecursiveDownload(bool disable)
void Preferences::disableRecursiveDownload(const bool disable)
{
setValue("Preferences/Advanced/DisableRecursiveDownload", disable);
}
@ -872,14 +872,14 @@ bool Preferences::neverCheckFileAssoc() const @@ -872,14 +872,14 @@ bool Preferences::neverCheckFileAssoc() const
return value("Preferences/Win32/NeverCheckFileAssocation", false).toBool();
}
void Preferences::setNeverCheckFileAssoc(bool check)
void Preferences::setNeverCheckFileAssoc(const bool check)
{
setValue("Preferences/Win32/NeverCheckFileAssocation", check);
}
bool Preferences::isTorrentFileAssocSet()
{
QSettings settings("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
const QSettings settings("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
if (settings.value(".torrent/Default").toString() != "qBittorrent") {
qDebug(".torrent != qBittorrent");
return false;
@ -890,7 +890,7 @@ bool Preferences::isTorrentFileAssocSet() @@ -890,7 +890,7 @@ bool Preferences::isTorrentFileAssocSet()
bool Preferences::isMagnetLinkAssocSet()
{
QSettings settings("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
const QSettings settings("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
// Check magnet link assoc
const QString shellCommand = Utils::Fs::toNativePath(settings.value("magnet/shell/open/command/Default", "").toString());
@ -906,13 +906,13 @@ bool Preferences::isMagnetLinkAssocSet() @@ -906,13 +906,13 @@ bool Preferences::isMagnetLinkAssocSet()
return true;
}
void Preferences::setTorrentFileAssoc(bool set)
void Preferences::setTorrentFileAssoc(const bool set)
{
QSettings settings("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
// .Torrent association
if (set) {
QString oldProgId = settings.value(".torrent/Default").toString();
const QString oldProgId = settings.value(".torrent/Default").toString();
if (!oldProgId.isEmpty() && (oldProgId != "qBittorrent"))
settings.setValue(".torrent/OpenWithProgids/" + oldProgId, "");
settings.setValue(".torrent/Default", "qBittorrent");
@ -924,7 +924,7 @@ void Preferences::setTorrentFileAssoc(bool set) @@ -924,7 +924,7 @@ void Preferences::setTorrentFileAssoc(bool set)
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
}
void Preferences::setMagnetLinkAssoc(bool set)
void Preferences::setMagnetLinkAssoc(const bool set)
{
QSettings settings("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
@ -951,18 +951,18 @@ void Preferences::setMagnetLinkAssoc(bool set) @@ -951,18 +951,18 @@ void Preferences::setMagnetLinkAssoc(bool set)
#ifdef Q_OS_MAC
namespace
{
CFStringRef torrentExtension = CFSTR("torrent");
CFStringRef magnetUrlScheme = CFSTR("magnet");
const CFStringRef torrentExtension = CFSTR("torrent");
const CFStringRef magnetUrlScheme = CFSTR("magnet");
}
bool Preferences::isTorrentFileAssocSet()
{
bool isSet = false;
CFStringRef torrentId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, torrentExtension, NULL);
const CFStringRef torrentId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, torrentExtension, NULL);
if (torrentId != NULL) {
CFStringRef defaultHandlerId = LSCopyDefaultRoleHandlerForContentType(torrentId, kLSRolesViewer);
const CFStringRef defaultHandlerId = LSCopyDefaultRoleHandlerForContentType(torrentId, kLSRolesViewer);
if (defaultHandlerId != NULL) {
CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
isSet = CFStringCompare(myBundleId, defaultHandlerId, 0) == kCFCompareEqualTo;
CFRelease(defaultHandlerId);
}
@ -974,9 +974,9 @@ bool Preferences::isTorrentFileAssocSet() @@ -974,9 +974,9 @@ bool Preferences::isTorrentFileAssocSet()
bool Preferences::isMagnetLinkAssocSet()
{
bool isSet = false;
CFStringRef defaultHandlerId = LSCopyDefaultHandlerForURLScheme(magnetUrlScheme);
const CFStringRef defaultHandlerId = LSCopyDefaultHandlerForURLScheme(magnetUrlScheme);
if (defaultHandlerId != NULL) {
CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
isSet = CFStringCompare(myBundleId, defaultHandlerId, 0) == kCFCompareEqualTo;
CFRelease(defaultHandlerId);
}
@ -987,9 +987,9 @@ void Preferences::setTorrentFileAssoc() @@ -987,9 +987,9 @@ void Preferences::setTorrentFileAssoc()
{
if (isTorrentFileAssocSet())
return;
CFStringRef torrentId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, torrentExtension, NULL);
const CFStringRef torrentId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, torrentExtension, NULL);
if (torrentId != NULL) {
CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
LSSetDefaultRoleHandlerForContentType(torrentId, kLSRolesViewer, myBundleId);
CFRelease(torrentId);
}
@ -999,7 +999,7 @@ void Preferences::setMagnetLinkAssoc() @@ -999,7 +999,7 @@ void Preferences::setMagnetLinkAssoc()
{
if (isMagnetLinkAssocSet())
return;
CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
LSSetDefaultHandlerForURLScheme(magnetUrlScheme, myBundleId);
}
#endif // Q_OS_MAC
@ -1009,7 +1009,7 @@ int Preferences::getTrackerPort() const @@ -1009,7 +1009,7 @@ int Preferences::getTrackerPort() const
return value("Preferences/Advanced/trackerPort", 9000).toInt();
}
void Preferences::setTrackerPort(int port)
void Preferences::setTrackerPort(const int port)
{
setValue("Preferences/Advanced/trackerPort", port);
}
@ -1020,7 +1020,7 @@ bool Preferences::isUpdateCheckEnabled() const @@ -1020,7 +1020,7 @@ bool Preferences::isUpdateCheckEnabled() const
return value("Preferences/Advanced/updateCheck", true).toBool();
}
void Preferences::setUpdateCheckEnabled(bool enabled)
void Preferences::setUpdateCheckEnabled(const bool enabled)
{
setValue("Preferences/Advanced/updateCheck", enabled);
}
@ -1031,7 +1031,7 @@ bool Preferences::confirmTorrentDeletion() const @@ -1031,7 +1031,7 @@ bool Preferences::confirmTorrentDeletion() const
return value("Preferences/Advanced/confirmTorrentDeletion", true).toBool();
}
void Preferences::setConfirmTorrentDeletion(bool enabled)
void Preferences::setConfirmTorrentDeletion(const bool enabled)
{
setValue("Preferences/Advanced/confirmTorrentDeletion", enabled);
}
@ -1041,7 +1041,7 @@ bool Preferences::confirmTorrentRecheck() const @@ -1041,7 +1041,7 @@ bool Preferences::confirmTorrentRecheck() const
return value("Preferences/Advanced/confirmTorrentRecheck", true).toBool();
}
void Preferences::setConfirmTorrentRecheck(bool enabled)
void Preferences::setConfirmTorrentRecheck(const bool enabled)
{
setValue("Preferences/Advanced/confirmTorrentRecheck", enabled);
}
@ -1051,7 +1051,7 @@ bool Preferences::confirmRemoveAllTags() const @@ -1051,7 +1051,7 @@ bool Preferences::confirmRemoveAllTags() const
return value("Preferences/Advanced/confirmRemoveAllTags", true).toBool();
}
void Preferences::setConfirmRemoveAllTags(bool enabled)
void Preferences::setConfirmRemoveAllTags(const bool enabled)
{
setValue("Preferences/Advanced/confirmRemoveAllTags", enabled);
}
@ -1062,7 +1062,7 @@ TrayIcon::Style Preferences::trayIconStyle() const @@ -1062,7 +1062,7 @@ TrayIcon::Style Preferences::trayIconStyle() const
return TrayIcon::Style(value("Preferences/Advanced/TrayIconStyle", TrayIcon::NORMAL).toInt());
}
void Preferences::setTrayIconStyle(TrayIcon::Style style)
void Preferences::setTrayIconStyle(const TrayIcon::Style style)
{
setValue("Preferences/Advanced/TrayIconStyle", style);
}
@ -1186,7 +1186,7 @@ int Preferences::getPropCurTab() const @@ -1186,7 +1186,7 @@ int Preferences::getPropCurTab() const
return value("TorrentProperties/CurrentTab", -1).toInt();
}
void Preferences::setPropCurTab(const int &tab)
void Preferences::setPropCurTab(const int tab)
{
setValue("TorrentProperties/CurrentTab", tab);
}
@ -1356,7 +1356,7 @@ int Preferences::getTransSelFilter() const @@ -1356,7 +1356,7 @@ int Preferences::getTransSelFilter() const
return value("TransferListFilters/selectedFilterIndex", 0).toInt();
}
void Preferences::setTransSelFilter(const int &index)
void Preferences::setTransSelFilter(const int index)
{
setValue("TransferListFilters/selectedFilterIndex", index);
}
@ -1426,7 +1426,7 @@ bool Preferences::isSpeedWidgetEnabled() const @@ -1426,7 +1426,7 @@ bool Preferences::isSpeedWidgetEnabled() const
return value("SpeedWidget/Enabled", true).toBool();
}
void Preferences::setSpeedWidgetEnabled(bool enabled)
void Preferences::setSpeedWidgetEnabled(const bool enabled)
{
setValue("SpeedWidget/Enabled", enabled);
}
@ -1441,13 +1441,13 @@ void Preferences::setSpeedWidgetPeriod(const int period) @@ -1441,13 +1441,13 @@ void Preferences::setSpeedWidgetPeriod(const int period)
setValue("SpeedWidget/period", period);
}
bool Preferences::getSpeedWidgetGraphEnable(int id) const
bool Preferences::getSpeedWidgetGraphEnable(const int id) const
{
// UP and DOWN graphs enabled by default
return value("SpeedWidget/graph_enable_" + QString::number(id), (id == 0 || id == 1)).toBool();
}
void Preferences::setSpeedWidgetGraphEnable(int id, const bool enable)
void Preferences::setSpeedWidgetGraphEnable(const int id, const bool enable)
{
setValue("SpeedWidget/graph_enable_" + QString::number(id), enable);
}

18
src/base/preferences.h

@ -83,7 +83,7 @@ class Preferences : public QObject @@ -83,7 +83,7 @@ class Preferences : public QObject
Preferences();
const QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;
const QVariant value(const QString &key, const QVariant &defaultValue = {}) const;
void setValue(const QString &key, const QVariant &value);
static Preferences *m_instance;
@ -303,7 +303,7 @@ public: @@ -303,7 +303,7 @@ public:
QString getDNSLastIP() const;
void setDNSLastIP(const QString &ip);
bool getAcceptedLegal() const;
void setAcceptedLegal(const bool accepted);
void setAcceptedLegal(bool accepted);
QByteArray getMainGeometry() const;
void setMainGeometry(const QByteArray &geometry);
QByteArray getMainVSplitterState() const;
@ -321,9 +321,9 @@ public: @@ -321,9 +321,9 @@ public:
QByteArray getPropFileListState() const;
void setPropFileListState(const QByteArray &state);
int getPropCurTab() const;
void setPropCurTab(const int &tab);
void setPropCurTab(int tab);
bool getPropVisible() const;
void setPropVisible(const bool visible);
void setPropVisible(bool visible);
QByteArray getPropTrackerListState() const;
void setPropTrackerListState(const QByteArray &state);
QSize getRssGeometrySize() const;
@ -351,17 +351,17 @@ public: @@ -351,17 +351,17 @@ public:
bool getTagFilterState() const;
bool getTrackerFilterState() const;
int getTransSelFilter() const;
void setTransSelFilter(const int &index);
void setTransSelFilter(int index);
QByteArray getTransHeaderState() const;
void setTransHeaderState(const QByteArray &state);
bool getRegexAsFilteringPatternForTransferList() const;
void setRegexAsFilteringPatternForTransferList(bool checked);
int getToolbarTextPosition() const;
void setToolbarTextPosition(const int position);
void setToolbarTextPosition(int position);
// From old RssSettings class
bool isRSSWidgetEnabled() const;
void setRSSWidgetVisible(const bool enabled);
void setRSSWidgetVisible(bool enabled);
// Network
QList<QNetworkCookie> getNetworkCookies() const;
@ -371,9 +371,9 @@ public: @@ -371,9 +371,9 @@ public:
bool isSpeedWidgetEnabled() const;
void setSpeedWidgetEnabled(bool enabled);
int getSpeedWidgetPeriod() const;
void setSpeedWidgetPeriod(const int period);
void setSpeedWidgetPeriod(int period);
bool getSpeedWidgetGraphEnable(int id) const;
void setSpeedWidgetGraphEnable(int id, const bool enable);
void setSpeedWidgetGraphEnable(int id, bool enable);
public slots:
void setStatusFilterState(bool checked);

8
src/base/private/profile_p.cpp

@ -103,7 +103,7 @@ SettingsPtr Private::DefaultProfile::applicationSettings(const QString &name) co @@ -103,7 +103,7 @@ SettingsPtr Private::DefaultProfile::applicationSettings(const QString &name) co
#endif
}
QString Private::DefaultProfile::locationWithConfigurationName(QStandardPaths::StandardLocation location) const
QString Private::DefaultProfile::locationWithConfigurationName(const QStandardPaths::StandardLocation location) const
{
return QStandardPaths::writableLocation(location) + configurationSuffix();
}
@ -174,9 +174,9 @@ QString Private::Converter::toPortablePath(const QString &path) const @@ -174,9 +174,9 @@ QString Private::Converter::toPortablePath(const QString &path) const
#ifdef Q_OS_WIN
if (QDir::isAbsolutePath(path)) {
QChar driveLeter = path[0].toUpper();
QChar baseDriveLetter = m_baseDir.path()[0].toUpper();
bool onSameDrive = (driveLeter.category() == QChar::Letter_Uppercase) && (driveLeter == baseDriveLetter);
const QChar driveLeter = path[0].toUpper();
const QChar baseDriveLetter = m_baseDir.path()[0].toUpper();
const bool onSameDrive = (driveLeter.category() == QChar::Letter_Uppercase) && (driveLeter == baseDriveLetter);
if (!onSameDrive)
return path;
}

6
src/base/profile.cpp

@ -65,7 +65,7 @@ const Profile &Profile::instance() @@ -65,7 +65,7 @@ const Profile &Profile::instance()
return *m_instance;
}
QString Profile::location(SpecialFolder folder) const
QString Profile::location(const SpecialFolder folder) const
{
QString result;
switch (folder) {
@ -98,9 +98,9 @@ SettingsPtr Profile::applicationSettings(const QString &name) const @@ -98,9 +98,9 @@ SettingsPtr Profile::applicationSettings(const QString &name) const
return m_profileImpl->applicationSettings(name);
}
void Profile::ensureDirectoryExists(SpecialFolder folder)
void Profile::ensureDirectoryExists(const SpecialFolder folder)
{
QString locationPath = location(folder);
const QString locationPath = location(folder);
if (!locationPath.isEmpty() && !QDir().mkpath(locationPath))
qFatal("Could not create required directory '%s'", qUtf8Printable(locationPath));
}

28
src/base/rss/private/rss_parser.cpp

@ -396,8 +396,8 @@ namespace @@ -396,8 +396,8 @@ namespace
if (!str.indexOf(rx)) {
// Check that if date has '-' separators, both separators are '-'.
parts = rx.capturedTexts();
bool h1 = (parts[3] == QLatin1String("-"));
bool h2 = (parts[5] == QLatin1String("-"));
const bool h1 = (parts[3] == QLatin1String("-"));
const bool h2 = (parts[5] == QLatin1String("-"));
if (h1 != h2)
return QDateTime::currentDateTime();
}
@ -431,7 +431,7 @@ namespace @@ -431,7 +431,7 @@ namespace
return QDateTime::currentDateTime();
}
bool leapSecond = (second == 60);
const bool leapSecond = (second == 60);
if (leapSecond)
second = 59; // apparently a leap second - validate below, once time zone is known
int month = 0;
@ -447,7 +447,7 @@ namespace @@ -447,7 +447,7 @@ namespace
// if (month >= 12 || dayOfWeek >= 7
// || (dayOfWeek < 0 && format == RFCDateDay))
// return QDateTime;
int i = parts[nyear].size();
const int i = parts[nyear].size();
if (i < 4) {
// It's an obsolete year specification with less than 4 digits
year += ((i == 2) && (year < 50)) ? 2000 : 1900;
@ -462,7 +462,7 @@ namespace @@ -462,7 +462,7 @@ namespace
// It's a UTC offset ±hhmm
parts = rx.capturedTexts();
offset = parts[2].toInt(&ok[0]) * 3600;
int offsetMin = parts[3].toInt(&ok[1]);
const int offsetMin = parts[3].toInt(&ok[1]);
if (!ok[0] || !ok[1] || offsetMin > 59)
return {};
offset += offsetMin * 60;
@ -472,7 +472,7 @@ namespace @@ -472,7 +472,7 @@ namespace
}
else {
// Check for an obsolete time zone name
QByteArray zone = parts[10].toLatin1();
const QByteArray zone = parts[10].toLatin1();
if ((zone.length() == 1) && (isalpha(zone[0])) && (toupper(zone[0]) != 'J')) {
negOffset = true; // military zone: RFC 2822 treats as '-0000'
}
@ -502,11 +502,11 @@ namespace @@ -502,11 +502,11 @@ namespace
}
}
QDate qDate(year, month + 1, day); // convert date, and check for out-of-range
const QDate qDate(year, month + 1, day); // convert date, and check for out-of-range
if (!qDate.isValid())
return QDateTime::currentDateTime();
QTime qTime(hour, minute, second);
const QTime qTime(hour, minute, second);
QDateTime result(qDate, qTime, Qt::UTC);
if (offset)
result = result.addSecs(-offset);
@ -528,7 +528,7 @@ using namespace RSS::Private; @@ -528,7 +528,7 @@ using namespace RSS::Private;
const int ParsingResultTypeId = qRegisterMetaType<ParsingResult>();
Parser::Parser(QString lastBuildDate)
Parser::Parser(const QString lastBuildDate)
{
m_result.lastBuildDate = lastBuildDate;
}
@ -642,7 +642,7 @@ void Parser::parseRSSChannel(QXmlStreamReader &xml) @@ -642,7 +642,7 @@ void Parser::parseRSSChannel(QXmlStreamReader &xml)
m_result.title = xml.readElementText();
}
else if (xml.name() == QLatin1String("lastBuildDate")) {
QString lastBuildDate = xml.readElementText();
const QString lastBuildDate = xml.readElementText();
if (!lastBuildDate.isEmpty()) {
if (m_result.lastBuildDate == lastBuildDate) {
qDebug() << "The RSS feed has not changed since last time, aborting parsing.";
@ -675,7 +675,7 @@ void Parser::parseAtomArticle(QXmlStreamReader &xml) @@ -675,7 +675,7 @@ void Parser::parseAtomArticle(QXmlStreamReader &xml)
article[Article::KeyTitle] = xml.readElementText().trimmed();
}
else if (name == QLatin1String("link")) {
QString link = (xml.attributes().isEmpty()
const QString link = (xml.attributes().isEmpty()
? xml.readElementText().trimmed()
: xml.attributes().value(QLatin1String("href")).toString());
@ -696,7 +696,7 @@ void Parser::parseAtomArticle(QXmlStreamReader &xml) @@ -696,7 +696,7 @@ void Parser::parseAtomArticle(QXmlStreamReader &xml)
// Try to also parse broken articles, which don't use html '&' escapes
// Actually works great for non-broken content too
QString feedText = xml.readElementText(QXmlStreamReader::IncludeChildElements).trimmed();
const QString feedText = xml.readElementText(QXmlStreamReader::IncludeChildElements).trimmed();
if (!feedText.isEmpty()) {
article[Article::KeyDescription] = feedText;
doubleContent = true;
@ -704,7 +704,7 @@ void Parser::parseAtomArticle(QXmlStreamReader &xml) @@ -704,7 +704,7 @@ void Parser::parseAtomArticle(QXmlStreamReader &xml)
}
else if (name == QLatin1String("updated")) {
// ATOM uses standard compliant date, don't do fancy stuff
QDateTime articleDate = QDateTime::fromString(xml.readElementText().trimmed(), Qt::ISODate);
const QDateTime articleDate = QDateTime::fromString(xml.readElementText().trimmed(), Qt::ISODate);
article[Article::KeyDate] = (articleDate.isValid() ? articleDate : QDateTime::currentDateTime());
}
else if (name == QLatin1String("author")) {
@ -739,7 +739,7 @@ void Parser::parseAtomChannel(QXmlStreamReader &xml) @@ -739,7 +739,7 @@ void Parser::parseAtomChannel(QXmlStreamReader &xml)
m_result.title = xml.readElementText();
}
else if (xml.name() == QLatin1String("updated")) {
QString lastBuildDate = xml.readElementText();
const QString lastBuildDate = xml.readElementText();
if (!lastBuildDate.isEmpty()) {
if (m_result.lastBuildDate == lastBuildDate) {
qDebug() << "The RSS feed has not changed since last time, aborting parsing.";

2
src/base/rss/rss_article.cpp

@ -142,7 +142,7 @@ QJsonObject Article::toJsonObject() const @@ -142,7 +142,7 @@ QJsonObject Article::toJsonObject() const
return jsonObj;
}
bool Article::articleDateRecentThan(Article *article, const QDateTime &date)
bool Article::articleDateRecentThan(const Article *article, const QDateTime &date)
{
return article->date() > date;
}

2
src/base/rss/rss_article.h

@ -74,7 +74,7 @@ namespace RSS @@ -74,7 +74,7 @@ namespace RSS
QJsonObject toJsonObject() const;
static bool articleDateRecentThan(Article *article, const QDateTime &date);
static bool articleDateRecentThan(const Article *article, const QDateTime &date);
signals:
void read(Article *article = nullptr);

18
src/base/rss/rss_autodownloader.cpp

@ -73,7 +73,7 @@ namespace @@ -73,7 +73,7 @@ namespace
QVector<RSS::AutoDownloadRule> rulesFromJSON(const QByteArray &jsonData)
{
QJsonParseError jsonError;
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData, &jsonError);
const QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData, &jsonError);
if (jsonError.error != QJsonParseError::NoError)
throw RSS::ParsingError(jsonError.errorString());
@ -227,7 +227,7 @@ QByteArray AutoDownloader::exportRules(AutoDownloader::RulesFileFormat format) c @@ -227,7 +227,7 @@ QByteArray AutoDownloader::exportRules(AutoDownloader::RulesFileFormat format) c
}
}
void AutoDownloader::importRules(const QByteArray &data, AutoDownloader::RulesFileFormat format)
void AutoDownloader::importRules(const QByteArray &data, const AutoDownloader::RulesFileFormat format)
{
switch (format) {
case RulesFileFormat::Legacy:
@ -333,7 +333,7 @@ void AutoDownloader::process() @@ -333,7 +333,7 @@ void AutoDownloader::process()
void AutoDownloader::handleTorrentDownloadFinished(const QString &url)
{
auto job = m_waitingJobs.take(url);
const auto job = m_waitingJobs.take(url);
if (!job) return;
if (Feed *feed = Session::instance()->feedByURL(job->feedURL))
@ -347,7 +347,7 @@ void AutoDownloader::handleTorrentDownloadFailed(const QString &url) @@ -347,7 +347,7 @@ void AutoDownloader::handleTorrentDownloadFailed(const QString &url)
// TODO: Re-schedule job here.
}
void AutoDownloader::handleNewArticle(Article *article)
void AutoDownloader::handleNewArticle(const Article *article)
{
if (!article->isRead() && !article->torrentUrl().isEmpty())
addJobForArticle(article);
@ -358,7 +358,7 @@ void AutoDownloader::setRule_impl(const AutoDownloadRule &rule) @@ -358,7 +358,7 @@ void AutoDownloader::setRule_impl(const AutoDownloadRule &rule)
m_rules.insert(rule.name(), rule);
}
void AutoDownloader::addJobForArticle(Article *article)
void AutoDownloader::addJobForArticle(const Article *article)
{
const QString torrentURL = article->torrentUrl();
if (m_waitingJobs.contains(torrentURL)) return;
@ -387,7 +387,7 @@ void AutoDownloader::processJob(const QSharedPointer<ProcessingJob> &job) @@ -387,7 +387,7 @@ void AutoDownloader::processJob(const QSharedPointer<ProcessingJob> &job)
params.addPaused = rule.addPaused();
if (!rule.savePath().isEmpty())
params.useAutoTMM = TriStateBool::False;
auto torrentURL = job->articleData.value(Article::KeyTorrentURL).toString();
const auto torrentURL = job->articleData.value(Article::KeyTorrentURL).toString();
BitTorrent::Session::instance()->addTorrent(torrentURL, params);
if (BitTorrent::MagnetUri(torrentURL).isValid()) {
@ -434,10 +434,10 @@ void AutoDownloader::loadRules(const QByteArray &data) @@ -434,10 +434,10 @@ void AutoDownloader::loadRules(const QByteArray &data)
void AutoDownloader::loadRulesLegacy()
{
SettingsPtr settings = Profile::instance().applicationSettings(QStringLiteral("qBittorrent-rss"));
const SettingsPtr settings = Profile::instance().applicationSettings(QStringLiteral("qBittorrent-rss"));
const QVariantHash rules = settings->value(QStringLiteral("download_rules")).toHash();
for (const QVariant &ruleVar : rules) {
auto rule = AutoDownloadRule::fromLegacyDict(ruleVar.toHash());
const auto rule = AutoDownloadRule::fromLegacyDict(ruleVar.toHash());
if (!rule.name().isEmpty())
insertRule(rule);
}
@ -485,7 +485,7 @@ void AutoDownloader::startProcessing() @@ -485,7 +485,7 @@ void AutoDownloader::startProcessing()
connect(Session::instance()->rootFolder(), &Folder::newArticle, this, &AutoDownloader::handleNewArticle);
}
void AutoDownloader::setProcessingEnabled(bool enabled)
void AutoDownloader::setProcessingEnabled(const bool enabled)
{
if (m_processingEnabled != enabled) {
m_processingEnabled = enabled;

4
src/base/rss/rss_autodownloader.h

@ -110,14 +110,14 @@ namespace RSS @@ -110,14 +110,14 @@ namespace RSS
void process();
void handleTorrentDownloadFinished(const QString &url);
void handleTorrentDownloadFailed(const QString &url);
void handleNewArticle(Article *article);
void handleNewArticle(const Article *article);
private:
void timerEvent(QTimerEvent *event) override;
void setRule_impl(const AutoDownloadRule &rule);
void resetProcessingQueue();
void startProcessing();
void addJobForArticle(Article *article);
void addJobForArticle(const Article *article);
void processJob(const QSharedPointer<ProcessingJob> &job);
void load();
void loadRules(const QByteArray &data);

18
src/base/rss/rss_autodownloadrule.cpp

@ -72,7 +72,7 @@ namespace @@ -72,7 +72,7 @@ namespace
}
}
TriStateBool addPausedLegacyToTriStateBool(int val)
TriStateBool addPausedLegacyToTriStateBool(const int val)
{
switch (val) {
case 1: return TriStateBool::True; // always
@ -163,13 +163,13 @@ QString computeEpisodeName(const QString &article) @@ -163,13 +163,13 @@ QString computeEpisodeName(const QString &article)
QStringList ret;
for (int i = 1; i <= match.lastCapturedIndex(); ++i) {
QString cap = match.captured(i);
const QString cap = match.captured(i);
if (cap.isEmpty())
continue;
bool isInt = false;
int x = cap.toInt(&isInt);
const int x = cap.toInt(&isInt);
ret.append(isInt ? QString::number(x) : cap);
}
@ -189,7 +189,7 @@ AutoDownloadRule::AutoDownloadRule(const AutoDownloadRule &other) @@ -189,7 +189,7 @@ AutoDownloadRule::AutoDownloadRule(const AutoDownloadRule &other)
AutoDownloadRule::~AutoDownloadRule() {}
QRegularExpression AutoDownloadRule::cachedRegex(const QString &expression, bool isRegex) const
QRegularExpression AutoDownloadRule::cachedRegex(const QString &expression, const bool isRegex) const
{
// Use a cache of regexes so we don't have to continually recompile - big performance increase.
// The cache is cleared whenever the regex/wildcard, must or must not contain fields or
@ -216,7 +216,7 @@ bool AutoDownloadRule::matchesExpression(const QString &articleTitle, const QStr @@ -216,7 +216,7 @@ bool AutoDownloadRule::matchesExpression(const QString &articleTitle, const QStr
}
if (m_dataPtr->useRegex) {
QRegularExpression reg(cachedRegex(expression));
const QRegularExpression reg(cachedRegex(expression));
return reg.match(articleTitle).hasMatch();
}
@ -600,7 +600,7 @@ bool AutoDownloadRule::isEnabled() const @@ -600,7 +600,7 @@ bool AutoDownloadRule::isEnabled() const
return m_dataPtr->enabled;
}
void AutoDownloadRule::setEnabled(bool enable)
void AutoDownloadRule::setEnabled(const bool enable)
{
m_dataPtr->enabled = enable;
}
@ -615,7 +615,7 @@ void AutoDownloadRule::setLastMatch(const QDateTime &lastMatch) @@ -615,7 +615,7 @@ void AutoDownloadRule::setLastMatch(const QDateTime &lastMatch)
m_dataPtr->lastMatch = lastMatch;
}
void AutoDownloadRule::setIgnoreDays(int d)
void AutoDownloadRule::setIgnoreDays(const int d)
{
m_dataPtr->ignoreDays = d;
}
@ -640,7 +640,7 @@ bool AutoDownloadRule::useSmartFilter() const @@ -640,7 +640,7 @@ bool AutoDownloadRule::useSmartFilter() const
return m_dataPtr->smartFilter;
}
void AutoDownloadRule::setUseSmartFilter(bool enabled)
void AutoDownloadRule::setUseSmartFilter(const bool enabled)
{
m_dataPtr->smartFilter = enabled;
}
@ -650,7 +650,7 @@ bool AutoDownloadRule::useRegex() const @@ -650,7 +650,7 @@ bool AutoDownloadRule::useRegex() const
return m_dataPtr->useRegex;
}
void AutoDownloadRule::setUseRegex(bool enabled)
void AutoDownloadRule::setUseRegex(const bool enabled)
{
m_dataPtr->useRegex = enabled;
m_dataPtr->cachedRegexes.clear();

20
src/base/rss/rss_feed.cpp

@ -108,7 +108,7 @@ QList<Article *> Feed::articles() const @@ -108,7 +108,7 @@ QList<Article *> Feed::articles() const
void Feed::markAsRead()
{
auto oldUnreadCount = m_unreadCount;
const int oldUnreadCount = m_unreadCount;
for (Article *article : asConst(m_articles)) {
if (!article->isRead()) {
article->disconnect(this);
@ -176,7 +176,7 @@ Article *Feed::articleByGUID(const QString &guid) const @@ -176,7 +176,7 @@ Article *Feed::articleByGUID(const QString &guid) const
return m_articles.value(guid);
}
void Feed::handleMaxArticlesPerFeedChanged(int n)
void Feed::handleMaxArticlesPerFeedChanged(const int n)
{
while (m_articlesByDate.size() > n)
removeOldestArticle();
@ -270,7 +270,7 @@ void Feed::load() @@ -270,7 +270,7 @@ void Feed::load()
void Feed::loadArticles(const QByteArray &data)
{
QJsonParseError jsonError;
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
const QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
if (jsonError.error != QJsonParseError::NoError) {
LogMsg(tr("Couldn't parse RSS Session data. Error: %1").arg(jsonError.errorString())
, Log::WARNING);
@ -303,7 +303,7 @@ void Feed::loadArticles(const QByteArray &data) @@ -303,7 +303,7 @@ void Feed::loadArticles(const QByteArray &data)
void Feed::loadArticlesLegacy()
{
SettingsPtr qBTRSSFeeds = Profile::instance().applicationSettings(QStringLiteral("qBittorrent-rss-feeds"));
const SettingsPtr qBTRSSFeeds = Profile::instance().applicationSettings(QStringLiteral("qBittorrent-rss-feeds"));
const QVariantHash allOldItems = qBTRSSFeeds->value("old_items").toHash();
for (const QVariant &var : asConst(allOldItems.value(m_url).toList())) {
@ -348,7 +348,7 @@ bool Feed::addArticle(Article *article) @@ -348,7 +348,7 @@ bool Feed::addArticle(Article *article)
// Insertion sort
const int maxArticles = m_session->maxArticlesPerFeed();
auto lowerBound = std::lower_bound(m_articlesByDate.begin(), m_articlesByDate.end()
const auto lowerBound = std::lower_bound(m_articlesByDate.begin(), m_articlesByDate.end()
, article->date(), Article::articleDateRecentThan);
if ((lowerBound - m_articlesByDate.begin()) >= maxArticles)
return false; // we reach max articles
@ -376,7 +376,7 @@ void Feed::removeOldestArticle() @@ -376,7 +376,7 @@ void Feed::removeOldestArticle()
m_articles.remove(oldestArticle->guid());
m_articlesByDate.removeLast();
bool isRead = oldestArticle->isRead();
const bool isRead = oldestArticle->isRead();
delete oldestArticle;
if (!isRead)
@ -402,8 +402,8 @@ void Feed::downloadIcon() @@ -402,8 +402,8 @@ void Feed::downloadIcon()
// Download the RSS Feed icon
// XXX: This works for most sites but it is not perfect
const QUrl url(m_url);
auto iconUrl = QString("%1://%2/favicon.ico").arg(url.scheme(), url.host());
Net::DownloadHandler *handler = Net::DownloadManager::instance()->download(
const auto iconUrl = QString("%1://%2/favicon.ico").arg(url.scheme(), url.host());
const Net::DownloadHandler *handler = Net::DownloadManager::instance()->download(
Net::DownloadRequest(iconUrl).saveToFile(true));
connect(handler
, static_cast<void (Net::DownloadHandler::*)(const QString &, const QString &)>(&Net::DownloadHandler::downloadFinished)
@ -494,7 +494,7 @@ QString Feed::iconPath() const @@ -494,7 +494,7 @@ QString Feed::iconPath() const
return m_iconPath;
}
QJsonValue Feed::toJsonValue(bool withData) const
QJsonValue Feed::toJsonValue(const bool withData) const
{
QJsonObject jsonObj;
jsonObj.insert(KEY_UID, uid().toString());
@ -515,7 +515,7 @@ QJsonValue Feed::toJsonValue(bool withData) const @@ -515,7 +515,7 @@ QJsonValue Feed::toJsonValue(bool withData) const
return jsonObj;
}
void Feed::handleSessionProcessingEnabledChanged(bool enabled)
void Feed::handleSessionProcessingEnabledChanged(const bool enabled)
{
if (enabled) {
downloadIcon();

6
src/base/rss/rss_session.cpp

@ -263,7 +263,7 @@ void Session::load() @@ -263,7 +263,7 @@ void Session::load()
}
QJsonParseError jsonError;
QJsonDocument jsonDoc = QJsonDocument::fromJson(itemsFile.readAll(), &jsonError);
const QJsonDocument jsonDoc = QJsonDocument::fromJson(itemsFile.readAll(), &jsonError);
if (jsonError.error != QJsonParseError::NoError) {
Logger::instance()->addMessage(
QString("Couldn't parse RSS Session data from %1. Error: %2")
@ -482,7 +482,7 @@ uint Session::refreshInterval() const @@ -482,7 +482,7 @@ uint Session::refreshInterval() const
return m_refreshInterval;
}
void Session::setRefreshInterval(uint refreshInterval)
void Session::setRefreshInterval(const uint refreshInterval)
{
if (m_refreshInterval != refreshInterval) {
SettingsStorage::instance()->storeValue(SettingsKey_RefreshInterval, refreshInterval);
@ -528,7 +528,7 @@ int Session::maxArticlesPerFeed() const @@ -528,7 +528,7 @@ int Session::maxArticlesPerFeed() const
return m_maxArticlesPerFeed;
}
void Session::setMaxArticlesPerFeed(int n)
void Session::setMaxArticlesPerFeed(const int n)
{
if (m_maxArticlesPerFeed != n) {
m_maxArticlesPerFeed = n;

28
src/base/scanfoldersmodel.cpp

@ -183,7 +183,7 @@ bool ScanFoldersModel::setData(const QModelIndex &index, const QVariant &value, @@ -183,7 +183,7 @@ bool ScanFoldersModel::setData(const QModelIndex &index, const QVariant &value,
return false;
if (role == Qt::UserRole) {
auto type = static_cast<PathType>(value.toInt());
const auto type = static_cast<PathType>(value.toInt());
if (type == CUSTOM_LOCATION)
return false;
@ -192,7 +192,7 @@ bool ScanFoldersModel::setData(const QModelIndex &index, const QVariant &value, @@ -192,7 +192,7 @@ bool ScanFoldersModel::setData(const QModelIndex &index, const QVariant &value,
emit dataChanged(index, index);
}
else if (role == Qt::DisplayRole) {
QString path = value.toString();
const QString path = value.toString();
if (path.isEmpty()) // means we didn't pass CUSTOM_LOCATION type
return false;
@ -209,14 +209,14 @@ bool ScanFoldersModel::setData(const QModelIndex &index, const QVariant &value, @@ -209,14 +209,14 @@ bool ScanFoldersModel::setData(const QModelIndex &index, const QVariant &value,
ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath, const PathType &downloadType, const QString &downloadPath, bool addToFSWatcher)
{
QDir watchDir(watchPath);
const QDir watchDir(watchPath);
if (!watchDir.exists()) return DoesNotExist;
if (!watchDir.isReadable()) return CannotRead;
const QString canonicalWatchPath = watchDir.canonicalPath();
if (findPathData(canonicalWatchPath) != -1) return AlreadyInList;
QDir downloadDir(downloadPath);
const QDir downloadDir(downloadPath);
const QString canonicalDownloadPath = downloadDir.canonicalPath();
if (!m_fsWatcher) {
@ -236,12 +236,12 @@ ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath, @@ -236,12 +236,12 @@ ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath,
ScanFoldersModel::PathStatus ScanFoldersModel::updatePath(const QString &watchPath, const PathType &downloadType, const QString &downloadPath)
{
QDir watchDir(watchPath);
const QDir watchDir(watchPath);
const QString canonicalWatchPath = watchDir.canonicalPath();
int row = findPathData(canonicalWatchPath);
const int row = findPathData(canonicalWatchPath);
if (row == -1) return DoesNotExist;
QDir downloadDir(downloadPath);
const QDir downloadDir(downloadPath);
const QString canonicalDownloadPath = downloadDir.canonicalPath();
m_pathList.at(row)->downloadType = downloadType;
@ -256,13 +256,13 @@ void ScanFoldersModel::addToFSWatcher(const QStringList &watchPaths) @@ -256,13 +256,13 @@ void ScanFoldersModel::addToFSWatcher(const QStringList &watchPaths)
return; // addPath() wasn't called before this
for (const QString &path : watchPaths) {
QDir watchDir(path);
const QDir watchDir(path);
const QString canonicalWatchPath = watchDir.canonicalPath();
m_fsWatcher->addPath(canonicalWatchPath);
}
}
void ScanFoldersModel::removePath(int row, bool removeFromFSWatcher)
void ScanFoldersModel::removePath(const int row, const bool removeFromFSWatcher)
{
Q_ASSERT((row >= 0) && (row < rowCount()));
beginRemoveRows(QModelIndex(), row, row);
@ -272,7 +272,7 @@ void ScanFoldersModel::removePath(int row, bool removeFromFSWatcher) @@ -272,7 +272,7 @@ void ScanFoldersModel::removePath(int row, bool removeFromFSWatcher)
endRemoveRows();
}
bool ScanFoldersModel::removePath(const QString &path, bool removeFromFSWatcher)
bool ScanFoldersModel::removePath(const QString &path, const bool removeFromFSWatcher)
{
const int row = findPathData(path);
if (row == -1) return false;
@ -291,7 +291,7 @@ bool ScanFoldersModel::downloadInWatchFolder(const QString &filePath) const @@ -291,7 +291,7 @@ bool ScanFoldersModel::downloadInWatchFolder(const QString &filePath) const
{
const int row = findPathData(QFileInfo(filePath).dir().path());
Q_ASSERT(row != -1);
PathData *data = m_pathList.at(row);
const PathData *data = m_pathList.at(row);
return (data->downloadType == DOWNLOAD_IN_WATCH_FOLDER);
}
@ -299,7 +299,7 @@ bool ScanFoldersModel::downloadInDefaultFolder(const QString &filePath) const @@ -299,7 +299,7 @@ bool ScanFoldersModel::downloadInDefaultFolder(const QString &filePath) const
{
const int row = findPathData(QFileInfo(filePath).dir().path());
Q_ASSERT(row != -1);
PathData *data = m_pathList.at(row);
const PathData *data = m_pathList.at(row);
return (data->downloadType == DEFAULT_LOCATION);
}
@ -307,7 +307,7 @@ QString ScanFoldersModel::downloadPathTorrentFolder(const QString &filePath) con @@ -307,7 +307,7 @@ QString ScanFoldersModel::downloadPathTorrentFolder(const QString &filePath) con
{
const int row = findPathData(QFileInfo(filePath).dir().path());
Q_ASSERT(row != -1);
PathData *data = m_pathList.at(row);
const PathData *data = m_pathList.at(row);
if (data->downloadType == CUSTOM_LOCATION)
return data->downloadPath;
@ -375,7 +375,7 @@ void ScanFoldersModel::addTorrentsToSession(const QStringList &pathList) @@ -375,7 +375,7 @@ void ScanFoldersModel::addTorrentsToSession(const QStringList &pathList)
}
}
else {
BitTorrent::TorrentInfo torrentInfo = BitTorrent::TorrentInfo::loadFromFile(file);
const BitTorrent::TorrentInfo torrentInfo = BitTorrent::TorrentInfo::loadFromFile(file);
if (torrentInfo.isValid()) {
BitTorrent::Session::instance()->addTorrent(torrentInfo, params);
Utils::Fs::forceRemove(file);

6
src/base/scanfoldersmodel.h

@ -68,10 +68,10 @@ public: @@ -68,10 +68,10 @@ public:
static void freeInstance();
static ScanFoldersModel *instance();
static QString pathTypeDisplayName(const PathType type);
static QString pathTypeDisplayName(PathType type);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
int rowCount(const QModelIndex &parent = {}) const;
int columnCount(const QModelIndex &parent = {}) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
Qt::ItemFlags flags(const QModelIndex &index) const;

2
src/base/search/searchhandler.cpp

@ -114,7 +114,7 @@ void SearchHandler::cancelSearch() @@ -114,7 +114,7 @@ void SearchHandler::cancelSearch()
// Slot called when QProcess is Finished
// QProcess can be finished for 3 reasons:
// Error | Stopped by user | Finished normally
void SearchHandler::processFinished(int exitcode)
void SearchHandler::processFinished(const int exitcode)
{
m_searchTimeout->stop();

24
src/base/search/searchpluginmanager.cpp

@ -168,9 +168,9 @@ PluginInfo *SearchPluginManager::pluginInfo(const QString &name) const @@ -168,9 +168,9 @@ PluginInfo *SearchPluginManager::pluginInfo(const QString &name) const
return m_plugins.value(name);
}
void SearchPluginManager::enablePlugin(const QString &name, bool enabled)
void SearchPluginManager::enablePlugin(const QString &name, const bool enabled)
{
PluginInfo *plugin = m_plugins.value(name, 0);
PluginInfo *plugin = m_plugins.value(name, nullptr);
if (plugin) {
plugin->enabled = enabled;
// Save to Hard disk
@ -222,7 +222,7 @@ void SearchPluginManager::installPlugin(const QString &source) @@ -222,7 +222,7 @@ void SearchPluginManager::installPlugin(const QString &source)
void SearchPluginManager::installPlugin_impl(const QString &name, const QString &path)
{
const PluginVersion newVersion = getPluginVersion(path);
PluginInfo *plugin = pluginInfo(name);
const PluginInfo *plugin = pluginInfo(name);
if (plugin && !(plugin->version < newVersion)) {
LogMsg(tr("Plugin already at version %1, which is greater than %2").arg(plugin->version, newVersion), Log::INFO);
emit pluginUpdateFailed(name, tr("A more recent version of this plugin is already installed."));
@ -230,7 +230,7 @@ void SearchPluginManager::installPlugin_impl(const QString &name, const QString @@ -230,7 +230,7 @@ void SearchPluginManager::installPlugin_impl(const QString &name, const QString
}
// Process with install
QString destPath = pluginPath(name);
const QString destPath = pluginPath(name);
bool updated = false;
if (QFile::exists(destPath)) {
// Backup in case install fails
@ -273,7 +273,7 @@ bool SearchPluginManager::uninstallPlugin(const QString &name) @@ -273,7 +273,7 @@ bool SearchPluginManager::uninstallPlugin(const QString &name)
clearPythonCache(engineLocation());
// remove it from hard drive
QDir pluginsFolder(pluginsLocation());
const QDir pluginsFolder(pluginsLocation());
QStringList filters;
filters << name + ".*";
const QStringList files = pluginsFolder.entryList(filters, QDir::Files, QDir::Unsorted);
@ -448,7 +448,7 @@ void SearchPluginManager::update() @@ -448,7 +448,7 @@ void SearchPluginManager::update()
nova.start(Utils::ForeignApps::pythonInfo().executableName, params, QIODevice::ReadOnly);
nova.waitForFinished();
QString capabilities = nova.readAll();
const QString capabilities = nova.readAll();
QDomDocument xmlDoc;
if (!xmlDoc.setContent(capabilities)) {
qWarning() << "Could not parse Nova search engine capabilities, msg: " << capabilities.toLocal8Bit().data();
@ -456,16 +456,16 @@ void SearchPluginManager::update() @@ -456,16 +456,16 @@ void SearchPluginManager::update()
return;
}
QDomElement root = xmlDoc.documentElement();
const QDomElement root = xmlDoc.documentElement();
if (root.tagName() != "capabilities") {
qWarning() << "Invalid XML file for Nova search engine capabilities, msg: " << capabilities.toLocal8Bit().data();
return;
}
for (QDomNode engineNode = root.firstChild(); !engineNode.isNull(); engineNode = engineNode.nextSibling()) {
QDomElement engineElem = engineNode.toElement();
const QDomElement engineElem = engineNode.toElement();
if (!engineElem.isNull()) {
QString pluginName = engineElem.tagName();
const QString pluginName = engineElem.tagName();
std::unique_ptr<PluginInfo> plugin {new PluginInfo {}};
plugin->name = pluginName;
@ -480,7 +480,7 @@ void SearchPluginManager::update() @@ -480,7 +480,7 @@ void SearchPluginManager::update()
plugin->supportedCategories << cat;
}
QStringList disabledEngines = Preferences::instance()->getSearchEngDisabled();
const QStringList disabledEngines = Preferences::instance()->getSearchEngDisabled();
plugin->enabled = !disabledEngines.contains(pluginName);
updateIconPath(plugin.get());
@ -533,9 +533,9 @@ void SearchPluginManager::parseVersionInfo(const QByteArray &info) @@ -533,9 +533,9 @@ void SearchPluginManager::parseVersionInfo(const QByteArray &info)
}
}
bool SearchPluginManager::isUpdateNeeded(const QString &pluginName, PluginVersion newVersion) const
bool SearchPluginManager::isUpdateNeeded(const QString &pluginName, const PluginVersion newVersion) const
{
PluginInfo *plugin = pluginInfo(pluginName);
const PluginInfo *plugin = pluginInfo(pluginName);
if (!plugin) return true;
PluginVersion oldVersion = plugin->version;

2
src/base/settingsstorage.h

@ -46,7 +46,7 @@ public: @@ -46,7 +46,7 @@ public:
static void freeInstance();
static SettingsStorage *instance();
QVariant loadValue(const QString &key, const QVariant &defaultValue = QVariant()) const;
QVariant loadValue(const QString &key, const QVariant &defaultValue = {}) const;
void storeValue(const QString &key, const QVariant &value);
void removeValue(const QString &key);

4
src/base/torrentfileguard.cpp

@ -37,7 +37,7 @@ FileGuard::FileGuard(const QString &path) @@ -37,7 +37,7 @@ FileGuard::FileGuard(const QString &path)
{
}
void FileGuard::setAutoRemove(bool remove) noexcept
void FileGuard::setAutoRemove(const bool remove) noexcept
{
m_remove = remove;
}
@ -48,7 +48,7 @@ FileGuard::~FileGuard() @@ -48,7 +48,7 @@ FileGuard::~FileGuard()
Utils::Fs::forceRemove(m_path); // forceRemove() checks for file existence
}
TorrentFileGuard::TorrentFileGuard(const QString &path, TorrentFileGuard::AutoDeleteMode mode)
TorrentFileGuard::TorrentFileGuard(const QString &path, const TorrentFileGuard::AutoDeleteMode mode)
: FileGuard {mode != Never ? path : QString()}
, m_mode {mode}
, m_wasAdded {false}

4
src/base/torrentfileguard.h

@ -37,7 +37,7 @@ template <typename T> class CachedSettingValue; @@ -37,7 +37,7 @@ template <typename T> class CachedSettingValue;
class FileGuard
{
public:
explicit FileGuard(const QString &path = QString());
explicit FileGuard(const QString &path = {});
~FileGuard();
/// Cancels or re-enables deferred file deletion
@ -55,7 +55,7 @@ class TorrentFileGuard : private FileGuard @@ -55,7 +55,7 @@ class TorrentFileGuard : private FileGuard
Q_GADGET
public:
explicit TorrentFileGuard(const QString &path = QString());
explicit TorrentFileGuard(const QString &path = {});
~TorrentFileGuard();
/// marks the torrent file as loaded (added) into the BitTorrent::Session

2
src/base/torrentfilter.h

@ -72,7 +72,7 @@ public: @@ -72,7 +72,7 @@ public:
TorrentFilter();
// category & tags: pass empty string for uncategorized / untagged torrents.
// Pass null string (QString()) to disable filtering (i.e. all torrents).
TorrentFilter(const Type type, const QStringSet &hashSet = AnyHash, const QString &category = AnyCategory, const QString &tag = AnyTag);
TorrentFilter(Type type, const QStringSet &hashSet = AnyHash, const QString &category = AnyCategory, const QString &tag = AnyTag);
TorrentFilter(const QString &filter, const QStringSet &hashSet = AnyHash, const QString &category = AnyCategory, const QString &tags = AnyTag);
bool setType(Type type);

2
src/base/utils/bytearray.h

@ -40,6 +40,6 @@ namespace Utils @@ -40,6 +40,6 @@ namespace Utils
// Mimic QByteArray::mid(pos, len) but instead of returning a full-copy,
// we only return a partial view
const QByteArray midView(const QByteArray &in, const int pos, const int len = -1);
const QByteArray midView(const QByteArray &in, int pos, int len = -1);
}
}

2
src/base/utils/foreignapps.cpp

@ -119,7 +119,7 @@ namespace @@ -119,7 +119,7 @@ namespace
return keys;
}
QString getRegValue(const HKEY handle, const QString &name = QString())
QString getRegValue(const HKEY handle, const QString &name = {})
{
QString result;

16
src/base/utils/fs.cpp

@ -81,14 +81,14 @@ QString Utils::Fs::fromNativePath(const QString &path) @@ -81,14 +81,14 @@ QString Utils::Fs::fromNativePath(const QString &path)
*/
QString Utils::Fs::fileExtension(const QString &filename)
{
QString ext = QString(filename).remove(QB_EXT);
const QString ext = QString(filename).remove(QB_EXT);
const int pointIndex = ext.lastIndexOf('.');
return (pointIndex >= 0) ? ext.mid(pointIndex + 1) : QString();
}
QString Utils::Fs::fileName(const QString &filePath)
{
QString path = fromNativePath(filePath);
const QString path = fromNativePath(filePath);
const int slashIndex = path.lastIndexOf('/');
if (slashIndex == -1)
return path;
@ -97,7 +97,7 @@ QString Utils::Fs::fileName(const QString &filePath) @@ -97,7 +97,7 @@ QString Utils::Fs::fileName(const QString &filePath)
QString Utils::Fs::folderName(const QString &filePath)
{
QString path = fromNativePath(filePath);
const QString path = fromNativePath(filePath);
const int slashIndex = path.lastIndexOf('/');
if (slashIndex == -1)
return path;
@ -140,7 +140,7 @@ bool Utils::Fs::smartRemoveEmptyFolderTree(const QString &path) @@ -140,7 +140,7 @@ bool Utils::Fs::smartRemoveEmptyFolderTree(const QString &path)
}
// remove temp files on linux (file ends with '~'), e.g. `filename~`
QDir dir(p);
const QDir dir(p);
const QStringList tmpFileList = dir.entryList(QDir::Files);
for (const QString &f : tmpFileList) {
if (f.endsWith('~'))
@ -188,7 +188,7 @@ void Utils::Fs::removeDirRecursive(const QString &path) @@ -188,7 +188,7 @@ void Utils::Fs::removeDirRecursive(const QString &path)
qint64 Utils::Fs::computePathSize(const QString &path)
{
// Check if it is a file
QFileInfo fi(path);
const QFileInfo fi(path);
if (!fi.exists()) return -1;
if (fi.isFile()) return fi.size();
@ -221,7 +221,7 @@ bool Utils::Fs::sameFiles(const QString &path1, const QString &path2) @@ -221,7 +221,7 @@ bool Utils::Fs::sameFiles(const QString &path1, const QString &path2)
return true;
}
QString Utils::Fs::toValidFileSystemName(const QString &name, bool allowSeparators, const QString &pad)
QString Utils::Fs::toValidFileSystemName(const QString &name, const bool allowSeparators, const QString &pad)
{
const QRegularExpression regex(allowSeparators ? "[:?\"*<>|]+" : "[\\\\/:?\"*<>|]+");
@ -232,7 +232,7 @@ QString Utils::Fs::toValidFileSystemName(const QString &name, bool allowSeparato @@ -232,7 +232,7 @@ QString Utils::Fs::toValidFileSystemName(const QString &name, bool allowSeparato
return validName;
}
bool Utils::Fs::isValidFileSystemName(const QString &name, bool allowSeparators)
bool Utils::Fs::isValidFileSystemName(const QString &name, const bool allowSeparators)
{
if (name.isEmpty()) return false;
@ -272,7 +272,7 @@ bool Utils::Fs::sameFileNames(const QString &first, const QString &second) @@ -272,7 +272,7 @@ bool Utils::Fs::sameFileNames(const QString &first, const QString &second)
QString Utils::Fs::expandPath(const QString &path)
{
QString ret = path.trimmed();
const QString ret = path.trimmed();
if (ret.isEmpty())
return ret;

16
src/base/utils/misc.cpp

@ -252,10 +252,10 @@ QPoint Utils::Misc::screenCenter(const QWidget *w) @@ -252,10 +252,10 @@ QPoint Utils::Misc::screenCenter(const QWidget *w)
{
// Returns the QPoint which the widget will be placed center on screen (where parent resides)
QWidget *parent = w->parentWidget();
QDesktopWidget *desktop = QApplication::desktop();
int scrn = desktop->screenNumber(parent); // fallback to `primaryScreen` when parent is invalid
QRect r = desktop->availableGeometry(scrn);
const QWidget *parent = w->parentWidget();
const QDesktopWidget *desktop = QApplication::desktop();
const int scrn = desktop->screenNumber(parent); // fallback to `primaryScreen` when parent is invalid
const QRect r = desktop->availableGeometry(scrn);
return {r.x() + (r.width() - w->frameSize().width()) / 2, r.y() + (r.height() - w->frameSize().height()) / 2};
}
#endif
@ -269,7 +269,7 @@ QString Utils::Misc::unitString(const SizeUnit unit, const bool isSpeed) @@ -269,7 +269,7 @@ QString Utils::Misc::unitString(const SizeUnit unit, const bool isSpeed)
return ret;
}
QString Utils::Misc::friendlyUnit(qint64 bytesValue, bool isSpeed)
QString Utils::Misc::friendlyUnit(const qint64 bytesValue, const bool isSpeed)
{
SizeUnit unit;
qreal friendlyVal;
@ -289,7 +289,7 @@ int Utils::Misc::friendlyUnitPrecision(SizeUnit unit) @@ -289,7 +289,7 @@ int Utils::Misc::friendlyUnitPrecision(SizeUnit unit)
return 3;
}
qlonglong Utils::Misc::sizeInBytes(qreal size, Utils::Misc::SizeUnit unit)
qlonglong Utils::Misc::sizeInBytes(qreal size, const Utils::Misc::SizeUnit unit)
{
for (int i = 0; i < static_cast<int>(unit); ++i)
size *= 1024;
@ -347,7 +347,7 @@ bool Utils::Misc::isPreviewable(const QString &extension) @@ -347,7 +347,7 @@ bool Utils::Misc::isPreviewable(const QString &extension)
// Take a number of seconds and return an user-friendly
// time duration like "1d 2h 10m".
QString Utils::Misc::userFriendlyDuration(qlonglong seconds)
QString Utils::Misc::userFriendlyDuration(const qlonglong seconds)
{
if ((seconds < 0) || (seconds >= MAX_ETA))
return QString::fromUtf8(C_INFINITY);
@ -511,7 +511,7 @@ void Utils::Misc::openFolderSelect(const QString &absolutePath) @@ -511,7 +511,7 @@ void Utils::Misc::openFolderSelect(const QString &absolutePath)
QProcess proc;
proc.start("xdg-mime", {"query", "default", "inode/directory"});
proc.waitForFinished();
QString output = proc.readLine().simplified();
const QString output = proc.readLine().simplified();
if ((output == "dolphin.desktop") || (output == "org.kde.dolphin.desktop")) {
proc.startDetached("dolphin", {"--select", Utils::Fs::toNativePath(path)});
}

2
src/base/utils/random.h

@ -35,7 +35,7 @@ namespace Utils @@ -35,7 +35,7 @@ namespace Utils
{
namespace Random
{
uint32_t rand(const uint32_t min = 0, const uint32_t max = UINT32_MAX);
uint32_t rand(uint32_t min = 0, uint32_t max = UINT32_MAX);
}
}

4
src/base/utils/string.cpp

@ -151,7 +151,7 @@ int Utils::String::naturalCompare(const QString &left, const QString &right, con @@ -151,7 +151,7 @@ int Utils::String::naturalCompare(const QString &left, const QString &right, con
}
// to send numbers instead of strings with suffixes
QString Utils::String::fromDouble(double n, int precision)
QString Utils::String::fromDouble(const double n, const int precision)
{
/* HACK because QString rounds up. Eg QString::number(0.999*100.0, 'f' ,1) == 99.9
** but QString::number(0.9999*100.0, 'f' ,1) == 100.0 The problem manifests when
@ -159,7 +159,7 @@ QString Utils::String::fromDouble(double n, int precision) @@ -159,7 +159,7 @@ QString Utils::String::fromDouble(double n, int precision)
** our 'wanted' is >= 5. In this case our last digit gets rounded up. So for each
** precision we add an extra 0 behind 1 in the below algorithm. */
double prec = std::pow(10.0, precision);
const double prec = std::pow(10.0, precision);
return QLocale::system().toString(std::floor(n * prec) / prec, 'f', precision);
}

2
src/base/utils/string.h

@ -63,7 +63,7 @@ namespace Utils @@ -63,7 +63,7 @@ namespace Utils
return str;
}
bool parseBool(const QString &string, const bool defaultValue);
bool parseBool(const QString &string, bool defaultValue);
TriStateBool parseTriStateBool(const QString &string);
}
}

4
src/gui/addnewtorrentdialog.cpp

@ -106,7 +106,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP @@ -106,7 +106,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
setModal(true);
#endif
auto session = BitTorrent::Session::instance();
const auto *session = BitTorrent::Session::instance();
if (m_torrentParams.addPaused == TriStateBool::True)
m_ui->startTorrentCheckBox->setChecked(false);
@ -233,7 +233,7 @@ void AddNewTorrentDialog::saveState() @@ -233,7 +233,7 @@ void AddNewTorrentDialog::saveState()
void AddNewTorrentDialog::show(const QString &source, const BitTorrent::AddTorrentParams &inParams, QWidget *parent)
{
AddNewTorrentDialog *dlg = new AddNewTorrentDialog(inParams, parent);
auto *dlg = new AddNewTorrentDialog(inParams, parent);
if (Net::DownloadManager::hasSupportedScheme(source)) {
// Launch downloader

2
src/gui/addnewtorrentdialog.h

@ -98,7 +98,7 @@ private: @@ -98,7 +98,7 @@ private:
int indexOfSavePath(const QString &savePath);
void loadState();
void saveState();
void setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText = QString());
void setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText = {});
void setupTreeview();
void setCommentText(const QString &str) const;
void setSavePath(const QString &newPath);

2
src/gui/autoexpandabledialog.h

@ -47,7 +47,7 @@ public: @@ -47,7 +47,7 @@ public:
~AutoExpandableDialog();
static QString getText(QWidget *parent, const QString &title, const QString &label,
QLineEdit::EchoMode mode = QLineEdit::Normal, const QString &text = QString(),
QLineEdit::EchoMode mode = QLineEdit::Normal, const QString &text = {},
bool *ok = nullptr, bool excludeExtension = false, Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
protected:

10
src/gui/categoryfiltermodel.cpp

@ -176,7 +176,7 @@ CategoryFilterModel::CategoryFilterModel(QObject *parent) @@ -176,7 +176,7 @@ CategoryFilterModel::CategoryFilterModel(QObject *parent)
, m_rootItem(new CategoryModelItem)
{
using namespace BitTorrent;
auto session = Session::instance();
const auto *session = Session::instance();
connect(session, &Session::categoryAdded, this, &CategoryFilterModel::categoryAdded);
connect(session, &Session::categoryRemoved, this, &CategoryFilterModel::categoryRemoved);
@ -209,7 +209,7 @@ QVariant CategoryFilterModel::data(const QModelIndex &index, int role) const @@ -209,7 +209,7 @@ QVariant CategoryFilterModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid()) return {};
auto item = static_cast<CategoryModelItem *>(index.internalPointer());
auto item = static_cast<const CategoryModelItem *>(index.internalPointer());
if ((index.column() == 0) && (role == Qt::DecorationRole)) {
return GuiIconProvider::instance()->getIcon("inode-directory");
@ -384,8 +384,8 @@ void CategoryFilterModel::populate() @@ -384,8 +384,8 @@ void CategoryFilterModel::populate()
{
m_rootItem->clear();
auto session = BitTorrent::Session::instance();
auto torrents = session->torrents();
const auto *session = BitTorrent::Session::instance();
const auto torrents = session->torrents();
m_isSubcategoriesEnabled = session->isSubcategoriesEnabled();
const QString UID_ALL;
@ -413,7 +413,7 @@ void CategoryFilterModel::populate() @@ -413,7 +413,7 @@ void CategoryFilterModel::populate()
if (!parent->hasChild(subcatName)) {
new CategoryModelItem(
parent, subcatName
, std::count_if(torrents.begin(), torrents.end()
, std::count_if(torrents.cbegin(), torrents.cend()
, [subcat](Torrent *torrent) { return torrent->category() == subcat; }));
}
parent = parent->child(subcatName);

6
src/gui/categoryfiltermodel.h

@ -49,13 +49,13 @@ public: @@ -49,13 +49,13 @@ public:
static bool isSpecialItem(const QModelIndex &index);
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = {}) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int rowCount(const QModelIndex &parent = {}) const override;
QModelIndex index(const QString &categoryName) const;
QString categoryName(const QModelIndex &index) const;

6
src/gui/categoryfilterwidget.cpp

@ -91,7 +91,7 @@ CategoryFilterWidget::CategoryFilterWidget(QWidget *parent) @@ -91,7 +91,7 @@ CategoryFilterWidget::CategoryFilterWidget(QWidget *parent)
QString CategoryFilterWidget::currentCategory() const
{
QModelIndex current;
auto selectedRows = selectionModel()->selectedRows();
const auto selectedRows = selectionModel()->selectedRows();
if (!selectedRows.isEmpty())
current = selectedRows.first();
@ -114,7 +114,7 @@ void CategoryFilterWidget::showMenu(QPoint) @@ -114,7 +114,7 @@ void CategoryFilterWidget::showMenu(QPoint)
, tr("Add category..."));
connect(addAct, &QAction::triggered, this, &CategoryFilterWidget::addCategory);
auto selectedRows = selectionModel()->selectedRows();
const auto selectedRows = selectionModel()->selectedRows();
if (!selectedRows.empty() && !CategoryFilterModel::isSpecialItem(selectedRows.first())) {
if (BitTorrent::Session::instance()->isSubcategoriesEnabled()) {
QAction *addSubAct = menu.addAction(
@ -220,7 +220,7 @@ void CategoryFilterWidget::editCategory() @@ -220,7 +220,7 @@ void CategoryFilterWidget::editCategory()
void CategoryFilterWidget::removeCategory()
{
auto selectedRows = selectionModel()->selectedRows();
const auto selectedRows = selectionModel()->selectedRows();
if (!selectedRows.empty() && !CategoryFilterModel::isSpecialItem(selectedRows.first())) {
BitTorrent::Session::instance()->removeCategory(
static_cast<CategoryFilterProxyModel *>(model())->categoryName(selectedRows.first()));

10
src/gui/cookiesmodel.h

@ -54,18 +54,18 @@ public: @@ -54,18 +54,18 @@ public:
QList<QNetworkCookie> cookies() const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
int rowCount(const QModelIndex &parent = {}) const override;
int columnCount(const QModelIndex &parent = {}) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
bool insertRows(int row, int count, const QModelIndex &parent = {}) override;
bool removeRows(int row, int count, const QModelIndex &parent = {}) override;
private:
mutable QList<QNetworkCookie> m_cookies;

4
src/gui/mainwindow.h

@ -84,7 +84,7 @@ public: @@ -84,7 +84,7 @@ public:
bool isExecutionLogEnabled() const;
void setExecutionLogEnabled(bool value);
int executionLogMsgTypes() const;
void setExecutionLogMsgTypes(const int value);
void setExecutionLogMsgTypes(int value);
// Notifications properties
bool isNotificationsEnabled() const;
@ -209,7 +209,7 @@ private: @@ -209,7 +209,7 @@ private:
bool event(QEvent *e) override;
void displayRSSTab(bool enable);
void displaySearchTab(bool enable);
void createTorrentTriggered(const QString &path = QString());
void createTorrentTriggered(const QString &path = {});
void showStatusBar(bool show);
Ui::MainWindow *m_ui;

4
src/gui/optionsdialog.cpp

@ -846,7 +846,7 @@ void OptionsDialog::loadOptions() @@ -846,7 +846,7 @@ void OptionsDialog::loadOptions()
m_ui->spinRSSRefreshInterval->setValue(RSS::Session::instance()->refreshInterval());
m_ui->spinRSSMaxArticlesPerFeed->setValue(RSS::Session::instance()->maxArticlesPerFeed());
auto session = BitTorrent::Session::instance();
const auto *session = BitTorrent::Session::instance();
// Downloads preferences
m_ui->checkAdditionDialog->setChecked(AddNewTorrentDialog::isEnabled());
@ -974,7 +974,7 @@ void OptionsDialog::loadOptions() @@ -974,7 +974,7 @@ void OptionsDialog::loadOptions()
m_ui->spinMaxUploadsPerTorrent->setEnabled(false);
}
auto proxyConfigManager = Net::ProxyConfigurationManager::instance();
const auto *proxyConfigManager = Net::ProxyConfigurationManager::instance();
Net::ProxyConfiguration proxyConf = proxyConfigManager->proxyConfiguration();
using Net::ProxyType;
bool useProxyAuth = false;

2
src/gui/properties/piecesbar.cpp

@ -118,7 +118,7 @@ PiecesBar::PiecesBar(QWidget *parent) @@ -118,7 +118,7 @@ PiecesBar::PiecesBar(QWidget *parent)
setMouseTracking(true);
}
void PiecesBar::setTorrent(BitTorrent::TorrentHandle *torrent)
void PiecesBar::setTorrent(const BitTorrent::TorrentHandle *torrent)
{
m_torrent = torrent;
if (!m_torrent)

2
src/gui/properties/piecesbar.h

@ -50,7 +50,7 @@ class PiecesBar : public QWidget @@ -50,7 +50,7 @@ class PiecesBar : public QWidget
public:
explicit PiecesBar(QWidget *parent = nullptr);
void setTorrent(BitTorrent::TorrentHandle *torrent);
void setTorrent(const BitTorrent::TorrentHandle *torrent);
void setColors(const QColor &background, const QColor &border, const QColor &complete);
virtual void clear();

2
src/gui/rss/automatedrssdownloader.cpp

@ -213,7 +213,7 @@ void AutomatedRssDownloader::updateFeedList() @@ -213,7 +213,7 @@ void AutomatedRssDownloader::updateFeedList()
bool anyEnabled = false;
for (const QListWidgetItem *ruleItem : asConst(selection)) {
auto rule = RSS::AutoDownloader::instance()->ruleByName(ruleItem->text());
const auto rule = RSS::AutoDownloader::instance()->ruleByName(ruleItem->text());
if (rule.feedURLs().contains(feedURL))
anyEnabled = true;
else

2
src/gui/search/searchsortmodel.h

@ -53,7 +53,7 @@ public: @@ -53,7 +53,7 @@ public:
explicit SearchSortModel(QObject *parent = nullptr);
void enableNameFilter(bool enabled);
void setNameFilter(const QString &searchTerm = QString());
void setNameFilter(const QString &searchTerm = {});
//! \brief Sets parameters for filtering by size
//! \param minSize minimal size in bytes

2
src/gui/search/searchwidget.cpp

@ -134,7 +134,7 @@ SearchWidget::SearchWidget(MainWindow *mainWindow) @@ -134,7 +134,7 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
connect(m_tabStatusChangedMapper, static_cast<void (QSignalMapper::*)(QWidget *)>(&QSignalMapper::mapped)
, this, &SearchWidget::tabStatusChanged);
auto *searchManager = SearchPluginManager::instance();
const auto *searchManager = SearchPluginManager::instance();
const auto onPluginChanged = [this]()
{
fillPluginComboBox();

10
src/gui/tagfiltermodel.cpp

@ -92,7 +92,7 @@ TagFilterModel::TagFilterModel(QObject *parent) @@ -92,7 +92,7 @@ TagFilterModel::TagFilterModel(QObject *parent)
: QAbstractListModel(parent)
{
using Session = BitTorrent::Session;
auto session = Session::instance();
const auto *session = Session::instance();
connect(session, &Session::tagAdded, this, &TagFilterModel::tagAdded);
connect(session, &Session::tagRemoved, this, &TagFilterModel::tagRemoved);
@ -265,18 +265,18 @@ void TagFilterModel::populate() @@ -265,18 +265,18 @@ void TagFilterModel::populate()
{
using Torrent = BitTorrent::TorrentHandle;
auto session = BitTorrent::Session::instance();
auto torrents = session->torrents();
const auto *session = BitTorrent::Session::instance();
const auto torrents = session->torrents();
// All torrents
addToModel(getSpecialAllTag(), torrents.count());
const int untaggedCount = std::count_if(torrents.begin(), torrents.end(),
const int untaggedCount = std::count_if(torrents.cbegin(), torrents.cend(),
[](Torrent *torrent) { return torrent->tags().isEmpty(); });
addToModel(getSpecialUntaggedTag(), untaggedCount);
for (const QString &tag : asConst(session->tags())) {
const int count = std::count_if(torrents.begin(), torrents.end(),
const int count = std::count_if(torrents.cbegin(), torrents.cend(),
[tag](Torrent *torrent) { return torrent->hasTag(tag); });
addToModel(tag, count);
}

4
src/gui/tagfiltermodel.h

@ -54,8 +54,8 @@ public: @@ -54,8 +54,8 @@ public:
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override;
int rowCount(const QModelIndex &parent = {}) const override;
QModelIndex index(const QString &tag) const;
QString tag(const QModelIndex &index) const;

6
src/gui/tagfilterwidget.cpp

@ -90,7 +90,7 @@ TagFilterWidget::TagFilterWidget(QWidget *parent) @@ -90,7 +90,7 @@ TagFilterWidget::TagFilterWidget(QWidget *parent)
QString TagFilterWidget::currentTag() const
{
QModelIndex current;
auto selectedRows = selectionModel()->selectedRows();
const auto selectedRows = selectionModel()->selectedRows();
if (!selectedRows.isEmpty())
current = selectedRows.first();
@ -113,7 +113,7 @@ void TagFilterWidget::showMenu(QPoint) @@ -113,7 +113,7 @@ void TagFilterWidget::showMenu(QPoint)
, tr("Add tag..."));
connect(addAct, &QAction::triggered, this, &TagFilterWidget::addTag);
auto selectedRows = selectionModel()->selectedRows();
const auto selectedRows = selectionModel()->selectedRows();
if (!selectedRows.empty() && !TagFilterModel::isSpecialItem(selectedRows.first())) {
QAction *removeAct = menu.addAction(
GuiIconProvider::instance()->getIcon("list-remove")
@ -212,7 +212,7 @@ void TagFilterWidget::addTag() @@ -212,7 +212,7 @@ void TagFilterWidget::addTag()
void TagFilterWidget::removeTag()
{
auto selectedRows = selectionModel()->selectedRows();
const auto selectedRows = selectionModel()->selectedRows();
if (!selectedRows.empty() && !TagFilterModel::isSpecialItem(selectedRows.first())) {
BitTorrent::Session::instance()->removeTag(
static_cast<TagFilterProxyModel *>(model())->tag(selectedRows.first()));

2
src/gui/torrentcategorydialog.h

@ -41,7 +41,7 @@ class TorrentCategoryDialog : public QDialog @@ -41,7 +41,7 @@ class TorrentCategoryDialog : public QDialog
Q_DISABLE_COPY(TorrentCategoryDialog)
public:
static QString createCategory(QWidget *parent, const QString &parentCategoryName = QString());
static QString createCategory(QWidget *parent, const QString &parentCategoryName = {});
static void editCategory(QWidget *parent, const QString &categoryName);
explicit TorrentCategoryDialog(QWidget *parent = nullptr);

6
src/gui/torrentcontentmodel.h

@ -53,16 +53,16 @@ public: @@ -53,16 +53,16 @@ public:
void updateFilesAvailability(const QVector<qreal> &fa);
QVector<int> getFilePriorities() const;
bool allFiltered() const;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = {}) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const;
int getFileIndex(const QModelIndex &index);
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int rowCount(const QModelIndex &parent = {}) const override;
void clear();
void setupModelData(const BitTorrent::TorrentInfo &info);

2
src/gui/torrentcreatordialog.h

@ -49,7 +49,7 @@ class TorrentCreatorDialog : public QDialog @@ -49,7 +49,7 @@ class TorrentCreatorDialog : public QDialog
Q_OBJECT
public:
TorrentCreatorDialog(QWidget *parent = nullptr, const QString &defaultPath = QString());
TorrentCreatorDialog(QWidget *parent = nullptr, const QString &defaultPath = {});
~TorrentCreatorDialog() override;
void updateInputPath(const QString &path);

2
src/gui/transferlistmodel.cpp

@ -149,7 +149,7 @@ QVariant TransferListModel::headerData(int section, Qt::Orientation orientation, @@ -149,7 +149,7 @@ QVariant TransferListModel::headerData(int section, Qt::Orientation orientation,
case TR_RATIO:
case TR_PRIORITY:
case TR_LAST_ACTIVITY:
return {Qt::AlignRight | Qt::AlignVCenter};
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
default:
return QAbstractListModel::headerData(section, orientation, role);
}

2
src/gui/transferlistmodel.h

@ -83,7 +83,7 @@ public: @@ -83,7 +83,7 @@ public:
explicit TransferListModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &index = QModelIndex()) const override;
int rowCount(const QModelIndex &index = {}) const override;
int columnCount(const QModelIndex &parent=QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;

2
src/gui/transferlistsortmodel.h

@ -52,7 +52,7 @@ public: @@ -52,7 +52,7 @@ public:
private:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
bool lowerPositionThan(const QModelIndex &left, const QModelIndex &right) const;
bool dateLessThan(const int dateColumn, const QModelIndex &left, const QModelIndex &right, bool sortInvalidInBottom) const;
bool dateLessThan(int dateColumn, const QModelIndex &left, const QModelIndex &right, bool sortInvalidInBottom) const;
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
bool matchFilter(int sourceRow, const QModelIndex &sourceParent) const;

6
src/gui/utils.h

@ -49,9 +49,9 @@ namespace Utils @@ -49,9 +49,9 @@ namespace Utils
return (size * screenScalingFactor(widget));
}
QPixmap scaledPixmap(const QIcon &icon, const QWidget *widget, const int height);
QPixmap scaledPixmap(const QString &path, const QWidget *widget, const int height = 0);
QPixmap scaledPixmapSvg(const QString &path, const QWidget *widget, const int baseHeight);
QPixmap scaledPixmap(const QIcon &icon, const QWidget *widget, int height);
QPixmap scaledPixmap(const QString &path, const QWidget *widget, int height = 0);
QPixmap scaledPixmapSvg(const QString &path, const QWidget *widget, int baseHeight);
QSize smallIconSize(const QWidget *widget = nullptr);
QSize mediumIconSize(const QWidget *widget = nullptr);
QSize largeIconSize(const QWidget *widget = nullptr);

4
src/webui/api/appcontroller.cpp

@ -89,7 +89,7 @@ void AppController::shutdownAction() @@ -89,7 +89,7 @@ void AppController::shutdownAction()
void AppController::preferencesAction()
{
const Preferences *const pref = Preferences::instance();
auto session = BitTorrent::Session::instance();
const auto *session = BitTorrent::Session::instance();
QVariantMap data;
// Downloads
@ -144,7 +144,7 @@ void AppController::preferencesAction() @@ -144,7 +144,7 @@ void AppController::preferencesAction()
data["max_uploads_per_torrent"] = session->maxUploadsPerTorrent();
// Proxy Server
auto proxyManager = Net::ProxyConfigurationManager::instance();
const auto *proxyManager = Net::ProxyConfigurationManager::instance();
Net::ProxyConfiguration proxyConf = proxyManager->proxyConfiguration();
data["proxy_type"] = static_cast<int>(proxyConf.type);
data["proxy_ip"] = proxyConf.ip;

2
src/webui/api/searchcontroller.cpp

@ -109,7 +109,7 @@ void SearchController::stopAction() @@ -109,7 +109,7 @@ void SearchController::stopAction()
const int id = params()["id"].toInt();
ISession *const session = sessionManager()->session();
auto searchHandlers = session->getData<SearchHandlerDict>(SEARCH_HANDLERS);
const auto searchHandlers = session->getData<SearchHandlerDict>(SEARCH_HANDLERS);
if (!searchHandlers.contains(id))
throw APIError(APIErrorType::NotFound);

4
src/webui/api/searchcontroller.h

@ -66,8 +66,8 @@ private: @@ -66,8 +66,8 @@ private:
void checkForUpdatesFinished(const QHash<QString, PluginVersion> &updateInfo);
void checkForUpdatesFailed(const QString &reason);
void searchFinished(ISession *session, const int id);
void searchFailed(ISession *session, const int id);
void searchFinished(ISession *session, int id);
void searchFailed(ISession *session, int id);
int generateSearchId() const;
QJsonObject getResults(const QList<SearchResult> &searchResults, bool isSearchActive, int totalResults) const;
QJsonArray getPluginsInfo(const QStringList &plugins) const;

2
src/webui/api/torrentscontroller.cpp

@ -134,7 +134,7 @@ namespace @@ -134,7 +134,7 @@ namespace
QVariantList getStickyTrackers(const BitTorrent::TorrentHandle *const torrent)
{
uint seedsDHT = 0, seedsPeX = 0, seedsLSD = 0, leechesDHT = 0, leechesPeX = 0, leechesLSD = 0;
for (const BitTorrent::PeerInfo &peer : torrent->peers()) {
for (const BitTorrent::PeerInfo &peer : asConst(torrent->peers())) {
if (peer.isConnecting()) continue;
if (peer.isSeed()) {

Loading…
Cancel
Save