mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
commit
46bc1d12b9
@ -159,7 +159,7 @@ namespace
|
|||||||
.arg(fullParameter()).arg(QLatin1String("<value>")));
|
.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());
|
QString val = env.value(envVarName());
|
||||||
return val.isEmpty() ? defaultValue : Utils::String::unquote(val, QLatin1String("'\""));
|
return val.isEmpty() ? defaultValue : Utils::String::unquote(val, QLatin1String("'\""));
|
||||||
|
@ -43,7 +43,7 @@ namespace BitTorrent
|
|||||||
class MagnetUri
|
class MagnetUri
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit MagnetUri(const QString &source = QString());
|
explicit MagnetUri(const QString &source = {});
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
InfoHash hash() const;
|
InfoHash hash() const;
|
||||||
|
@ -581,7 +581,7 @@ namespace BitTorrent
|
|||||||
|
|
||||||
bool addTorrent_impl(CreateTorrentParams params, const MagnetUri &magnetUri,
|
bool addTorrent_impl(CreateTorrentParams params, const MagnetUri &magnetUri,
|
||||||
TorrentInfo torrentInfo = TorrentInfo(),
|
TorrentInfo torrentInfo = TorrentInfo(),
|
||||||
const QByteArray &fastresumeData = QByteArray());
|
const QByteArray &fastresumeData = {});
|
||||||
bool findIncompleteFiles(TorrentInfo &torrentInfo, QString &savePath) const;
|
bool findIncompleteFiles(TorrentInfo &torrentInfo, QString &savePath) const;
|
||||||
|
|
||||||
void updateSeedingLimitTimer();
|
void updateSeedingLimitTimer();
|
||||||
|
@ -57,7 +57,7 @@ namespace BitTorrent
|
|||||||
typedef boost::shared_ptr<const libtorrent::torrent_info> NativeConstPtr;
|
typedef boost::shared_ptr<const libtorrent::torrent_info> NativeConstPtr;
|
||||||
typedef boost::shared_ptr<libtorrent::torrent_info> NativePtr;
|
typedef boost::shared_ptr<libtorrent::torrent_info> NativePtr;
|
||||||
|
|
||||||
explicit TorrentInfo(NativeConstPtr nativeInfo = NativeConstPtr());
|
explicit TorrentInfo(NativeConstPtr nativeInfo = {});
|
||||||
TorrentInfo(const TorrentInfo &other);
|
TorrentInfo(const TorrentInfo &other);
|
||||||
|
|
||||||
static TorrentInfo load(const QByteArray &data, QString *error = nullptr) noexcept;
|
static TorrentInfo load(const QByteArray &data, QString *error = nullptr) noexcept;
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
using namespace Http;
|
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);
|
m_response.status = ResponseStatus(code, text);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ Server::Server(IRequestHandler *requestHandler, QObject *parent)
|
|||||||
dropConnectionTimer->start(CONNECTIONS_SCAN_INTERVAL * 1000);
|
dropConnectionTimer->start(CONNECTIONS_SCAN_INTERVAL * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::incomingConnection(qintptr socketDescriptor)
|
void Server::incomingConnection(const qintptr socketDescriptor)
|
||||||
{
|
{
|
||||||
if (m_connections.size() >= CONNECTIONS_LIMIT) return;
|
if (m_connections.size() >= CONNECTIONS_LIMIT) return;
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ void Server::dropTimedOutConnection()
|
|||||||
{
|
{
|
||||||
QMutableListIterator<Connection *> i(m_connections);
|
QMutableListIterator<Connection *> i(m_connections);
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
auto connection = i.next();
|
const auto *connection = i.next();
|
||||||
if (connection->isClosed() || connection->hasExpired(KEEP_ALIVE_DURATION)) {
|
if (connection->isClosed() || connection->hasExpired(KEEP_ALIVE_DURATION)) {
|
||||||
delete connection;
|
delete connection;
|
||||||
i.remove();
|
i.remove();
|
||||||
|
@ -65,7 +65,7 @@ void Logger::addMessage(const QString &message, const Log::MsgType &type)
|
|||||||
{
|
{
|
||||||
QWriteLocker locker(&m_lock);
|
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);
|
m_messages.push_back(temp);
|
||||||
|
|
||||||
if (m_messages.size() >= MAX_LOG_MESSAGES)
|
if (m_messages.size() >= MAX_LOG_MESSAGES)
|
||||||
@ -74,11 +74,11 @@ void Logger::addMessage(const QString &message, const Log::MsgType &type)
|
|||||||
emit newLogMessage(temp);
|
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);
|
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);
|
m_peers.push_back(temp);
|
||||||
|
|
||||||
if (m_peers.size() >= MAX_LOG_MESSAGES)
|
if (m_peers.size() >= MAX_LOG_MESSAGES)
|
||||||
@ -87,12 +87,12 @@ void Logger::addPeer(const QString &ip, bool blocked, const QString &reason)
|
|||||||
emit newLogPeer(temp);
|
emit newLogPeer(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<Log::Msg> Logger::getMessages(int lastKnownId) const
|
QVector<Log::Msg> Logger::getMessages(const int lastKnownId) const
|
||||||
{
|
{
|
||||||
QReadLocker locker(&m_lock);
|
QReadLocker locker(&m_lock);
|
||||||
|
|
||||||
int diff = m_msgCounter - lastKnownId - 1;
|
const int diff = m_msgCounter - lastKnownId - 1;
|
||||||
int size = m_messages.size();
|
const int size = m_messages.size();
|
||||||
|
|
||||||
if ((lastKnownId == -1) || (diff >= size))
|
if ((lastKnownId == -1) || (diff >= size))
|
||||||
return m_messages;
|
return m_messages;
|
||||||
@ -103,12 +103,12 @@ QVector<Log::Msg> Logger::getMessages(int lastKnownId) const
|
|||||||
return m_messages.mid(size - diff);
|
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);
|
QReadLocker locker(&m_lock);
|
||||||
|
|
||||||
int diff = m_peerCounter - lastKnownId - 1;
|
const int diff = m_peerCounter - lastKnownId - 1;
|
||||||
int size = m_peers.size();
|
const int size = m_peers.size();
|
||||||
|
|
||||||
if ((lastKnownId == -1) || (diff >= size))
|
if ((lastKnownId == -1) || (diff >= size))
|
||||||
return m_peers;
|
return m_peers;
|
||||||
|
@ -79,7 +79,7 @@ public:
|
|||||||
static Logger *instance();
|
static Logger *instance();
|
||||||
|
|
||||||
void addMessage(const QString &message, const Log::MsgType &type = Log::NORMAL);
|
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::Msg> getMessages(int lastKnownId = -1) const;
|
||||||
QVector<Log::Peer> getPeers(int lastKnownId = -1) const;
|
QVector<Log::Peer> getPeers(int lastKnownId = -1) const;
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ void DNSUpdater::processIPUpdateReply(const QString &reply)
|
|||||||
{
|
{
|
||||||
Logger *const logger = Logger::instance();
|
Logger *const logger = Logger::instance();
|
||||||
qDebug() << Q_FUNC_INFO << reply;
|
qDebug() << Q_FUNC_INFO << reply;
|
||||||
QString code = reply.split(' ').first();
|
const QString code = reply.split(' ').first();
|
||||||
qDebug() << Q_FUNC_INFO << "Code:" << code;
|
qDebug() << Q_FUNC_INFO << "Code:" << code;
|
||||||
|
|
||||||
if ((code == "good") || (code == "nochg")) {
|
if ((code == "good") || (code == "nochg")) {
|
||||||
@ -284,7 +284,7 @@ void DNSUpdater::updateCredentials()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl DNSUpdater::getRegistrationUrl(int service)
|
QUrl DNSUpdater::getRegistrationUrl(const int service)
|
||||||
{
|
{
|
||||||
switch (service) {
|
switch (service) {
|
||||||
case DNS::DYNDNS:
|
case DNS::DYNDNS:
|
||||||
|
@ -135,7 +135,7 @@ void Net::DownloadHandler::processFinishedDownload()
|
|||||||
this->deleteLater();
|
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.");
|
QString msg = tr("The file size is %1. It exceeds the download limit of %2.");
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ namespace
|
|||||||
explicit NetworkCookieJar(QObject *parent = nullptr)
|
explicit NetworkCookieJar(QObject *parent = nullptr)
|
||||||
: QNetworkCookieJar(parent)
|
: QNetworkCookieJar(parent)
|
||||||
{
|
{
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
const QDateTime now = QDateTime::currentDateTime();
|
||||||
QList<QNetworkCookie> cookies = Preferences::instance()->getNetworkCookies();
|
QList<QNetworkCookie> cookies = Preferences::instance()->getNetworkCookies();
|
||||||
for (const QNetworkCookie &cookie : asConst(Preferences::instance()->getNetworkCookies())) {
|
for (const QNetworkCookie &cookie : asConst(Preferences::instance()->getNetworkCookies())) {
|
||||||
if (cookie.isSessionCookie() || (cookie.expirationDate() <= now))
|
if (cookie.isSessionCookie() || (cookie.expirationDate() <= now))
|
||||||
@ -70,7 +70,7 @@ namespace
|
|||||||
|
|
||||||
~NetworkCookieJar() override
|
~NetworkCookieJar() override
|
||||||
{
|
{
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
const QDateTime now = QDateTime::currentDateTime();
|
||||||
QList<QNetworkCookie> cookies = allCookies();
|
QList<QNetworkCookie> cookies = allCookies();
|
||||||
for (const QNetworkCookie &cookie : asConst(allCookies())) {
|
for (const QNetworkCookie &cookie : asConst(allCookies())) {
|
||||||
if (cookie.isSessionCookie() || (cookie.expirationDate() <= now))
|
if (cookie.isSessionCookie() || (cookie.expirationDate() <= now))
|
||||||
@ -85,7 +85,7 @@ namespace
|
|||||||
|
|
||||||
QList<QNetworkCookie> cookiesForUrl(const QUrl &url) const override
|
QList<QNetworkCookie> cookiesForUrl(const QUrl &url) const override
|
||||||
{
|
{
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
const QDateTime now = QDateTime::currentDateTime();
|
||||||
QList<QNetworkCookie> cookies = QNetworkCookieJar::cookiesForUrl(url);
|
QList<QNetworkCookie> cookies = QNetworkCookieJar::cookiesForUrl(url);
|
||||||
for (const QNetworkCookie &cookie : asConst(QNetworkCookieJar::cookiesForUrl(url))) {
|
for (const QNetworkCookie &cookie : asConst(QNetworkCookieJar::cookiesForUrl(url))) {
|
||||||
if (!cookie.isSessionCookie() && (cookie.expirationDate() <= now))
|
if (!cookie.isSessionCookie() && (cookie.expirationDate() <= now))
|
||||||
@ -97,7 +97,7 @@ namespace
|
|||||||
|
|
||||||
bool setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const QUrl &url) override
|
bool setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const QUrl &url) override
|
||||||
{
|
{
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
const QDateTime now = QDateTime::currentDateTime();
|
||||||
QList<QNetworkCookie> cookies = cookieList;
|
QList<QNetworkCookie> cookies = cookieList;
|
||||||
for (const QNetworkCookie &cookie : cookieList) {
|
for (const QNetworkCookie &cookie : cookieList) {
|
||||||
if (!cookie.isSessionCookie() && (cookie.expirationDate() <= now))
|
if (!cookie.isSessionCookie() && (cookie.expirationDate() <= now))
|
||||||
@ -222,8 +222,8 @@ bool Net::DownloadManager::hasSupportedScheme(const QString &url)
|
|||||||
|
|
||||||
void Net::DownloadManager::applyProxySettings()
|
void Net::DownloadManager::applyProxySettings()
|
||||||
{
|
{
|
||||||
auto proxyManager = ProxyConfigurationManager::instance();
|
const auto *proxyManager = ProxyConfigurationManager::instance();
|
||||||
ProxyConfiguration proxyConfig = proxyManager->proxyConfiguration();
|
const ProxyConfiguration proxyConfig = proxyManager->proxyConfiguration();
|
||||||
QNetworkProxy proxy;
|
QNetworkProxy proxy;
|
||||||
|
|
||||||
if (!proxyManager->isProxyOnlyForTorrents() && (proxyConfig.type != ProxyType::None)) {
|
if (!proxyManager->isProxyOnlyForTorrents() && (proxyConfig.type != ProxyType::None)) {
|
||||||
@ -253,10 +253,10 @@ void Net::DownloadManager::applyProxySettings()
|
|||||||
m_networkManager.setProxy(proxy);
|
m_networkManager.setProxy(proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Net::DownloadManager::handleReplyFinished(QNetworkReply *reply)
|
void Net::DownloadManager::handleReplyFinished(const QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
const ServiceID id = ServiceID::fromURL(reply->url());
|
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()) {
|
if ((waitingJobsIter == m_waitingJobs.end()) || waitingJobsIter.value().isEmpty()) {
|
||||||
m_busyServices.remove(id);
|
m_busyServices.remove(id);
|
||||||
return;
|
return;
|
||||||
@ -311,7 +311,7 @@ qint64 Net::DownloadRequest::limit() const
|
|||||||
return m_limit;
|
return m_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
Net::DownloadRequest &Net::DownloadRequest::limit(qint64 value)
|
Net::DownloadRequest &Net::DownloadRequest::limit(const qint64 value)
|
||||||
{
|
{
|
||||||
m_limit = value;
|
m_limit = value;
|
||||||
return *this;
|
return *this;
|
||||||
@ -322,7 +322,7 @@ bool Net::DownloadRequest::saveToFile() const
|
|||||||
return m_saveToFile;
|
return m_saveToFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
Net::DownloadRequest &Net::DownloadRequest::saveToFile(bool value)
|
Net::DownloadRequest &Net::DownloadRequest::saveToFile(const bool value)
|
||||||
{
|
{
|
||||||
m_saveToFile = value;
|
m_saveToFile = value;
|
||||||
return *this;
|
return *this;
|
||||||
@ -333,7 +333,7 @@ bool Net::DownloadRequest::handleRedirectToMagnet() const
|
|||||||
return m_handleRedirectToMagnet;
|
return m_handleRedirectToMagnet;
|
||||||
}
|
}
|
||||||
|
|
||||||
Net::DownloadRequest &Net::DownloadRequest::handleRedirectToMagnet(bool value)
|
Net::DownloadRequest &Net::DownloadRequest::handleRedirectToMagnet(const bool value)
|
||||||
{
|
{
|
||||||
m_handleRedirectToMagnet = value;
|
m_handleRedirectToMagnet = value;
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -115,7 +115,7 @@ namespace Net
|
|||||||
explicit DownloadManager(QObject *parent = nullptr);
|
explicit DownloadManager(QObject *parent = nullptr);
|
||||||
|
|
||||||
void applyProxySettings();
|
void applyProxySettings();
|
||||||
void handleReplyFinished(QNetworkReply *reply);
|
void handleReplyFinished(const QNetworkReply *reply);
|
||||||
|
|
||||||
static DownloadManager *m_instance;
|
static DownloadManager *m_instance;
|
||||||
QNetworkAccessManager m_networkManager;
|
QNetworkAccessManager m_networkManager;
|
||||||
|
@ -95,7 +95,7 @@ void GeoIPManager::loadDatabase()
|
|||||||
m_geoIPDatabase = nullptr;
|
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("%1%2/%3").arg(specialFolderLocation(SpecialFolder::Data), GEOIP_FOLDER, GEOIP_FILENAME));
|
||||||
|
|
||||||
QString error;
|
QString error;
|
||||||
@ -118,7 +118,7 @@ void GeoIPManager::manageDatabaseUpdate()
|
|||||||
|
|
||||||
void GeoIPManager::downloadDatabaseFile()
|
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)
|
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QByteArray &)>(&Net::DownloadHandler::downloadFinished)
|
||||||
, this, &GeoIPManager::downloadFinished);
|
, this, &GeoIPManager::downloadFinished);
|
||||||
connect(handler, &Net::DownloadHandler::downloadFailed, this, &GeoIPManager::downloadFailed);
|
connect(handler, &Net::DownloadHandler::downloadFailed, this, &GeoIPManager::downloadFailed);
|
||||||
@ -434,7 +434,7 @@ void GeoIPManager::downloadFinished(const QString &url, QByteArray data)
|
|||||||
Logger::instance()->addMessage(tr("GeoIP database loaded. Type: %1. Build time: %2.")
|
Logger::instance()->addMessage(tr("GeoIP database loaded. Type: %1. Build time: %2.")
|
||||||
.arg(m_geoIPDatabase->type(), m_geoIPDatabase->buildEpoch().toString()),
|
.arg(m_geoIPDatabase->type(), m_geoIPDatabase->buildEpoch().toString()),
|
||||||
Log::INFO);
|
Log::INFO);
|
||||||
QString targetPath = Utils::Fs::expandPathAbs(
|
const QString targetPath = Utils::Fs::expandPathAbs(
|
||||||
specialFolderLocation(SpecialFolder::Data) + GEOIP_FOLDER);
|
specialFolderLocation(SpecialFolder::Data) + GEOIP_FOLDER);
|
||||||
if (!QDir(targetPath).exists())
|
if (!QDir(targetPath).exists())
|
||||||
QDir().mkpath(targetPath);
|
QDir().mkpath(targetPath);
|
||||||
|
@ -78,7 +78,7 @@ bool PortForwarder::isEnabled() const
|
|||||||
return m_active;
|
return m_active;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PortForwarder::setEnabled(bool enabled)
|
void PortForwarder::setEnabled(const bool enabled)
|
||||||
{
|
{
|
||||||
if (m_active != enabled) {
|
if (m_active != enabled) {
|
||||||
if (enabled)
|
if (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)) {
|
if (!m_mappedPorts.contains(port)) {
|
||||||
m_mappedPorts.insert(port, 0);
|
m_mappedPorts.insert(port, 0);
|
||||||
@ -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_mappedPorts.contains(port)) {
|
||||||
if (m_active)
|
if (m_active)
|
||||||
|
@ -74,7 +74,7 @@ struct DataFieldDescriptor
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
GeoIPDatabase::GeoIPDatabase(quint32 size)
|
GeoIPDatabase::GeoIPDatabase(const quint32 size)
|
||||||
: m_ipVersion(0)
|
: m_ipVersion(0)
|
||||||
, m_recordSize(0)
|
, m_recordSize(0)
|
||||||
, m_nodeCount(0)
|
, m_nodeCount(0)
|
||||||
@ -165,7 +165,7 @@ QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const
|
|||||||
|
|
||||||
for (int i = 0; i < 16; ++i) {
|
for (int i = 0; i < 16; ++i) {
|
||||||
for (int j = 0; j < 8; ++j) {
|
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
|
// Interpret the left/right record as number
|
||||||
if (right)
|
if (right)
|
||||||
ptr += m_recordBytes;
|
ptr += m_recordBytes;
|
||||||
@ -183,7 +183,7 @@ QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const
|
|||||||
if (country.isEmpty()) {
|
if (country.isEmpty()) {
|
||||||
const quint32 offset = id - m_nodeCount - sizeof(DATA_SECTION_SEPARATOR);
|
const quint32 offset = id - m_nodeCount - sizeof(DATA_SECTION_SEPARATOR);
|
||||||
quint32 tmp = offset + m_indexSize + 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) {
|
if (val.userType() == QMetaType::QVariantHash) {
|
||||||
country = val.toHash()["country"].toHash()["iso_code"].toString();
|
country = val.toHash()["country"].toHash()["iso_code"].toString();
|
||||||
m_countries[id] = country;
|
m_countries[id] = country;
|
||||||
@ -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_major_version, UShort);
|
||||||
CHECK_METADATA_REQ(binary_format_minor_version, UShort);
|
CHECK_METADATA_REQ(binary_format_minor_version, UShort);
|
||||||
uint versionMajor = metadata.value("binary_format_major_version").toUInt();
|
const uint versionMajor = metadata.value("binary_format_major_version").toUInt();
|
||||||
uint versionMinor = metadata.value("binary_format_minor_version").toUInt();
|
const uint versionMinor = metadata.value("binary_format_minor_version").toUInt();
|
||||||
if (versionMajor != 2) {
|
if (versionMajor != 2) {
|
||||||
error = tr("Unsupported database version: %1.%2").arg(versionMajor).arg(versionMinor);
|
error = tr("Unsupported database version: %1.%2").arg(versionMajor).arg(versionMinor);
|
||||||
return false;
|
return false;
|
||||||
@ -254,7 +254,7 @@ bool GeoIPDatabase::parseMetadata(const QVariantHash &metadata, QString &error)
|
|||||||
m_indexSize = m_nodeCount * m_nodeSize;
|
m_indexSize = m_nodeCount * m_nodeSize;
|
||||||
|
|
||||||
CHECK_METADATA_REQ(database_type, QString);
|
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) {
|
if (dbType != DB_TYPE) {
|
||||||
error = tr("Invalid database type: %1").arg(dbType);
|
error = tr("Invalid database type: %1").arg(dbType);
|
||||||
return false;
|
return false;
|
||||||
@ -299,7 +299,7 @@ QVariantHash GeoIPDatabase::readMetadata() const
|
|||||||
if (m_size > MAX_METADATA_SIZE)
|
if (m_size > MAX_METADATA_SIZE)
|
||||||
index += (m_size - MAX_METADATA_SIZE); // from begin of all data
|
index += (m_size - MAX_METADATA_SIZE); // from begin of all data
|
||||||
auto offset = static_cast<quint32>(index + strlen(METADATA_BEGIN_MARK));
|
auto offset = static_cast<quint32>(index + strlen(METADATA_BEGIN_MARK));
|
||||||
QVariant metadata = readDataField(offset);
|
const QVariant metadata = readDataField(offset);
|
||||||
if (metadata.userType() == QMetaType::QVariantHash)
|
if (metadata.userType() == QMetaType::QVariantHash)
|
||||||
return metadata.toHash();
|
return metadata.toHash();
|
||||||
}
|
}
|
||||||
@ -390,12 +390,12 @@ QVariant GeoIPDatabase::readDataField(quint32 &offset) const
|
|||||||
bool GeoIPDatabase::readDataFieldDescriptor(quint32 &offset, DataFieldDescriptor &out) const
|
bool GeoIPDatabase::readDataFieldDescriptor(quint32 &offset, DataFieldDescriptor &out) const
|
||||||
{
|
{
|
||||||
const uchar *dataPtr = m_data + offset;
|
const uchar *dataPtr = m_data + offset;
|
||||||
int availSize = m_size - offset;
|
const int availSize = m_size - offset;
|
||||||
if (availSize < 1) return false;
|
if (availSize < 1) return false;
|
||||||
|
|
||||||
out.fieldType = static_cast<DataType>((dataPtr[0] & 0xE0) >> 5);
|
out.fieldType = static_cast<DataType>((dataPtr[0] & 0xE0) >> 5);
|
||||||
if (out.fieldType == DataType::Pointer) {
|
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 (availSize < (size + 2)) return false;
|
||||||
|
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
@ -442,7 +442,7 @@ bool GeoIPDatabase::readDataFieldDescriptor(quint32 &offset, DataFieldDescriptor
|
|||||||
return true;
|
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)
|
#if (Q_BYTE_ORDER == Q_LITTLE_ENDIAN)
|
||||||
std::reverse(buf, buf + len);
|
std::reverse(buf, buf + len);
|
||||||
@ -452,7 +452,7 @@ void GeoIPDatabase::fromBigEndian(uchar *buf, quint32 len) const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant GeoIPDatabase::readMapValue(quint32 &offset, quint32 count) const
|
QVariant GeoIPDatabase::readMapValue(quint32 &offset, const quint32 count) const
|
||||||
{
|
{
|
||||||
QVariantHash map;
|
QVariantHash map;
|
||||||
|
|
||||||
@ -461,7 +461,7 @@ QVariant GeoIPDatabase::readMapValue(quint32 &offset, quint32 count) const
|
|||||||
if (field.userType() != QMetaType::QString)
|
if (field.userType() != QMetaType::QString)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
QString key = field.toString();
|
const QString key = field.toString();
|
||||||
field = readDataField(offset);
|
field = readDataField(offset);
|
||||||
if (field.userType() == QVariant::Invalid)
|
if (field.userType() == QVariant::Invalid)
|
||||||
return {};
|
return {};
|
||||||
@ -472,12 +472,12 @@ QVariant GeoIPDatabase::readMapValue(quint32 &offset, quint32 count) const
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant GeoIPDatabase::readArrayValue(quint32 &offset, quint32 count) const
|
QVariant GeoIPDatabase::readArrayValue(quint32 &offset, const quint32 count) const
|
||||||
{
|
{
|
||||||
QVariantList array;
|
QVariantList array;
|
||||||
|
|
||||||
for (quint32 i = 0; i < count; ++i) {
|
for (quint32 i = 0; i < count; ++i) {
|
||||||
QVariant field = readDataField(offset);
|
const QVariant field = readDataField(offset);
|
||||||
if (field.userType() == QVariant::Invalid)
|
if (field.userType() == QVariant::Invalid)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
@ -140,8 +140,8 @@ void Smtp::sendMail(const QString &from, const QString &to, const QString &subje
|
|||||||
+ "\r\n";
|
+ "\r\n";
|
||||||
// Encode the body in base64
|
// Encode the body in base64
|
||||||
QString crlfBody = body;
|
QString crlfBody = body;
|
||||||
QByteArray b = crlfBody.replace("\n", "\r\n").toUtf8().toBase64();
|
const QByteArray b = crlfBody.replace("\n", "\r\n").toUtf8().toBase64();
|
||||||
int ct = b.length();
|
const int ct = b.length();
|
||||||
for (int i = 0; i < ct; i += 78)
|
for (int i = 0; i < ct; i += 78)
|
||||||
m_message += b.mid(i, 78);
|
m_message += b.mid(i, 78);
|
||||||
m_from = from;
|
m_from = from;
|
||||||
@ -173,13 +173,13 @@ void Smtp::readyRead()
|
|||||||
// SMTP is line-oriented
|
// SMTP is line-oriented
|
||||||
m_buffer += m_socket->readAll();
|
m_buffer += m_socket->readAll();
|
||||||
while (true) {
|
while (true) {
|
||||||
int pos = m_buffer.indexOf("\r\n");
|
const int pos = m_buffer.indexOf("\r\n");
|
||||||
if (pos < 0) return; // Loop exit condition
|
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);
|
m_buffer = m_buffer.mid(pos + 2);
|
||||||
qDebug() << "Response line:" << line;
|
qDebug() << "Response line:" << line;
|
||||||
// Extract response code
|
// Extract response code
|
||||||
QByteArray code = line.left(3);
|
const QByteArray code = line.left(3);
|
||||||
|
|
||||||
switch (m_state) {
|
switch (m_state) {
|
||||||
case Init:
|
case Init:
|
||||||
@ -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 rv = "";
|
||||||
QByteArray line = key.toLatin1() + ": ";
|
QByteArray line = key.toLatin1() + ": ";
|
||||||
@ -307,10 +307,10 @@ QByteArray Smtp::encodeMimeHeader(const QString &key, const QString &value, QTex
|
|||||||
else {
|
else {
|
||||||
// The text cannot be losslessly encoded as Latin-1. Therefore, we
|
// The text cannot be losslessly encoded as Latin-1. Therefore, we
|
||||||
// must use base64 encoding.
|
// must use base64 encoding.
|
||||||
QByteArray utf8 = value.toUtf8();
|
const QByteArray utf8 = value.toUtf8();
|
||||||
// Use base64 encoding
|
// Use base64 encoding
|
||||||
QByteArray base64 = utf8.toBase64();
|
const QByteArray base64 = utf8.toBase64();
|
||||||
int ct = base64.length();
|
const int ct = base64.length();
|
||||||
line += "=?utf-8?b?";
|
line += "=?utf-8?b?";
|
||||||
for (int i = 0; i < ct; i += 4) {
|
for (int i = 0; i < ct; i += 4) {
|
||||||
/*if (line.length() > 72) {
|
/*if (line.length() > 72) {
|
||||||
@ -326,7 +326,7 @@ QByteArray Smtp::encodeMimeHeader(const QString &key, const QString &value, QTex
|
|||||||
|
|
||||||
void Smtp::ehlo()
|
void Smtp::ehlo()
|
||||||
{
|
{
|
||||||
QByteArray address = determineFQDN();
|
const QByteArray address = determineFQDN();
|
||||||
m_socket->write("ehlo " + address + "\r\n");
|
m_socket->write("ehlo " + address + "\r\n");
|
||||||
m_socket->flush();
|
m_socket->flush();
|
||||||
m_state = EhloSent;
|
m_state = EhloSent;
|
||||||
@ -334,13 +334,13 @@ void Smtp::ehlo()
|
|||||||
|
|
||||||
void Smtp::helo()
|
void Smtp::helo()
|
||||||
{
|
{
|
||||||
QByteArray address = determineFQDN();
|
const QByteArray address = determineFQDN();
|
||||||
m_socket->write("helo " + address + "\r\n");
|
m_socket->write("helo " + address + "\r\n");
|
||||||
m_socket->flush();
|
m_socket->flush();
|
||||||
m_state = HeloSent;
|
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") {
|
if (code != "250") {
|
||||||
// Error
|
// Error
|
||||||
@ -407,7 +407,7 @@ void Smtp::authenticate()
|
|||||||
// AUTH extension is supported, check which
|
// AUTH extension is supported, check which
|
||||||
// authentication modes are supported by
|
// authentication modes are supported by
|
||||||
// the server
|
// 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")) {
|
if (auth.contains("CRAM-MD5")) {
|
||||||
qDebug() << "Using CRAM-MD5 authentication...";
|
qDebug() << "Using CRAM-MD5 authentication...";
|
||||||
authCramMD5();
|
authCramMD5();
|
||||||
@ -454,7 +454,7 @@ void Smtp::authCramMD5(const QByteArray &challenge)
|
|||||||
m_state = AuthRequestSent;
|
m_state = AuthRequestSent;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QByteArray response = m_username.toLatin1() + ' '
|
const QByteArray response = m_username.toLatin1() + ' '
|
||||||
+ hmacMD5(m_password.toLatin1(), QByteArray::fromBase64(challenge)).toHex();
|
+ hmacMD5(m_password.toLatin1(), QByteArray::fromBase64(challenge)).toHex();
|
||||||
m_socket->write(response.toBase64() + "\r\n");
|
m_socket->write(response.toBase64() + "\r\n");
|
||||||
m_socket->flush();
|
m_socket->flush();
|
||||||
@ -514,23 +514,23 @@ QString Smtp::getCurrentDateTime() const
|
|||||||
const QDate nowDate = nowDateTime.date();
|
const QDate nowDate = nowDateTime.date();
|
||||||
const QLocale eng(QLocale::English);
|
const QLocale eng(QLocale::English);
|
||||||
|
|
||||||
QString timeStr = nowDateTime.time().toString("HH:mm:ss");
|
const QString timeStr = nowDateTime.time().toString("HH:mm:ss");
|
||||||
QString weekDayStr = eng.dayName(nowDate.dayOfWeek(), QLocale::ShortFormat);
|
const QString weekDayStr = eng.dayName(nowDate.dayOfWeek(), QLocale::ShortFormat);
|
||||||
QString dayStr = QString::number(nowDate.day());
|
const QString dayStr = QString::number(nowDate.day());
|
||||||
QString monthStr = eng.monthName(nowDate.month(), QLocale::ShortFormat);
|
const QString monthStr = eng.monthName(nowDate.month(), QLocale::ShortFormat);
|
||||||
QString yearStr = QString::number(nowDate.year());
|
const QString yearStr = QString::number(nowDate.year());
|
||||||
|
|
||||||
QDateTime tmp = nowDateTime;
|
QDateTime tmp = nowDateTime;
|
||||||
tmp.setTimeSpec(Qt::UTC);
|
tmp.setTimeSpec(Qt::UTC);
|
||||||
int timeOffsetHour = nowDateTime.secsTo(tmp) / 3600;
|
const int timeOffsetHour = nowDateTime.secsTo(tmp) / 3600;
|
||||||
int timeOffsetMin = nowDateTime.secsTo(tmp) / 60 - (60 * timeOffsetHour);
|
const int timeOffsetMin = nowDateTime.secsTo(tmp) / 60 - (60 * timeOffsetHour);
|
||||||
int timeOffset = timeOffsetHour * 100 + timeOffsetMin;
|
const int timeOffset = timeOffsetHour * 100 + timeOffsetMin;
|
||||||
// buf size = 11 to avoid format truncation warnings from snprintf
|
// buf size = 11 to avoid format truncation warnings from snprintf
|
||||||
char buf[11] = {0};
|
char buf[11] = {0};
|
||||||
std::snprintf(buf, sizeof(buf), "%+05d", timeOffset);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,13 +90,13 @@ namespace Net
|
|||||||
AuthCramMD5
|
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 ehlo();
|
||||||
void helo();
|
void helo();
|
||||||
void parseEhloResponse(const QByteArray &code, bool continued, const QString &line);
|
void parseEhloResponse(const QByteArray &code, bool continued, const QString &line);
|
||||||
void authenticate();
|
void authenticate();
|
||||||
void startTLS();
|
void startTLS();
|
||||||
void authCramMD5(const QByteArray &challenge = QByteArray());
|
void authCramMD5(const QByteArray &challenge = {});
|
||||||
void authPlain();
|
void authPlain();
|
||||||
void authLogin();
|
void authLogin();
|
||||||
void logError(const QString &msg);
|
void logError(const QString &msg);
|
||||||
|
@ -104,7 +104,7 @@ bool Preferences::deleteTorrentFilesAsDefault() const
|
|||||||
return value("Preferences/General/DeleteTorrentsFilesAsDefault", false).toBool();
|
return value("Preferences/General/DeleteTorrentsFilesAsDefault", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setDeleteTorrentFilesAsDefault(bool del)
|
void Preferences::setDeleteTorrentFilesAsDefault(const bool del)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/DeleteTorrentsFilesAsDefault", del);
|
setValue("Preferences/General/DeleteTorrentsFilesAsDefault", del);
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ bool Preferences::confirmOnExit() const
|
|||||||
return value("Preferences/General/ExitConfirm", true).toBool();
|
return value("Preferences/General/ExitConfirm", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setConfirmOnExit(bool confirm)
|
void Preferences::setConfirmOnExit(const bool confirm)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/ExitConfirm", confirm);
|
setValue("Preferences/General/ExitConfirm", confirm);
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ bool Preferences::speedInTitleBar() const
|
|||||||
return value("Preferences/General/SpeedInTitleBar", false).toBool();
|
return value("Preferences/General/SpeedInTitleBar", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::showSpeedInTitleBar(bool show)
|
void Preferences::showSpeedInTitleBar(const bool show)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/SpeedInTitleBar", show);
|
setValue("Preferences/General/SpeedInTitleBar", show);
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ bool Preferences::useAlternatingRowColors() const
|
|||||||
return value("Preferences/General/AlternatingRowColors", true).toBool();
|
return value("Preferences/General/AlternatingRowColors", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setAlternatingRowColors(bool b)
|
void Preferences::setAlternatingRowColors(const bool b)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/AlternatingRowColors", b);
|
setValue("Preferences/General/AlternatingRowColors", b);
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ bool Preferences::getHideZeroValues() const
|
|||||||
return value("Preferences/General/HideZeroValues", false).toBool();
|
return value("Preferences/General/HideZeroValues", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setHideZeroValues(bool b)
|
void Preferences::setHideZeroValues(const bool b)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/HideZeroValues", b);
|
setValue("Preferences/General/HideZeroValues", b);
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ int Preferences::getHideZeroComboValues() const
|
|||||||
return value("Preferences/General/HideZeroComboValues", 0).toInt();
|
return value("Preferences/General/HideZeroComboValues", 0).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setHideZeroComboValues(int n)
|
void Preferences::setHideZeroComboValues(const int n)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/HideZeroComboValues", n);
|
setValue("Preferences/General/HideZeroComboValues", n);
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ bool Preferences::systrayIntegration() const
|
|||||||
return value("Preferences/General/SystrayEnabled", true).toBool();
|
return value("Preferences/General/SystrayEnabled", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setSystrayIntegration(bool enabled)
|
void Preferences::setSystrayIntegration(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/SystrayEnabled", enabled);
|
setValue("Preferences/General/SystrayEnabled", enabled);
|
||||||
}
|
}
|
||||||
@ -177,7 +177,7 @@ bool Preferences::minimizeToTray() const
|
|||||||
return value("Preferences/General/MinimizeToTray", false).toBool();
|
return value("Preferences/General/MinimizeToTray", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setMinimizeToTray(bool b)
|
void Preferences::setMinimizeToTray(const bool b)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/MinimizeToTray", b);
|
setValue("Preferences/General/MinimizeToTray", b);
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ bool Preferences::minimizeToTrayNotified() const
|
|||||||
return value("Preferences/General/MinimizeToTrayNotified", false).toBool();
|
return value("Preferences/General/MinimizeToTrayNotified", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setMinimizeToTrayNotified(bool b)
|
void Preferences::setMinimizeToTrayNotified(const bool b)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/MinimizeToTrayNotified", b);
|
setValue("Preferences/General/MinimizeToTrayNotified", b);
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ bool Preferences::closeToTray() const
|
|||||||
return value("Preferences/General/CloseToTray", true).toBool();
|
return value("Preferences/General/CloseToTray", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setCloseToTray(bool b)
|
void Preferences::setCloseToTray(const bool b)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/CloseToTray", b);
|
setValue("Preferences/General/CloseToTray", b);
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ bool Preferences::closeToTrayNotified() const
|
|||||||
return value("Preferences/General/CloseToTrayNotified", false).toBool();
|
return value("Preferences/General/CloseToTrayNotified", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setCloseToTrayNotified(bool b)
|
void Preferences::setCloseToTrayNotified(const bool b)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/CloseToTrayNotified", b);
|
setValue("Preferences/General/CloseToTrayNotified", b);
|
||||||
}
|
}
|
||||||
@ -218,7 +218,7 @@ bool Preferences::isToolbarDisplayed() const
|
|||||||
return value("Preferences/General/ToolbarDisplayed", true).toBool();
|
return value("Preferences/General/ToolbarDisplayed", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setToolbarDisplayed(bool displayed)
|
void Preferences::setToolbarDisplayed(const bool displayed)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/ToolbarDisplayed", displayed);
|
setValue("Preferences/General/ToolbarDisplayed", displayed);
|
||||||
}
|
}
|
||||||
@ -228,7 +228,7 @@ bool Preferences::isStatusbarDisplayed() const
|
|||||||
return value("Preferences/General/StatusbarDisplayed", true).toBool();
|
return value("Preferences/General/StatusbarDisplayed", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setStatusbarDisplayed(bool displayed)
|
void Preferences::setStatusbarDisplayed(const bool displayed)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/StatusbarDisplayed", displayed);
|
setValue("Preferences/General/StatusbarDisplayed", displayed);
|
||||||
}
|
}
|
||||||
@ -238,7 +238,7 @@ bool Preferences::startMinimized() const
|
|||||||
return value("Preferences/General/StartMinimized", false).toBool();
|
return value("Preferences/General/StartMinimized", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setStartMinimized(bool b)
|
void Preferences::setStartMinimized(const bool b)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/StartMinimized", b);
|
setValue("Preferences/General/StartMinimized", b);
|
||||||
}
|
}
|
||||||
@ -248,7 +248,7 @@ bool Preferences::isSplashScreenDisabled() const
|
|||||||
return value("Preferences/General/NoSplashScreen", true).toBool();
|
return value("Preferences/General/NoSplashScreen", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setSplashScreenDisabled(bool b)
|
void Preferences::setSplashScreenDisabled(const bool b)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/NoSplashScreen", b);
|
setValue("Preferences/General/NoSplashScreen", b);
|
||||||
}
|
}
|
||||||
@ -259,7 +259,7 @@ bool Preferences::preventFromSuspendWhenDownloading() const
|
|||||||
return value("Preferences/General/PreventFromSuspendWhenDownloading", false).toBool();
|
return value("Preferences/General/PreventFromSuspendWhenDownloading", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setPreventFromSuspendWhenDownloading(bool b)
|
void Preferences::setPreventFromSuspendWhenDownloading(const bool b)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/PreventFromSuspendWhenDownloading", b);
|
setValue("Preferences/General/PreventFromSuspendWhenDownloading", b);
|
||||||
}
|
}
|
||||||
@ -269,7 +269,7 @@ bool Preferences::preventFromSuspendWhenSeeding() const
|
|||||||
return value("Preferences/General/PreventFromSuspendWhenSeeding", false).toBool();
|
return value("Preferences/General/PreventFromSuspendWhenSeeding", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setPreventFromSuspendWhenSeeding(bool b)
|
void Preferences::setPreventFromSuspendWhenSeeding(const bool b)
|
||||||
{
|
{
|
||||||
setValue("Preferences/General/PreventFromSuspendWhenSeeding", b);
|
setValue("Preferences/General/PreventFromSuspendWhenSeeding", b);
|
||||||
}
|
}
|
||||||
@ -281,7 +281,7 @@ bool Preferences::WinStartup() const
|
|||||||
return settings.contains("qBittorrent");
|
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);
|
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
|
||||||
if (b) {
|
if (b) {
|
||||||
@ -331,7 +331,7 @@ bool Preferences::isMailNotificationEnabled() const
|
|||||||
return value("Preferences/MailNotification/enabled", false).toBool();
|
return value("Preferences/MailNotification/enabled", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setMailNotificationEnabled(bool enabled)
|
void Preferences::setMailNotificationEnabled(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("Preferences/MailNotification/enabled", enabled);
|
setValue("Preferences/MailNotification/enabled", enabled);
|
||||||
}
|
}
|
||||||
@ -371,7 +371,7 @@ bool Preferences::getMailNotificationSMTPSSL() const
|
|||||||
return value("Preferences/MailNotification/req_ssl", false).toBool();
|
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);
|
setValue("Preferences/MailNotification/req_ssl", use);
|
||||||
}
|
}
|
||||||
@ -381,7 +381,7 @@ bool Preferences::getMailNotificationSMTPAuth() const
|
|||||||
return value("Preferences/MailNotification/req_auth", false).toBool();
|
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);
|
setValue("Preferences/MailNotification/req_auth", use);
|
||||||
}
|
}
|
||||||
@ -411,7 +411,7 @@ int Preferences::getActionOnDblClOnTorrentDl() const
|
|||||||
return value("Preferences/Downloads/DblClOnTorDl", 0).toInt();
|
return value("Preferences/Downloads/DblClOnTorDl", 0).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setActionOnDblClOnTorrentDl(int act)
|
void Preferences::setActionOnDblClOnTorrentDl(const int act)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Downloads/DblClOnTorDl", act);
|
setValue("Preferences/Downloads/DblClOnTorDl", act);
|
||||||
}
|
}
|
||||||
@ -421,7 +421,7 @@ int Preferences::getActionOnDblClOnTorrentFn() const
|
|||||||
return value("Preferences/Downloads/DblClOnTorFn", 1).toInt();
|
return value("Preferences/Downloads/DblClOnTorFn", 1).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setActionOnDblClOnTorrentFn(int act)
|
void Preferences::setActionOnDblClOnTorrentFn(const int act)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Downloads/DblClOnTorFn", act);
|
setValue("Preferences/Downloads/DblClOnTorFn", act);
|
||||||
}
|
}
|
||||||
@ -451,7 +451,7 @@ SchedulerDays Preferences::getSchedulerDays() const
|
|||||||
return static_cast<SchedulerDays>(value("Preferences/Scheduler/days", EVERY_DAY).toInt());
|
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));
|
setValue("Preferences/Scheduler/days", static_cast<int>(days));
|
||||||
}
|
}
|
||||||
@ -462,7 +462,7 @@ bool Preferences::isSearchEnabled() const
|
|||||||
return value("Preferences/Search/SearchEnabled", false).toBool();
|
return value("Preferences/Search/SearchEnabled", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setSearchEnabled(bool enabled)
|
void Preferences::setSearchEnabled(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Search/SearchEnabled", enabled);
|
setValue("Preferences/Search/SearchEnabled", enabled);
|
||||||
}
|
}
|
||||||
@ -476,7 +476,7 @@ bool Preferences::isWebUiEnabled() const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setWebUiEnabled(bool enabled)
|
void Preferences::setWebUiEnabled(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("Preferences/WebUI/Enabled", enabled);
|
setValue("Preferences/WebUI/Enabled", enabled);
|
||||||
}
|
}
|
||||||
@ -486,7 +486,7 @@ bool Preferences::isWebUiLocalAuthEnabled() const
|
|||||||
return value("Preferences/WebUI/LocalHostAuth", true).toBool();
|
return value("Preferences/WebUI/LocalHostAuth", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setWebUiLocalAuthEnabled(bool enabled)
|
void Preferences::setWebUiLocalAuthEnabled(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("Preferences/WebUI/LocalHostAuth", enabled);
|
setValue("Preferences/WebUI/LocalHostAuth", enabled);
|
||||||
}
|
}
|
||||||
@ -496,7 +496,7 @@ bool Preferences::isWebUiAuthSubnetWhitelistEnabled() const
|
|||||||
return value("Preferences/WebUI/AuthSubnetWhitelistEnabled", false).toBool();
|
return value("Preferences/WebUI/AuthSubnetWhitelistEnabled", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setWebUiAuthSubnetWhitelistEnabled(bool enabled)
|
void Preferences::setWebUiAuthSubnetWhitelistEnabled(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("Preferences/WebUI/AuthSubnetWhitelistEnabled", enabled);
|
setValue("Preferences/WebUI/AuthSubnetWhitelistEnabled", enabled);
|
||||||
}
|
}
|
||||||
@ -552,7 +552,7 @@ quint16 Preferences::getWebUiPort() const
|
|||||||
return value("Preferences/WebUI/Port", 8080).toInt();
|
return value("Preferences/WebUI/Port", 8080).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setWebUiPort(quint16 port)
|
void Preferences::setWebUiPort(const quint16 port)
|
||||||
{
|
{
|
||||||
setValue("Preferences/WebUI/Port", port);
|
setValue("Preferences/WebUI/Port", port);
|
||||||
}
|
}
|
||||||
@ -566,7 +566,7 @@ bool Preferences::useUPnPForWebUIPort() const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setUPnPForWebUIPort(bool enabled)
|
void Preferences::setUPnPForWebUIPort(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("Preferences/WebUI/UseUPnP", enabled);
|
setValue("Preferences/WebUI/UseUPnP", enabled);
|
||||||
}
|
}
|
||||||
@ -598,7 +598,7 @@ bool Preferences::isWebUiClickjackingProtectionEnabled() const
|
|||||||
return value("Preferences/WebUI/ClickjackingProtection", true).toBool();
|
return value("Preferences/WebUI/ClickjackingProtection", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setWebUiClickjackingProtectionEnabled(bool enabled)
|
void Preferences::setWebUiClickjackingProtectionEnabled(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("Preferences/WebUI/ClickjackingProtection", enabled);
|
setValue("Preferences/WebUI/ClickjackingProtection", enabled);
|
||||||
}
|
}
|
||||||
@ -608,7 +608,7 @@ bool Preferences::isWebUiCSRFProtectionEnabled() const
|
|||||||
return value("Preferences/WebUI/CSRFProtection", true).toBool();
|
return value("Preferences/WebUI/CSRFProtection", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setWebUiCSRFProtectionEnabled(bool enabled)
|
void Preferences::setWebUiCSRFProtectionEnabled(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("Preferences/WebUI/CSRFProtection", enabled);
|
setValue("Preferences/WebUI/CSRFProtection", enabled);
|
||||||
}
|
}
|
||||||
@ -628,7 +628,7 @@ bool Preferences::isWebUiHttpsEnabled() const
|
|||||||
return value("Preferences/WebUI/HTTPS/Enabled", false).toBool();
|
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);
|
setValue("Preferences/WebUI/HTTPS/Enabled", enabled);
|
||||||
}
|
}
|
||||||
@ -658,7 +658,7 @@ bool Preferences::isAltWebUiEnabled() const
|
|||||||
return value("Preferences/WebUI/AlternativeUIEnabled", false).toBool();
|
return value("Preferences/WebUI/AlternativeUIEnabled", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setAltWebUiEnabled(bool enabled)
|
void Preferences::setAltWebUiEnabled(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("Preferences/WebUI/AlternativeUIEnabled", enabled);
|
setValue("Preferences/WebUI/AlternativeUIEnabled", enabled);
|
||||||
}
|
}
|
||||||
@ -678,7 +678,7 @@ bool Preferences::isDynDNSEnabled() const
|
|||||||
return value("Preferences/DynDNS/Enabled", false).toBool();
|
return value("Preferences/DynDNS/Enabled", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setDynDNSEnabled(bool enabled)
|
void Preferences::setDynDNSEnabled(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("Preferences/DynDNS/Enabled", enabled);
|
setValue("Preferences/DynDNS/Enabled", enabled);
|
||||||
}
|
}
|
||||||
@ -688,7 +688,7 @@ DNS::Service Preferences::getDynDNSService() const
|
|||||||
return DNS::Service(value("Preferences/DynDNS/Service", DNS::DYNDNS).toInt());
|
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);
|
setValue("Preferences/DynDNS/Service", service);
|
||||||
}
|
}
|
||||||
@ -739,7 +739,7 @@ bool Preferences::isUILocked() const
|
|||||||
return value("Locking/locked", false).toBool();
|
return value("Locking/locked", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setUILocked(bool locked)
|
void Preferences::setUILocked(const bool locked)
|
||||||
{
|
{
|
||||||
return setValue("Locking/locked", locked);
|
return setValue("Locking/locked", locked);
|
||||||
}
|
}
|
||||||
@ -749,7 +749,7 @@ bool Preferences::isAutoRunEnabled() const
|
|||||||
return value("AutoRun/enabled", false).toBool();
|
return value("AutoRun/enabled", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setAutoRunEnabled(bool enabled)
|
void Preferences::setAutoRunEnabled(const bool enabled)
|
||||||
{
|
{
|
||||||
return setValue("AutoRun/enabled", enabled);
|
return setValue("AutoRun/enabled", enabled);
|
||||||
}
|
}
|
||||||
@ -769,7 +769,7 @@ bool Preferences::shutdownWhenDownloadsComplete() const
|
|||||||
return value("Preferences/Downloads/AutoShutDownOnCompletion", false).toBool();
|
return value("Preferences/Downloads/AutoShutDownOnCompletion", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setShutdownWhenDownloadsComplete(bool shutdown)
|
void Preferences::setShutdownWhenDownloadsComplete(const bool shutdown)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Downloads/AutoShutDownOnCompletion", shutdown);
|
setValue("Preferences/Downloads/AutoShutDownOnCompletion", shutdown);
|
||||||
}
|
}
|
||||||
@ -779,7 +779,7 @@ bool Preferences::suspendWhenDownloadsComplete() const
|
|||||||
return value("Preferences/Downloads/AutoSuspendOnCompletion", false).toBool();
|
return value("Preferences/Downloads/AutoSuspendOnCompletion", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setSuspendWhenDownloadsComplete(bool suspend)
|
void Preferences::setSuspendWhenDownloadsComplete(const bool suspend)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Downloads/AutoSuspendOnCompletion", suspend);
|
setValue("Preferences/Downloads/AutoSuspendOnCompletion", suspend);
|
||||||
}
|
}
|
||||||
@ -789,7 +789,7 @@ bool Preferences::hibernateWhenDownloadsComplete() const
|
|||||||
return value("Preferences/Downloads/AutoHibernateOnCompletion", false).toBool();
|
return value("Preferences/Downloads/AutoHibernateOnCompletion", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setHibernateWhenDownloadsComplete(bool hibernate)
|
void Preferences::setHibernateWhenDownloadsComplete(const bool hibernate)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Downloads/AutoHibernateOnCompletion", hibernate);
|
setValue("Preferences/Downloads/AutoHibernateOnCompletion", hibernate);
|
||||||
}
|
}
|
||||||
@ -799,7 +799,7 @@ bool Preferences::shutdownqBTWhenDownloadsComplete() const
|
|||||||
return value("Preferences/Downloads/AutoShutDownqBTOnCompletion", false).toBool();
|
return value("Preferences/Downloads/AutoShutDownqBTOnCompletion", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setShutdownqBTWhenDownloadsComplete(bool shutdown)
|
void Preferences::setShutdownqBTWhenDownloadsComplete(const bool shutdown)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Downloads/AutoShutDownqBTOnCompletion", shutdown);
|
setValue("Preferences/Downloads/AutoShutDownqBTOnCompletion", shutdown);
|
||||||
}
|
}
|
||||||
@ -809,7 +809,7 @@ bool Preferences::dontConfirmAutoExit() const
|
|||||||
return value("ShutdownConfirmDlg/DontConfirmAutoExit", false).toBool();
|
return value("ShutdownConfirmDlg/DontConfirmAutoExit", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setDontConfirmAutoExit(bool dontConfirmAutoExit)
|
void Preferences::setDontConfirmAutoExit(const bool dontConfirmAutoExit)
|
||||||
{
|
{
|
||||||
setValue("ShutdownConfirmDlg/DontConfirmAutoExit", dontConfirmAutoExit);
|
setValue("ShutdownConfirmDlg/DontConfirmAutoExit", dontConfirmAutoExit);
|
||||||
}
|
}
|
||||||
@ -819,7 +819,7 @@ bool Preferences::recheckTorrentsOnCompletion() const
|
|||||||
return value("Preferences/Advanced/RecheckOnCompletion", false).toBool();
|
return value("Preferences/Advanced/RecheckOnCompletion", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::recheckTorrentsOnCompletion(bool recheck)
|
void Preferences::recheckTorrentsOnCompletion(const bool recheck)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Advanced/RecheckOnCompletion", recheck);
|
setValue("Preferences/Advanced/RecheckOnCompletion", recheck);
|
||||||
}
|
}
|
||||||
@ -829,7 +829,7 @@ bool Preferences::resolvePeerCountries() const
|
|||||||
return value("Preferences/Connection/ResolvePeerCountries", true).toBool();
|
return value("Preferences/Connection/ResolvePeerCountries", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::resolvePeerCountries(bool resolve)
|
void Preferences::resolvePeerCountries(const bool resolve)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Connection/ResolvePeerCountries", resolve);
|
setValue("Preferences/Connection/ResolvePeerCountries", resolve);
|
||||||
}
|
}
|
||||||
@ -839,7 +839,7 @@ bool Preferences::resolvePeerHostNames() const
|
|||||||
return value("Preferences/Connection/ResolvePeerHostNames", false).toBool();
|
return value("Preferences/Connection/ResolvePeerHostNames", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::resolvePeerHostNames(bool resolve)
|
void Preferences::resolvePeerHostNames(const bool resolve)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Connection/ResolvePeerHostNames", resolve);
|
setValue("Preferences/Connection/ResolvePeerHostNames", resolve);
|
||||||
}
|
}
|
||||||
@ -850,7 +850,7 @@ bool Preferences::useSystemIconTheme() const
|
|||||||
return value("Preferences/Advanced/useSystemIconTheme", true).toBool();
|
return value("Preferences/Advanced/useSystemIconTheme", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::useSystemIconTheme(bool enabled)
|
void Preferences::useSystemIconTheme(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Advanced/useSystemIconTheme", enabled);
|
setValue("Preferences/Advanced/useSystemIconTheme", enabled);
|
||||||
}
|
}
|
||||||
@ -861,7 +861,7 @@ bool Preferences::recursiveDownloadDisabled() const
|
|||||||
return value("Preferences/Advanced/DisableRecursiveDownload", false).toBool();
|
return value("Preferences/Advanced/DisableRecursiveDownload", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::disableRecursiveDownload(bool disable)
|
void Preferences::disableRecursiveDownload(const bool disable)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Advanced/DisableRecursiveDownload", disable);
|
setValue("Preferences/Advanced/DisableRecursiveDownload", disable);
|
||||||
}
|
}
|
||||||
@ -872,14 +872,14 @@ bool Preferences::neverCheckFileAssoc() const
|
|||||||
return value("Preferences/Win32/NeverCheckFileAssocation", false).toBool();
|
return value("Preferences/Win32/NeverCheckFileAssocation", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setNeverCheckFileAssoc(bool check)
|
void Preferences::setNeverCheckFileAssoc(const bool check)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Win32/NeverCheckFileAssocation", check);
|
setValue("Preferences/Win32/NeverCheckFileAssocation", check);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Preferences::isTorrentFileAssocSet()
|
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") {
|
if (settings.value(".torrent/Default").toString() != "qBittorrent") {
|
||||||
qDebug(".torrent != qBittorrent");
|
qDebug(".torrent != qBittorrent");
|
||||||
return false;
|
return false;
|
||||||
@ -890,7 +890,7 @@ bool Preferences::isTorrentFileAssocSet()
|
|||||||
|
|
||||||
bool Preferences::isMagnetLinkAssocSet()
|
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
|
// Check magnet link assoc
|
||||||
const QString shellCommand = Utils::Fs::toNativePath(settings.value("magnet/shell/open/command/Default", "").toString());
|
const QString shellCommand = Utils::Fs::toNativePath(settings.value("magnet/shell/open/command/Default", "").toString());
|
||||||
@ -906,13 +906,13 @@ bool Preferences::isMagnetLinkAssocSet()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setTorrentFileAssoc(bool set)
|
void Preferences::setTorrentFileAssoc(const bool set)
|
||||||
{
|
{
|
||||||
QSettings settings("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
|
QSettings settings("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
|
||||||
|
|
||||||
// .Torrent association
|
// .Torrent association
|
||||||
if (set) {
|
if (set) {
|
||||||
QString oldProgId = settings.value(".torrent/Default").toString();
|
const QString oldProgId = settings.value(".torrent/Default").toString();
|
||||||
if (!oldProgId.isEmpty() && (oldProgId != "qBittorrent"))
|
if (!oldProgId.isEmpty() && (oldProgId != "qBittorrent"))
|
||||||
settings.setValue(".torrent/OpenWithProgids/" + oldProgId, "");
|
settings.setValue(".torrent/OpenWithProgids/" + oldProgId, "");
|
||||||
settings.setValue(".torrent/Default", "qBittorrent");
|
settings.setValue(".torrent/Default", "qBittorrent");
|
||||||
@ -924,7 +924,7 @@ void Preferences::setTorrentFileAssoc(bool set)
|
|||||||
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
|
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);
|
QSettings settings("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
|
||||||
|
|
||||||
@ -951,18 +951,18 @@ void Preferences::setMagnetLinkAssoc(bool set)
|
|||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
CFStringRef torrentExtension = CFSTR("torrent");
|
const CFStringRef torrentExtension = CFSTR("torrent");
|
||||||
CFStringRef magnetUrlScheme = CFSTR("magnet");
|
const CFStringRef magnetUrlScheme = CFSTR("magnet");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Preferences::isTorrentFileAssocSet()
|
bool Preferences::isTorrentFileAssocSet()
|
||||||
{
|
{
|
||||||
bool isSet = false;
|
bool isSet = false;
|
||||||
CFStringRef torrentId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, torrentExtension, NULL);
|
const CFStringRef torrentId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, torrentExtension, NULL);
|
||||||
if (torrentId != NULL) {
|
if (torrentId != NULL) {
|
||||||
CFStringRef defaultHandlerId = LSCopyDefaultRoleHandlerForContentType(torrentId, kLSRolesViewer);
|
const CFStringRef defaultHandlerId = LSCopyDefaultRoleHandlerForContentType(torrentId, kLSRolesViewer);
|
||||||
if (defaultHandlerId != NULL) {
|
if (defaultHandlerId != NULL) {
|
||||||
CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
|
const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
|
||||||
isSet = CFStringCompare(myBundleId, defaultHandlerId, 0) == kCFCompareEqualTo;
|
isSet = CFStringCompare(myBundleId, defaultHandlerId, 0) == kCFCompareEqualTo;
|
||||||
CFRelease(defaultHandlerId);
|
CFRelease(defaultHandlerId);
|
||||||
}
|
}
|
||||||
@ -974,9 +974,9 @@ bool Preferences::isTorrentFileAssocSet()
|
|||||||
bool Preferences::isMagnetLinkAssocSet()
|
bool Preferences::isMagnetLinkAssocSet()
|
||||||
{
|
{
|
||||||
bool isSet = false;
|
bool isSet = false;
|
||||||
CFStringRef defaultHandlerId = LSCopyDefaultHandlerForURLScheme(magnetUrlScheme);
|
const CFStringRef defaultHandlerId = LSCopyDefaultHandlerForURLScheme(magnetUrlScheme);
|
||||||
if (defaultHandlerId != NULL) {
|
if (defaultHandlerId != NULL) {
|
||||||
CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
|
const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
|
||||||
isSet = CFStringCompare(myBundleId, defaultHandlerId, 0) == kCFCompareEqualTo;
|
isSet = CFStringCompare(myBundleId, defaultHandlerId, 0) == kCFCompareEqualTo;
|
||||||
CFRelease(defaultHandlerId);
|
CFRelease(defaultHandlerId);
|
||||||
}
|
}
|
||||||
@ -987,9 +987,9 @@ void Preferences::setTorrentFileAssoc()
|
|||||||
{
|
{
|
||||||
if (isTorrentFileAssocSet())
|
if (isTorrentFileAssocSet())
|
||||||
return;
|
return;
|
||||||
CFStringRef torrentId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, torrentExtension, NULL);
|
const CFStringRef torrentId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, torrentExtension, NULL);
|
||||||
if (torrentId != NULL) {
|
if (torrentId != NULL) {
|
||||||
CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
|
const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
|
||||||
LSSetDefaultRoleHandlerForContentType(torrentId, kLSRolesViewer, myBundleId);
|
LSSetDefaultRoleHandlerForContentType(torrentId, kLSRolesViewer, myBundleId);
|
||||||
CFRelease(torrentId);
|
CFRelease(torrentId);
|
||||||
}
|
}
|
||||||
@ -999,7 +999,7 @@ void Preferences::setMagnetLinkAssoc()
|
|||||||
{
|
{
|
||||||
if (isMagnetLinkAssocSet())
|
if (isMagnetLinkAssocSet())
|
||||||
return;
|
return;
|
||||||
CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
|
const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
|
||||||
LSSetDefaultHandlerForURLScheme(magnetUrlScheme, myBundleId);
|
LSSetDefaultHandlerForURLScheme(magnetUrlScheme, myBundleId);
|
||||||
}
|
}
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
@ -1009,7 +1009,7 @@ int Preferences::getTrackerPort() const
|
|||||||
return value("Preferences/Advanced/trackerPort", 9000).toInt();
|
return value("Preferences/Advanced/trackerPort", 9000).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setTrackerPort(int port)
|
void Preferences::setTrackerPort(const int port)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Advanced/trackerPort", port);
|
setValue("Preferences/Advanced/trackerPort", port);
|
||||||
}
|
}
|
||||||
@ -1020,7 +1020,7 @@ bool Preferences::isUpdateCheckEnabled() const
|
|||||||
return value("Preferences/Advanced/updateCheck", true).toBool();
|
return value("Preferences/Advanced/updateCheck", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setUpdateCheckEnabled(bool enabled)
|
void Preferences::setUpdateCheckEnabled(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Advanced/updateCheck", enabled);
|
setValue("Preferences/Advanced/updateCheck", enabled);
|
||||||
}
|
}
|
||||||
@ -1031,7 +1031,7 @@ bool Preferences::confirmTorrentDeletion() const
|
|||||||
return value("Preferences/Advanced/confirmTorrentDeletion", true).toBool();
|
return value("Preferences/Advanced/confirmTorrentDeletion", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setConfirmTorrentDeletion(bool enabled)
|
void Preferences::setConfirmTorrentDeletion(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Advanced/confirmTorrentDeletion", enabled);
|
setValue("Preferences/Advanced/confirmTorrentDeletion", enabled);
|
||||||
}
|
}
|
||||||
@ -1041,7 +1041,7 @@ bool Preferences::confirmTorrentRecheck() const
|
|||||||
return value("Preferences/Advanced/confirmTorrentRecheck", true).toBool();
|
return value("Preferences/Advanced/confirmTorrentRecheck", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setConfirmTorrentRecheck(bool enabled)
|
void Preferences::setConfirmTorrentRecheck(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Advanced/confirmTorrentRecheck", enabled);
|
setValue("Preferences/Advanced/confirmTorrentRecheck", enabled);
|
||||||
}
|
}
|
||||||
@ -1051,7 +1051,7 @@ bool Preferences::confirmRemoveAllTags() const
|
|||||||
return value("Preferences/Advanced/confirmRemoveAllTags", true).toBool();
|
return value("Preferences/Advanced/confirmRemoveAllTags", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setConfirmRemoveAllTags(bool enabled)
|
void Preferences::setConfirmRemoveAllTags(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("Preferences/Advanced/confirmRemoveAllTags", enabled);
|
setValue("Preferences/Advanced/confirmRemoveAllTags", enabled);
|
||||||
}
|
}
|
||||||
@ -1062,7 +1062,7 @@ TrayIcon::Style Preferences::trayIconStyle() const
|
|||||||
return TrayIcon::Style(value("Preferences/Advanced/TrayIconStyle", TrayIcon::NORMAL).toInt());
|
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);
|
setValue("Preferences/Advanced/TrayIconStyle", style);
|
||||||
}
|
}
|
||||||
@ -1186,7 +1186,7 @@ int Preferences::getPropCurTab() const
|
|||||||
return value("TorrentProperties/CurrentTab", -1).toInt();
|
return value("TorrentProperties/CurrentTab", -1).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setPropCurTab(const int &tab)
|
void Preferences::setPropCurTab(const int tab)
|
||||||
{
|
{
|
||||||
setValue("TorrentProperties/CurrentTab", tab);
|
setValue("TorrentProperties/CurrentTab", tab);
|
||||||
}
|
}
|
||||||
@ -1356,7 +1356,7 @@ int Preferences::getTransSelFilter() const
|
|||||||
return value("TransferListFilters/selectedFilterIndex", 0).toInt();
|
return value("TransferListFilters/selectedFilterIndex", 0).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setTransSelFilter(const int &index)
|
void Preferences::setTransSelFilter(const int index)
|
||||||
{
|
{
|
||||||
setValue("TransferListFilters/selectedFilterIndex", index);
|
setValue("TransferListFilters/selectedFilterIndex", index);
|
||||||
}
|
}
|
||||||
@ -1426,7 +1426,7 @@ bool Preferences::isSpeedWidgetEnabled() const
|
|||||||
return value("SpeedWidget/Enabled", true).toBool();
|
return value("SpeedWidget/Enabled", true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setSpeedWidgetEnabled(bool enabled)
|
void Preferences::setSpeedWidgetEnabled(const bool enabled)
|
||||||
{
|
{
|
||||||
setValue("SpeedWidget/Enabled", enabled);
|
setValue("SpeedWidget/Enabled", enabled);
|
||||||
}
|
}
|
||||||
@ -1441,13 +1441,13 @@ void Preferences::setSpeedWidgetPeriod(const int period)
|
|||||||
setValue("SpeedWidget/period", 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
|
// UP and DOWN graphs enabled by default
|
||||||
return value("SpeedWidget/graph_enable_" + QString::number(id), (id == 0 || id == 1)).toBool();
|
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);
|
setValue("SpeedWidget/graph_enable_" + QString::number(id), enable);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ class Preferences : public QObject
|
|||||||
|
|
||||||
Preferences();
|
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);
|
void setValue(const QString &key, const QVariant &value);
|
||||||
|
|
||||||
static Preferences *m_instance;
|
static Preferences *m_instance;
|
||||||
@ -303,7 +303,7 @@ public:
|
|||||||
QString getDNSLastIP() const;
|
QString getDNSLastIP() const;
|
||||||
void setDNSLastIP(const QString &ip);
|
void setDNSLastIP(const QString &ip);
|
||||||
bool getAcceptedLegal() const;
|
bool getAcceptedLegal() const;
|
||||||
void setAcceptedLegal(const bool accepted);
|
void setAcceptedLegal(bool accepted);
|
||||||
QByteArray getMainGeometry() const;
|
QByteArray getMainGeometry() const;
|
||||||
void setMainGeometry(const QByteArray &geometry);
|
void setMainGeometry(const QByteArray &geometry);
|
||||||
QByteArray getMainVSplitterState() const;
|
QByteArray getMainVSplitterState() const;
|
||||||
@ -321,9 +321,9 @@ public:
|
|||||||
QByteArray getPropFileListState() const;
|
QByteArray getPropFileListState() const;
|
||||||
void setPropFileListState(const QByteArray &state);
|
void setPropFileListState(const QByteArray &state);
|
||||||
int getPropCurTab() const;
|
int getPropCurTab() const;
|
||||||
void setPropCurTab(const int &tab);
|
void setPropCurTab(int tab);
|
||||||
bool getPropVisible() const;
|
bool getPropVisible() const;
|
||||||
void setPropVisible(const bool visible);
|
void setPropVisible(bool visible);
|
||||||
QByteArray getPropTrackerListState() const;
|
QByteArray getPropTrackerListState() const;
|
||||||
void setPropTrackerListState(const QByteArray &state);
|
void setPropTrackerListState(const QByteArray &state);
|
||||||
QSize getRssGeometrySize() const;
|
QSize getRssGeometrySize() const;
|
||||||
@ -351,17 +351,17 @@ public:
|
|||||||
bool getTagFilterState() const;
|
bool getTagFilterState() const;
|
||||||
bool getTrackerFilterState() const;
|
bool getTrackerFilterState() const;
|
||||||
int getTransSelFilter() const;
|
int getTransSelFilter() const;
|
||||||
void setTransSelFilter(const int &index);
|
void setTransSelFilter(int index);
|
||||||
QByteArray getTransHeaderState() const;
|
QByteArray getTransHeaderState() const;
|
||||||
void setTransHeaderState(const QByteArray &state);
|
void setTransHeaderState(const QByteArray &state);
|
||||||
bool getRegexAsFilteringPatternForTransferList() const;
|
bool getRegexAsFilteringPatternForTransferList() const;
|
||||||
void setRegexAsFilteringPatternForTransferList(bool checked);
|
void setRegexAsFilteringPatternForTransferList(bool checked);
|
||||||
int getToolbarTextPosition() const;
|
int getToolbarTextPosition() const;
|
||||||
void setToolbarTextPosition(const int position);
|
void setToolbarTextPosition(int position);
|
||||||
|
|
||||||
// From old RssSettings class
|
// From old RssSettings class
|
||||||
bool isRSSWidgetEnabled() const;
|
bool isRSSWidgetEnabled() const;
|
||||||
void setRSSWidgetVisible(const bool enabled);
|
void setRSSWidgetVisible(bool enabled);
|
||||||
|
|
||||||
// Network
|
// Network
|
||||||
QList<QNetworkCookie> getNetworkCookies() const;
|
QList<QNetworkCookie> getNetworkCookies() const;
|
||||||
@ -371,9 +371,9 @@ public:
|
|||||||
bool isSpeedWidgetEnabled() const;
|
bool isSpeedWidgetEnabled() const;
|
||||||
void setSpeedWidgetEnabled(bool enabled);
|
void setSpeedWidgetEnabled(bool enabled);
|
||||||
int getSpeedWidgetPeriod() const;
|
int getSpeedWidgetPeriod() const;
|
||||||
void setSpeedWidgetPeriod(const int period);
|
void setSpeedWidgetPeriod(int period);
|
||||||
bool getSpeedWidgetGraphEnable(int id) const;
|
bool getSpeedWidgetGraphEnable(int id) const;
|
||||||
void setSpeedWidgetGraphEnable(int id, const bool enable);
|
void setSpeedWidgetGraphEnable(int id, bool enable);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setStatusFilterState(bool checked);
|
void setStatusFilterState(bool checked);
|
||||||
|
@ -103,7 +103,7 @@ SettingsPtr Private::DefaultProfile::applicationSettings(const QString &name) co
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Private::DefaultProfile::locationWithConfigurationName(QStandardPaths::StandardLocation location) const
|
QString Private::DefaultProfile::locationWithConfigurationName(const QStandardPaths::StandardLocation location) const
|
||||||
{
|
{
|
||||||
return QStandardPaths::writableLocation(location) + configurationSuffix();
|
return QStandardPaths::writableLocation(location) + configurationSuffix();
|
||||||
}
|
}
|
||||||
@ -174,9 +174,9 @@ QString Private::Converter::toPortablePath(const QString &path) const
|
|||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (QDir::isAbsolutePath(path)) {
|
if (QDir::isAbsolutePath(path)) {
|
||||||
QChar driveLeter = path[0].toUpper();
|
const QChar driveLeter = path[0].toUpper();
|
||||||
QChar baseDriveLetter = m_baseDir.path()[0].toUpper();
|
const QChar baseDriveLetter = m_baseDir.path()[0].toUpper();
|
||||||
bool onSameDrive = (driveLeter.category() == QChar::Letter_Uppercase) && (driveLeter == baseDriveLetter);
|
const bool onSameDrive = (driveLeter.category() == QChar::Letter_Uppercase) && (driveLeter == baseDriveLetter);
|
||||||
if (!onSameDrive)
|
if (!onSameDrive)
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ const Profile &Profile::instance()
|
|||||||
return *m_instance;
|
return *m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Profile::location(SpecialFolder folder) const
|
QString Profile::location(const SpecialFolder folder) const
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
switch (folder) {
|
switch (folder) {
|
||||||
@ -98,9 +98,9 @@ SettingsPtr Profile::applicationSettings(const QString &name) const
|
|||||||
return m_profileImpl->applicationSettings(name);
|
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))
|
if (!locationPath.isEmpty() && !QDir().mkpath(locationPath))
|
||||||
qFatal("Could not create required directory '%s'", qUtf8Printable(locationPath));
|
qFatal("Could not create required directory '%s'", qUtf8Printable(locationPath));
|
||||||
}
|
}
|
||||||
|
@ -396,8 +396,8 @@ namespace
|
|||||||
if (!str.indexOf(rx)) {
|
if (!str.indexOf(rx)) {
|
||||||
// Check that if date has '-' separators, both separators are '-'.
|
// Check that if date has '-' separators, both separators are '-'.
|
||||||
parts = rx.capturedTexts();
|
parts = rx.capturedTexts();
|
||||||
bool h1 = (parts[3] == QLatin1String("-"));
|
const bool h1 = (parts[3] == QLatin1String("-"));
|
||||||
bool h2 = (parts[5] == QLatin1String("-"));
|
const bool h2 = (parts[5] == QLatin1String("-"));
|
||||||
if (h1 != h2)
|
if (h1 != h2)
|
||||||
return QDateTime::currentDateTime();
|
return QDateTime::currentDateTime();
|
||||||
}
|
}
|
||||||
@ -431,7 +431,7 @@ namespace
|
|||||||
return QDateTime::currentDateTime();
|
return QDateTime::currentDateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool leapSecond = (second == 60);
|
const bool leapSecond = (second == 60);
|
||||||
if (leapSecond)
|
if (leapSecond)
|
||||||
second = 59; // apparently a leap second - validate below, once time zone is known
|
second = 59; // apparently a leap second - validate below, once time zone is known
|
||||||
int month = 0;
|
int month = 0;
|
||||||
@ -447,7 +447,7 @@ namespace
|
|||||||
// if (month >= 12 || dayOfWeek >= 7
|
// if (month >= 12 || dayOfWeek >= 7
|
||||||
// || (dayOfWeek < 0 && format == RFCDateDay))
|
// || (dayOfWeek < 0 && format == RFCDateDay))
|
||||||
// return QDateTime;
|
// return QDateTime;
|
||||||
int i = parts[nyear].size();
|
const int i = parts[nyear].size();
|
||||||
if (i < 4) {
|
if (i < 4) {
|
||||||
// It's an obsolete year specification with less than 4 digits
|
// It's an obsolete year specification with less than 4 digits
|
||||||
year += ((i == 2) && (year < 50)) ? 2000 : 1900;
|
year += ((i == 2) && (year < 50)) ? 2000 : 1900;
|
||||||
@ -462,7 +462,7 @@ namespace
|
|||||||
// It's a UTC offset ±hhmm
|
// It's a UTC offset ±hhmm
|
||||||
parts = rx.capturedTexts();
|
parts = rx.capturedTexts();
|
||||||
offset = parts[2].toInt(&ok[0]) * 3600;
|
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)
|
if (!ok[0] || !ok[1] || offsetMin > 59)
|
||||||
return {};
|
return {};
|
||||||
offset += offsetMin * 60;
|
offset += offsetMin * 60;
|
||||||
@ -472,7 +472,7 @@ namespace
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Check for an obsolete time zone name
|
// 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')) {
|
if ((zone.length() == 1) && (isalpha(zone[0])) && (toupper(zone[0]) != 'J')) {
|
||||||
negOffset = true; // military zone: RFC 2822 treats as '-0000'
|
negOffset = true; // military zone: RFC 2822 treats as '-0000'
|
||||||
}
|
}
|
||||||
@ -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())
|
if (!qDate.isValid())
|
||||||
return QDateTime::currentDateTime();
|
return QDateTime::currentDateTime();
|
||||||
|
|
||||||
QTime qTime(hour, minute, second);
|
const QTime qTime(hour, minute, second);
|
||||||
QDateTime result(qDate, qTime, Qt::UTC);
|
QDateTime result(qDate, qTime, Qt::UTC);
|
||||||
if (offset)
|
if (offset)
|
||||||
result = result.addSecs(-offset);
|
result = result.addSecs(-offset);
|
||||||
@ -528,7 +528,7 @@ using namespace RSS::Private;
|
|||||||
|
|
||||||
const int ParsingResultTypeId = qRegisterMetaType<ParsingResult>();
|
const int ParsingResultTypeId = qRegisterMetaType<ParsingResult>();
|
||||||
|
|
||||||
Parser::Parser(QString lastBuildDate)
|
Parser::Parser(const QString lastBuildDate)
|
||||||
{
|
{
|
||||||
m_result.lastBuildDate = lastBuildDate;
|
m_result.lastBuildDate = lastBuildDate;
|
||||||
}
|
}
|
||||||
@ -642,7 +642,7 @@ void Parser::parseRSSChannel(QXmlStreamReader &xml)
|
|||||||
m_result.title = xml.readElementText();
|
m_result.title = xml.readElementText();
|
||||||
}
|
}
|
||||||
else if (xml.name() == QLatin1String("lastBuildDate")) {
|
else if (xml.name() == QLatin1String("lastBuildDate")) {
|
||||||
QString lastBuildDate = xml.readElementText();
|
const QString lastBuildDate = xml.readElementText();
|
||||||
if (!lastBuildDate.isEmpty()) {
|
if (!lastBuildDate.isEmpty()) {
|
||||||
if (m_result.lastBuildDate == lastBuildDate) {
|
if (m_result.lastBuildDate == lastBuildDate) {
|
||||||
qDebug() << "The RSS feed has not changed since last time, aborting parsing.";
|
qDebug() << "The RSS feed has not changed since last time, aborting parsing.";
|
||||||
@ -675,7 +675,7 @@ void Parser::parseAtomArticle(QXmlStreamReader &xml)
|
|||||||
article[Article::KeyTitle] = xml.readElementText().trimmed();
|
article[Article::KeyTitle] = xml.readElementText().trimmed();
|
||||||
}
|
}
|
||||||
else if (name == QLatin1String("link")) {
|
else if (name == QLatin1String("link")) {
|
||||||
QString link = (xml.attributes().isEmpty()
|
const QString link = (xml.attributes().isEmpty()
|
||||||
? xml.readElementText().trimmed()
|
? xml.readElementText().trimmed()
|
||||||
: xml.attributes().value(QLatin1String("href")).toString());
|
: xml.attributes().value(QLatin1String("href")).toString());
|
||||||
|
|
||||||
@ -696,7 +696,7 @@ void Parser::parseAtomArticle(QXmlStreamReader &xml)
|
|||||||
|
|
||||||
// Try to also parse broken articles, which don't use html '&' escapes
|
// Try to also parse broken articles, which don't use html '&' escapes
|
||||||
// Actually works great for non-broken content too
|
// 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()) {
|
if (!feedText.isEmpty()) {
|
||||||
article[Article::KeyDescription] = feedText;
|
article[Article::KeyDescription] = feedText;
|
||||||
doubleContent = true;
|
doubleContent = true;
|
||||||
@ -704,7 +704,7 @@ void Parser::parseAtomArticle(QXmlStreamReader &xml)
|
|||||||
}
|
}
|
||||||
else if (name == QLatin1String("updated")) {
|
else if (name == QLatin1String("updated")) {
|
||||||
// ATOM uses standard compliant date, don't do fancy stuff
|
// 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());
|
article[Article::KeyDate] = (articleDate.isValid() ? articleDate : QDateTime::currentDateTime());
|
||||||
}
|
}
|
||||||
else if (name == QLatin1String("author")) {
|
else if (name == QLatin1String("author")) {
|
||||||
@ -739,7 +739,7 @@ void Parser::parseAtomChannel(QXmlStreamReader &xml)
|
|||||||
m_result.title = xml.readElementText();
|
m_result.title = xml.readElementText();
|
||||||
}
|
}
|
||||||
else if (xml.name() == QLatin1String("updated")) {
|
else if (xml.name() == QLatin1String("updated")) {
|
||||||
QString lastBuildDate = xml.readElementText();
|
const QString lastBuildDate = xml.readElementText();
|
||||||
if (!lastBuildDate.isEmpty()) {
|
if (!lastBuildDate.isEmpty()) {
|
||||||
if (m_result.lastBuildDate == lastBuildDate) {
|
if (m_result.lastBuildDate == lastBuildDate) {
|
||||||
qDebug() << "The RSS feed has not changed since last time, aborting parsing.";
|
qDebug() << "The RSS feed has not changed since last time, aborting parsing.";
|
||||||
|
@ -142,7 +142,7 @@ QJsonObject Article::toJsonObject() const
|
|||||||
return jsonObj;
|
return jsonObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Article::articleDateRecentThan(Article *article, const QDateTime &date)
|
bool Article::articleDateRecentThan(const Article *article, const QDateTime &date)
|
||||||
{
|
{
|
||||||
return article->date() > date;
|
return article->date() > date;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ namespace RSS
|
|||||||
|
|
||||||
QJsonObject toJsonObject() const;
|
QJsonObject toJsonObject() const;
|
||||||
|
|
||||||
static bool articleDateRecentThan(Article *article, const QDateTime &date);
|
static bool articleDateRecentThan(const Article *article, const QDateTime &date);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void read(Article *article = nullptr);
|
void read(Article *article = nullptr);
|
||||||
|
@ -73,7 +73,7 @@ namespace
|
|||||||
QVector<RSS::AutoDownloadRule> rulesFromJSON(const QByteArray &jsonData)
|
QVector<RSS::AutoDownloadRule> rulesFromJSON(const QByteArray &jsonData)
|
||||||
{
|
{
|
||||||
QJsonParseError jsonError;
|
QJsonParseError jsonError;
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData, &jsonError);
|
const QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData, &jsonError);
|
||||||
if (jsonError.error != QJsonParseError::NoError)
|
if (jsonError.error != QJsonParseError::NoError)
|
||||||
throw RSS::ParsingError(jsonError.errorString());
|
throw RSS::ParsingError(jsonError.errorString());
|
||||||
|
|
||||||
@ -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) {
|
switch (format) {
|
||||||
case RulesFileFormat::Legacy:
|
case RulesFileFormat::Legacy:
|
||||||
@ -333,7 +333,7 @@ void AutoDownloader::process()
|
|||||||
|
|
||||||
void AutoDownloader::handleTorrentDownloadFinished(const QString &url)
|
void AutoDownloader::handleTorrentDownloadFinished(const QString &url)
|
||||||
{
|
{
|
||||||
auto job = m_waitingJobs.take(url);
|
const auto job = m_waitingJobs.take(url);
|
||||||
if (!job) return;
|
if (!job) return;
|
||||||
|
|
||||||
if (Feed *feed = Session::instance()->feedByURL(job->feedURL))
|
if (Feed *feed = Session::instance()->feedByURL(job->feedURL))
|
||||||
@ -347,7 +347,7 @@ void AutoDownloader::handleTorrentDownloadFailed(const QString &url)
|
|||||||
// TODO: Re-schedule job here.
|
// TODO: Re-schedule job here.
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoDownloader::handleNewArticle(Article *article)
|
void AutoDownloader::handleNewArticle(const Article *article)
|
||||||
{
|
{
|
||||||
if (!article->isRead() && !article->torrentUrl().isEmpty())
|
if (!article->isRead() && !article->torrentUrl().isEmpty())
|
||||||
addJobForArticle(article);
|
addJobForArticle(article);
|
||||||
@ -358,7 +358,7 @@ void AutoDownloader::setRule_impl(const AutoDownloadRule &rule)
|
|||||||
m_rules.insert(rule.name(), rule);
|
m_rules.insert(rule.name(), rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoDownloader::addJobForArticle(Article *article)
|
void AutoDownloader::addJobForArticle(const Article *article)
|
||||||
{
|
{
|
||||||
const QString torrentURL = article->torrentUrl();
|
const QString torrentURL = article->torrentUrl();
|
||||||
if (m_waitingJobs.contains(torrentURL)) return;
|
if (m_waitingJobs.contains(torrentURL)) return;
|
||||||
@ -387,7 +387,7 @@ void AutoDownloader::processJob(const QSharedPointer<ProcessingJob> &job)
|
|||||||
params.addPaused = rule.addPaused();
|
params.addPaused = rule.addPaused();
|
||||||
if (!rule.savePath().isEmpty())
|
if (!rule.savePath().isEmpty())
|
||||||
params.useAutoTMM = TriStateBool::False;
|
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);
|
BitTorrent::Session::instance()->addTorrent(torrentURL, params);
|
||||||
|
|
||||||
if (BitTorrent::MagnetUri(torrentURL).isValid()) {
|
if (BitTorrent::MagnetUri(torrentURL).isValid()) {
|
||||||
@ -434,10 +434,10 @@ void AutoDownloader::loadRules(const QByteArray &data)
|
|||||||
|
|
||||||
void AutoDownloader::loadRulesLegacy()
|
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();
|
const QVariantHash rules = settings->value(QStringLiteral("download_rules")).toHash();
|
||||||
for (const QVariant &ruleVar : rules) {
|
for (const QVariant &ruleVar : rules) {
|
||||||
auto rule = AutoDownloadRule::fromLegacyDict(ruleVar.toHash());
|
const auto rule = AutoDownloadRule::fromLegacyDict(ruleVar.toHash());
|
||||||
if (!rule.name().isEmpty())
|
if (!rule.name().isEmpty())
|
||||||
insertRule(rule);
|
insertRule(rule);
|
||||||
}
|
}
|
||||||
@ -485,7 +485,7 @@ void AutoDownloader::startProcessing()
|
|||||||
connect(Session::instance()->rootFolder(), &Folder::newArticle, this, &AutoDownloader::handleNewArticle);
|
connect(Session::instance()->rootFolder(), &Folder::newArticle, this, &AutoDownloader::handleNewArticle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoDownloader::setProcessingEnabled(bool enabled)
|
void AutoDownloader::setProcessingEnabled(const bool enabled)
|
||||||
{
|
{
|
||||||
if (m_processingEnabled != enabled) {
|
if (m_processingEnabled != enabled) {
|
||||||
m_processingEnabled = enabled;
|
m_processingEnabled = enabled;
|
||||||
|
@ -110,14 +110,14 @@ namespace RSS
|
|||||||
void process();
|
void process();
|
||||||
void handleTorrentDownloadFinished(const QString &url);
|
void handleTorrentDownloadFinished(const QString &url);
|
||||||
void handleTorrentDownloadFailed(const QString &url);
|
void handleTorrentDownloadFailed(const QString &url);
|
||||||
void handleNewArticle(Article *article);
|
void handleNewArticle(const Article *article);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void timerEvent(QTimerEvent *event) override;
|
void timerEvent(QTimerEvent *event) override;
|
||||||
void setRule_impl(const AutoDownloadRule &rule);
|
void setRule_impl(const AutoDownloadRule &rule);
|
||||||
void resetProcessingQueue();
|
void resetProcessingQueue();
|
||||||
void startProcessing();
|
void startProcessing();
|
||||||
void addJobForArticle(Article *article);
|
void addJobForArticle(const Article *article);
|
||||||
void processJob(const QSharedPointer<ProcessingJob> &job);
|
void processJob(const QSharedPointer<ProcessingJob> &job);
|
||||||
void load();
|
void load();
|
||||||
void loadRules(const QByteArray &data);
|
void loadRules(const QByteArray &data);
|
||||||
|
@ -72,7 +72,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TriStateBool addPausedLegacyToTriStateBool(int val)
|
TriStateBool addPausedLegacyToTriStateBool(const int val)
|
||||||
{
|
{
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case 1: return TriStateBool::True; // always
|
case 1: return TriStateBool::True; // always
|
||||||
@ -163,13 +163,13 @@ QString computeEpisodeName(const QString &article)
|
|||||||
|
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
for (int i = 1; i <= match.lastCapturedIndex(); ++i) {
|
for (int i = 1; i <= match.lastCapturedIndex(); ++i) {
|
||||||
QString cap = match.captured(i);
|
const QString cap = match.captured(i);
|
||||||
|
|
||||||
if (cap.isEmpty())
|
if (cap.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool isInt = false;
|
bool isInt = false;
|
||||||
int x = cap.toInt(&isInt);
|
const int x = cap.toInt(&isInt);
|
||||||
|
|
||||||
ret.append(isInt ? QString::number(x) : cap);
|
ret.append(isInt ? QString::number(x) : cap);
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ AutoDownloadRule::AutoDownloadRule(const AutoDownloadRule &other)
|
|||||||
|
|
||||||
AutoDownloadRule::~AutoDownloadRule() {}
|
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.
|
// 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
|
// 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
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_dataPtr->useRegex) {
|
if (m_dataPtr->useRegex) {
|
||||||
QRegularExpression reg(cachedRegex(expression));
|
const QRegularExpression reg(cachedRegex(expression));
|
||||||
return reg.match(articleTitle).hasMatch();
|
return reg.match(articleTitle).hasMatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -600,7 +600,7 @@ bool AutoDownloadRule::isEnabled() const
|
|||||||
return m_dataPtr->enabled;
|
return m_dataPtr->enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoDownloadRule::setEnabled(bool enable)
|
void AutoDownloadRule::setEnabled(const bool enable)
|
||||||
{
|
{
|
||||||
m_dataPtr->enabled = enable;
|
m_dataPtr->enabled = enable;
|
||||||
}
|
}
|
||||||
@ -615,7 +615,7 @@ void AutoDownloadRule::setLastMatch(const QDateTime &lastMatch)
|
|||||||
m_dataPtr->lastMatch = lastMatch;
|
m_dataPtr->lastMatch = lastMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoDownloadRule::setIgnoreDays(int d)
|
void AutoDownloadRule::setIgnoreDays(const int d)
|
||||||
{
|
{
|
||||||
m_dataPtr->ignoreDays = d;
|
m_dataPtr->ignoreDays = d;
|
||||||
}
|
}
|
||||||
@ -640,7 +640,7 @@ bool AutoDownloadRule::useSmartFilter() const
|
|||||||
return m_dataPtr->smartFilter;
|
return m_dataPtr->smartFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoDownloadRule::setUseSmartFilter(bool enabled)
|
void AutoDownloadRule::setUseSmartFilter(const bool enabled)
|
||||||
{
|
{
|
||||||
m_dataPtr->smartFilter = enabled;
|
m_dataPtr->smartFilter = enabled;
|
||||||
}
|
}
|
||||||
@ -650,7 +650,7 @@ bool AutoDownloadRule::useRegex() const
|
|||||||
return m_dataPtr->useRegex;
|
return m_dataPtr->useRegex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoDownloadRule::setUseRegex(bool enabled)
|
void AutoDownloadRule::setUseRegex(const bool enabled)
|
||||||
{
|
{
|
||||||
m_dataPtr->useRegex = enabled;
|
m_dataPtr->useRegex = enabled;
|
||||||
m_dataPtr->cachedRegexes.clear();
|
m_dataPtr->cachedRegexes.clear();
|
||||||
|
@ -108,7 +108,7 @@ QList<Article *> Feed::articles() const
|
|||||||
|
|
||||||
void Feed::markAsRead()
|
void Feed::markAsRead()
|
||||||
{
|
{
|
||||||
auto oldUnreadCount = m_unreadCount;
|
const int oldUnreadCount = m_unreadCount;
|
||||||
for (Article *article : asConst(m_articles)) {
|
for (Article *article : asConst(m_articles)) {
|
||||||
if (!article->isRead()) {
|
if (!article->isRead()) {
|
||||||
article->disconnect(this);
|
article->disconnect(this);
|
||||||
@ -176,7 +176,7 @@ Article *Feed::articleByGUID(const QString &guid) const
|
|||||||
return m_articles.value(guid);
|
return m_articles.value(guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Feed::handleMaxArticlesPerFeedChanged(int n)
|
void Feed::handleMaxArticlesPerFeedChanged(const int n)
|
||||||
{
|
{
|
||||||
while (m_articlesByDate.size() > n)
|
while (m_articlesByDate.size() > n)
|
||||||
removeOldestArticle();
|
removeOldestArticle();
|
||||||
@ -270,7 +270,7 @@ void Feed::load()
|
|||||||
void Feed::loadArticles(const QByteArray &data)
|
void Feed::loadArticles(const QByteArray &data)
|
||||||
{
|
{
|
||||||
QJsonParseError jsonError;
|
QJsonParseError jsonError;
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
|
const QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
|
||||||
if (jsonError.error != QJsonParseError::NoError) {
|
if (jsonError.error != QJsonParseError::NoError) {
|
||||||
LogMsg(tr("Couldn't parse RSS Session data. Error: %1").arg(jsonError.errorString())
|
LogMsg(tr("Couldn't parse RSS Session data. Error: %1").arg(jsonError.errorString())
|
||||||
, Log::WARNING);
|
, Log::WARNING);
|
||||||
@ -303,7 +303,7 @@ void Feed::loadArticles(const QByteArray &data)
|
|||||||
|
|
||||||
void Feed::loadArticlesLegacy()
|
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();
|
const QVariantHash allOldItems = qBTRSSFeeds->value("old_items").toHash();
|
||||||
|
|
||||||
for (const QVariant &var : asConst(allOldItems.value(m_url).toList())) {
|
for (const QVariant &var : asConst(allOldItems.value(m_url).toList())) {
|
||||||
@ -348,7 +348,7 @@ bool Feed::addArticle(Article *article)
|
|||||||
|
|
||||||
// Insertion sort
|
// Insertion sort
|
||||||
const int maxArticles = m_session->maxArticlesPerFeed();
|
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);
|
, article->date(), Article::articleDateRecentThan);
|
||||||
if ((lowerBound - m_articlesByDate.begin()) >= maxArticles)
|
if ((lowerBound - m_articlesByDate.begin()) >= maxArticles)
|
||||||
return false; // we reach max articles
|
return false; // we reach max articles
|
||||||
@ -376,7 +376,7 @@ void Feed::removeOldestArticle()
|
|||||||
|
|
||||||
m_articles.remove(oldestArticle->guid());
|
m_articles.remove(oldestArticle->guid());
|
||||||
m_articlesByDate.removeLast();
|
m_articlesByDate.removeLast();
|
||||||
bool isRead = oldestArticle->isRead();
|
const bool isRead = oldestArticle->isRead();
|
||||||
delete oldestArticle;
|
delete oldestArticle;
|
||||||
|
|
||||||
if (!isRead)
|
if (!isRead)
|
||||||
@ -402,8 +402,8 @@ void Feed::downloadIcon()
|
|||||||
// Download the RSS Feed icon
|
// Download the RSS Feed icon
|
||||||
// XXX: This works for most sites but it is not perfect
|
// XXX: This works for most sites but it is not perfect
|
||||||
const QUrl url(m_url);
|
const QUrl url(m_url);
|
||||||
auto iconUrl = QString("%1://%2/favicon.ico").arg(url.scheme(), url.host());
|
const auto iconUrl = QString("%1://%2/favicon.ico").arg(url.scheme(), url.host());
|
||||||
Net::DownloadHandler *handler = Net::DownloadManager::instance()->download(
|
const Net::DownloadHandler *handler = Net::DownloadManager::instance()->download(
|
||||||
Net::DownloadRequest(iconUrl).saveToFile(true));
|
Net::DownloadRequest(iconUrl).saveToFile(true));
|
||||||
connect(handler
|
connect(handler
|
||||||
, static_cast<void (Net::DownloadHandler::*)(const QString &, const QString &)>(&Net::DownloadHandler::downloadFinished)
|
, static_cast<void (Net::DownloadHandler::*)(const QString &, const QString &)>(&Net::DownloadHandler::downloadFinished)
|
||||||
@ -494,7 +494,7 @@ QString Feed::iconPath() const
|
|||||||
return m_iconPath;
|
return m_iconPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonValue Feed::toJsonValue(bool withData) const
|
QJsonValue Feed::toJsonValue(const bool withData) const
|
||||||
{
|
{
|
||||||
QJsonObject jsonObj;
|
QJsonObject jsonObj;
|
||||||
jsonObj.insert(KEY_UID, uid().toString());
|
jsonObj.insert(KEY_UID, uid().toString());
|
||||||
@ -515,7 +515,7 @@ QJsonValue Feed::toJsonValue(bool withData) const
|
|||||||
return jsonObj;
|
return jsonObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Feed::handleSessionProcessingEnabledChanged(bool enabled)
|
void Feed::handleSessionProcessingEnabledChanged(const bool enabled)
|
||||||
{
|
{
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
downloadIcon();
|
downloadIcon();
|
||||||
|
@ -263,7 +263,7 @@ void Session::load()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QJsonParseError jsonError;
|
QJsonParseError jsonError;
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(itemsFile.readAll(), &jsonError);
|
const QJsonDocument jsonDoc = QJsonDocument::fromJson(itemsFile.readAll(), &jsonError);
|
||||||
if (jsonError.error != QJsonParseError::NoError) {
|
if (jsonError.error != QJsonParseError::NoError) {
|
||||||
Logger::instance()->addMessage(
|
Logger::instance()->addMessage(
|
||||||
QString("Couldn't parse RSS Session data from %1. Error: %2")
|
QString("Couldn't parse RSS Session data from %1. Error: %2")
|
||||||
@ -482,7 +482,7 @@ uint Session::refreshInterval() const
|
|||||||
return m_refreshInterval;
|
return m_refreshInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::setRefreshInterval(uint refreshInterval)
|
void Session::setRefreshInterval(const uint refreshInterval)
|
||||||
{
|
{
|
||||||
if (m_refreshInterval != refreshInterval) {
|
if (m_refreshInterval != refreshInterval) {
|
||||||
SettingsStorage::instance()->storeValue(SettingsKey_RefreshInterval, refreshInterval);
|
SettingsStorage::instance()->storeValue(SettingsKey_RefreshInterval, refreshInterval);
|
||||||
@ -528,7 +528,7 @@ int Session::maxArticlesPerFeed() const
|
|||||||
return m_maxArticlesPerFeed;
|
return m_maxArticlesPerFeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::setMaxArticlesPerFeed(int n)
|
void Session::setMaxArticlesPerFeed(const int n)
|
||||||
{
|
{
|
||||||
if (m_maxArticlesPerFeed != n) {
|
if (m_maxArticlesPerFeed != n) {
|
||||||
m_maxArticlesPerFeed = n;
|
m_maxArticlesPerFeed = n;
|
||||||
|
@ -183,7 +183,7 @@ bool ScanFoldersModel::setData(const QModelIndex &index, const QVariant &value,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (role == Qt::UserRole) {
|
if (role == Qt::UserRole) {
|
||||||
auto type = static_cast<PathType>(value.toInt());
|
const auto type = static_cast<PathType>(value.toInt());
|
||||||
if (type == CUSTOM_LOCATION)
|
if (type == CUSTOM_LOCATION)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ bool ScanFoldersModel::setData(const QModelIndex &index, const QVariant &value,
|
|||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
}
|
}
|
||||||
else if (role == Qt::DisplayRole) {
|
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
|
if (path.isEmpty()) // means we didn't pass CUSTOM_LOCATION type
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -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)
|
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.exists()) return DoesNotExist;
|
||||||
if (!watchDir.isReadable()) return CannotRead;
|
if (!watchDir.isReadable()) return CannotRead;
|
||||||
|
|
||||||
const QString canonicalWatchPath = watchDir.canonicalPath();
|
const QString canonicalWatchPath = watchDir.canonicalPath();
|
||||||
if (findPathData(canonicalWatchPath) != -1) return AlreadyInList;
|
if (findPathData(canonicalWatchPath) != -1) return AlreadyInList;
|
||||||
|
|
||||||
QDir downloadDir(downloadPath);
|
const QDir downloadDir(downloadPath);
|
||||||
const QString canonicalDownloadPath = downloadDir.canonicalPath();
|
const QString canonicalDownloadPath = downloadDir.canonicalPath();
|
||||||
|
|
||||||
if (!m_fsWatcher) {
|
if (!m_fsWatcher) {
|
||||||
@ -236,12 +236,12 @@ ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath,
|
|||||||
|
|
||||||
ScanFoldersModel::PathStatus ScanFoldersModel::updatePath(const QString &watchPath, const PathType &downloadType, const QString &downloadPath)
|
ScanFoldersModel::PathStatus ScanFoldersModel::updatePath(const QString &watchPath, const PathType &downloadType, const QString &downloadPath)
|
||||||
{
|
{
|
||||||
QDir watchDir(watchPath);
|
const QDir watchDir(watchPath);
|
||||||
const QString canonicalWatchPath = watchDir.canonicalPath();
|
const QString canonicalWatchPath = watchDir.canonicalPath();
|
||||||
int row = findPathData(canonicalWatchPath);
|
const int row = findPathData(canonicalWatchPath);
|
||||||
if (row == -1) return DoesNotExist;
|
if (row == -1) return DoesNotExist;
|
||||||
|
|
||||||
QDir downloadDir(downloadPath);
|
const QDir downloadDir(downloadPath);
|
||||||
const QString canonicalDownloadPath = downloadDir.canonicalPath();
|
const QString canonicalDownloadPath = downloadDir.canonicalPath();
|
||||||
|
|
||||||
m_pathList.at(row)->downloadType = downloadType;
|
m_pathList.at(row)->downloadType = downloadType;
|
||||||
@ -256,13 +256,13 @@ void ScanFoldersModel::addToFSWatcher(const QStringList &watchPaths)
|
|||||||
return; // addPath() wasn't called before this
|
return; // addPath() wasn't called before this
|
||||||
|
|
||||||
for (const QString &path : watchPaths) {
|
for (const QString &path : watchPaths) {
|
||||||
QDir watchDir(path);
|
const QDir watchDir(path);
|
||||||
const QString canonicalWatchPath = watchDir.canonicalPath();
|
const QString canonicalWatchPath = watchDir.canonicalPath();
|
||||||
m_fsWatcher->addPath(canonicalWatchPath);
|
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()));
|
Q_ASSERT((row >= 0) && (row < rowCount()));
|
||||||
beginRemoveRows(QModelIndex(), row, row);
|
beginRemoveRows(QModelIndex(), row, row);
|
||||||
@ -272,7 +272,7 @@ void ScanFoldersModel::removePath(int row, bool removeFromFSWatcher)
|
|||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScanFoldersModel::removePath(const QString &path, bool removeFromFSWatcher)
|
bool ScanFoldersModel::removePath(const QString &path, const bool removeFromFSWatcher)
|
||||||
{
|
{
|
||||||
const int row = findPathData(path);
|
const int row = findPathData(path);
|
||||||
if (row == -1) return false;
|
if (row == -1) return false;
|
||||||
@ -291,7 +291,7 @@ bool ScanFoldersModel::downloadInWatchFolder(const QString &filePath) const
|
|||||||
{
|
{
|
||||||
const int row = findPathData(QFileInfo(filePath).dir().path());
|
const int row = findPathData(QFileInfo(filePath).dir().path());
|
||||||
Q_ASSERT(row != -1);
|
Q_ASSERT(row != -1);
|
||||||
PathData *data = m_pathList.at(row);
|
const PathData *data = m_pathList.at(row);
|
||||||
return (data->downloadType == DOWNLOAD_IN_WATCH_FOLDER);
|
return (data->downloadType == DOWNLOAD_IN_WATCH_FOLDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ bool ScanFoldersModel::downloadInDefaultFolder(const QString &filePath) const
|
|||||||
{
|
{
|
||||||
const int row = findPathData(QFileInfo(filePath).dir().path());
|
const int row = findPathData(QFileInfo(filePath).dir().path());
|
||||||
Q_ASSERT(row != -1);
|
Q_ASSERT(row != -1);
|
||||||
PathData *data = m_pathList.at(row);
|
const PathData *data = m_pathList.at(row);
|
||||||
return (data->downloadType == DEFAULT_LOCATION);
|
return (data->downloadType == DEFAULT_LOCATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ QString ScanFoldersModel::downloadPathTorrentFolder(const QString &filePath) con
|
|||||||
{
|
{
|
||||||
const int row = findPathData(QFileInfo(filePath).dir().path());
|
const int row = findPathData(QFileInfo(filePath).dir().path());
|
||||||
Q_ASSERT(row != -1);
|
Q_ASSERT(row != -1);
|
||||||
PathData *data = m_pathList.at(row);
|
const PathData *data = m_pathList.at(row);
|
||||||
if (data->downloadType == CUSTOM_LOCATION)
|
if (data->downloadType == CUSTOM_LOCATION)
|
||||||
return data->downloadPath;
|
return data->downloadPath;
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ void ScanFoldersModel::addTorrentsToSession(const QStringList &pathList)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BitTorrent::TorrentInfo torrentInfo = BitTorrent::TorrentInfo::loadFromFile(file);
|
const BitTorrent::TorrentInfo torrentInfo = BitTorrent::TorrentInfo::loadFromFile(file);
|
||||||
if (torrentInfo.isValid()) {
|
if (torrentInfo.isValid()) {
|
||||||
BitTorrent::Session::instance()->addTorrent(torrentInfo, params);
|
BitTorrent::Session::instance()->addTorrent(torrentInfo, params);
|
||||||
Utils::Fs::forceRemove(file);
|
Utils::Fs::forceRemove(file);
|
||||||
|
@ -68,10 +68,10 @@ public:
|
|||||||
static void freeInstance();
|
static void freeInstance();
|
||||||
static ScanFoldersModel *instance();
|
static ScanFoldersModel *instance();
|
||||||
|
|
||||||
static QString pathTypeDisplayName(const PathType type);
|
static QString pathTypeDisplayName(PathType type);
|
||||||
|
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const QModelIndex &parent = {}) const;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
int columnCount(const QModelIndex &parent = {}) const;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
@ -114,7 +114,7 @@ void SearchHandler::cancelSearch()
|
|||||||
// Slot called when QProcess is Finished
|
// Slot called when QProcess is Finished
|
||||||
// QProcess can be finished for 3 reasons:
|
// QProcess can be finished for 3 reasons:
|
||||||
// Error | Stopped by user | Finished normally
|
// Error | Stopped by user | Finished normally
|
||||||
void SearchHandler::processFinished(int exitcode)
|
void SearchHandler::processFinished(const int exitcode)
|
||||||
{
|
{
|
||||||
m_searchTimeout->stop();
|
m_searchTimeout->stop();
|
||||||
|
|
||||||
|
@ -168,9 +168,9 @@ PluginInfo *SearchPluginManager::pluginInfo(const QString &name) const
|
|||||||
return m_plugins.value(name);
|
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) {
|
if (plugin) {
|
||||||
plugin->enabled = enabled;
|
plugin->enabled = enabled;
|
||||||
// Save to Hard disk
|
// Save to Hard disk
|
||||||
@ -222,7 +222,7 @@ void SearchPluginManager::installPlugin(const QString &source)
|
|||||||
void SearchPluginManager::installPlugin_impl(const QString &name, const QString &path)
|
void SearchPluginManager::installPlugin_impl(const QString &name, const QString &path)
|
||||||
{
|
{
|
||||||
const PluginVersion newVersion = getPluginVersion(path);
|
const PluginVersion newVersion = getPluginVersion(path);
|
||||||
PluginInfo *plugin = pluginInfo(name);
|
const PluginInfo *plugin = pluginInfo(name);
|
||||||
if (plugin && !(plugin->version < newVersion)) {
|
if (plugin && !(plugin->version < newVersion)) {
|
||||||
LogMsg(tr("Plugin already at version %1, which is greater than %2").arg(plugin->version, newVersion), Log::INFO);
|
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."));
|
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
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process with install
|
// Process with install
|
||||||
QString destPath = pluginPath(name);
|
const QString destPath = pluginPath(name);
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
if (QFile::exists(destPath)) {
|
if (QFile::exists(destPath)) {
|
||||||
// Backup in case install fails
|
// Backup in case install fails
|
||||||
@ -273,7 +273,7 @@ bool SearchPluginManager::uninstallPlugin(const QString &name)
|
|||||||
clearPythonCache(engineLocation());
|
clearPythonCache(engineLocation());
|
||||||
|
|
||||||
// remove it from hard drive
|
// remove it from hard drive
|
||||||
QDir pluginsFolder(pluginsLocation());
|
const QDir pluginsFolder(pluginsLocation());
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
filters << name + ".*";
|
filters << name + ".*";
|
||||||
const QStringList files = pluginsFolder.entryList(filters, QDir::Files, QDir::Unsorted);
|
const QStringList files = pluginsFolder.entryList(filters, QDir::Files, QDir::Unsorted);
|
||||||
@ -448,7 +448,7 @@ void SearchPluginManager::update()
|
|||||||
nova.start(Utils::ForeignApps::pythonInfo().executableName, params, QIODevice::ReadOnly);
|
nova.start(Utils::ForeignApps::pythonInfo().executableName, params, QIODevice::ReadOnly);
|
||||||
nova.waitForFinished();
|
nova.waitForFinished();
|
||||||
|
|
||||||
QString capabilities = nova.readAll();
|
const QString capabilities = nova.readAll();
|
||||||
QDomDocument xmlDoc;
|
QDomDocument xmlDoc;
|
||||||
if (!xmlDoc.setContent(capabilities)) {
|
if (!xmlDoc.setContent(capabilities)) {
|
||||||
qWarning() << "Could not parse Nova search engine capabilities, msg: " << capabilities.toLocal8Bit().data();
|
qWarning() << "Could not parse Nova search engine capabilities, msg: " << capabilities.toLocal8Bit().data();
|
||||||
@ -456,16 +456,16 @@ void SearchPluginManager::update()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement root = xmlDoc.documentElement();
|
const QDomElement root = xmlDoc.documentElement();
|
||||||
if (root.tagName() != "capabilities") {
|
if (root.tagName() != "capabilities") {
|
||||||
qWarning() << "Invalid XML file for Nova search engine capabilities, msg: " << capabilities.toLocal8Bit().data();
|
qWarning() << "Invalid XML file for Nova search engine capabilities, msg: " << capabilities.toLocal8Bit().data();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QDomNode engineNode = root.firstChild(); !engineNode.isNull(); engineNode = engineNode.nextSibling()) {
|
for (QDomNode engineNode = root.firstChild(); !engineNode.isNull(); engineNode = engineNode.nextSibling()) {
|
||||||
QDomElement engineElem = engineNode.toElement();
|
const QDomElement engineElem = engineNode.toElement();
|
||||||
if (!engineElem.isNull()) {
|
if (!engineElem.isNull()) {
|
||||||
QString pluginName = engineElem.tagName();
|
const QString pluginName = engineElem.tagName();
|
||||||
|
|
||||||
std::unique_ptr<PluginInfo> plugin {new PluginInfo {}};
|
std::unique_ptr<PluginInfo> plugin {new PluginInfo {}};
|
||||||
plugin->name = pluginName;
|
plugin->name = pluginName;
|
||||||
@ -480,7 +480,7 @@ void SearchPluginManager::update()
|
|||||||
plugin->supportedCategories << cat;
|
plugin->supportedCategories << cat;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList disabledEngines = Preferences::instance()->getSearchEngDisabled();
|
const QStringList disabledEngines = Preferences::instance()->getSearchEngDisabled();
|
||||||
plugin->enabled = !disabledEngines.contains(pluginName);
|
plugin->enabled = !disabledEngines.contains(pluginName);
|
||||||
|
|
||||||
updateIconPath(plugin.get());
|
updateIconPath(plugin.get());
|
||||||
@ -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;
|
if (!plugin) return true;
|
||||||
|
|
||||||
PluginVersion oldVersion = plugin->version;
|
PluginVersion oldVersion = plugin->version;
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
static void freeInstance();
|
static void freeInstance();
|
||||||
static SettingsStorage *instance();
|
static SettingsStorage *instance();
|
||||||
|
|
||||||
QVariant loadValue(const QString &key, const QVariant &defaultValue = QVariant()) const;
|
QVariant loadValue(const QString &key, const QVariant &defaultValue = {}) const;
|
||||||
void storeValue(const QString &key, const QVariant &value);
|
void storeValue(const QString &key, const QVariant &value);
|
||||||
void removeValue(const QString &key);
|
void removeValue(const QString &key);
|
||||||
|
|
||||||
|
@ -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;
|
m_remove = remove;
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ FileGuard::~FileGuard()
|
|||||||
Utils::Fs::forceRemove(m_path); // forceRemove() checks for file existence
|
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()}
|
: FileGuard {mode != Never ? path : QString()}
|
||||||
, m_mode {mode}
|
, m_mode {mode}
|
||||||
, m_wasAdded {false}
|
, m_wasAdded {false}
|
||||||
|
@ -37,7 +37,7 @@ template <typename T> class CachedSettingValue;
|
|||||||
class FileGuard
|
class FileGuard
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit FileGuard(const QString &path = QString());
|
explicit FileGuard(const QString &path = {});
|
||||||
~FileGuard();
|
~FileGuard();
|
||||||
|
|
||||||
/// Cancels or re-enables deferred file deletion
|
/// Cancels or re-enables deferred file deletion
|
||||||
@ -55,7 +55,7 @@ class TorrentFileGuard : private FileGuard
|
|||||||
Q_GADGET
|
Q_GADGET
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TorrentFileGuard(const QString &path = QString());
|
explicit TorrentFileGuard(const QString &path = {});
|
||||||
~TorrentFileGuard();
|
~TorrentFileGuard();
|
||||||
|
|
||||||
/// marks the torrent file as loaded (added) into the BitTorrent::Session
|
/// marks the torrent file as loaded (added) into the BitTorrent::Session
|
||||||
|
@ -72,7 +72,7 @@ public:
|
|||||||
TorrentFilter();
|
TorrentFilter();
|
||||||
// category & tags: pass empty string for uncategorized / untagged torrents.
|
// category & tags: pass empty string for uncategorized / untagged torrents.
|
||||||
// Pass null string (QString()) to disable filtering (i.e. all 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);
|
TorrentFilter(const QString &filter, const QStringSet &hashSet = AnyHash, const QString &category = AnyCategory, const QString &tags = AnyTag);
|
||||||
|
|
||||||
bool setType(Type type);
|
bool setType(Type type);
|
||||||
|
@ -40,6 +40,6 @@ namespace Utils
|
|||||||
|
|
||||||
// Mimic QByteArray::mid(pos, len) but instead of returning a full-copy,
|
// Mimic QByteArray::mid(pos, len) but instead of returning a full-copy,
|
||||||
// we only return a partial view
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ namespace
|
|||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getRegValue(const HKEY handle, const QString &name = QString())
|
QString getRegValue(const HKEY handle, const QString &name = {})
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
|
|
||||||
|
@ -81,14 +81,14 @@ QString Utils::Fs::fromNativePath(const QString &path)
|
|||||||
*/
|
*/
|
||||||
QString Utils::Fs::fileExtension(const QString &filename)
|
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('.');
|
const int pointIndex = ext.lastIndexOf('.');
|
||||||
return (pointIndex >= 0) ? ext.mid(pointIndex + 1) : QString();
|
return (pointIndex >= 0) ? ext.mid(pointIndex + 1) : QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Utils::Fs::fileName(const QString &filePath)
|
QString Utils::Fs::fileName(const QString &filePath)
|
||||||
{
|
{
|
||||||
QString path = fromNativePath(filePath);
|
const QString path = fromNativePath(filePath);
|
||||||
const int slashIndex = path.lastIndexOf('/');
|
const int slashIndex = path.lastIndexOf('/');
|
||||||
if (slashIndex == -1)
|
if (slashIndex == -1)
|
||||||
return path;
|
return path;
|
||||||
@ -97,7 +97,7 @@ QString Utils::Fs::fileName(const QString &filePath)
|
|||||||
|
|
||||||
QString Utils::Fs::folderName(const QString &filePath)
|
QString Utils::Fs::folderName(const QString &filePath)
|
||||||
{
|
{
|
||||||
QString path = fromNativePath(filePath);
|
const QString path = fromNativePath(filePath);
|
||||||
const int slashIndex = path.lastIndexOf('/');
|
const int slashIndex = path.lastIndexOf('/');
|
||||||
if (slashIndex == -1)
|
if (slashIndex == -1)
|
||||||
return path;
|
return path;
|
||||||
@ -140,7 +140,7 @@ bool Utils::Fs::smartRemoveEmptyFolderTree(const QString &path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remove temp files on linux (file ends with '~'), e.g. `filename~`
|
// remove temp files on linux (file ends with '~'), e.g. `filename~`
|
||||||
QDir dir(p);
|
const QDir dir(p);
|
||||||
const QStringList tmpFileList = dir.entryList(QDir::Files);
|
const QStringList tmpFileList = dir.entryList(QDir::Files);
|
||||||
for (const QString &f : tmpFileList) {
|
for (const QString &f : tmpFileList) {
|
||||||
if (f.endsWith('~'))
|
if (f.endsWith('~'))
|
||||||
@ -188,7 +188,7 @@ void Utils::Fs::removeDirRecursive(const QString &path)
|
|||||||
qint64 Utils::Fs::computePathSize(const QString &path)
|
qint64 Utils::Fs::computePathSize(const QString &path)
|
||||||
{
|
{
|
||||||
// Check if it is a file
|
// Check if it is a file
|
||||||
QFileInfo fi(path);
|
const QFileInfo fi(path);
|
||||||
if (!fi.exists()) return -1;
|
if (!fi.exists()) return -1;
|
||||||
if (fi.isFile()) return fi.size();
|
if (fi.isFile()) return fi.size();
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ bool Utils::Fs::sameFiles(const QString &path1, const QString &path2)
|
|||||||
return true;
|
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 ? "[:?\"*<>|]+" : "[\\\\/:?\"*<>|]+");
|
const QRegularExpression regex(allowSeparators ? "[:?\"*<>|]+" : "[\\\\/:?\"*<>|]+");
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ QString Utils::Fs::toValidFileSystemName(const QString &name, bool allowSeparato
|
|||||||
return validName;
|
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;
|
if (name.isEmpty()) return false;
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ bool Utils::Fs::sameFileNames(const QString &first, const QString &second)
|
|||||||
|
|
||||||
QString Utils::Fs::expandPath(const QString &path)
|
QString Utils::Fs::expandPath(const QString &path)
|
||||||
{
|
{
|
||||||
QString ret = path.trimmed();
|
const QString ret = path.trimmed();
|
||||||
if (ret.isEmpty())
|
if (ret.isEmpty())
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -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)
|
// Returns the QPoint which the widget will be placed center on screen (where parent resides)
|
||||||
|
|
||||||
QWidget *parent = w->parentWidget();
|
const QWidget *parent = w->parentWidget();
|
||||||
QDesktopWidget *desktop = QApplication::desktop();
|
const QDesktopWidget *desktop = QApplication::desktop();
|
||||||
int scrn = desktop->screenNumber(parent); // fallback to `primaryScreen` when parent is invalid
|
const int scrn = desktop->screenNumber(parent); // fallback to `primaryScreen` when parent is invalid
|
||||||
QRect r = desktop->availableGeometry(scrn);
|
const QRect r = desktop->availableGeometry(scrn);
|
||||||
return {r.x() + (r.width() - w->frameSize().width()) / 2, r.y() + (r.height() - w->frameSize().height()) / 2};
|
return {r.x() + (r.width() - w->frameSize().width()) / 2, r.y() + (r.height() - w->frameSize().height()) / 2};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -269,7 +269,7 @@ QString Utils::Misc::unitString(const SizeUnit unit, const bool isSpeed)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Utils::Misc::friendlyUnit(qint64 bytesValue, bool isSpeed)
|
QString Utils::Misc::friendlyUnit(const qint64 bytesValue, const bool isSpeed)
|
||||||
{
|
{
|
||||||
SizeUnit unit;
|
SizeUnit unit;
|
||||||
qreal friendlyVal;
|
qreal friendlyVal;
|
||||||
@ -289,7 +289,7 @@ int Utils::Misc::friendlyUnitPrecision(SizeUnit unit)
|
|||||||
return 3;
|
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)
|
for (int i = 0; i < static_cast<int>(unit); ++i)
|
||||||
size *= 1024;
|
size *= 1024;
|
||||||
@ -347,7 +347,7 @@ bool Utils::Misc::isPreviewable(const QString &extension)
|
|||||||
|
|
||||||
// Take a number of seconds and return an user-friendly
|
// Take a number of seconds and return an user-friendly
|
||||||
// time duration like "1d 2h 10m".
|
// 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))
|
if ((seconds < 0) || (seconds >= MAX_ETA))
|
||||||
return QString::fromUtf8(C_INFINITY);
|
return QString::fromUtf8(C_INFINITY);
|
||||||
@ -511,7 +511,7 @@ void Utils::Misc::openFolderSelect(const QString &absolutePath)
|
|||||||
QProcess proc;
|
QProcess proc;
|
||||||
proc.start("xdg-mime", {"query", "default", "inode/directory"});
|
proc.start("xdg-mime", {"query", "default", "inode/directory"});
|
||||||
proc.waitForFinished();
|
proc.waitForFinished();
|
||||||
QString output = proc.readLine().simplified();
|
const QString output = proc.readLine().simplified();
|
||||||
if ((output == "dolphin.desktop") || (output == "org.kde.dolphin.desktop")) {
|
if ((output == "dolphin.desktop") || (output == "org.kde.dolphin.desktop")) {
|
||||||
proc.startDetached("dolphin", {"--select", Utils::Fs::toNativePath(path)});
|
proc.startDetached("dolphin", {"--select", Utils::Fs::toNativePath(path)});
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ namespace Utils
|
|||||||
{
|
{
|
||||||
namespace Random
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ int Utils::String::naturalCompare(const QString &left, const QString &right, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
// to send numbers instead of strings with suffixes
|
// 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
|
/* 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
|
** 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)
|
|||||||
** our 'wanted' is >= 5. In this case our last digit gets rounded up. So for each
|
** 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. */
|
** 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);
|
return QLocale::system().toString(std::floor(n * prec) / prec, 'f', precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ namespace Utils
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parseBool(const QString &string, const bool defaultValue);
|
bool parseBool(const QString &string, bool defaultValue);
|
||||||
TriStateBool parseTriStateBool(const QString &string);
|
TriStateBool parseTriStateBool(const QString &string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
|
|||||||
setModal(true);
|
setModal(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto session = BitTorrent::Session::instance();
|
const auto *session = BitTorrent::Session::instance();
|
||||||
|
|
||||||
if (m_torrentParams.addPaused == TriStateBool::True)
|
if (m_torrentParams.addPaused == TriStateBool::True)
|
||||||
m_ui->startTorrentCheckBox->setChecked(false);
|
m_ui->startTorrentCheckBox->setChecked(false);
|
||||||
@ -233,7 +233,7 @@ void AddNewTorrentDialog::saveState()
|
|||||||
|
|
||||||
void AddNewTorrentDialog::show(const QString &source, const BitTorrent::AddTorrentParams &inParams, QWidget *parent)
|
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)) {
|
if (Net::DownloadManager::hasSupportedScheme(source)) {
|
||||||
// Launch downloader
|
// Launch downloader
|
||||||
|
@ -98,7 +98,7 @@ private:
|
|||||||
int indexOfSavePath(const QString &savePath);
|
int indexOfSavePath(const QString &savePath);
|
||||||
void loadState();
|
void loadState();
|
||||||
void saveState();
|
void saveState();
|
||||||
void setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText = QString());
|
void setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText = {});
|
||||||
void setupTreeview();
|
void setupTreeview();
|
||||||
void setCommentText(const QString &str) const;
|
void setCommentText(const QString &str) const;
|
||||||
void setSavePath(const QString &newPath);
|
void setSavePath(const QString &newPath);
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
~AutoExpandableDialog();
|
~AutoExpandableDialog();
|
||||||
|
|
||||||
static QString getText(QWidget *parent, const QString &title, const QString &label,
|
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);
|
bool *ok = nullptr, bool excludeExtension = false, Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -176,7 +176,7 @@ CategoryFilterModel::CategoryFilterModel(QObject *parent)
|
|||||||
, m_rootItem(new CategoryModelItem)
|
, m_rootItem(new CategoryModelItem)
|
||||||
{
|
{
|
||||||
using namespace BitTorrent;
|
using namespace BitTorrent;
|
||||||
auto session = Session::instance();
|
const auto *session = Session::instance();
|
||||||
|
|
||||||
connect(session, &Session::categoryAdded, this, &CategoryFilterModel::categoryAdded);
|
connect(session, &Session::categoryAdded, this, &CategoryFilterModel::categoryAdded);
|
||||||
connect(session, &Session::categoryRemoved, this, &CategoryFilterModel::categoryRemoved);
|
connect(session, &Session::categoryRemoved, this, &CategoryFilterModel::categoryRemoved);
|
||||||
@ -209,7 +209,7 @@ QVariant CategoryFilterModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
if (!index.isValid()) return {};
|
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)) {
|
if ((index.column() == 0) && (role == Qt::DecorationRole)) {
|
||||||
return GuiIconProvider::instance()->getIcon("inode-directory");
|
return GuiIconProvider::instance()->getIcon("inode-directory");
|
||||||
@ -384,8 +384,8 @@ void CategoryFilterModel::populate()
|
|||||||
{
|
{
|
||||||
m_rootItem->clear();
|
m_rootItem->clear();
|
||||||
|
|
||||||
auto session = BitTorrent::Session::instance();
|
const auto *session = BitTorrent::Session::instance();
|
||||||
auto torrents = session->torrents();
|
const auto torrents = session->torrents();
|
||||||
m_isSubcategoriesEnabled = session->isSubcategoriesEnabled();
|
m_isSubcategoriesEnabled = session->isSubcategoriesEnabled();
|
||||||
|
|
||||||
const QString UID_ALL;
|
const QString UID_ALL;
|
||||||
@ -413,7 +413,7 @@ void CategoryFilterModel::populate()
|
|||||||
if (!parent->hasChild(subcatName)) {
|
if (!parent->hasChild(subcatName)) {
|
||||||
new CategoryModelItem(
|
new CategoryModelItem(
|
||||||
parent, subcatName
|
parent, subcatName
|
||||||
, std::count_if(torrents.begin(), torrents.end()
|
, std::count_if(torrents.cbegin(), torrents.cend()
|
||||||
, [subcat](Torrent *torrent) { return torrent->category() == subcat; }));
|
, [subcat](Torrent *torrent) { return torrent->category() == subcat; }));
|
||||||
}
|
}
|
||||||
parent = parent->child(subcatName);
|
parent = parent->child(subcatName);
|
||||||
|
@ -49,13 +49,13 @@ public:
|
|||||||
|
|
||||||
static bool isSpecialItem(const QModelIndex &index);
|
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;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override;
|
||||||
QModelIndex parent(const QModelIndex &index) const override;
|
QModelIndex parent(const QModelIndex &index) const override;
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex &parent = {}) const override;
|
||||||
|
|
||||||
QModelIndex index(const QString &categoryName) const;
|
QModelIndex index(const QString &categoryName) const;
|
||||||
QString categoryName(const QModelIndex &index) const;
|
QString categoryName(const QModelIndex &index) const;
|
||||||
|
@ -91,7 +91,7 @@ CategoryFilterWidget::CategoryFilterWidget(QWidget *parent)
|
|||||||
QString CategoryFilterWidget::currentCategory() const
|
QString CategoryFilterWidget::currentCategory() const
|
||||||
{
|
{
|
||||||
QModelIndex current;
|
QModelIndex current;
|
||||||
auto selectedRows = selectionModel()->selectedRows();
|
const auto selectedRows = selectionModel()->selectedRows();
|
||||||
if (!selectedRows.isEmpty())
|
if (!selectedRows.isEmpty())
|
||||||
current = selectedRows.first();
|
current = selectedRows.first();
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ void CategoryFilterWidget::showMenu(QPoint)
|
|||||||
, tr("Add category..."));
|
, tr("Add category..."));
|
||||||
connect(addAct, &QAction::triggered, this, &CategoryFilterWidget::addCategory);
|
connect(addAct, &QAction::triggered, this, &CategoryFilterWidget::addCategory);
|
||||||
|
|
||||||
auto selectedRows = selectionModel()->selectedRows();
|
const auto selectedRows = selectionModel()->selectedRows();
|
||||||
if (!selectedRows.empty() && !CategoryFilterModel::isSpecialItem(selectedRows.first())) {
|
if (!selectedRows.empty() && !CategoryFilterModel::isSpecialItem(selectedRows.first())) {
|
||||||
if (BitTorrent::Session::instance()->isSubcategoriesEnabled()) {
|
if (BitTorrent::Session::instance()->isSubcategoriesEnabled()) {
|
||||||
QAction *addSubAct = menu.addAction(
|
QAction *addSubAct = menu.addAction(
|
||||||
@ -220,7 +220,7 @@ void CategoryFilterWidget::editCategory()
|
|||||||
|
|
||||||
void CategoryFilterWidget::removeCategory()
|
void CategoryFilterWidget::removeCategory()
|
||||||
{
|
{
|
||||||
auto selectedRows = selectionModel()->selectedRows();
|
const auto selectedRows = selectionModel()->selectedRows();
|
||||||
if (!selectedRows.empty() && !CategoryFilterModel::isSpecialItem(selectedRows.first())) {
|
if (!selectedRows.empty() && !CategoryFilterModel::isSpecialItem(selectedRows.first())) {
|
||||||
BitTorrent::Session::instance()->removeCategory(
|
BitTorrent::Session::instance()->removeCategory(
|
||||||
static_cast<CategoryFilterProxyModel *>(model())->categoryName(selectedRows.first()));
|
static_cast<CategoryFilterProxyModel *>(model())->categoryName(selectedRows.first()));
|
||||||
|
@ -54,18 +54,18 @@ public:
|
|||||||
QList<QNetworkCookie> cookies() const;
|
QList<QNetworkCookie> cookies() const;
|
||||||
|
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
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;
|
QModelIndex parent(const QModelIndex &index) const override;
|
||||||
|
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex &parent = {}) const override;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
int columnCount(const QModelIndex &parent = {}) const override;
|
||||||
|
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
|
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||||
bool insertRows(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 = QModelIndex()) override;
|
bool removeRows(int row, int count, const QModelIndex &parent = {}) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable QList<QNetworkCookie> m_cookies;
|
mutable QList<QNetworkCookie> m_cookies;
|
||||||
|
@ -84,7 +84,7 @@ public:
|
|||||||
bool isExecutionLogEnabled() const;
|
bool isExecutionLogEnabled() const;
|
||||||
void setExecutionLogEnabled(bool value);
|
void setExecutionLogEnabled(bool value);
|
||||||
int executionLogMsgTypes() const;
|
int executionLogMsgTypes() const;
|
||||||
void setExecutionLogMsgTypes(const int value);
|
void setExecutionLogMsgTypes(int value);
|
||||||
|
|
||||||
// Notifications properties
|
// Notifications properties
|
||||||
bool isNotificationsEnabled() const;
|
bool isNotificationsEnabled() const;
|
||||||
@ -209,7 +209,7 @@ private:
|
|||||||
bool event(QEvent *e) override;
|
bool event(QEvent *e) override;
|
||||||
void displayRSSTab(bool enable);
|
void displayRSSTab(bool enable);
|
||||||
void displaySearchTab(bool enable);
|
void displaySearchTab(bool enable);
|
||||||
void createTorrentTriggered(const QString &path = QString());
|
void createTorrentTriggered(const QString &path = {});
|
||||||
void showStatusBar(bool show);
|
void showStatusBar(bool show);
|
||||||
|
|
||||||
Ui::MainWindow *m_ui;
|
Ui::MainWindow *m_ui;
|
||||||
|
@ -846,7 +846,7 @@ void OptionsDialog::loadOptions()
|
|||||||
m_ui->spinRSSRefreshInterval->setValue(RSS::Session::instance()->refreshInterval());
|
m_ui->spinRSSRefreshInterval->setValue(RSS::Session::instance()->refreshInterval());
|
||||||
m_ui->spinRSSMaxArticlesPerFeed->setValue(RSS::Session::instance()->maxArticlesPerFeed());
|
m_ui->spinRSSMaxArticlesPerFeed->setValue(RSS::Session::instance()->maxArticlesPerFeed());
|
||||||
|
|
||||||
auto session = BitTorrent::Session::instance();
|
const auto *session = BitTorrent::Session::instance();
|
||||||
|
|
||||||
// Downloads preferences
|
// Downloads preferences
|
||||||
m_ui->checkAdditionDialog->setChecked(AddNewTorrentDialog::isEnabled());
|
m_ui->checkAdditionDialog->setChecked(AddNewTorrentDialog::isEnabled());
|
||||||
@ -974,7 +974,7 @@ void OptionsDialog::loadOptions()
|
|||||||
m_ui->spinMaxUploadsPerTorrent->setEnabled(false);
|
m_ui->spinMaxUploadsPerTorrent->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto proxyConfigManager = Net::ProxyConfigurationManager::instance();
|
const auto *proxyConfigManager = Net::ProxyConfigurationManager::instance();
|
||||||
Net::ProxyConfiguration proxyConf = proxyConfigManager->proxyConfiguration();
|
Net::ProxyConfiguration proxyConf = proxyConfigManager->proxyConfiguration();
|
||||||
using Net::ProxyType;
|
using Net::ProxyType;
|
||||||
bool useProxyAuth = false;
|
bool useProxyAuth = false;
|
||||||
|
@ -118,7 +118,7 @@ PiecesBar::PiecesBar(QWidget *parent)
|
|||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PiecesBar::setTorrent(BitTorrent::TorrentHandle *torrent)
|
void PiecesBar::setTorrent(const BitTorrent::TorrentHandle *torrent)
|
||||||
{
|
{
|
||||||
m_torrent = torrent;
|
m_torrent = torrent;
|
||||||
if (!m_torrent)
|
if (!m_torrent)
|
||||||
|
@ -50,7 +50,7 @@ class PiecesBar : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit PiecesBar(QWidget *parent = nullptr);
|
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);
|
void setColors(const QColor &background, const QColor &border, const QColor &complete);
|
||||||
|
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
@ -213,7 +213,7 @@ void AutomatedRssDownloader::updateFeedList()
|
|||||||
bool anyEnabled = false;
|
bool anyEnabled = false;
|
||||||
|
|
||||||
for (const QListWidgetItem *ruleItem : asConst(selection)) {
|
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))
|
if (rule.feedURLs().contains(feedURL))
|
||||||
anyEnabled = true;
|
anyEnabled = true;
|
||||||
else
|
else
|
||||||
|
@ -53,7 +53,7 @@ public:
|
|||||||
explicit SearchSortModel(QObject *parent = nullptr);
|
explicit SearchSortModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
void enableNameFilter(bool enabled);
|
void enableNameFilter(bool enabled);
|
||||||
void setNameFilter(const QString &searchTerm = QString());
|
void setNameFilter(const QString &searchTerm = {});
|
||||||
|
|
||||||
//! \brief Sets parameters for filtering by size
|
//! \brief Sets parameters for filtering by size
|
||||||
//! \param minSize minimal size in bytes
|
//! \param minSize minimal size in bytes
|
||||||
|
@ -134,7 +134,7 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
|
|||||||
connect(m_tabStatusChangedMapper, static_cast<void (QSignalMapper::*)(QWidget *)>(&QSignalMapper::mapped)
|
connect(m_tabStatusChangedMapper, static_cast<void (QSignalMapper::*)(QWidget *)>(&QSignalMapper::mapped)
|
||||||
, this, &SearchWidget::tabStatusChanged);
|
, this, &SearchWidget::tabStatusChanged);
|
||||||
|
|
||||||
auto *searchManager = SearchPluginManager::instance();
|
const auto *searchManager = SearchPluginManager::instance();
|
||||||
const auto onPluginChanged = [this]()
|
const auto onPluginChanged = [this]()
|
||||||
{
|
{
|
||||||
fillPluginComboBox();
|
fillPluginComboBox();
|
||||||
|
@ -92,7 +92,7 @@ TagFilterModel::TagFilterModel(QObject *parent)
|
|||||||
: QAbstractListModel(parent)
|
: QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
using Session = BitTorrent::Session;
|
using Session = BitTorrent::Session;
|
||||||
auto session = Session::instance();
|
const auto *session = Session::instance();
|
||||||
|
|
||||||
connect(session, &Session::tagAdded, this, &TagFilterModel::tagAdded);
|
connect(session, &Session::tagAdded, this, &TagFilterModel::tagAdded);
|
||||||
connect(session, &Session::tagRemoved, this, &TagFilterModel::tagRemoved);
|
connect(session, &Session::tagRemoved, this, &TagFilterModel::tagRemoved);
|
||||||
@ -265,18 +265,18 @@ void TagFilterModel::populate()
|
|||||||
{
|
{
|
||||||
using Torrent = BitTorrent::TorrentHandle;
|
using Torrent = BitTorrent::TorrentHandle;
|
||||||
|
|
||||||
auto session = BitTorrent::Session::instance();
|
const auto *session = BitTorrent::Session::instance();
|
||||||
auto torrents = session->torrents();
|
const auto torrents = session->torrents();
|
||||||
|
|
||||||
// All torrents
|
// All torrents
|
||||||
addToModel(getSpecialAllTag(), torrents.count());
|
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(); });
|
[](Torrent *torrent) { return torrent->tags().isEmpty(); });
|
||||||
addToModel(getSpecialUntaggedTag(), untaggedCount);
|
addToModel(getSpecialUntaggedTag(), untaggedCount);
|
||||||
|
|
||||||
for (const QString &tag : asConst(session->tags())) {
|
for (const QString &tag : asConst(session->tags())) {
|
||||||
const int count = std::count_if(torrents.begin(), torrents.end(),
|
const int count = std::count_if(torrents.cbegin(), torrents.cend(),
|
||||||
[tag](Torrent *torrent) { return torrent->hasTag(tag); });
|
[tag](Torrent *torrent) { return torrent->hasTag(tag); });
|
||||||
addToModel(tag, count);
|
addToModel(tag, count);
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,8 @@ public:
|
|||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override;
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex &parent = {}) const override;
|
||||||
|
|
||||||
QModelIndex index(const QString &tag) const;
|
QModelIndex index(const QString &tag) const;
|
||||||
QString tag(const QModelIndex &index) const;
|
QString tag(const QModelIndex &index) const;
|
||||||
|
@ -90,7 +90,7 @@ TagFilterWidget::TagFilterWidget(QWidget *parent)
|
|||||||
QString TagFilterWidget::currentTag() const
|
QString TagFilterWidget::currentTag() const
|
||||||
{
|
{
|
||||||
QModelIndex current;
|
QModelIndex current;
|
||||||
auto selectedRows = selectionModel()->selectedRows();
|
const auto selectedRows = selectionModel()->selectedRows();
|
||||||
if (!selectedRows.isEmpty())
|
if (!selectedRows.isEmpty())
|
||||||
current = selectedRows.first();
|
current = selectedRows.first();
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ void TagFilterWidget::showMenu(QPoint)
|
|||||||
, tr("Add tag..."));
|
, tr("Add tag..."));
|
||||||
connect(addAct, &QAction::triggered, this, &TagFilterWidget::addTag);
|
connect(addAct, &QAction::triggered, this, &TagFilterWidget::addTag);
|
||||||
|
|
||||||
auto selectedRows = selectionModel()->selectedRows();
|
const auto selectedRows = selectionModel()->selectedRows();
|
||||||
if (!selectedRows.empty() && !TagFilterModel::isSpecialItem(selectedRows.first())) {
|
if (!selectedRows.empty() && !TagFilterModel::isSpecialItem(selectedRows.first())) {
|
||||||
QAction *removeAct = menu.addAction(
|
QAction *removeAct = menu.addAction(
|
||||||
GuiIconProvider::instance()->getIcon("list-remove")
|
GuiIconProvider::instance()->getIcon("list-remove")
|
||||||
@ -212,7 +212,7 @@ void TagFilterWidget::addTag()
|
|||||||
|
|
||||||
void TagFilterWidget::removeTag()
|
void TagFilterWidget::removeTag()
|
||||||
{
|
{
|
||||||
auto selectedRows = selectionModel()->selectedRows();
|
const auto selectedRows = selectionModel()->selectedRows();
|
||||||
if (!selectedRows.empty() && !TagFilterModel::isSpecialItem(selectedRows.first())) {
|
if (!selectedRows.empty() && !TagFilterModel::isSpecialItem(selectedRows.first())) {
|
||||||
BitTorrent::Session::instance()->removeTag(
|
BitTorrent::Session::instance()->removeTag(
|
||||||
static_cast<TagFilterProxyModel *>(model())->tag(selectedRows.first()));
|
static_cast<TagFilterProxyModel *>(model())->tag(selectedRows.first()));
|
||||||
|
@ -41,7 +41,7 @@ class TorrentCategoryDialog : public QDialog
|
|||||||
Q_DISABLE_COPY(TorrentCategoryDialog)
|
Q_DISABLE_COPY(TorrentCategoryDialog)
|
||||||
|
|
||||||
public:
|
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);
|
static void editCategory(QWidget *parent, const QString &categoryName);
|
||||||
|
|
||||||
explicit TorrentCategoryDialog(QWidget *parent = nullptr);
|
explicit TorrentCategoryDialog(QWidget *parent = nullptr);
|
||||||
|
@ -53,16 +53,16 @@ public:
|
|||||||
void updateFilesAvailability(const QVector<qreal> &fa);
|
void updateFilesAvailability(const QVector<qreal> &fa);
|
||||||
QVector<int> getFilePriorities() const;
|
QVector<int> getFilePriorities() const;
|
||||||
bool allFiltered() const;
|
bool allFiltered() const;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
int columnCount(const QModelIndex &parent = {}) const override;
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||||
TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const;
|
TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const;
|
||||||
int getFileIndex(const QModelIndex &index);
|
int getFileIndex(const QModelIndex &index);
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override;
|
||||||
QModelIndex parent(const QModelIndex &index) const override;
|
QModelIndex parent(const QModelIndex &index) const override;
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex &parent = {}) const override;
|
||||||
void clear();
|
void clear();
|
||||||
void setupModelData(const BitTorrent::TorrentInfo &info);
|
void setupModelData(const BitTorrent::TorrentInfo &info);
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ class TorrentCreatorDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TorrentCreatorDialog(QWidget *parent = nullptr, const QString &defaultPath = QString());
|
TorrentCreatorDialog(QWidget *parent = nullptr, const QString &defaultPath = {});
|
||||||
~TorrentCreatorDialog() override;
|
~TorrentCreatorDialog() override;
|
||||||
void updateInputPath(const QString &path);
|
void updateInputPath(const QString &path);
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ QVariant TransferListModel::headerData(int section, Qt::Orientation orientation,
|
|||||||
case TR_RATIO:
|
case TR_RATIO:
|
||||||
case TR_PRIORITY:
|
case TR_PRIORITY:
|
||||||
case TR_LAST_ACTIVITY:
|
case TR_LAST_ACTIVITY:
|
||||||
return {Qt::AlignRight | Qt::AlignVCenter};
|
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
default:
|
default:
|
||||||
return QAbstractListModel::headerData(section, orientation, role);
|
return QAbstractListModel::headerData(section, orientation, role);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public:
|
|||||||
|
|
||||||
explicit TransferListModel(QObject *parent = nullptr);
|
explicit TransferListModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
int rowCount(const QModelIndex &index = QModelIndex()) const override;
|
int rowCount(const QModelIndex &index = {}) const override;
|
||||||
int columnCount(const QModelIndex &parent=QModelIndex()) const override;
|
int columnCount(const QModelIndex &parent=QModelIndex()) const override;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||||
|
@ -52,7 +52,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
||||||
bool lowerPositionThan(const QModelIndex &left, const QModelIndex &right) const;
|
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 filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||||
bool matchFilter(int sourceRow, const QModelIndex &sourceParent) const;
|
bool matchFilter(int sourceRow, const QModelIndex &sourceParent) const;
|
||||||
|
|
||||||
|
@ -49,9 +49,9 @@ namespace Utils
|
|||||||
return (size * screenScalingFactor(widget));
|
return (size * screenScalingFactor(widget));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap scaledPixmap(const QIcon &icon, const QWidget *widget, const int height);
|
QPixmap scaledPixmap(const QIcon &icon, const QWidget *widget, int height);
|
||||||
QPixmap scaledPixmap(const QString &path, const QWidget *widget, const int height = 0);
|
QPixmap scaledPixmap(const QString &path, const QWidget *widget, int height = 0);
|
||||||
QPixmap scaledPixmapSvg(const QString &path, const QWidget *widget, const int baseHeight);
|
QPixmap scaledPixmapSvg(const QString &path, const QWidget *widget, int baseHeight);
|
||||||
QSize smallIconSize(const QWidget *widget = nullptr);
|
QSize smallIconSize(const QWidget *widget = nullptr);
|
||||||
QSize mediumIconSize(const QWidget *widget = nullptr);
|
QSize mediumIconSize(const QWidget *widget = nullptr);
|
||||||
QSize largeIconSize(const QWidget *widget = nullptr);
|
QSize largeIconSize(const QWidget *widget = nullptr);
|
||||||
|
@ -89,7 +89,7 @@ void AppController::shutdownAction()
|
|||||||
void AppController::preferencesAction()
|
void AppController::preferencesAction()
|
||||||
{
|
{
|
||||||
const Preferences *const pref = Preferences::instance();
|
const Preferences *const pref = Preferences::instance();
|
||||||
auto session = BitTorrent::Session::instance();
|
const auto *session = BitTorrent::Session::instance();
|
||||||
QVariantMap data;
|
QVariantMap data;
|
||||||
|
|
||||||
// Downloads
|
// Downloads
|
||||||
@ -144,7 +144,7 @@ void AppController::preferencesAction()
|
|||||||
data["max_uploads_per_torrent"] = session->maxUploadsPerTorrent();
|
data["max_uploads_per_torrent"] = session->maxUploadsPerTorrent();
|
||||||
|
|
||||||
// Proxy Server
|
// Proxy Server
|
||||||
auto proxyManager = Net::ProxyConfigurationManager::instance();
|
const auto *proxyManager = Net::ProxyConfigurationManager::instance();
|
||||||
Net::ProxyConfiguration proxyConf = proxyManager->proxyConfiguration();
|
Net::ProxyConfiguration proxyConf = proxyManager->proxyConfiguration();
|
||||||
data["proxy_type"] = static_cast<int>(proxyConf.type);
|
data["proxy_type"] = static_cast<int>(proxyConf.type);
|
||||||
data["proxy_ip"] = proxyConf.ip;
|
data["proxy_ip"] = proxyConf.ip;
|
||||||
|
@ -109,7 +109,7 @@ void SearchController::stopAction()
|
|||||||
const int id = params()["id"].toInt();
|
const int id = params()["id"].toInt();
|
||||||
ISession *const session = sessionManager()->session();
|
ISession *const session = sessionManager()->session();
|
||||||
|
|
||||||
auto searchHandlers = session->getData<SearchHandlerDict>(SEARCH_HANDLERS);
|
const auto searchHandlers = session->getData<SearchHandlerDict>(SEARCH_HANDLERS);
|
||||||
if (!searchHandlers.contains(id))
|
if (!searchHandlers.contains(id))
|
||||||
throw APIError(APIErrorType::NotFound);
|
throw APIError(APIErrorType::NotFound);
|
||||||
|
|
||||||
|
@ -66,8 +66,8 @@ private:
|
|||||||
|
|
||||||
void checkForUpdatesFinished(const QHash<QString, PluginVersion> &updateInfo);
|
void checkForUpdatesFinished(const QHash<QString, PluginVersion> &updateInfo);
|
||||||
void checkForUpdatesFailed(const QString &reason);
|
void checkForUpdatesFailed(const QString &reason);
|
||||||
void searchFinished(ISession *session, const int id);
|
void searchFinished(ISession *session, int id);
|
||||||
void searchFailed(ISession *session, const int id);
|
void searchFailed(ISession *session, int id);
|
||||||
int generateSearchId() const;
|
int generateSearchId() const;
|
||||||
QJsonObject getResults(const QList<SearchResult> &searchResults, bool isSearchActive, int totalResults) const;
|
QJsonObject getResults(const QList<SearchResult> &searchResults, bool isSearchActive, int totalResults) const;
|
||||||
QJsonArray getPluginsInfo(const QStringList &plugins) const;
|
QJsonArray getPluginsInfo(const QStringList &plugins) const;
|
||||||
|
@ -134,7 +134,7 @@ namespace
|
|||||||
QVariantList getStickyTrackers(const BitTorrent::TorrentHandle *const torrent)
|
QVariantList getStickyTrackers(const BitTorrent::TorrentHandle *const torrent)
|
||||||
{
|
{
|
||||||
uint seedsDHT = 0, seedsPeX = 0, seedsLSD = 0, leechesDHT = 0, leechesPeX = 0, leechesLSD = 0;
|
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.isConnecting()) continue;
|
||||||
|
|
||||||
if (peer.isSeed()) {
|
if (peer.isSeed()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user