mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-05 03:14:44 +00:00
Fix coding style
This commit is contained in:
parent
6c6e23910d
commit
20ca90800d
@ -34,14 +34,14 @@
|
||||
#include <QFile>
|
||||
#include <QObject>
|
||||
|
||||
class AsyncFileStorageError: public std::runtime_error
|
||||
class AsyncFileStorageError : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit AsyncFileStorageError(const QString &message);
|
||||
QString message() const;
|
||||
};
|
||||
|
||||
class AsyncFileStorage: public QObject
|
||||
class AsyncFileStorage : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -55,7 +55,7 @@ void BandwidthScheduler::start()
|
||||
|
||||
bool BandwidthScheduler::isTimeForAlternative() const
|
||||
{
|
||||
const Preferences* const pref = Preferences::instance();
|
||||
const Preferences *const pref = Preferences::instance();
|
||||
|
||||
QTime start = pref->getSchedulerStartTime();
|
||||
QTime end = pref->getSchedulerEndTime();
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
|
||||
class BandwidthScheduler: public QObject
|
||||
class BandwidthScheduler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(BandwidthScheduler)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libt.
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@ -147,13 +147,13 @@ int FilterParserThread::parseDATFilterFile()
|
||||
if (bytesRead < 0)
|
||||
break;
|
||||
int dataSize = bytesRead + offset;
|
||||
if (bytesRead == 0 && dataSize == 0)
|
||||
if ((bytesRead == 0) && (dataSize == 0))
|
||||
break;
|
||||
|
||||
for (start = 0; start < dataSize; ++start) {
|
||||
endOfLine = -1;
|
||||
// The file might have ended without the last line having a newline
|
||||
if (!(bytesRead == 0 && dataSize > 0)) {
|
||||
if (!((bytesRead == 0) && (dataSize > 0))) {
|
||||
for (int i = start; i < dataSize; ++i) {
|
||||
if (buffer[i] == '\n') {
|
||||
endOfLine = i;
|
||||
@ -295,13 +295,13 @@ int FilterParserThread::parseP2PFilterFile()
|
||||
if (bytesRead < 0)
|
||||
break;
|
||||
int dataSize = bytesRead + offset;
|
||||
if (bytesRead == 0 && dataSize == 0)
|
||||
if ((bytesRead == 0) && (dataSize == 0))
|
||||
break;
|
||||
|
||||
for (start = 0; start < dataSize; ++start) {
|
||||
endOfLine = -1;
|
||||
// The file might have ended without the last line having a newline
|
||||
if (!(bytesRead == 0 && dataSize > 0)) {
|
||||
if (!((bytesRead == 0) && (dataSize > 0))) {
|
||||
for (int i = start; i < dataSize; ++i) {
|
||||
if (buffer[i] == '\n') {
|
||||
endOfLine = i;
|
||||
@ -610,7 +610,7 @@ int FilterParserThread::findAndNullDelimiter(char *const data, char delimiter, i
|
||||
return -1;
|
||||
}
|
||||
|
||||
int FilterParserThread::trim(char* const data, int start, int end)
|
||||
int FilterParserThread::trim(char *const data, int start, int end)
|
||||
{
|
||||
if (start >= end) return start;
|
||||
int newStart = start;
|
||||
|
@ -370,7 +370,7 @@ Session::Session(QObject *parent)
|
||||
, m_extraLimit(0)
|
||||
, m_useProxy(false)
|
||||
{
|
||||
Logger* const logger = Logger::instance();
|
||||
Logger *const logger = Logger::instance();
|
||||
|
||||
initResumeFolder();
|
||||
|
||||
@ -940,7 +940,7 @@ qreal Session::globalMaxRatio() const
|
||||
return m_globalMaxRatio;
|
||||
}
|
||||
|
||||
// Torrents will a ratio superior to the given value will
|
||||
// Torrents with a ratio superior to the given value will
|
||||
// be automatically deleted
|
||||
void Session::setGlobalMaxRatio(qreal ratio)
|
||||
{
|
||||
@ -1083,7 +1083,7 @@ void Session::processBannedIPs(libt::ip_filter &filter)
|
||||
#if LIBTORRENT_VERSION_NUM >= 10100
|
||||
void Session::adjustLimits(libt::settings_pack &settingsPack)
|
||||
{
|
||||
//Internally increase the queue limits to ensure that the magnet is started
|
||||
// Internally increase the queue limits to ensure that the magnet is started
|
||||
int maxDownloads = maxActiveDownloads();
|
||||
int maxActive = maxActiveTorrents();
|
||||
|
||||
@ -1180,7 +1180,7 @@ void Session::initMetrics()
|
||||
|
||||
void Session::configure(libtorrent::settings_pack &settingsPack)
|
||||
{
|
||||
Logger* const logger = Logger::instance();
|
||||
Logger *const logger = Logger::instance();
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QString chosenIP;
|
||||
@ -1249,7 +1249,7 @@ void Session::configure(libtorrent::settings_pack &settingsPack)
|
||||
settingsPack.set_int(libt::settings_pack::allowed_enc_level, libt::settings_pack::pe_rc4);
|
||||
settingsPack.set_bool(libt::settings_pack::prefer_rc4, true);
|
||||
switch (encryption()) {
|
||||
case 0: //Enabled
|
||||
case 0: // Enabled
|
||||
settingsPack.set_int(libt::settings_pack::out_enc_policy, libt::settings_pack::pe_enabled);
|
||||
settingsPack.set_int(libt::settings_pack::in_enc_policy, libt::settings_pack::pe_enabled);
|
||||
break;
|
||||
@ -1302,7 +1302,7 @@ void Session::configure(libtorrent::settings_pack &settingsPack)
|
||||
settingsPack.set_bool(libt::settings_pack::announce_to_all_trackers, announceToAllTrackers());
|
||||
settingsPack.set_bool(libt::settings_pack::announce_to_all_tiers, announceToAllTiers());
|
||||
|
||||
const int cacheSize = (diskCacheSize() > -1) ? diskCacheSize() * 64 : -1;
|
||||
const int cacheSize = (diskCacheSize() > -1) ? (diskCacheSize() * 64) : -1;
|
||||
settingsPack.set_int(libt::settings_pack::cache_size, cacheSize);
|
||||
settingsPack.set_int(libt::settings_pack::cache_expiry, diskCacheTTL());
|
||||
qDebug() << "Using a disk cache size of" << cacheSize << "MiB";
|
||||
@ -1510,12 +1510,12 @@ void Session::configurePeerClasses()
|
||||
|
||||
void Session::adjustLimits(libt::session_settings &sessionSettings)
|
||||
{
|
||||
//Internally increase the queue limits to ensure that the magnet is started
|
||||
// Internally increase the queue limits to ensure that the magnet is started
|
||||
int maxDownloads = maxActiveDownloads();
|
||||
int maxActive = maxActiveTorrents();
|
||||
|
||||
sessionSettings.active_downloads = maxDownloads > -1 ? maxDownloads + m_extraLimit : maxDownloads;
|
||||
sessionSettings.active_limit = maxActive > -1 ? maxActive + m_extraLimit : maxActive;
|
||||
sessionSettings.active_downloads = (maxDownloads > -1) ? (maxDownloads + m_extraLimit) : maxDownloads;
|
||||
sessionSettings.active_limit = (maxActive > -1) ? (maxActive + m_extraLimit) : maxActive;
|
||||
}
|
||||
|
||||
void Session::applyBandwidthLimits(libt::session_settings &sessionSettings)
|
||||
@ -1534,7 +1534,7 @@ void Session::configure(libtorrent::session_settings &sessionSettings)
|
||||
encryptionSettings.allowed_enc_level = libt::pe_settings::rc4;
|
||||
encryptionSettings.prefer_rc4 = true;
|
||||
switch (encryption()) {
|
||||
case 0: //Enabled
|
||||
case 0: // Enabled
|
||||
encryptionSettings.out_enc_policy = libt::pe_settings::enabled;
|
||||
encryptionSettings.in_enc_policy = libt::pe_settings::enabled;
|
||||
break;
|
||||
@ -1589,7 +1589,7 @@ void Session::configure(libtorrent::session_settings &sessionSettings)
|
||||
|
||||
sessionSettings.announce_to_all_trackers = announceToAllTrackers();
|
||||
sessionSettings.announce_to_all_tiers = announceToAllTiers();
|
||||
const int cacheSize = (diskCacheSize() > -1) ? diskCacheSize() * 64 : -1;
|
||||
const int cacheSize = (diskCacheSize() > -1) ? (diskCacheSize() * 64) : -1;
|
||||
sessionSettings.cache_size = cacheSize;
|
||||
sessionSettings.cache_expiry = diskCacheTTL();
|
||||
qDebug() << "Using a disk cache size of" << cacheSize << "MiB";
|
||||
@ -1762,7 +1762,7 @@ void Session::enableBandwidthScheduler()
|
||||
void Session::populateAdditionalTrackers()
|
||||
{
|
||||
m_additionalTrackerList.clear();
|
||||
foreach (QString tracker, additionalTrackers().split("\n")) {
|
||||
foreach (QString tracker, additionalTrackers().split('\n')) {
|
||||
tracker = tracker.trimmed();
|
||||
if (!tracker.isEmpty())
|
||||
m_additionalTrackerList << tracker;
|
||||
@ -1786,7 +1786,7 @@ void Session::processShareLimits()
|
||||
qDebug("Ratio: %f (limit: %f)", ratio, ratioLimit);
|
||||
|
||||
if ((ratio <= TorrentHandle::MAX_RATIO) && (ratio >= ratioLimit)) {
|
||||
Logger* const logger = Logger::instance();
|
||||
Logger *const logger = Logger::instance();
|
||||
if (m_maxRatioAction == Remove) {
|
||||
logger->addMessage(tr("'%1' reached the maximum ratio you set. Removed.").arg(torrent->name()));
|
||||
deleteTorrent(torrent->hash());
|
||||
@ -1811,7 +1811,7 @@ void Session::processShareLimits()
|
||||
qDebug("Seeding Time: %d (limit: %d)", seedingTimeInMinutes, seedingTimeLimit);
|
||||
|
||||
if ((seedingTimeInMinutes <= TorrentHandle::MAX_SEEDING_TIME) && (seedingTimeInMinutes >= seedingTimeLimit)) {
|
||||
Logger* const logger = Logger::instance();
|
||||
Logger *const logger = Logger::instance();
|
||||
if (m_maxRatioAction == Remove) {
|
||||
logger->addMessage(tr("'%1' reached the maximum seeding time you set. Removed.").arg(torrent->name()));
|
||||
deleteTorrent(torrent->hash());
|
||||
@ -2259,7 +2259,7 @@ bool Session::loadMetadata(const MagnetUri &magnetUri)
|
||||
InfoHash hash = magnetUri.hash();
|
||||
QString name = magnetUri.name();
|
||||
|
||||
// We should not add torrent if it already
|
||||
// We should not add torrent if it's already
|
||||
// processed or adding to session
|
||||
if (m_torrents.contains(hash)) return false;
|
||||
if (m_addingTorrents.contains(hash)) return false;
|
||||
@ -2404,7 +2404,7 @@ void Session::networkOnlineStateChanged(const bool online)
|
||||
Logger::instance()->addMessage(tr("System network status changed to %1", "e.g: System network status changed to ONLINE").arg(online ? tr("ONLINE") : tr("OFFLINE")), Log::INFO);
|
||||
}
|
||||
|
||||
void Session::networkConfigurationChange(const QNetworkConfiguration& cfg)
|
||||
void Session::networkConfigurationChange(const QNetworkConfiguration &cfg)
|
||||
{
|
||||
const QString configuredInterfaceName = networkInterface();
|
||||
// Empty means "Any Interface". In this case libtorrent has binded to 0.0.0.0 so any change to any interface will
|
||||
@ -2430,7 +2430,7 @@ void Session::networkConfigurationChange(const QNetworkConfiguration& cfg)
|
||||
|
||||
const QStringList Session::getListeningIPs()
|
||||
{
|
||||
Logger* const logger = Logger::instance();
|
||||
Logger *const logger = Logger::instance();
|
||||
QStringList IPs;
|
||||
|
||||
const QString ifaceName = networkInterface();
|
||||
@ -2473,12 +2473,12 @@ const QStringList Session::getListeningIPs()
|
||||
ip = entry.ip();
|
||||
ipString = ip.toString();
|
||||
protocol = ip.protocol();
|
||||
Q_ASSERT(protocol == QAbstractSocket::IPv4Protocol || protocol == QAbstractSocket::IPv6Protocol);
|
||||
Q_ASSERT((protocol == QAbstractSocket::IPv4Protocol) || (protocol == QAbstractSocket::IPv6Protocol));
|
||||
if ((!listenIPv6 && (protocol == QAbstractSocket::IPv6Protocol))
|
||||
|| (listenIPv6 && (protocol == QAbstractSocket::IPv4Protocol)))
|
||||
continue;
|
||||
|
||||
//If an iface address has been defined only allow ip's that match it to go through
|
||||
// If an iface address has been defined to only allow ip's that match it to go through
|
||||
if (!ifaceAddr.isEmpty()) {
|
||||
if (ifaceAddr == ipString) {
|
||||
IPs.append(ipString);
|
||||
@ -2509,7 +2509,7 @@ void Session::configureListeningInterface()
|
||||
const ushort port = this->port();
|
||||
qDebug() << Q_FUNC_INFO << port;
|
||||
|
||||
Logger* const logger = Logger::instance();
|
||||
Logger *const logger = Logger::instance();
|
||||
|
||||
std::pair<int, int> ports(port, port);
|
||||
libt::error_code ec;
|
||||
@ -3512,7 +3512,7 @@ void Session::handleTorrentTagRemoved(TorrentHandle *const torrent, const QStrin
|
||||
emit torrentTagRemoved(torrent, tag);
|
||||
}
|
||||
|
||||
void Session::handleTorrentSavingModeChanged(TorrentHandle * const torrent)
|
||||
void Session::handleTorrentSavingModeChanged(TorrentHandle *const torrent)
|
||||
{
|
||||
emit torrentSavingModeChanged(torrent);
|
||||
}
|
||||
@ -3798,7 +3798,7 @@ void Session::startUpTorrents()
|
||||
.arg(params.hash), Log::CRITICAL);
|
||||
|
||||
// process add torrent messages before message queue overflow
|
||||
if (resumedTorrentsCount % 100 == 0) readAlerts();
|
||||
if ((resumedTorrentsCount % 100) == 0) readAlerts();
|
||||
|
||||
++resumedTorrentsCount;
|
||||
};
|
||||
@ -3833,12 +3833,12 @@ void Session::startUpTorrents()
|
||||
}
|
||||
else {
|
||||
int q = queuePosition;
|
||||
for(; queuedResumeData.contains(q); ++q) {
|
||||
for (; queuedResumeData.contains(q); ++q) {
|
||||
}
|
||||
if (q != queuePosition) {
|
||||
++numOfRemappedFiles;
|
||||
}
|
||||
queuedResumeData[q] = { hash, magnetUri, resumeData, data };
|
||||
queuedResumeData[q] = {hash, magnetUri, resumeData, data};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2010 Christophe Dumez
|
||||
* Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -24,8 +24,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#include "torrentcreatorthread.h"
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2010 Christophe Dumez
|
||||
* Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -24,8 +24,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#ifndef BITTORRENT_TORRENTCREATORTHREAD_H
|
||||
|
@ -30,13 +30,13 @@
|
||||
|
||||
#include <libtorrent/error_code.hpp>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "base/utils/misc.h"
|
||||
#include "base/utils/fs.h"
|
||||
#include "base/utils/misc.h"
|
||||
#include "base/utils/string.h"
|
||||
#include "infohash.h"
|
||||
#include "trackerentry.h"
|
||||
@ -315,7 +315,7 @@ QVector<QByteArray> TorrentInfo::pieceHashes() const
|
||||
return hashes;
|
||||
}
|
||||
|
||||
TorrentInfo::PieceRange TorrentInfo::filePieces(const QString& file) const
|
||||
TorrentInfo::PieceRange TorrentInfo::filePieces(const QString &file) const
|
||||
{
|
||||
if (!isValid()) // if we do not check here the debug message will be printed, which would be not correct
|
||||
return {};
|
||||
@ -353,8 +353,8 @@ void TorrentInfo::renameFile(uint index, const QString &newPath)
|
||||
|
||||
int BitTorrent::TorrentInfo::fileIndex(const QString& fileName) const
|
||||
{
|
||||
// the check whether the object valid is not needed here
|
||||
// because filesCount() returns -1 in that case and the loop exits immediately
|
||||
// the check whether the object is valid is not needed here
|
||||
// because if filesCount() returns -1 the loop exits immediately
|
||||
for (int i = 0; i < filesCount(); ++i)
|
||||
if (fileName == filePath(i))
|
||||
return i;
|
||||
|
@ -39,11 +39,11 @@
|
||||
|
||||
#include "base/indexrange.h"
|
||||
|
||||
class QString;
|
||||
class QUrl;
|
||||
class QDateTime;
|
||||
class QStringList;
|
||||
class QByteArray;
|
||||
class QDateTime;
|
||||
class QString;
|
||||
class QStringList;
|
||||
class QUrl;
|
||||
|
||||
namespace BitTorrent
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
@ -27,6 +27,8 @@
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#include "tracker.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <libtorrent/bencode.hpp>
|
||||
@ -37,7 +39,6 @@
|
||||
#include "base/preferences.h"
|
||||
#include "base/utils/bytearray.h"
|
||||
#include "base/utils/string.h"
|
||||
#include "tracker.h"
|
||||
|
||||
// static limits
|
||||
static const int MAX_TORRENTS = 100;
|
||||
@ -277,5 +278,3 @@ void Tracker::replyWithPeerList(const TrackerAnnounceRequest &annonceReq)
|
||||
// HTTP reply
|
||||
print(reply, Http::CONTENT_TYPE_TXT);
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,14 +28,14 @@
|
||||
|
||||
#include "filesystemwatcher.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_FREEBSD)
|
||||
#include <cstring>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "base/algorithm.h"
|
||||
#include "base/bittorrent/magneturi.h"
|
||||
#include "base/bittorrent/torrentinfo.h"
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2018 Mike Tzou (Chocobo1)
|
||||
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2006 Ishan Arora and Christophe Dumez
|
||||
* Copyright (C) 2006 Ishan Arora and Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -26,8 +26,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#include "connection.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2006 Ishan Arora and Christophe Dumez
|
||||
* Copyright (C) 2006 Ishan Arora and Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -25,8 +25,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
|
||||
|
@ -3,12 +3,12 @@
|
||||
#include <QDateTime>
|
||||
#include "base/utils/string.h"
|
||||
|
||||
Logger* Logger::m_instance = nullptr;
|
||||
Logger *Logger::m_instance = nullptr;
|
||||
|
||||
Logger::Logger()
|
||||
: lock(QReadWriteLock::Recursive)
|
||||
, msgCounter(0)
|
||||
, peerCounter(0)
|
||||
: m_lock(QReadWriteLock::Recursive)
|
||||
, m_msgCounter(0)
|
||||
, m_peerCounter(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -35,9 +35,9 @@ void Logger::freeInstance()
|
||||
|
||||
void Logger::addMessage(const QString &message, const Log::MsgType &type)
|
||||
{
|
||||
QWriteLocker locker(&lock);
|
||||
QWriteLocker locker(&m_lock);
|
||||
|
||||
Log::Msg temp = { msgCounter++, QDateTime::currentMSecsSinceEpoch(), type, message.toHtmlEscaped() };
|
||||
Log::Msg temp = {m_msgCounter++, QDateTime::currentMSecsSinceEpoch(), type, message.toHtmlEscaped()};
|
||||
m_messages.push_back(temp);
|
||||
|
||||
if (m_messages.size() >= MAX_LOG_MESSAGES)
|
||||
@ -48,9 +48,9 @@ void Logger::addMessage(const QString &message, const Log::MsgType &type)
|
||||
|
||||
void Logger::addPeer(const QString &ip, bool blocked, const QString &reason)
|
||||
{
|
||||
QWriteLocker locker(&lock);
|
||||
QWriteLocker locker(&m_lock);
|
||||
|
||||
Log::Peer temp = { peerCounter++, QDateTime::currentMSecsSinceEpoch(), ip.toHtmlEscaped(), blocked, reason.toHtmlEscaped() };
|
||||
Log::Peer temp = {m_peerCounter++, QDateTime::currentMSecsSinceEpoch(), ip.toHtmlEscaped(), blocked, reason.toHtmlEscaped()};
|
||||
m_peers.push_back(temp);
|
||||
|
||||
if (m_peers.size() >= MAX_LOG_MESSAGES)
|
||||
@ -61,9 +61,9 @@ void Logger::addPeer(const QString &ip, bool blocked, const QString &reason)
|
||||
|
||||
QVector<Log::Msg> Logger::getMessages(int lastKnownId) const
|
||||
{
|
||||
QReadLocker locker(&lock);
|
||||
QReadLocker locker(&m_lock);
|
||||
|
||||
int diff = msgCounter - lastKnownId - 1;
|
||||
int diff = m_msgCounter - lastKnownId - 1;
|
||||
int size = m_messages.size();
|
||||
|
||||
if ((lastKnownId == -1) || (diff >= size))
|
||||
@ -77,9 +77,9 @@ QVector<Log::Msg> Logger::getMessages(int lastKnownId) const
|
||||
|
||||
QVector<Log::Peer> Logger::getPeers(int lastKnownId) const
|
||||
{
|
||||
QReadLocker locker(&lock);
|
||||
QReadLocker locker(&m_lock);
|
||||
|
||||
int diff = peerCounter - lastKnownId - 1;
|
||||
int diff = m_peerCounter - lastKnownId - 1;
|
||||
int size = m_peers.size();
|
||||
|
||||
if ((lastKnownId == -1) || (diff >= size))
|
||||
|
@ -1,10 +1,10 @@
|
||||
#ifndef LOGGER_H
|
||||
#define LOGGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QReadWriteLock>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QReadWriteLock>
|
||||
#include <QObject>
|
||||
|
||||
const int MAX_LOG_MESSAGES = 20000;
|
||||
|
||||
@ -16,7 +16,7 @@ namespace Log
|
||||
NORMAL = 0x1,
|
||||
INFO = 0x2,
|
||||
WARNING = 0x4,
|
||||
CRITICAL = 0x8 //ERROR is defined by libtorrent and results in compiler error
|
||||
CRITICAL = 0x8 // ERROR is defined by libtorrent and results in compiler error
|
||||
};
|
||||
Q_DECLARE_FLAGS(MsgTypes, MsgType)
|
||||
|
||||
@ -63,12 +63,12 @@ private:
|
||||
Logger();
|
||||
~Logger();
|
||||
|
||||
static Logger* m_instance;
|
||||
static Logger *m_instance;
|
||||
QVector<Log::Msg> m_messages;
|
||||
QVector<Log::Peer> m_peers;
|
||||
mutable QReadWriteLock lock;
|
||||
int msgCounter;
|
||||
int peerCounter;
|
||||
mutable QReadWriteLock m_lock;
|
||||
int m_msgCounter;
|
||||
int m_peerCounter;
|
||||
};
|
||||
|
||||
// Helper function
|
||||
|
@ -48,7 +48,7 @@ const char DEFAULT_USER_AGENT[] = "Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/
|
||||
|
||||
namespace
|
||||
{
|
||||
class NetworkCookieJar: public QNetworkCookieJar
|
||||
class NetworkCookieJar : public QNetworkCookieJar
|
||||
{
|
||||
public:
|
||||
explicit NetworkCookieJar(QObject *parent = nullptr)
|
||||
|
@ -26,12 +26,12 @@
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QVariant>
|
||||
#include <QFile>
|
||||
#include <QHash>
|
||||
#include <QHostAddress>
|
||||
#include <QDateTime>
|
||||
#include <QFile>
|
||||
#include <QVariant>
|
||||
|
||||
#include "base/types.h"
|
||||
#include "geoipdatabase.h"
|
||||
@ -44,7 +44,7 @@ namespace
|
||||
const char DB_TYPE[] = "GeoLite2-Country";
|
||||
const quint32 MAX_METADATA_SIZE = 131072; // 128KB
|
||||
const char METADATA_BEGIN_MARK[] = "\xab\xcd\xefMaxMind.com";
|
||||
const char DATA_SECTION_SEPARATOR[16] = { 0 };
|
||||
const char DATA_SECTION_SEPARATOR[16] = {0};
|
||||
|
||||
enum class DataType
|
||||
{
|
||||
|
@ -29,13 +29,13 @@
|
||||
#ifndef GEOIPDATABASE_H
|
||||
#define GEOIPDATABASE_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QCoreApplication>
|
||||
#include <QtGlobal>
|
||||
|
||||
class QHostAddress;
|
||||
class QString;
|
||||
class QByteArray;
|
||||
class QDateTime;
|
||||
class QHostAddress;
|
||||
class QString;
|
||||
|
||||
struct DataFieldDescriptor;
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
*/
|
||||
|
||||
#include "proxyconfigurationmanager.h"
|
||||
|
||||
#include "base/settingsstorage.h"
|
||||
|
||||
#define SETTINGS_KEY(name) "Network/Proxy/" name
|
||||
|
@ -52,7 +52,7 @@ namespace Net
|
||||
QString password;
|
||||
};
|
||||
|
||||
class ProxyConfigurationManager: public QObject
|
||||
class ProxyConfigurationManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(ProxyConfigurationManager)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2006 Christophe Dumez
|
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -24,26 +24,24 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#include "reverseresolution.h"
|
||||
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QHostInfo>
|
||||
#include <QString>
|
||||
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
|
||||
#include "reverseresolution.h"
|
||||
|
||||
const int CACHE_SIZE = 500;
|
||||
|
||||
using namespace Net;
|
||||
|
||||
static inline bool isUsefulHostName(const QString &hostname, const QString &ip)
|
||||
{
|
||||
return (!hostname.isEmpty() && hostname != ip);
|
||||
return (!hostname.isEmpty() && (hostname != ip));
|
||||
}
|
||||
|
||||
ReverseResolution::ReverseResolution(QObject *parent)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2006 Christophe Dumez
|
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -24,8 +24,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#ifndef NET_REVERSERESOLUTION_H
|
||||
@ -34,10 +32,8 @@
|
||||
#include <QCache>
|
||||
#include <QObject>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QHostInfo;
|
||||
class QString;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Net
|
||||
{
|
||||
|
@ -130,8 +130,8 @@ Smtp::~Smtp()
|
||||
|
||||
void Smtp::sendMail(const QString &from, const QString &to, const QString &subject, const QString &body)
|
||||
{
|
||||
const Preferences* const pref = Preferences::instance();
|
||||
QTextCodec* latin1 = QTextCodec::codecForName("latin1");
|
||||
const Preferences *const pref = Preferences::instance();
|
||||
QTextCodec *latin1 = QTextCodec::codecForName("latin1");
|
||||
m_message = "Date: " + getCurrentDateTime().toLatin1() + "\r\n"
|
||||
+ encodeMimeHeader("From", from, latin1)
|
||||
+ encodeMimeHeader("Subject", subject, latin1)
|
||||
@ -141,8 +141,8 @@ void Smtp::sendMail(const QString &from, const QString &to, const QString &subje
|
||||
+ "Content-Transfer-Encoding: base64\r\n"
|
||||
+ "\r\n";
|
||||
// Encode the body in base64
|
||||
QString crlf_body = body;
|
||||
QByteArray b = crlf_body.replace("\n", "\r\n").toUtf8().toBase64();
|
||||
QString crlfBody = body;
|
||||
QByteArray b = crlfBody.replace("\n", "\r\n").toUtf8().toBase64();
|
||||
int ct = b.length();
|
||||
for (int i = 0; i < ct; i += 78)
|
||||
m_message += b.mid(i, 78);
|
||||
@ -165,7 +165,7 @@ void Smtp::sendMail(const QString &from, const QString &to, const QString &subje
|
||||
m_socket->connectToHost(pref->getMailNotificationSMTP(), DEFAULT_PORT);
|
||||
m_useSsl = false;
|
||||
#ifndef QT_NO_OPENSSL
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ void Smtp::readyRead()
|
||||
QByteArray code = line.left(3);
|
||||
|
||||
switch (m_state) {
|
||||
case Init: {
|
||||
case Init:
|
||||
if (code[0] == '2') {
|
||||
// The server may send a multiline greeting/INIT/220 response.
|
||||
// We wait until it finishes.
|
||||
@ -198,7 +198,6 @@ void Smtp::readyRead()
|
||||
m_state = Close;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EhloSent:
|
||||
case HeloSent:
|
||||
case EhloGreetReceived:
|
||||
@ -448,7 +447,7 @@ void Smtp::startTLS()
|
||||
#endif
|
||||
}
|
||||
|
||||
void Smtp::authCramMD5(const QByteArray& challenge)
|
||||
void Smtp::authCramMD5(const QByteArray &challenge)
|
||||
{
|
||||
if (m_state != AuthRequestSent) {
|
||||
m_socket->write("auth cram-md5\r\n");
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Copyright (C) 2006 Christophe Dumez
|
||||
* Copyright (C) 2014 sledgehammer999
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2014 sledgehammer999 <sledgehammer999@qbittorrent.org>
|
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -25,9 +25,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
* Contact : hammered999@gmail.com
|
||||
*/
|
||||
|
||||
#include "preferences.h"
|
||||
@ -420,12 +417,12 @@ void Preferences::setSchedulerEndTime(const QTime &time)
|
||||
setValue("Preferences/Scheduler/end_time", time);
|
||||
}
|
||||
|
||||
scheduler_days Preferences::getSchedulerDays() const
|
||||
SchedulerDays Preferences::getSchedulerDays() const
|
||||
{
|
||||
return static_cast<scheduler_days>(value("Preferences/Scheduler/days", EVERY_DAY).toInt());
|
||||
return static_cast<SchedulerDays>(value("Preferences/Scheduler/days", EVERY_DAY).toInt());
|
||||
}
|
||||
|
||||
void Preferences::setSchedulerDays(scheduler_days days)
|
||||
void Preferences::setSchedulerDays(SchedulerDays days)
|
||||
{
|
||||
setValue("Preferences/Scheduler/days", static_cast<int>(days));
|
||||
}
|
||||
@ -690,12 +687,12 @@ QString Preferences::getUILockPasswordMD5() const
|
||||
return value("Locking/password").toString();
|
||||
}
|
||||
|
||||
void Preferences::setUILockPassword(const QString &clear_password)
|
||||
void Preferences::setUILockPassword(const QString &clearPassword)
|
||||
{
|
||||
QCryptographicHash md5(QCryptographicHash::Md5);
|
||||
md5.addData(clear_password.toLocal8Bit());
|
||||
QString md5_password = md5.result().toHex();
|
||||
setValue("Locking/password", md5_password);
|
||||
md5.addData(clearPassword.toLocal8Bit());
|
||||
QString md5Password = md5.result().toHex();
|
||||
setValue("Locking/password", md5Password);
|
||||
}
|
||||
|
||||
bool Preferences::isUILocked() const
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Copyright (C) 2006 Christophe Dumez
|
||||
* Copyright (C) 2014 sledgehammer999
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2014 sledgehammer999 <sledgehammer999@qbittorrent.org>
|
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -25,9 +25,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
* Contact : hammered999@gmail.com
|
||||
*/
|
||||
|
||||
#ifndef PREFERENCES_H
|
||||
@ -47,7 +44,7 @@
|
||||
#include "base/utils/net.h"
|
||||
#include "types.h"
|
||||
|
||||
enum scheduler_days
|
||||
enum SchedulerDays
|
||||
{
|
||||
EVERY_DAY,
|
||||
WEEK_DAYS,
|
||||
@ -83,7 +80,7 @@ namespace DNS
|
||||
|
||||
class SettingsStorage;
|
||||
|
||||
class Preferences: public QObject
|
||||
class Preferences : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(Preferences)
|
||||
@ -166,8 +163,8 @@ public:
|
||||
void setSchedulerStartTime(const QTime &time);
|
||||
QTime getSchedulerEndTime() const;
|
||||
void setSchedulerEndTime(const QTime &time);
|
||||
scheduler_days getSchedulerDays() const;
|
||||
void setSchedulerDays(scheduler_days days);
|
||||
SchedulerDays getSchedulerDays() const;
|
||||
void setSchedulerDays(SchedulerDays days);
|
||||
|
||||
// Search
|
||||
bool isSearchEnabled() const;
|
||||
@ -222,7 +219,7 @@ public:
|
||||
void setDynDNSPassword(const QString &password);
|
||||
|
||||
// Advanced settings
|
||||
void setUILockPassword(const QString &clear_password);
|
||||
void setUILockPassword(const QString &clearPassword);
|
||||
void clearUILockPassword();
|
||||
QString getUILockPasswordMD5() const;
|
||||
bool isUILocked() const;
|
||||
|
@ -25,7 +25,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef QBT_PROFILE_P_H
|
||||
@ -33,6 +32,7 @@
|
||||
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include "base/profile.h"
|
||||
|
||||
namespace Private
|
||||
@ -63,7 +63,7 @@ namespace Private
|
||||
};
|
||||
|
||||
/// Default implementation. Takes paths from system
|
||||
class DefaultProfile: public Profile
|
||||
class DefaultProfile : public Profile
|
||||
{
|
||||
public:
|
||||
DefaultProfile(const QString &configurationName);
|
||||
@ -86,7 +86,7 @@ namespace Private
|
||||
};
|
||||
|
||||
/// Custom tree: creates directories under the specified root directory
|
||||
class CustomProfile: public Profile
|
||||
class CustomProfile : public Profile
|
||||
{
|
||||
public:
|
||||
CustomProfile(const QString &rootPath, const QString &configurationName);
|
||||
@ -114,14 +114,14 @@ namespace Private
|
||||
virtual ~PathConverter() = default;
|
||||
};
|
||||
|
||||
class NoConvertConverter: public PathConverter
|
||||
class NoConvertConverter : public PathConverter
|
||||
{
|
||||
public:
|
||||
QString toPortablePath(const QString &path) const override;
|
||||
QString fromPortablePath(const QString &portablePath) const override;
|
||||
};
|
||||
|
||||
class Converter: public PathConverter
|
||||
class Converter : public PathConverter
|
||||
{
|
||||
public:
|
||||
Converter(const QString &basePath);
|
||||
@ -132,4 +132,5 @@ namespace Private
|
||||
QDir m_baseDir;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // QBT_PROFILE_P_H
|
||||
|
@ -25,7 +25,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "profile.h"
|
||||
|
@ -33,9 +33,9 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QString>
|
||||
#include <QScopedPointer>
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
|
||||
class Application;
|
||||
|
||||
|
@ -29,8 +29,8 @@
|
||||
|
||||
#include "rss_parser.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QGlobalStatic>
|
||||
#include <QHash>
|
||||
#include <QMetaObject>
|
||||
|
@ -48,7 +48,7 @@ namespace RSS
|
||||
QList<QVariantHash> articles;
|
||||
};
|
||||
|
||||
class Parser: public QObject
|
||||
class Parser : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace RSS
|
||||
{
|
||||
class Feed;
|
||||
|
||||
class Article: public QObject
|
||||
class Article : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(Article)
|
||||
|
@ -59,7 +59,7 @@ namespace RSS
|
||||
QString message() const;
|
||||
};
|
||||
|
||||
class AutoDownloader final: public QObject
|
||||
class AutoDownloader final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(AutoDownloader)
|
||||
|
@ -43,9 +43,9 @@
|
||||
#include "../tristatebool.h"
|
||||
#include "../utils/fs.h"
|
||||
#include "../utils/string.h"
|
||||
#include "rss_feed.h"
|
||||
#include "rss_article.h"
|
||||
#include "rss_autodownloader.h"
|
||||
#include "rss_feed.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -105,7 +105,7 @@ const QString Str_PreviouslyMatched(QStringLiteral("previouslyMatchedEpisodes"))
|
||||
|
||||
namespace RSS
|
||||
{
|
||||
struct AutoDownloadRuleData: public QSharedData
|
||||
struct AutoDownloadRuleData : public QSharedData
|
||||
{
|
||||
QString name;
|
||||
bool enabled = true;
|
||||
|
@ -49,7 +49,7 @@ namespace RSS
|
||||
struct ParsingResult;
|
||||
}
|
||||
|
||||
class Feed final: public Item
|
||||
class Feed final : public Item
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(Feed)
|
||||
|
@ -37,7 +37,7 @@ namespace RSS
|
||||
{
|
||||
class Session;
|
||||
|
||||
class Folder final: public Item
|
||||
class Folder final : public Item
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(Folder)
|
||||
|
@ -39,7 +39,7 @@ namespace RSS
|
||||
class Folder;
|
||||
class Session;
|
||||
|
||||
class Item: public QObject
|
||||
class Item : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(Item)
|
||||
|
@ -47,8 +47,8 @@
|
||||
#include "../utils/fs.h"
|
||||
#include "rss_article.h"
|
||||
#include "rss_feed.h"
|
||||
#include "rss_item.h"
|
||||
#include "rss_folder.h"
|
||||
#include "rss_item.h"
|
||||
|
||||
const int MsecsPerMin = 60000;
|
||||
const QString ConfFolderName(QStringLiteral("rss"));
|
||||
|
@ -69,11 +69,11 @@ class AsyncFileStorage;
|
||||
|
||||
namespace RSS
|
||||
{
|
||||
class Item;
|
||||
class Feed;
|
||||
class Folder;
|
||||
class Item;
|
||||
|
||||
class Session: public QObject
|
||||
class Session : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(Session)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2010 Christian Kandeler, Christophe Dumez
|
||||
* Copyright (C) 2010 Christian Kandeler, Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -24,8 +24,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#include "scanfoldersmodel.h"
|
||||
@ -235,7 +233,7 @@ ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath,
|
||||
return Ok;
|
||||
}
|
||||
|
||||
ScanFoldersModel::PathStatus ScanFoldersModel::updatePath(const QString &watchPath, const PathType& downloadType, const QString &downloadPath)
|
||||
ScanFoldersModel::PathStatus ScanFoldersModel::updatePath(const QString &watchPath, const PathType &downloadType, const QString &downloadPath)
|
||||
{
|
||||
QDir watchDir(watchPath);
|
||||
const QString &canonicalWatchPath = watchDir.canonicalPath();
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2010 Christian Kandeler, Christophe Dumez
|
||||
* Copyright (C) 2010 Christian Kandeler, Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -24,8 +24,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#ifndef SCANFOLDERSMODEL_H
|
||||
@ -37,7 +35,7 @@
|
||||
class QStringList;
|
||||
class FileSystemWatcher;
|
||||
|
||||
class ScanFoldersModel: public QAbstractListModel
|
||||
class ScanFoldersModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(ScanFoldersModel)
|
||||
@ -68,7 +66,7 @@ public:
|
||||
|
||||
static bool initInstance(QObject *parent = nullptr);
|
||||
static void freeInstance();
|
||||
static ScanFoldersModel* instance();
|
||||
static ScanFoldersModel *instance();
|
||||
|
||||
static QString pathTypeDisplayName(const PathType type);
|
||||
|
||||
|
@ -42,8 +42,8 @@
|
||||
|
||||
#include "base/global.h"
|
||||
#include "base/logger.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/net/downloadhandler.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/preferences.h"
|
||||
#include "base/profile.h"
|
||||
#include "base/utils/fs.h"
|
||||
@ -256,7 +256,7 @@ bool SearchPluginManager::uninstallPlugin(const QString &name)
|
||||
return true;
|
||||
}
|
||||
|
||||
void SearchPluginManager::updateIconPath(PluginInfo * const plugin)
|
||||
void SearchPluginManager::updateIconPath(PluginInfo *const plugin)
|
||||
{
|
||||
if (!plugin) return;
|
||||
QString iconPath = QString("%1/%2.png").arg(pluginsLocation(), plugin->name);
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
void updatePlugin(const QString &name);
|
||||
void installPlugin(const QString &source);
|
||||
bool uninstallPlugin(const QString &name);
|
||||
static void updateIconPath(PluginInfo * const plugin);
|
||||
static void updateIconPath(PluginInfo *const plugin);
|
||||
void checkForUpdates();
|
||||
|
||||
SearchHandler *startSearch(const QString &pattern, const QString &category, const QStringList &usedPlugins);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2016 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2014 sledgehammer999 <hammered999@gmail.com>
|
||||
* Copyright (C) 2014 sledgehammer999 <sledgehammer999@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -258,7 +258,7 @@ QVariantHash TransactionalSettings::read()
|
||||
|
||||
bool TransactionalSettings::write(const QVariantHash &data)
|
||||
{
|
||||
// QSettings delete the file before writing it out. This can result in problems
|
||||
// QSettings deletes the file before writing it out. This can result in problems
|
||||
// if the disk is full or a power outage occurs. Those events might occur
|
||||
// between deleting the file and recreating it. This is a safety measure.
|
||||
// Write everything to qBittorrent_new.ini/qBittorrent_new.conf and if it succeeds
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2016 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2014 sledgehammer999 <hammered999@gmail.com>
|
||||
* Copyright (C) 2014 sledgehammer999 <sledgehammer999@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -31,11 +31,11 @@
|
||||
#define SETTINGSSTORAGE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariantHash>
|
||||
#include <QTimer>
|
||||
#include <QReadWriteLock>
|
||||
#include <QTimer>
|
||||
#include <QVariantHash>
|
||||
|
||||
class SettingsStorage: public QObject
|
||||
class SettingsStorage : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
SettingsStorage();
|
||||
@ -44,7 +44,7 @@ class SettingsStorage: public QObject
|
||||
public:
|
||||
static void initInstance();
|
||||
static void freeInstance();
|
||||
static SettingsStorage* instance();
|
||||
static SettingsStorage *instance();
|
||||
|
||||
QVariant loadValue(const QString &key, const QVariant &defaultValue = QVariant()) const;
|
||||
void storeValue(const QString &key, const QVariant &value);
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
|
||||
#include <QMetaEnum>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
@ -51,7 +51,7 @@ private:
|
||||
|
||||
/// Reads settings for .torrent files from preferences
|
||||
/// and sets the file guard up accordingly
|
||||
class TorrentFileGuard: private FileGuard
|
||||
class TorrentFileGuard : private FileGuard
|
||||
{
|
||||
Q_GADGET
|
||||
|
||||
|
@ -29,8 +29,8 @@
|
||||
#ifndef TORRENTFILTER_H
|
||||
#define TORRENTFILTER_H
|
||||
|
||||
#include <QString>
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
|
||||
typedef QSet<QString> QStringSet;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2012 Christophe Dumez
|
||||
* Copyright (C) 2012 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -24,20 +24,18 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#include "fs.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDirIterator>
|
||||
#include <QCoreApplication>
|
||||
#include <QStorageInfo>
|
||||
|
||||
#include <sys/stat.h>
|
||||
@ -152,7 +150,7 @@ bool Utils::Fs::smartRemoveEmptyFolderTree(const QString &path)
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the file with the given file_path.
|
||||
* Removes the file with the given filePath.
|
||||
*
|
||||
* This function will try to fix the file permissions before removing it.
|
||||
*/
|
||||
@ -169,7 +167,6 @@ bool Utils::Fs::forceRemove(const QString &filePath)
|
||||
|
||||
/**
|
||||
* Removes directory and its content recursively.
|
||||
*
|
||||
*/
|
||||
void Utils::Fs::removeDirRecursive(const QString &path)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2012 Christophe Dumez
|
||||
* Copyright (C) 2012 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -24,8 +24,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#ifndef UTILS_FS_H
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2006 Christophe Dumez
|
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -24,8 +24,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#include "misc.h"
|
||||
@ -70,9 +68,9 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "base/utils/string.h"
|
||||
#include "base/unicodestrings.h"
|
||||
#include "base/logger.h"
|
||||
#include "base/unicodestrings.h"
|
||||
#include "base/utils/string.h"
|
||||
#include "fs.h"
|
||||
|
||||
namespace
|
||||
@ -141,7 +139,7 @@ void Utils::Misc::shutdownComputer(const ShutdownDialogAction &action)
|
||||
else
|
||||
EventToSend = kAEShutDown;
|
||||
AEAddressDesc targetDesc;
|
||||
static const ProcessSerialNumber kPSNOfSystemProcess = { 0, kSystemProcess };
|
||||
static const ProcessSerialNumber kPSNOfSystemProcess = {0, kSystemProcess};
|
||||
AppleEvent eventReply = {typeNull, NULL};
|
||||
AppleEvent appleEventToSend = {typeNull, NULL};
|
||||
|
||||
@ -525,9 +523,9 @@ bool Utils::Misc::isUrl(const QString &s)
|
||||
return reURLScheme.match(QUrl(s).scheme()).hasMatch();
|
||||
}
|
||||
|
||||
QString Utils::Misc::parseHtmlLinks(const QString &raw_text)
|
||||
QString Utils::Misc::parseHtmlLinks(const QString &rawText)
|
||||
{
|
||||
QString result = raw_text;
|
||||
QString result = rawText;
|
||||
static QRegExp reURL(
|
||||
"(\\s|^)" // start with whitespace or beginning of line
|
||||
"("
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2006 Christophe Dumez
|
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -24,8 +24,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#ifndef UTILS_MISC_H
|
||||
@ -73,7 +71,7 @@ namespace Utils
|
||||
// YobiByte, // 1024^8
|
||||
};
|
||||
|
||||
QString parseHtmlLinks(const QString &raw_text);
|
||||
QString parseHtmlLinks(const QString &rawText);
|
||||
bool isUrl(const QString &s);
|
||||
|
||||
void shutdownComputer(const ShutdownDialogAction &action);
|
||||
@ -88,16 +86,16 @@ namespace Utils
|
||||
|
||||
QString unitString(SizeUnit unit);
|
||||
|
||||
// return best user friendly storage unit (B, KiB, MiB, GiB, TiB)
|
||||
// return the best user friendly storage unit (B, KiB, MiB, GiB, TiB)
|
||||
// value must be given in bytes
|
||||
bool friendlyUnit(qint64 sizeInBytes, qreal& val, SizeUnit& unit);
|
||||
bool friendlyUnit(qint64 sizeInBytes, qreal &val, SizeUnit &unit);
|
||||
QString friendlyUnit(qint64 bytesValue, bool isSpeed = false);
|
||||
int friendlyUnitPrecision(SizeUnit unit);
|
||||
qint64 sizeInBytes(qreal size, SizeUnit unit);
|
||||
|
||||
bool isPreviewable(const QString& extension);
|
||||
bool isPreviewable(const QString &extension);
|
||||
|
||||
// Take a number of seconds and return an user-friendly
|
||||
// Take a number of seconds and return a user-friendly
|
||||
// time duration like "1d 2h 10m".
|
||||
QString userFriendlyDuration(qlonglong seconds);
|
||||
QString getUserIDString();
|
||||
@ -108,8 +106,8 @@ namespace Utils
|
||||
QList<bool> boolListfromStringList(const QStringList &l);
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
void openPath(const QString& absolutePath);
|
||||
void openFolderSelect(const QString& absolutePath);
|
||||
void openPath(const QString &absolutePath);
|
||||
void openFolderSelect(const QString &absolutePath);
|
||||
|
||||
QPoint screenCenter(const QWidget *w);
|
||||
#endif
|
||||
@ -136,4 +134,4 @@ namespace Utils
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // UTILS_MISC_H
|
||||
|
@ -27,6 +27,7 @@
|
||||
*/
|
||||
|
||||
#include "net.h"
|
||||
|
||||
#include <QHostAddress>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
@ -24,7 +24,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "random.h"
|
||||
|
@ -24,7 +24,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef UTILS_RANDOM_H
|
||||
|
@ -117,7 +117,7 @@ namespace Utils
|
||||
{
|
||||
// find the last one non-zero component
|
||||
std::size_t lastSignificantIndex = N - 1;
|
||||
while (lastSignificantIndex > 0 && (*this)[lastSignificantIndex] == 0)
|
||||
while ((lastSignificantIndex > 0) && ((*this)[lastSignificantIndex] == 0))
|
||||
--lastSignificantIndex;
|
||||
|
||||
if (lastSignificantIndex + 1 < Mandatory) // lastSignificantIndex >= 0
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2012 Christophe Dumez
|
||||
* Copyright (C) 2012 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -24,8 +24,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#include "addnewtorrentdialog.h"
|
||||
@ -38,7 +36,6 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "autoexpandabledialog.h"
|
||||
#include "base/bittorrent/magneturi.h"
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/bittorrent/torrenthandle.h"
|
||||
@ -53,6 +50,7 @@
|
||||
#include "base/utils/fs.h"
|
||||
#include "base/utils/misc.h"
|
||||
#include "base/utils/string.h"
|
||||
#include "autoexpandabledialog.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "messageboxraised.h"
|
||||
#include "proplistdelegate.h"
|
||||
@ -85,7 +83,7 @@ constexpr int AddNewTorrentDialog::maxPathHistoryLength;
|
||||
|
||||
AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inParams, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::AddNewTorrentDialog)
|
||||
, m_ui(new Ui::AddNewTorrentDialog)
|
||||
, m_contentModel(nullptr)
|
||||
, m_contentDelegate(nullptr)
|
||||
, m_hasMetadata(false)
|
||||
@ -93,40 +91,40 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
|
||||
, m_torrentParams(inParams)
|
||||
{
|
||||
// TODO: set dialog file properties using m_torrentParams.filePriorities
|
||||
ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
ui->lblMetaLoading->setVisible(false);
|
||||
ui->progMetaLoading->setVisible(false);
|
||||
m_ui->lblMetaLoading->setVisible(false);
|
||||
m_ui->progMetaLoading->setVisible(false);
|
||||
|
||||
ui->savePath->setMode(FileSystemPathEdit::Mode::DirectorySave);
|
||||
ui->savePath->setDialogCaption(tr("Choose save path"));
|
||||
ui->savePath->setMaxVisibleItems(20);
|
||||
m_ui->savePath->setMode(FileSystemPathEdit::Mode::DirectorySave);
|
||||
m_ui->savePath->setDialogCaption(tr("Choose save path"));
|
||||
m_ui->savePath->setMaxVisibleItems(20);
|
||||
|
||||
auto session = BitTorrent::Session::instance();
|
||||
|
||||
if (m_torrentParams.addPaused == TriStateBool::True)
|
||||
ui->startTorrentCheckBox->setChecked(false);
|
||||
m_ui->startTorrentCheckBox->setChecked(false);
|
||||
else if (m_torrentParams.addPaused == TriStateBool::False)
|
||||
ui->startTorrentCheckBox->setChecked(true);
|
||||
m_ui->startTorrentCheckBox->setChecked(true);
|
||||
else
|
||||
ui->startTorrentCheckBox->setChecked(!session->isAddTorrentPaused());
|
||||
m_ui->startTorrentCheckBox->setChecked(!session->isAddTorrentPaused());
|
||||
|
||||
ui->comboTTM->blockSignals(true); // the TreeView size isn't correct if the slot does it job at this point
|
||||
ui->comboTTM->setCurrentIndex(!session->isAutoTMMDisabledByDefault());
|
||||
ui->comboTTM->blockSignals(false);
|
||||
m_ui->comboTTM->blockSignals(true); // the TreeView size isn't correct if the slot does it job at this point
|
||||
m_ui->comboTTM->setCurrentIndex(!session->isAutoTMMDisabledByDefault());
|
||||
m_ui->comboTTM->blockSignals(false);
|
||||
populateSavePathComboBox();
|
||||
connect(ui->savePath, &FileSystemPathEdit::selectedPathChanged, this, &AddNewTorrentDialog::onSavePathChanged);
|
||||
ui->defaultSavePathCheckBox->setVisible(false); // Default path is selected by default
|
||||
connect(m_ui->savePath, &FileSystemPathEdit::selectedPathChanged, this, &AddNewTorrentDialog::onSavePathChanged);
|
||||
m_ui->defaultSavePathCheckBox->setVisible(false); // Default path is selected by default
|
||||
|
||||
if (m_torrentParams.createSubfolder == TriStateBool::True)
|
||||
ui->createSubfolderCheckBox->setChecked(true);
|
||||
m_ui->createSubfolderCheckBox->setChecked(true);
|
||||
else if (m_torrentParams.createSubfolder == TriStateBool::False)
|
||||
ui->createSubfolderCheckBox->setChecked(false);
|
||||
m_ui->createSubfolderCheckBox->setChecked(false);
|
||||
else
|
||||
ui->createSubfolderCheckBox->setChecked(session->isCreateTorrentSubfolder());
|
||||
m_ui->createSubfolderCheckBox->setChecked(session->isCreateTorrentSubfolder());
|
||||
|
||||
ui->skipCheckingCheckBox->setChecked(m_torrentParams.skipChecking);
|
||||
ui->doNotDeleteTorrentCheckBox->setVisible(TorrentFileGuard::autoDeleteMode() != TorrentFileGuard::Never);
|
||||
m_ui->skipCheckingCheckBox->setChecked(m_torrentParams.skipChecking);
|
||||
m_ui->doNotDeleteTorrentCheckBox->setVisible(TorrentFileGuard::autoDeleteMode() != TorrentFileGuard::Never);
|
||||
|
||||
// Load categories
|
||||
QStringList categories = session->categories().keys();
|
||||
@ -134,25 +132,25 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
|
||||
QString defaultCategory = settings()->loadValue(KEY_DEFAULTCATEGORY).toString();
|
||||
|
||||
if (!m_torrentParams.category.isEmpty())
|
||||
ui->categoryComboBox->addItem(m_torrentParams.category);
|
||||
m_ui->categoryComboBox->addItem(m_torrentParams.category);
|
||||
if (!defaultCategory.isEmpty())
|
||||
ui->categoryComboBox->addItem(defaultCategory);
|
||||
ui->categoryComboBox->addItem("");
|
||||
m_ui->categoryComboBox->addItem(defaultCategory);
|
||||
m_ui->categoryComboBox->addItem("");
|
||||
|
||||
foreach (const QString &category, categories)
|
||||
if (category != defaultCategory && category != m_torrentParams.category)
|
||||
ui->categoryComboBox->addItem(category);
|
||||
m_ui->categoryComboBox->addItem(category);
|
||||
|
||||
ui->contentTreeView->header()->setSortIndicator(0, Qt::AscendingOrder);
|
||||
m_ui->contentTreeView->header()->setSortIndicator(0, Qt::AscendingOrder);
|
||||
loadState();
|
||||
// Signal / slots
|
||||
connect(ui->adv_button, &QToolButton::clicked, this, &AddNewTorrentDialog::showAdvancedSettings);
|
||||
connect(ui->doNotDeleteTorrentCheckBox, &QCheckBox::clicked, this, &AddNewTorrentDialog::doNotDeleteTorrentClicked);
|
||||
QShortcut *editHotkey = new QShortcut(Qt::Key_F2, ui->contentTreeView, nullptr, nullptr, Qt::WidgetShortcut);
|
||||
connect(m_ui->adv_button, &QToolButton::clicked, this, &AddNewTorrentDialog::showAdvancedSettings);
|
||||
connect(m_ui->doNotDeleteTorrentCheckBox, &QCheckBox::clicked, this, &AddNewTorrentDialog::doNotDeleteTorrentClicked);
|
||||
QShortcut *editHotkey = new QShortcut(Qt::Key_F2, m_ui->contentTreeView, nullptr, nullptr, Qt::WidgetShortcut);
|
||||
connect(editHotkey, &QShortcut::activated, this, &AddNewTorrentDialog::renameSelectedFile);
|
||||
connect(ui->contentTreeView, &QAbstractItemView::doubleClicked, this, &AddNewTorrentDialog::renameSelectedFile);
|
||||
connect(m_ui->contentTreeView, &QAbstractItemView::doubleClicked, this, &AddNewTorrentDialog::renameSelectedFile);
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setFocus();
|
||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setFocus();
|
||||
}
|
||||
|
||||
AddNewTorrentDialog::~AddNewTorrentDialog()
|
||||
@ -160,7 +158,7 @@ AddNewTorrentDialog::~AddNewTorrentDialog()
|
||||
saveState();
|
||||
|
||||
delete m_contentDelegate;
|
||||
delete ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool AddNewTorrentDialog::isEnabled()
|
||||
@ -220,15 +218,15 @@ void AddNewTorrentDialog::loadState()
|
||||
const int height = newSize.height();
|
||||
resize(width, height);
|
||||
|
||||
ui->adv_button->setChecked(settings()->loadValue(KEY_EXPANDED).toBool());
|
||||
m_ui->adv_button->setChecked(settings()->loadValue(KEY_EXPANDED).toBool());
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::saveState()
|
||||
{
|
||||
if (m_contentModel)
|
||||
settings()->storeValue(KEY_TREEHEADERSTATE, ui->contentTreeView->header()->saveState());
|
||||
settings()->storeValue(KEY_TREEHEADERSTATE, m_ui->contentTreeView->header()->saveState());
|
||||
settings()->storeValue(KEY_WIDTH, width());
|
||||
settings()->storeValue(KEY_EXPANDED, ui->adv_button->isChecked());
|
||||
settings()->storeValue(KEY_EXPANDED, m_ui->adv_button->isChecked());
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::show(QString source, const BitTorrent::AddTorrentParams &inParams, QWidget *parent)
|
||||
@ -316,9 +314,9 @@ bool AddNewTorrentDialog::loadTorrent(const QString &torrentPath)
|
||||
return false;
|
||||
}
|
||||
|
||||
ui->lblhash->setText(m_hash);
|
||||
m_ui->lblhash->setText(m_hash);
|
||||
setupTreeview();
|
||||
TMMChanged(ui->comboTTM->currentIndex());
|
||||
TMMChanged(m_ui->comboTTM->currentIndex());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -353,15 +351,15 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
|
||||
connect(BitTorrent::Session::instance(), &BitTorrent::Session::metadataLoaded, this, &AddNewTorrentDialog::updateMetadata);
|
||||
|
||||
// Set dialog title
|
||||
QString torrent_name = magnetUri.name();
|
||||
setWindowTitle(torrent_name.isEmpty() ? tr("Magnet link") : torrent_name);
|
||||
QString torrentName = magnetUri.name();
|
||||
setWindowTitle(torrentName.isEmpty() ? tr("Magnet link") : torrentName);
|
||||
|
||||
setupTreeview();
|
||||
TMMChanged(ui->comboTTM->currentIndex());
|
||||
TMMChanged(m_ui->comboTTM->currentIndex());
|
||||
|
||||
BitTorrent::Session::instance()->loadMetadata(magnetUri);
|
||||
setMetadataProgressIndicator(true, tr("Retrieving metadata..."));
|
||||
ui->lblhash->setText(m_hash);
|
||||
m_ui->lblhash->setText(m_hash);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -378,19 +376,19 @@ void AddNewTorrentDialog::showEvent(QShowEvent *event)
|
||||
void AddNewTorrentDialog::showAdvancedSettings(bool show)
|
||||
{
|
||||
const int minimumW = minimumWidth();
|
||||
setMinimumWidth(width()); // to remain the same width
|
||||
setMinimumWidth(width()); // to remain the same width
|
||||
if (show) {
|
||||
ui->adv_button->setText(QString::fromUtf8(C_UP));
|
||||
ui->settings_group->setVisible(true);
|
||||
ui->infoGroup->setVisible(true);
|
||||
ui->contentTreeView->setVisible(m_hasMetadata);
|
||||
static_cast<QVBoxLayout *>(layout())->insertWidget(layout()->indexOf(ui->never_show_cb) + 1, ui->adv_button);
|
||||
m_ui->adv_button->setText(QString::fromUtf8(C_UP));
|
||||
m_ui->settings_group->setVisible(true);
|
||||
m_ui->infoGroup->setVisible(true);
|
||||
m_ui->contentTreeView->setVisible(m_hasMetadata);
|
||||
static_cast<QVBoxLayout *>(layout())->insertWidget(layout()->indexOf(m_ui->never_show_cb) + 1, m_ui->adv_button);
|
||||
}
|
||||
else {
|
||||
ui->adv_button->setText(QString::fromUtf8(C_DOWN));
|
||||
ui->settings_group->setVisible(false);
|
||||
ui->infoGroup->setVisible(false);
|
||||
ui->buttonsHLayout->insertWidget(0, layout()->takeAt(layout()->indexOf(ui->never_show_cb) + 1)->widget());
|
||||
m_ui->adv_button->setText(QString::fromUtf8(C_DOWN));
|
||||
m_ui->settings_group->setVisible(false);
|
||||
m_ui->infoGroup->setVisible(false);
|
||||
m_ui->buttonsHLayout->insertWidget(0, layout()->takeAt(layout()->indexOf(m_ui->never_show_cb) + 1)->widget());
|
||||
}
|
||||
adjustSize();
|
||||
setMinimumWidth(minimumW);
|
||||
@ -398,7 +396,7 @@ void AddNewTorrentDialog::showAdvancedSettings(bool show)
|
||||
|
||||
void AddNewTorrentDialog::saveSavePathHistory() const
|
||||
{
|
||||
QDir selectedSavePath(ui->savePath->selectedPath());
|
||||
QDir selectedSavePath(m_ui->savePath->selectedPath());
|
||||
// Get current history
|
||||
QStringList history = settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList();
|
||||
if (history.size() > savePathHistoryLength())
|
||||
@ -417,12 +415,12 @@ void AddNewTorrentDialog::saveSavePathHistory() const
|
||||
}
|
||||
}
|
||||
|
||||
// save_path is a folder, not an absolute file path
|
||||
int AddNewTorrentDialog::indexOfSavePath(const QString &save_path)
|
||||
// savePath is a folder, not an absolute file path
|
||||
int AddNewTorrentDialog::indexOfSavePath(const QString &savePath)
|
||||
{
|
||||
QDir saveDir(save_path);
|
||||
for (int i = 0; i < ui->savePath->count(); ++i)
|
||||
if (QDir(ui->savePath->item(i)) == saveDir)
|
||||
QDir saveDir(savePath);
|
||||
for (int i = 0; i < m_ui->savePath->count(); ++i)
|
||||
if (QDir(m_ui->savePath->item(i)) == saveDir)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
@ -430,7 +428,7 @@ int AddNewTorrentDialog::indexOfSavePath(const QString &save_path)
|
||||
void AddNewTorrentDialog::updateDiskSpaceLabel()
|
||||
{
|
||||
// Determine torrent size
|
||||
qulonglong torrent_size = 0;
|
||||
qulonglong torrentSize = 0;
|
||||
|
||||
if (m_hasMetadata) {
|
||||
if (m_contentModel) {
|
||||
@ -438,28 +436,28 @@ void AddNewTorrentDialog::updateDiskSpaceLabel()
|
||||
Q_ASSERT(priorities.size() == m_torrentInfo.filesCount());
|
||||
for (int i = 0; i < priorities.size(); ++i)
|
||||
if (priorities[i] > 0)
|
||||
torrent_size += m_torrentInfo.fileSize(i);
|
||||
torrentSize += m_torrentInfo.fileSize(i);
|
||||
}
|
||||
else {
|
||||
torrent_size = m_torrentInfo.totalSize();
|
||||
torrentSize = m_torrentInfo.totalSize();
|
||||
}
|
||||
}
|
||||
|
||||
QString size_string = torrent_size ? Utils::Misc::friendlyUnit(torrent_size) : QString(tr("Not Available", "This size is unavailable."));
|
||||
size_string += " (";
|
||||
size_string += tr("Free space on disk: %1").arg(Utils::Misc::friendlyUnit(Utils::Fs::freeDiskSpaceOnPath(
|
||||
ui->savePath->selectedPath())));
|
||||
size_string += ")";
|
||||
ui->size_lbl->setText(size_string);
|
||||
QString sizeString = torrentSize ? Utils::Misc::friendlyUnit(torrentSize) : QString(tr("Not Available", "This size is unavailable."));
|
||||
sizeString += " (";
|
||||
sizeString += tr("Free space on disk: %1").arg(Utils::Misc::friendlyUnit(Utils::Fs::freeDiskSpaceOnPath(
|
||||
m_ui->savePath->selectedPath())));
|
||||
sizeString += ")";
|
||||
m_ui->size_lbl->setText(sizeString);
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::onSavePathChanged(const QString &newPath)
|
||||
{
|
||||
// Toggle default save path setting checkbox visibility
|
||||
ui->defaultSavePathCheckBox->setChecked(false);
|
||||
ui->defaultSavePathCheckBox->setVisible(QDir(newPath) != QDir(BitTorrent::Session::instance()->defaultSavePath()));
|
||||
m_ui->defaultSavePathCheckBox->setChecked(false);
|
||||
m_ui->defaultSavePathCheckBox->setVisible(QDir(newPath) != QDir(BitTorrent::Session::instance()->defaultSavePath()));
|
||||
// Remember index
|
||||
m_oldIndex = ui->savePath->currentIndex();
|
||||
m_oldIndex = m_ui->savePath->currentIndex();
|
||||
updateDiskSpaceLabel();
|
||||
}
|
||||
|
||||
@ -467,9 +465,9 @@ void AddNewTorrentDialog::categoryChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
|
||||
if (ui->comboTTM->currentIndex() == 1) {
|
||||
QString savePath = BitTorrent::Session::instance()->categorySavePath(ui->categoryComboBox->currentText());
|
||||
ui->savePath->setSelectedPath(Utils::Fs::toNativePath(savePath));
|
||||
if (m_ui->comboTTM->currentIndex() == 1) {
|
||||
QString savePath = BitTorrent::Session::instance()->categorySavePath(m_ui->categoryComboBox->currentText());
|
||||
m_ui->savePath->setSelectedPath(Utils::Fs::toNativePath(savePath));
|
||||
}
|
||||
}
|
||||
|
||||
@ -478,16 +476,16 @@ void AddNewTorrentDialog::setSavePath(const QString &newPath)
|
||||
int existingIndex = indexOfSavePath(newPath);
|
||||
if (existingIndex < 0) {
|
||||
// New path, prepend to combo box
|
||||
ui->savePath->insertItem(0, newPath);
|
||||
m_ui->savePath->insertItem(0, newPath);
|
||||
existingIndex = 0;
|
||||
}
|
||||
ui->savePath->setCurrentIndex(existingIndex);
|
||||
m_ui->savePath->setCurrentIndex(existingIndex);
|
||||
onSavePathChanged(newPath);
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::renameSelectedFile()
|
||||
{
|
||||
const QModelIndexList selectedIndexes = ui->contentTreeView->selectionModel()->selectedRows(0);
|
||||
const QModelIndexList selectedIndexes = m_ui->contentTreeView->selectionModel()->selectedRows(0);
|
||||
if (selectedIndexes.size() != 1) return;
|
||||
|
||||
const QModelIndex modelIndex = selectedIndexes.first();
|
||||
@ -590,13 +588,13 @@ void AddNewTorrentDialog::populateSavePathComboBox()
|
||||
{
|
||||
QString defSavePath = BitTorrent::Session::instance()->defaultSavePath();
|
||||
|
||||
ui->savePath->clear();
|
||||
ui->savePath->addItem(defSavePath);
|
||||
m_ui->savePath->clear();
|
||||
m_ui->savePath->addItem(defSavePath);
|
||||
QDir defaultSaveDir(defSavePath);
|
||||
// Load save path history
|
||||
foreach (const QString &savePath, settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList())
|
||||
if (QDir(savePath) != defaultSaveDir)
|
||||
ui->savePath->addItem(savePath);
|
||||
m_ui->savePath->addItem(savePath);
|
||||
|
||||
if (!m_torrentParams.savePath.isEmpty())
|
||||
setSavePath(m_torrentParams.savePath);
|
||||
@ -605,7 +603,7 @@ void AddNewTorrentDialog::populateSavePathComboBox()
|
||||
void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
|
||||
{
|
||||
QMenu myFilesLlistMenu;
|
||||
const QModelIndexList selectedRows = ui->contentTreeView->selectionModel()->selectedRows(0);
|
||||
const QModelIndexList selectedRows = m_ui->contentTreeView->selectionModel()->selectedRows(0);
|
||||
QAction *actRename = nullptr;
|
||||
if (selectedRows.size() == 1) {
|
||||
actRename = myFilesLlistMenu.addAction(GuiIconProvider::instance()->getIcon("edit-rename"), tr("Rename..."));
|
||||
@ -613,10 +611,10 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
|
||||
}
|
||||
QMenu subMenu;
|
||||
subMenu.setTitle(tr("Priority"));
|
||||
subMenu.addAction(ui->actionNot_downloaded);
|
||||
subMenu.addAction(ui->actionNormal);
|
||||
subMenu.addAction(ui->actionHigh);
|
||||
subMenu.addAction(ui->actionMaximum);
|
||||
subMenu.addAction(m_ui->actionNot_downloaded);
|
||||
subMenu.addAction(m_ui->actionNormal);
|
||||
subMenu.addAction(m_ui->actionHigh);
|
||||
subMenu.addAction(m_ui->actionMaximum);
|
||||
myFilesLlistMenu.addMenu(&subMenu);
|
||||
// Call menu
|
||||
QAction *act = myFilesLlistMenu.exec(QCursor::pos());
|
||||
@ -626,11 +624,11 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
|
||||
}
|
||||
else {
|
||||
int prio = prio::NORMAL;
|
||||
if (act == ui->actionHigh)
|
||||
if (act == m_ui->actionHigh)
|
||||
prio = prio::HIGH;
|
||||
else if (act == ui->actionMaximum)
|
||||
else if (act == m_ui->actionMaximum)
|
||||
prio = prio::MAXIMUM;
|
||||
else if (act == ui->actionNot_downloaded)
|
||||
else if (act == m_ui->actionNot_downloaded)
|
||||
prio = prio::IGNORED;
|
||||
|
||||
qDebug("Setting files priority");
|
||||
@ -648,34 +646,34 @@ void AddNewTorrentDialog::accept()
|
||||
disconnect(this, SLOT(updateMetadata(const BitTorrent::TorrentInfo&)));
|
||||
|
||||
// TODO: Check if destination actually exists
|
||||
m_torrentParams.skipChecking = ui->skipCheckingCheckBox->isChecked();
|
||||
m_torrentParams.skipChecking = m_ui->skipCheckingCheckBox->isChecked();
|
||||
|
||||
// Category
|
||||
m_torrentParams.category = ui->categoryComboBox->currentText();
|
||||
m_torrentParams.category = m_ui->categoryComboBox->currentText();
|
||||
|
||||
if (ui->defaultCategoryCheckbox->isChecked())
|
||||
if (m_ui->defaultCategoryCheckbox->isChecked())
|
||||
settings()->storeValue(KEY_DEFAULTCATEGORY, m_torrentParams.category);
|
||||
|
||||
// Save file priorities
|
||||
if (m_contentModel)
|
||||
m_torrentParams.filePriorities = m_contentModel->model()->getFilePriorities();
|
||||
|
||||
m_torrentParams.addPaused = TriStateBool(!ui->startTorrentCheckBox->isChecked());
|
||||
m_torrentParams.createSubfolder = TriStateBool(ui->createSubfolderCheckBox->isChecked());
|
||||
m_torrentParams.addPaused = TriStateBool(!m_ui->startTorrentCheckBox->isChecked());
|
||||
m_torrentParams.createSubfolder = TriStateBool(m_ui->createSubfolderCheckBox->isChecked());
|
||||
|
||||
QString savePath = ui->savePath->selectedPath();
|
||||
if (ui->comboTTM->currentIndex() != 1) { // 0 is Manual mode and 1 is Automatic mode. Handle all non 1 values as manual mode.
|
||||
QString savePath = m_ui->savePath->selectedPath();
|
||||
if (m_ui->comboTTM->currentIndex() != 1) { // 0 is Manual mode and 1 is Automatic mode. Handle all non 1 values as manual mode.
|
||||
m_torrentParams.useAutoTMM = TriStateBool::False;
|
||||
m_torrentParams.savePath = savePath;
|
||||
saveSavePathHistory();
|
||||
if (ui->defaultSavePathCheckBox->isChecked())
|
||||
if (m_ui->defaultSavePathCheckBox->isChecked())
|
||||
BitTorrent::Session::instance()->setDefaultSavePath(savePath);
|
||||
}
|
||||
else {
|
||||
m_torrentParams.useAutoTMM = TriStateBool::True;
|
||||
}
|
||||
|
||||
setEnabled(!ui->never_show_cb->isChecked());
|
||||
setEnabled(!m_ui->never_show_cb->isChecked());
|
||||
|
||||
// Add torrent
|
||||
if (!m_hasMetadata)
|
||||
@ -722,16 +720,16 @@ void AddNewTorrentDialog::updateMetadata(const BitTorrent::TorrentInfo &info)
|
||||
void AddNewTorrentDialog::setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText)
|
||||
{
|
||||
// Always show info label when waiting for metadata
|
||||
ui->lblMetaLoading->setVisible(true);
|
||||
ui->lblMetaLoading->setText(labelText);
|
||||
ui->progMetaLoading->setVisible(visibleIndicator);
|
||||
m_ui->lblMetaLoading->setVisible(true);
|
||||
m_ui->lblMetaLoading->setText(labelText);
|
||||
m_ui->progMetaLoading->setVisible(visibleIndicator);
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::setupTreeview()
|
||||
{
|
||||
if (!m_hasMetadata) {
|
||||
setCommentText(tr("Not Available", "This comment is unavailable"));
|
||||
ui->date_lbl->setText(tr("Not Available", "This date is unavailable"));
|
||||
m_ui->date_lbl->setText(tr("Not Available", "This date is unavailable"));
|
||||
}
|
||||
else {
|
||||
// Set dialog title
|
||||
@ -739,30 +737,30 @@ void AddNewTorrentDialog::setupTreeview()
|
||||
|
||||
// Set torrent information
|
||||
setCommentText(Utils::Misc::parseHtmlLinks(m_torrentInfo.comment()));
|
||||
ui->date_lbl->setText(!m_torrentInfo.creationDate().isNull() ? m_torrentInfo.creationDate().toString(Qt::DefaultLocaleShortDate) : tr("Not available"));
|
||||
m_ui->date_lbl->setText(!m_torrentInfo.creationDate().isNull() ? m_torrentInfo.creationDate().toString(Qt::DefaultLocaleShortDate) : tr("Not available"));
|
||||
|
||||
// Prepare content tree
|
||||
m_contentModel = new TorrentContentFilterModel(this);
|
||||
connect(m_contentModel->model(), &TorrentContentModel::filteredFilesChanged, this, &AddNewTorrentDialog::updateDiskSpaceLabel);
|
||||
ui->contentTreeView->setModel(m_contentModel);
|
||||
m_ui->contentTreeView->setModel(m_contentModel);
|
||||
m_contentDelegate = new PropListDelegate(nullptr);
|
||||
ui->contentTreeView->setItemDelegate(m_contentDelegate);
|
||||
connect(ui->contentTreeView, &QAbstractItemView::clicked, ui->contentTreeView
|
||||
m_ui->contentTreeView->setItemDelegate(m_contentDelegate);
|
||||
connect(m_ui->contentTreeView, &QAbstractItemView::clicked, m_ui->contentTreeView
|
||||
, static_cast<void (QAbstractItemView::*)(const QModelIndex &)>(&QAbstractItemView::edit));
|
||||
connect(ui->contentTreeView, &QWidget::customContextMenuRequested, this, &AddNewTorrentDialog::displayContentTreeMenu);
|
||||
connect(m_ui->contentTreeView, &QWidget::customContextMenuRequested, this, &AddNewTorrentDialog::displayContentTreeMenu);
|
||||
|
||||
// List files in torrent
|
||||
m_contentModel->model()->setupModelData(m_torrentInfo);
|
||||
if (!m_headerState.isEmpty())
|
||||
ui->contentTreeView->header()->restoreState(m_headerState);
|
||||
m_ui->contentTreeView->header()->restoreState(m_headerState);
|
||||
|
||||
// Hide useless columns after loading the header state
|
||||
ui->contentTreeView->hideColumn(PROGRESS);
|
||||
ui->contentTreeView->hideColumn(REMAINING);
|
||||
ui->contentTreeView->hideColumn(AVAILABILITY);
|
||||
m_ui->contentTreeView->hideColumn(PROGRESS);
|
||||
m_ui->contentTreeView->hideColumn(REMAINING);
|
||||
m_ui->contentTreeView->hideColumn(AVAILABILITY);
|
||||
|
||||
// Expand root folder
|
||||
ui->contentTreeView->setExpanded(m_contentModel->index(0, 0), true);
|
||||
m_ui->contentTreeView->setExpanded(m_contentModel->index(0, 0), true);
|
||||
}
|
||||
|
||||
updateDiskSpaceLabel();
|
||||
@ -798,33 +796,33 @@ void AddNewTorrentDialog::TMMChanged(int index)
|
||||
{
|
||||
if (index != 1) { // 0 is Manual mode and 1 is Automatic mode. Handle all non 1 values as manual mode.
|
||||
populateSavePathComboBox();
|
||||
ui->groupBoxSavePath->setEnabled(true);
|
||||
ui->savePath->blockSignals(false);
|
||||
ui->savePath->setCurrentIndex(m_oldIndex < ui->savePath->count() ? m_oldIndex : ui->savePath->count() - 1);
|
||||
ui->adv_button->setEnabled(true);
|
||||
m_ui->groupBoxSavePath->setEnabled(true);
|
||||
m_ui->savePath->blockSignals(false);
|
||||
m_ui->savePath->setCurrentIndex(m_oldIndex < m_ui->savePath->count() ? m_oldIndex : m_ui->savePath->count() - 1);
|
||||
m_ui->adv_button->setEnabled(true);
|
||||
}
|
||||
else {
|
||||
ui->groupBoxSavePath->setEnabled(false);
|
||||
ui->savePath->blockSignals(true);
|
||||
ui->savePath->clear();
|
||||
QString savePath = BitTorrent::Session::instance()->categorySavePath(ui->categoryComboBox->currentText());
|
||||
ui->savePath->addItem(savePath);
|
||||
ui->defaultSavePathCheckBox->setVisible(false);
|
||||
ui->adv_button->setChecked(true);
|
||||
ui->adv_button->setEnabled(false);
|
||||
m_ui->groupBoxSavePath->setEnabled(false);
|
||||
m_ui->savePath->blockSignals(true);
|
||||
m_ui->savePath->clear();
|
||||
QString savePath = BitTorrent::Session::instance()->categorySavePath(m_ui->categoryComboBox->currentText());
|
||||
m_ui->savePath->addItem(savePath);
|
||||
m_ui->defaultSavePathCheckBox->setVisible(false);
|
||||
m_ui->adv_button->setChecked(true);
|
||||
m_ui->adv_button->setEnabled(false);
|
||||
showAdvancedSettings(true);
|
||||
}
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::setCommentText(const QString &str) const
|
||||
{
|
||||
ui->commentLabel->setText(str);
|
||||
m_ui->commentLabel->setText(str);
|
||||
|
||||
// workaround for the additional space introduced by QScrollArea
|
||||
int lineHeight = ui->commentLabel->fontMetrics().lineSpacing();
|
||||
int lineHeight = m_ui->commentLabel->fontMetrics().lineSpacing();
|
||||
int lines = 1 + str.count("\n");
|
||||
int height = lineHeight * lines;
|
||||
ui->scrollArea->setMaximumHeight(height);
|
||||
m_ui->scrollArea->setMaximumHeight(height);
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::doNotDeleteTorrentClicked(bool checked)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Copyright (C) 2012 Christophe Dumez
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2012 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -24,8 +24,6 @@
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#ifndef ADDNEWTORRENTDIALOG_H
|
||||
@ -36,9 +34,9 @@
|
||||
#include <QShortcut>
|
||||
#include <QUrl>
|
||||
|
||||
#include "base/bittorrent/addtorrentparams.h"
|
||||
#include "base/bittorrent/infohash.h"
|
||||
#include "base/bittorrent/torrentinfo.h"
|
||||
#include "base/bittorrent/addtorrentparams.h"
|
||||
|
||||
namespace BitTorrent
|
||||
{
|
||||
@ -50,12 +48,12 @@ namespace Ui
|
||||
class AddNewTorrentDialog;
|
||||
}
|
||||
|
||||
class PropListDelegate;
|
||||
class TorrentContentFilterModel;
|
||||
class TorrentFileGuard;
|
||||
class PropListDelegate;
|
||||
template <typename T> class CachedSettingValue;
|
||||
|
||||
class AddNewTorrentDialog: public QDialog
|
||||
class AddNewTorrentDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -98,7 +96,7 @@ private:
|
||||
bool loadMagnet(const BitTorrent::MagnetUri &magnetUri);
|
||||
void populateSavePathComboBox();
|
||||
void saveSavePathHistory() const;
|
||||
int indexOfSavePath(const QString &save_path);
|
||||
int indexOfSavePath(const QString &savePath);
|
||||
void loadState();
|
||||
void saveState();
|
||||
void setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText = QString());
|
||||
@ -109,7 +107,7 @@ private:
|
||||
|
||||
void showEvent(QShowEvent *event) override;
|
||||
|
||||
Ui::AddNewTorrentDialog *ui;
|
||||
Ui::AddNewTorrentDialog *m_ui;
|
||||
TorrentContentFilterModel *m_contentModel;
|
||||
PropListDelegate *m_contentDelegate;
|
||||
bool m_hasMetadata;
|
||||
|
@ -115,7 +115,7 @@ AdvancedSettings::AdvancedSettings(QWidget *parent)
|
||||
{
|
||||
// column
|
||||
setColumnCount(COL_COUNT);
|
||||
QStringList header = { tr("Setting"), tr("Value", "Value set for this setting") };
|
||||
QStringList header = {tr("Setting"), tr("Value", "Value set for this setting")};
|
||||
setHorizontalHeaderLabels(header);
|
||||
// row
|
||||
setRowCount(ROW_COUNT);
|
||||
|
@ -626,7 +626,7 @@ void OptionsDialog::saveOptions()
|
||||
session->setAltGlobalUploadSpeedLimit(alt_down_up_limit.second);
|
||||
pref->setSchedulerStartTime(m_ui->schedule_from->time());
|
||||
pref->setSchedulerEndTime(m_ui->schedule_to->time());
|
||||
pref->setSchedulerDays(static_cast<scheduler_days>(m_ui->schedule_days->currentIndex()));
|
||||
pref->setSchedulerDays(static_cast<SchedulerDays>(m_ui->schedule_days->currentIndex()));
|
||||
session->setBandwidthSchedulerEnabled(m_ui->check_schedule->isChecked());
|
||||
|
||||
auto proxyConfigManager = Net::ProxyConfigurationManager::instance();
|
||||
|
@ -383,7 +383,7 @@ void AppController::setPreferencesAction()
|
||||
if (m.contains("schedule_to_hour") && m.contains("schedule_to_min"))
|
||||
pref->setSchedulerEndTime(QTime(m["schedule_to_hour"].toInt(), m["schedule_to_min"].toInt()));
|
||||
if (m.contains("scheduler_days"))
|
||||
pref->setSchedulerDays(scheduler_days(m["scheduler_days"].toInt()));
|
||||
pref->setSchedulerDays(SchedulerDays(m["scheduler_days"].toInt()));
|
||||
|
||||
// Bittorrent
|
||||
// Privacy
|
||||
|
Loading…
x
Reference in New Issue
Block a user