- extending Queueing system to seeding list (unfinished)

This commit is contained in:
Christophe Dumez 2008-07-14 22:01:05 +00:00
parent b73d0548c8
commit 20ae3d997c
11 changed files with 414 additions and 169 deletions

View file

@ -37,7 +37,8 @@
#define F_UPSPEED 2 #define F_UPSPEED 2
#define F_LEECH 3 #define F_LEECH 3
#define F_RATIO 4 #define F_RATIO 4
#define F_HASH 5 #define F_PRIORITY 5
#define F_HASH 6
class FinishedListDelegate: public QItemDelegate { class FinishedListDelegate: public QItemDelegate {
Q_OBJECT Q_OBJECT

View file

@ -38,14 +38,17 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par
actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png"))); actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png")));
actionPause->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/pause.png"))); actionPause->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/pause.png")));
connect(BTSession, SIGNAL(addedTorrent(QString, QTorrentHandle&, bool)), this, SLOT(torrentAdded(QString, QTorrentHandle&, bool))); connect(BTSession, SIGNAL(addedTorrent(QString, QTorrentHandle&, bool)), this, SLOT(torrentAdded(QString, QTorrentHandle&, bool)));
finishedListModel = new QStandardItemModel(0,6); finishedListModel = new QStandardItemModel(0,7);
finishedListModel->setHeaderData(F_NAME, Qt::Horizontal, tr("Name", "i.e: file name")); finishedListModel->setHeaderData(F_NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
finishedListModel->setHeaderData(F_SIZE, Qt::Horizontal, tr("Size", "i.e: file size")); finishedListModel->setHeaderData(F_SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
finishedListModel->setHeaderData(F_UPSPEED, Qt::Horizontal, tr("UP Speed", "i.e: Upload speed")); finishedListModel->setHeaderData(F_UPSPEED, Qt::Horizontal, tr("UP Speed", "i.e: Upload speed"));
finishedListModel->setHeaderData(F_LEECH, Qt::Horizontal, tr("Leechers", "i.e: full/partial sources")); finishedListModel->setHeaderData(F_LEECH, Qt::Horizontal, tr("Leechers", "i.e: full/partial sources"));
finishedListModel->setHeaderData(F_RATIO, Qt::Horizontal, tr("Ratio")); finishedListModel->setHeaderData(F_RATIO, Qt::Horizontal, tr("Ratio"));
finishedListModel->setHeaderData(F_PRIORITY, Qt::Horizontal, tr("Priority"));
finishedList->setModel(finishedListModel); finishedList->setModel(finishedListModel);
loadHiddenColumns(); loadHiddenColumns();
// Hide priority column
finishedList->hideColumn(F_PRIORITY);
// Hide hash column // Hide hash column
finishedList->hideColumn(F_HASH); finishedList->hideColumn(F_HASH);
// Load last columns width for download list // Load last columns width for download list
@ -82,6 +85,7 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par
connect(actionHOSColUpSpeed, SIGNAL(triggered()), this, SLOT(hideOrShowColumnUpSpeed())); connect(actionHOSColUpSpeed, SIGNAL(triggered()), this, SLOT(hideOrShowColumnUpSpeed()));
connect(actionHOSColLeechers, SIGNAL(triggered()), this, SLOT(hideOrShowColumnLeechers())); connect(actionHOSColLeechers, SIGNAL(triggered()), this, SLOT(hideOrShowColumnLeechers()));
connect(actionHOSColRatio, SIGNAL(triggered()), this, SLOT(hideOrShowColumnRatio())); connect(actionHOSColRatio, SIGNAL(triggered()), this, SLOT(hideOrShowColumnRatio()));
connect(actionHOSColPriority, SIGNAL(triggered()), this, SLOT(hideOrShowColumnPriority()));
} }
FinishedTorrents::~FinishedTorrents(){ FinishedTorrents::~FinishedTorrents(){
@ -97,6 +101,10 @@ void FinishedTorrents::notifyTorrentDoubleClicked(const QModelIndex& index) {
emit torrentDoubleClicked(hash, true); emit torrentDoubleClicked(hash, true);
} }
void FinishedTorrents::hidePriorityColumn(bool hide) {
finishedList->setColumnHidden(F_PRIORITY, hide);
}
void FinishedTorrents::addTorrent(QString hash){ void FinishedTorrents::addTorrent(QString hash){
if(!BTSession->isFinished(hash)){ if(!BTSession->isFinished(hash)){
BTSession->setFinishedTorrent(hash); BTSession->setFinishedTorrent(hash);
@ -112,6 +120,8 @@ void FinishedTorrents::addTorrent(QString hash){
finishedListModel->setData(finishedListModel->index(row, F_UPSPEED), QVariant((double)0.)); finishedListModel->setData(finishedListModel->index(row, F_UPSPEED), QVariant((double)0.));
finishedListModel->setData(finishedListModel->index(row, F_LEECH), QVariant("0")); finishedListModel->setData(finishedListModel->index(row, F_LEECH), QVariant("0"));
finishedListModel->setData(finishedListModel->index(row, F_RATIO), QVariant(QString::fromUtf8(misc::toString(BTSession->getRealRatio(hash)).c_str()))); finishedListModel->setData(finishedListModel->index(row, F_RATIO), QVariant(QString::fromUtf8(misc::toString(BTSession->getRealRatio(hash)).c_str())));
if(BTSession->isQueueingEnabled())
finishedListModel->setData(finishedListModel->index(row, F_PRIORITY), QVariant((int)BTSession->getUpTorrentPriority(hash)));
finishedListModel->setData(finishedListModel->index(row, F_HASH), QVariant(hash)); finishedListModel->setData(finishedListModel->index(row, F_HASH), QVariant(hash));
if(h.is_paused()) { if(h.is_paused()) {
finishedListModel->setData(finishedListModel->index(row, F_NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole); finishedListModel->setData(finishedListModel->index(row, F_NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole);
@ -237,6 +247,14 @@ void FinishedTorrents::updateFinishedList(){
row = getRowFromHash(hash); row = getRowFromHash(hash);
} }
Q_ASSERT(row != -1); Q_ASSERT(row != -1);
// Update priority
if(BTSession->isQueueingEnabled()) {
finishedListModel->setData(finishedListModel->index(row, F_PRIORITY), QVariant((int)BTSession->getDlTorrentPriority(hash)));
if(h.is_paused() && BTSession->isUploadQueued(hash)) {
finishedListModel->setData(finishedListModel->index(row, F_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/queued.png"))), Qt::DecorationRole);
setRowColor(row, QString::fromUtf8("grey"));
}
}
if(h.is_paused()) continue; if(h.is_paused()) continue;
if(BTSession->getTorrentsToPauseAfterChecking().indexOf(hash) != -1) { if(BTSession->getTorrentsToPauseAfterChecking().indexOf(hash) != -1) {
continue; continue;
@ -406,6 +424,12 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint& pos){
void FinishedTorrents::displayFinishedHoSMenu(const QPoint& pos){ void FinishedTorrents::displayFinishedHoSMenu(const QPoint& pos){
QMenu hideshowColumn(this); QMenu hideshowColumn(this);
hideshowColumn.setTitle(tr("Hide or Show Column")); hideshowColumn.setTitle(tr("Hide or Show Column"));
int lastCol;
if(BTSession->isQueueingEnabled()) {
lastCol = F_PRIORITY;
} else {
lastCol = F_RATIO;
}
for(int i=0; i<=F_RATIO; i++) { for(int i=0; i<=F_RATIO; i++) {
hideshowColumn.addAction(getActionHoSCol(i)); hideshowColumn.addAction(getActionHoSCol(i));
} }
@ -464,6 +488,10 @@ void FinishedTorrents::hideOrShowColumnRatio() {
hideOrShowColumn(F_RATIO); hideOrShowColumn(F_RATIO);
} }
void FinishedTorrents::hideOrShowColumnPriority() {
hideOrShowColumn(F_PRIORITY);
}
// load the previous settings, and hide the columns // load the previous settings, and hide the columns
bool FinishedTorrents::loadHiddenColumns() { bool FinishedTorrents::loadHiddenColumns() {
bool loaded = false; bool loaded = false;
@ -525,6 +553,9 @@ QAction* FinishedTorrents::getActionHoSCol(int index) {
case F_RATIO : case F_RATIO :
return actionHOSColRatio; return actionHOSColRatio;
break; break;
case F_PRIORITY :
return actionHOSColPriority;
break;
default : default :
return NULL; return NULL;
} }

View file

@ -72,6 +72,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding {
void hideOrShowColumnUpSpeed(); void hideOrShowColumnUpSpeed();
void hideOrShowColumnLeechers(); void hideOrShowColumnLeechers();
void hideOrShowColumnRatio(); void hideOrShowColumnRatio();
void hideOrShowColumnPriority();
public slots: public slots:
void addTorrent(QString hash); void addTorrent(QString hash);
@ -81,6 +82,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding {
void propertiesSelection(); void propertiesSelection();
void deleteTorrent(QString hash); void deleteTorrent(QString hash);
void showPropertiesFromHash(QString hash); void showPropertiesFromHash(QString hash);
void hidePriorityColumn(bool hide);
signals: signals:
void torrentMovedFromFinishedList(QString); void torrentMovedFromFinishedList(QString);

View file

@ -1112,15 +1112,22 @@ void GUI::configureSession(bool deleteOptions) {
} }
// Queueing System // Queueing System
if(options->isQueueingSystemEnabled()) { if(options->isQueueingSystemEnabled()) {
if(!BTSession->isDlQueueingEnabled()) { if(!BTSession->isQueueingEnabled()) {
BTSession->setMaxActiveDlTorrents(options->getMaxActiveDownloads()); int max_torrents = options->getMaxActiveTorrents();
BTSession->setDlQueueingEnabled(true); int max_downloads = options->getMaxActiveDownloads();
if(max_torrents < max_downloads)
max_torrents = max_downloads;
BTSession->setMaxActiveTorrents(max_torrents);
BTSession->setMaxActiveDownloads(max_downloads);
BTSession->setQueueingEnabled(true);
downloadingTorrentTab->hidePriorityColumn(false); downloadingTorrentTab->hidePriorityColumn(false);
finishedTorrentTab->hidePriorityColumn(false);
} }
} else { } else {
if(BTSession->isDlQueueingEnabled()) { if(BTSession->isQueueingEnabled()) {
BTSession->setDlQueueingEnabled(false); BTSession->setQueueingEnabled(false);
downloadingTorrentTab->hidePriorityColumn(true); downloadingTorrentTab->hidePriorityColumn(true);
finishedTorrentTab->hidePriorityColumn(true);
} }
} }
// Clean up // Clean up

View file

@ -43,7 +43,7 @@
#define MAX_TRACKER_ERRORS 2 #define MAX_TRACKER_ERRORS 2
// Main constructor // Main constructor
bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false), addInPause(false), maxConnecsPerTorrent(500), maxUploadsPerTorrent(4), max_ratio(-1), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false), folderScanInterval(5), dlQueueingEnabled(false) { bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false), addInPause(false), maxConnecsPerTorrent(500), maxUploadsPerTorrent(4), max_ratio(-1), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false), folderScanInterval(5), queueingEnabled(false) {
// To avoid some exceptions // To avoid some exceptions
fs::path::default_name_check(fs::no_check); fs::path::default_name_check(fs::no_check);
// Creating bittorrent session // Creating bittorrent session
@ -99,11 +99,15 @@ bittorrent::~bittorrent() {
if(filterParser != 0) if(filterParser != 0)
delete filterParser; delete filterParser;
delete downloader; delete downloader;
if(dlQueueingEnabled) { if(queueingEnabled) {
Q_ASSERT(downloadQueue); Q_ASSERT(downloadQueue);
delete downloadQueue; delete downloadQueue;
Q_ASSERT(queuedDownloads); Q_ASSERT(queuedDownloads);
delete queuedDownloads; delete queuedDownloads;
Q_ASSERT(uploadQueue);
delete uploadQueue;
Q_ASSERT(queuedUploads);
delete queuedUploads;
} }
// Delete BT session // Delete BT session
qDebug("Deleting session"); qDebug("Deleting session");
@ -154,12 +158,16 @@ void bittorrent::setDownloadLimit(QString hash, long val) {
saveTorrentSpeedLimits(hash); saveTorrentSpeedLimits(hash);
} }
bool bittorrent::isDlQueueingEnabled() const { bool bittorrent::isQueueingEnabled() const {
return dlQueueingEnabled; return queueingEnabled;
} }
void bittorrent::setMaxActiveDlTorrents(int val) { void bittorrent::setMaxActiveDownloads(int val) {
maxActiveDlTorrents = val; maxActiveDownloads = val;
}
void bittorrent::setMaxActiveTorrents(int val) {
maxActiveTorrents = val;
} }
void bittorrent::increaseDlTorrentPriority(QString hash) { void bittorrent::increaseDlTorrentPriority(QString hash) {
@ -167,24 +175,46 @@ void bittorrent::increaseDlTorrentPriority(QString hash) {
Q_ASSERT(index != -1); Q_ASSERT(index != -1);
if(index > 0) { if(index > 0) {
downloadQueue->swap(index-1, index); downloadQueue->swap(index-1, index);
saveDlTorrentPriority(hash, index-1); saveTorrentPriority(hash, index-1);
saveDlTorrentPriority(downloadQueue->at(index), index); saveTorrentPriority(downloadQueue->at(index), index);
updateDownloadQueue(); updateDownloadQueue();
} }
} }
void bittorrent::increaseUpTorrentPriority(QString hash) {
int index = uploadQueue->indexOf(hash);
Q_ASSERT(index != -1);
if(index > 0) {
uploadQueue->swap(index-1, index);
saveTorrentPriority(hash, index-1);
saveTorrentPriority(uploadQueue->at(index), index);
updateUploadQueue();
}
}
void bittorrent::decreaseDlTorrentPriority(QString hash) { void bittorrent::decreaseDlTorrentPriority(QString hash) {
int index = downloadQueue->indexOf(hash); int index = downloadQueue->indexOf(hash);
Q_ASSERT(index != -1); Q_ASSERT(index != -1);
if(index >= 0 && index < (downloadQueue->size()-1)) { if(index >= 0 && index < (downloadQueue->size()-1)) {
downloadQueue->swap(index+1, index); downloadQueue->swap(index+1, index);
saveDlTorrentPriority(hash, index+1); saveTorrentPriority(hash, index+1);
saveDlTorrentPriority(downloadQueue->at(index), index); saveTorrentPriority(downloadQueue->at(index), index);
updateDownloadQueue(); updateDownloadQueue();
} }
} }
void bittorrent::saveDlTorrentPriority(QString hash, int prio) { void bittorrent::decreaseUpTorrentPriority(QString hash) {
int index = uploadQueue->indexOf(hash);
Q_ASSERT(index != -1);
if(index >= 0 && index < (uploadQueue->size()-1)) {
uploadQueue->swap(index+1, index);
saveTorrentPriority(hash, index+1);
saveTorrentPriority(uploadQueue->at(index), index);
updateUploadQueue();
}
}
void bittorrent::saveTorrentPriority(QString hash, int prio) {
// Write .queued file // Write .queued file
QFile prio_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio"); QFile prio_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio");
prio_file.open(QIODevice::WriteOnly | QIODevice::Text); prio_file.open(QIODevice::WriteOnly | QIODevice::Text);
@ -192,7 +222,7 @@ void bittorrent::saveDlTorrentPriority(QString hash, int prio) {
prio_file.close(); prio_file.close();
} }
int bittorrent::loadDlTorrentPriority(QString hash) { int bittorrent::loadTorrentPriority(QString hash) {
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio")) { if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio")) {
// Read .queued file // Read .queued file
QFile prio_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio"); QFile prio_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio");
@ -212,10 +242,15 @@ int bittorrent::loadDlTorrentPriority(QString hash) {
} }
bool bittorrent::isDownloadQueued(QString hash) const { bool bittorrent::isDownloadQueued(QString hash) const {
Q_ASSERT(dlQueueingEnabled); Q_ASSERT(queueingEnabled);
return queuedDownloads->contains(hash); return queuedDownloads->contains(hash);
} }
bool bittorrent::isUploadQueued(QString hash) const {
Q_ASSERT(queueingEnabled);
return queuedUploads->contains(hash);
}
void bittorrent::setUploadLimit(QString hash, long val) { void bittorrent::setUploadLimit(QString hash, long val) {
qDebug("Set upload limit rate to %ld", val); qDebug("Set upload limit rate to %ld", val);
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
@ -232,16 +267,16 @@ void bittorrent::startTorrentsInPause(bool b) {
addInPause = b; addInPause = b;
} }
void bittorrent::setDlQueueingEnabled(bool enable) { void bittorrent::setQueueingEnabled(bool enable) {
if(dlQueueingEnabled != enable) { if(queueingEnabled != enable) {
dlQueueingEnabled = enable; queueingEnabled = enable;
if(enable) { if(enable) {
// Load priorities // Load priorities
QList<QPair<int, QString> > tmp_list; QList<QPair<int, QString> > tmp_list;
QStringList noprio; QStringList noprio;
QStringList finished = getUnfinishedTorrents(); QStringList unfinished = getUnfinishedTorrents();
foreach(QString hash, finished) { foreach(QString hash, unfinished) {
int prio = loadDlTorrentPriority(hash); int prio = loadTorrentPriority(hash);
if(prio != -1) { if(prio != -1) {
misc::insertSort2<QString>(tmp_list, QPair<int,QString>(prio,hash), Qt::AscendingOrder); misc::insertSort2<QString>(tmp_list, QPair<int,QString>(prio,hash), Qt::AscendingOrder);
} else { } else {
@ -257,16 +292,45 @@ void bittorrent::setDlQueueingEnabled(bool enable) {
// save priorities // save priorities
int i=0; int i=0;
foreach(QString hash, *downloadQueue) { foreach(QString hash, *downloadQueue) {
saveDlTorrentPriority(hash, i); saveTorrentPriority(hash, i);
++i; ++i;
} }
queuedDownloads = new QStringList(); queuedDownloads = new QStringList();
updateDownloadQueue(); updateDownloadQueue();
QList<QPair<int, QString> > tmp_list2;
QStringList noprio2;
QStringList finished = getFinishedTorrents();
foreach(QString hash, finished) {
int prio = loadTorrentPriority(hash);
if(prio != -1) {
misc::insertSort2<QString>(tmp_list2, QPair<int,QString>(prio,hash), Qt::AscendingOrder);
} else {
noprio2 << hash;
}
}
uploadQueue = new QStringList();
QPair<int,QString> couple2;
foreach(couple2, tmp_list2) {
uploadQueue->append(couple2.second);
}
(*uploadQueue)<<noprio;
// save priorities
int j=0;
foreach(QString hash, *uploadQueue) {
saveTorrentPriority(hash, j);
++j;
}
queuedUploads = new QStringList();
updateUploadQueue();
} else { } else {
delete downloadQueue; delete downloadQueue;
downloadQueue = 0; downloadQueue = 0;
delete queuedDownloads; delete queuedDownloads;
queuedDownloads = 0; queuedDownloads = 0;
delete uploadQueue;
uploadQueue = 0;
delete queuedUploads;
queuedUploads = 0;
} }
} }
} }
@ -276,15 +340,71 @@ int bittorrent::getDlTorrentPriority(QString hash) const {
return downloadQueue->indexOf(hash); return downloadQueue->indexOf(hash);
} }
int bittorrent::getUpTorrentPriority(QString hash) const {
Q_ASSERT(uploadQueue != 0);
return uploadQueue->indexOf(hash);
}
void bittorrent::updateUploadQueue() {
Q_ASSERT(queueingEnabled);
int maxActiveUploads = maxActiveTorrents - currentActiveDownloads;
int currentActiveUploads = 0;
// Check if it is necessary to queue uploads
foreach(QString hash, *uploadQueue) {
QTorrentHandle h = getTorrentHandle(hash);
if(!h.is_paused()) {
if(currentActiveUploads < maxActiveUploads) {
++currentActiveUploads;
} else {
// Queue it
h.pause();
if(!queuedUploads->contains(hash)) {
queuedUploads->append(hash);
// Create .queued file
if(!QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued")) {
QFile queued_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
queued_file.open(QIODevice::WriteOnly | QIODevice::Text);
queued_file.close();
}
}
}
} else {
if(currentActiveUploads < maxActiveUploads && isUploadQueued(hash)) {
QTorrentHandle h = getTorrentHandle(hash);
h.resume();
queuedUploads->removeAll(hash);
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
++currentActiveUploads;
}
}
}
if(currentActiveUploads < maxActiveUploads) {
// Could not fill download slots, unqueue torrents
foreach(QString hash, *uploadQueue) {
if(uploadQueue->size() != 0 && currentActiveUploads < maxActiveUploads) {
if(uploadQueue->contains(hash)) {
QTorrentHandle h = getTorrentHandle(hash);
h.resume();
queuedUploads->removeAll(hash);
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
++currentActiveUploads;
}
} else {
break;
}
}
}
}
void bittorrent::updateDownloadQueue() { void bittorrent::updateDownloadQueue() {
Q_ASSERT(dlQueueingEnabled); Q_ASSERT(queueingEnabled);
int currentActiveTorrents = 0; currentActiveDownloads = 0;
// Check if it is necessary to queue torrents // Check if it is necessary to queue torrents
foreach(QString hash, *downloadQueue) { foreach(QString hash, *downloadQueue) {
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
if(!h.is_paused()) { if(!h.is_paused()) {
if(currentActiveTorrents < maxActiveDlTorrents) { if(currentActiveDownloads < maxActiveDownloads) {
++currentActiveTorrents; ++currentActiveDownloads;
} else { } else {
// Queue it // Queue it
h.pause(); h.pause();
@ -299,25 +419,25 @@ void bittorrent::updateDownloadQueue() {
} }
} }
} else { } else {
if(currentActiveTorrents < maxActiveDlTorrents && isDownloadQueued(hash)) { if(currentActiveDownloads < maxActiveDownloads && isDownloadQueued(hash)) {
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
h.resume(); h.resume();
queuedDownloads->removeAll(hash); queuedDownloads->removeAll(hash);
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"); QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
++currentActiveTorrents; ++currentActiveDownloads;
} }
} }
} }
if(currentActiveTorrents < maxActiveDlTorrents) { if(currentActiveDownloads < maxActiveDownloads) {
// Could not fill download slots, unqueue torrents // Could not fill download slots, unqueue torrents
foreach(QString hash, *downloadQueue) { foreach(QString hash, *downloadQueue) {
if(downloadQueue->size() != 0 && currentActiveTorrents < maxActiveDlTorrents) { if(downloadQueue->size() != 0 && currentActiveDownloads < maxActiveDownloads) {
if(downloadQueue->contains(hash)) { if(downloadQueue->contains(hash)) {
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
h.resume(); h.resume();
queuedDownloads->removeAll(hash); queuedDownloads->removeAll(hash);
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"); QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
++currentActiveTorrents; ++currentActiveDownloads;
} }
} else { } else {
break; break;
@ -438,14 +558,23 @@ void bittorrent::deleteTorrent(QString hash, bool permanent) {
std::cerr << "Error: Torrent " << hash.toStdString() << " is neither in finished or unfinished list\n"; std::cerr << "Error: Torrent " << hash.toStdString() << " is neither in finished or unfinished list\n";
} }
} }
// Remove it from downloadQueue // Remove it from downloadQueue or UploadQueue
if(dlQueueingEnabled) { if(queueingEnabled) {
downloadQueue->removeAll(hash); if(downloadQueue->contains(hash)) {
queuedDownloads->removeAll(hash); downloadQueue->removeAll(hash);
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio")) queuedDownloads->removeAll(hash);
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio"); updateDownloadQueue();
updateDownloadQueue(); }
if(uploadQueue->contains(hash)) {
uploadQueue->removeAll(hash);
queuedUploads->removeAll(hash);
updateUploadQueue();
}
} }
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio");
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
if(permanent && files_arb != 0) { if(permanent && files_arb != 0) {
// Remove from Hard drive // Remove from Hard drive
qDebug("Removing this on hard drive: %s", qPrintable(savePath+QDir::separator()+fileName)); qDebug("Removing this on hard drive: %s", qPrintable(savePath+QDir::separator()+fileName));
@ -484,10 +613,10 @@ void bittorrent::setUnfinishedTorrent(QString hash) {
TorrentsStartTime[hash] = QDateTime::currentDateTime(); TorrentsStartTime[hash] = QDateTime::currentDateTime();
} }
// Add it to downloadQueue // Add it to downloadQueue
if(dlQueueingEnabled) { if(queueingEnabled) {
if(!downloadQueue->contains(hash)) { if(!downloadQueue->contains(hash)) {
downloadQueue->append(hash); downloadQueue->append(hash);
saveDlTorrentPriority(hash, downloadQueue->size()-1); saveTorrentPriority(hash, downloadQueue->size()-1);
updateDownloadQueue(); updateDownloadQueue();
} }
} }
@ -511,12 +640,16 @@ void bittorrent::setFinishedTorrent(QString hash) {
TorrentsStartTime.remove(hash); TorrentsStartTime.remove(hash);
TorrentsStartData.remove(hash); TorrentsStartData.remove(hash);
// Remove it from downloadQueue // Remove it from downloadQueue
if(dlQueueingEnabled) { if(queueingEnabled) {
downloadQueue->removeAll(hash); downloadQueue->removeAll(hash);
queuedDownloads->removeAll(hash); queuedDownloads->removeAll(hash);
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio")) if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio"); QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio");
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
updateDownloadQueue(); updateDownloadQueue();
uploadQueue->append(hash);
updateUploadQueue();
} }
// Save fast resume data // Save fast resume data
saveFastResumeAndRatioData(hash); saveFastResumeAndRatioData(hash);
@ -549,6 +682,13 @@ bool bittorrent::pauseTorrent(QString hash) {
// Remove it from TorrentsStartTime hash table // Remove it from TorrentsStartTime hash table
TorrentsStartTime.remove(hash); TorrentsStartTime.remove(hash);
TorrentsStartData.remove(hash); TorrentsStartData.remove(hash);
// Remove it from queued list if present
if(queuedDownloads->contains(hash))
queuedDownloads->removeAll(hash);
if(queuedUploads->contains(hash))
queuedUploads->removeAll(hash);
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
return change; return change;
} }
@ -744,12 +884,17 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
h.resume(); h.resume();
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) { if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) {
finishedTorrents << hash; finishedTorrents << hash;
if(queueingEnabled) {
uploadQueue->append(hash);
saveTorrentPriority(hash, uploadQueue->size()-1);
updateUploadQueue();
}
}else{ }else{
unfinishedTorrents << hash; unfinishedTorrents << hash;
// Add it to downloadQueue // Add it to downloadQueue
if(dlQueueingEnabled) { if(queueingEnabled) {
downloadQueue->append(hash); downloadQueue->append(hash);
saveDlTorrentPriority(hash, downloadQueue->size()-1); saveTorrentPriority(hash, downloadQueue->size()-1);
updateDownloadQueue(); updateDownloadQueue();
} }
} }

View file

@ -70,10 +70,14 @@ class bittorrent : public QObject{
FilterParserThread *filterParser; FilterParserThread *filterParser;
QString filterPath; QString filterPath;
int folderScanInterval; // in seconds int folderScanInterval; // in seconds
bool dlQueueingEnabled; bool queueingEnabled;
int maxActiveDlTorrents; int maxActiveDownloads;
int maxActiveTorrents;
int currentActiveDownloads;
QStringList *downloadQueue; QStringList *downloadQueue;
QStringList *queuedDownloads; QStringList *queuedDownloads;
QStringList *uploadQueue;
QStringList *queuedUploads;
protected: protected:
QString getSavePath(QString hash); QString getSavePath(QString hash);
@ -101,10 +105,12 @@ class bittorrent : public QObject{
bool has_filtered_files(QString hash) const; bool has_filtered_files(QString hash) const;
unsigned int getFinishedPausedTorrentsNb() const; unsigned int getFinishedPausedTorrentsNb() const;
unsigned int getUnfinishedPausedTorrentsNb() const; unsigned int getUnfinishedPausedTorrentsNb() const;
bool isDlQueueingEnabled() const; bool isQueueingEnabled() const;
int getDlTorrentPriority(QString hash) const; int getDlTorrentPriority(QString hash) const;
int getUpTorrentPriority(QString hash) const;
bool isDownloadQueued(QString hash) const; bool isDownloadQueued(QString hash) const;
int loadDlTorrentPriority(QString hash); bool isUploadQueued(QString hash) const;
int loadTorrentPriority(QString hash);
public slots: public slots:
void addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false); void addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false);
@ -124,7 +130,7 @@ class bittorrent : public QObject{
void enablePeerExchange(); void enablePeerExchange();
void enableIPFilter(QString filter); void enableIPFilter(QString filter);
void disableIPFilter(); void disableIPFilter();
void setDlQueueingEnabled(bool enable); void setQueueingEnabled(bool enable);
void resumeUnfinishedTorrents(); void resumeUnfinishedTorrents();
void saveTorrentSpeedLimits(QString hash); void saveTorrentSpeedLimits(QString hash);
void loadTorrentSpeedLimits(QString hash); void loadTorrentSpeedLimits(QString hash);
@ -133,9 +139,12 @@ class bittorrent : public QObject{
void handleDownloadFailure(QString url, QString reason); void handleDownloadFailure(QString url, QString reason);
void loadWebSeeds(QString fileHash); void loadWebSeeds(QString fileHash);
void updateDownloadQueue(); void updateDownloadQueue();
void updateUploadQueue();
void increaseDlTorrentPriority(QString hash); void increaseDlTorrentPriority(QString hash);
void decreaseDlTorrentPriority(QString hash); void decreaseDlTorrentPriority(QString hash);
void saveDlTorrentPriority(QString hash, int prio); void increaseUpTorrentPriority(QString hash);
void decreaseUpTorrentPriority(QString hash);
void saveTorrentPriority(QString hash, int prio);
// Session configuration - Setters // Session configuration - Setters
void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports); void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports);
void setMaxConnections(int maxConnec); void setMaxConnections(int maxConnec);
@ -162,7 +171,8 @@ class bittorrent : public QObject{
bool enableDHT(bool b); bool enableDHT(bool b);
void reloadTorrent(const QTorrentHandle &h, bool full_alloc); void reloadTorrent(const QTorrentHandle &h, bool full_alloc);
void setTimerScanInterval(int secs); void setTimerScanInterval(int secs);
void setMaxActiveDlTorrents(int val); void setMaxActiveDownloads(int val);
void setMaxActiveTorrents(int val);
protected slots: protected slots:
void scanDirectory(); void scanDirectory();

View file

@ -335,7 +335,7 @@ void DownloadingTorrents::displayDLHoSMenu(const QPoint& pos){
QMenu hideshowColumn(this); QMenu hideshowColumn(this);
hideshowColumn.setTitle(tr("Hide or Show Column")); hideshowColumn.setTitle(tr("Hide or Show Column"));
int lastCol; int lastCol;
if(BTSession->isDlQueueingEnabled()) { if(BTSession->isQueueingEnabled()) {
lastCol = PRIORITY; lastCol = PRIORITY;
} else { } else {
lastCol = ETA; lastCol = ETA;
@ -552,10 +552,9 @@ void DownloadingTorrents::updateDlList() {
} }
Q_ASSERT(row != -1); Q_ASSERT(row != -1);
// Update Priority // Update Priority
if(BTSession->isDlQueueingEnabled()) { if(BTSession->isQueueingEnabled()) {
DLListModel->setData(DLListModel->index(row, PRIORITY), QVariant((int)BTSession->getDlTorrentPriority(hash))); DLListModel->setData(DLListModel->index(row, PRIORITY), QVariant((int)BTSession->getDlTorrentPriority(hash)));
if(h.is_paused() && BTSession->isDownloadQueued(hash)) { if(h.is_paused() && BTSession->isDownloadQueued(hash)) {
qDebug("Download queued");
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/queued.png"))), Qt::DecorationRole); DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/queued.png"))), Qt::DecorationRole);
if(!downloadList->isColumnHidden(ETA)) { if(!downloadList->isColumnHidden(ETA)) {
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1)); DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
@ -672,7 +671,7 @@ void DownloadingTorrents::addTorrent(QString hash) {
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.)); DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.));
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant(QString::fromUtf8("0/0"))); DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant(QString::fromUtf8("0/0")));
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1)); DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
if(BTSession->isDlQueueingEnabled()) if(BTSession->isQueueingEnabled())
DLListModel->setData(DLListModel->index(row, PRIORITY), QVariant((int)BTSession->getDlTorrentPriority(hash))); DLListModel->setData(DLListModel->index(row, PRIORITY), QVariant((int)BTSession->getDlTorrentPriority(hash)));
DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash)); DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash));
// Pause torrent if it was paused last time // Pause torrent if it was paused last time

View file

@ -22,7 +22,16 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="margin" > <property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number> <number>9</number>
</property> </property>
<item> <item>
@ -74,20 +83,11 @@
<enum>Qt::ElideLeft</enum> <enum>Qt::ElideLeft</enum>
</property> </property>
<widget class="QWidget" name="tab" > <widget class="QWidget" name="tab" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>641</width>
<height>457</height>
</rect>
</property>
<attribute name="title" > <attribute name="title" >
<string>General</string> <string>General</string>
</attribute> </attribute>
<attribute name="icon" > <attribute name="icon" >
<iconset resource="icons.qrc" > <iconset resource="icons.qrc" >:/Icons/star.png</iconset>
<normaloff>:/Icons/star.png</normaloff>:/Icons/star.png</iconset>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<item> <item>
@ -120,7 +120,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -189,7 +189,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -250,7 +250,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -318,7 +318,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>623</width> <width>623</width>
<height>20</height> <height>20</height>
@ -329,22 +329,13 @@
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_5" > <widget class="QWidget" name="tab_5" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>641</width>
<height>457</height>
</rect>
</property>
<attribute name="title" > <attribute name="title" >
<string>Downloads</string> <string>Downloads</string>
</attribute> </attribute>
<attribute name="icon" > <attribute name="icon" >
<iconset resource="icons.qrc" > <iconset resource="icons.qrc" >:/Icons/download.png</iconset>
<normaloff>:/Icons/download.png</normaloff>:/Icons/download.png</iconset>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_4" > <layout class="QVBoxLayout" >
<item> <item>
<widget class="QGroupBox" name="fileSystemBox" > <widget class="QGroupBox" name="fileSystemBox" >
<property name="sizePolicy" > <property name="sizePolicy" >
@ -369,7 +360,16 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="margin" > <property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -377,7 +377,16 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="margin" > <property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -419,9 +428,9 @@
<property name="title" > <property name="title" >
<string>When adding a torrent</string> <string>When adding a torrent</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3" > <layout class="QVBoxLayout" >
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3" > <layout class="QHBoxLayout" >
<item> <item>
<widget class="QCheckBox" name="checkAdditionDialog" > <widget class="QCheckBox" name="checkAdditionDialog" >
<property name="text" > <property name="text" >
@ -433,11 +442,11 @@
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer" > <spacer>
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -468,7 +477,7 @@
<property name="title" > <property name="title" >
<string comment="qBittorrent will watch a directory and automatically download torrents present in it" >Folder watching</string> <string comment="qBittorrent will watch a directory and automatically download torrents present in it" >Folder watching</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2" > <layout class="QVBoxLayout" >
<item> <item>
<widget class="QCheckBox" name="checkScanDir" > <widget class="QCheckBox" name="checkScanDir" >
<property name="text" > <property name="text" >
@ -481,7 +490,16 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="margin" > <property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -504,7 +522,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2" > <layout class="QHBoxLayout" >
<item> <item>
<widget class="QLabel" name="FolderScanLbl" > <widget class="QLabel" name="FolderScanLbl" >
<property name="text" > <property name="text" >
@ -591,7 +609,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -634,7 +652,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -650,20 +668,11 @@
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_3" > <widget class="QWidget" name="tab_3" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>641</width>
<height>457</height>
</rect>
</property>
<attribute name="title" > <attribute name="title" >
<string>Connection</string> <string>Connection</string>
</attribute> </attribute>
<attribute name="icon" > <attribute name="icon" >
<iconset resource="icons.qrc" > <iconset resource="icons.qrc" >:/Icons/connection.png</iconset>
<normaloff>:/Icons/connection.png</normaloff>:/Icons/connection.png</iconset>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<item> <item>
@ -726,7 +735,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>20</width> <width>20</width>
<height>20</height> <height>20</height>
@ -974,7 +983,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>21</width> <width>21</width>
<height>29</height> <height>29</height>
@ -1063,7 +1072,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1165,20 +1174,11 @@
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_6" > <widget class="QWidget" name="tab_6" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>641</width>
<height>457</height>
</rect>
</property>
<attribute name="title" > <attribute name="title" >
<string>Bittorrent</string> <string>Bittorrent</string>
</attribute> </attribute>
<attribute name="icon" > <attribute name="icon" >
<iconset resource="icons.qrc" > <iconset resource="icons.qrc" >:/Icons/bt_settings.png</iconset>
<normaloff>:/Icons/bt_settings.png</normaloff>:/Icons/bt_settings.png</iconset>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<item> <item>
@ -1225,7 +1225,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1270,7 +1270,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1312,7 +1312,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1401,7 +1401,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1464,7 +1464,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1518,7 +1518,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1536,7 +1536,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>20</width> <width>20</width>
<height>40</height> <height>40</height>
@ -1547,22 +1547,13 @@
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_4" > <widget class="QWidget" name="tab_4" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>641</width>
<height>457</height>
</rect>
</property>
<attribute name="title" > <attribute name="title" >
<string>Misc</string> <string>Misc</string>
</attribute> </attribute>
<attribute name="icon" > <attribute name="icon" >
<iconset resource="icons.qrc" > <iconset resource="icons.qrc" >:/Icons/configure.png</iconset>
<normaloff>:/Icons/configure.png</normaloff>:/Icons/configure.png</iconset>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_8" > <layout class="QVBoxLayout" >
<item> <item>
<widget class="QGroupBox" name="filterBox" > <widget class="QGroupBox" name="filterBox" >
<property name="enabled" > <property name="enabled" >
@ -1571,20 +1562,19 @@
<property name="title" > <property name="title" >
<string>Filter Settings</string> <string>Filter Settings</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout" > <layout class="QVBoxLayout" >
<item> <item>
<widget class="QCheckBox" name="checkIPFilter" > <widget class="QCheckBox" name="checkIPFilter" >
<property name="text" > <property name="text" >
<string>Activate IP Filtering</string> <string>Activate IP Filtering</string>
</property> </property>
<property name="icon" > <property name="icon" >
<iconset resource="icons.qrc" > <iconset resource="icons.qrc" >:/Icons/filter.png</iconset>
<normaloff>:/Icons/filter.png</normaloff>:/Icons/filter.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout" > <layout class="QHBoxLayout" >
<item> <item>
<widget class="QLabel" name="lblFilterPath" > <widget class="QLabel" name="lblFilterPath" >
<property name="enabled" > <property name="enabled" >
@ -1622,7 +1612,7 @@
<property name="title" > <property name="title" >
<string>RSS</string> <string>RSS</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_6" > <layout class="QVBoxLayout" >
<item> <item>
<widget class="QCheckBox" name="checkEnableRSS" > <widget class="QCheckBox" name="checkEnableRSS" >
<property name="text" > <property name="text" >
@ -1638,7 +1628,7 @@
<property name="title" > <property name="title" >
<string>RSS settings</string> <string>RSS settings</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_5" > <layout class="QVBoxLayout" >
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<item> <item>
@ -1702,7 +1692,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1736,7 +1726,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1759,9 +1749,9 @@
<item> <item>
<widget class="QGroupBox" name="groupQueueing" > <widget class="QGroupBox" name="groupQueueing" >
<property name="title" > <property name="title" >
<string>Download queueing</string> <string>Torrent queueing</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_7" > <layout class="QVBoxLayout" >
<item> <item>
<widget class="QCheckBox" name="checkEnableQueueing" > <widget class="QCheckBox" name="checkEnableQueueing" >
<property name="text" > <property name="text" >
@ -1770,7 +1760,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_4" > <layout class="QHBoxLayout" >
<item> <item>
<widget class="QLabel" name="label_max_active" > <widget class="QLabel" name="label_max_active" >
<property name="enabled" > <property name="enabled" >
@ -1798,11 +1788,11 @@
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_2" > <spacer>
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1812,18 +1802,61 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="maxActiveTorrents_lbl" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Maximum active torrents:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinMaxActiveTorrents" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="minimum" >
<number>1</number>
</property>
<property name="maximum" >
<number>999</number>
</property>
<property name="value" >
<number>5</number>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>381</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer" > <spacer>
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>20</width> <width>623</width>
<height>40</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -1831,20 +1864,11 @@
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_2" > <widget class="QWidget" name="tab_2" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>641</width>
<height>457</height>
</rect>
</property>
<attribute name="title" > <attribute name="title" >
<string>Web UI</string> <string>Web UI</string>
</attribute> </attribute>
<attribute name="icon" > <attribute name="icon" >
<iconset resource="icons.qrc" > <iconset resource="icons.qrc" >:/Icons/password.png</iconset>
<normaloff>:/Icons/password.png</normaloff>:/Icons/password.png</iconset>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<item> <item>
@ -1897,7 +1921,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>21</width> <width>21</width>
<height>29</height> <height>29</height>
@ -1982,7 +2006,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>198</width> <width>198</width>
<height>57</height> <height>57</height>
@ -1998,7 +2022,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" >
<size> <size>
<width>623</width> <width>623</width>
<height>41</height> <height>41</height>
@ -2015,7 +2039,16 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="margin" > <property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -2024,7 +2057,7 @@
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="standardButtons" > <property name="standardButtons" >
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property> </property>
<property name="centerButtons" > <property name="centerButtons" >
<bool>true</bool> <bool>true</bool>

View file

@ -210,6 +210,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
connect(checkEnableRSS, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(checkEnableRSS, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
connect(checkEnableQueueing, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(checkEnableQueueing, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
connect(spinMaxActiveDownloads, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinMaxActiveDownloads, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(spinMaxActiveTorrents, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
// Web UI tab // Web UI tab
connect(checkWebUi, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkWebUi, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(spinWebUiPort, SIGNAL(valueChanged(int)), this, SLOT(enableApplyButton())); connect(spinWebUiPort, SIGNAL(valueChanged(int)), this, SLOT(enableApplyButton()));
@ -354,6 +355,7 @@ void options_imp::saveOptions(){
settings.beginGroup("Queueing"); settings.beginGroup("Queueing");
settings.setValue(QString::fromUtf8("QueueingEnabled"), isQueueingSystemEnabled()); settings.setValue(QString::fromUtf8("QueueingEnabled"), isQueueingSystemEnabled());
settings.setValue(QString::fromUtf8("MaxActiveDownloads"), spinMaxActiveDownloads->value()); settings.setValue(QString::fromUtf8("MaxActiveDownloads"), spinMaxActiveDownloads->value());
settings.setValue(QString::fromUtf8("MaxActiveTorrents"), spinMaxActiveTorrents->value());
// End Queueing system preferences // End Queueing system preferences
settings.endGroup(); settings.endGroup();
// Web UI // Web UI
@ -635,6 +637,7 @@ void options_imp::loadOptions(){
if(isQueueingSystemEnabled()) { if(isQueueingSystemEnabled()) {
enableQueueingSystem(2); // Enable enableQueueingSystem(2); // Enable
spinMaxActiveDownloads->setValue(settings.value(QString::fromUtf8("MaxActiveDownloads"), 3).toInt()); spinMaxActiveDownloads->setValue(settings.value(QString::fromUtf8("MaxActiveDownloads"), 3).toInt());
spinMaxActiveTorrents->setValue(settings.value(QString::fromUtf8("MaxActiveTorrents"), 5).toInt());
} else { } else {
enableQueueingSystem(0); // Disable enableQueueingSystem(0); // Disable
} }
@ -665,6 +668,10 @@ int options_imp::getMaxActiveDownloads() const {
return spinMaxActiveDownloads->value(); return spinMaxActiveDownloads->value();
} }
int options_imp::getMaxActiveTorrents() const {
return spinMaxActiveTorrents->value();
}
bool options_imp::minimizeToTray() const{ bool options_imp::minimizeToTray() const{
if(checkNoSystray->isChecked()) return false; if(checkNoSystray->isChecked()) return false;
return checkMinimizeToSysTray->isChecked(); return checkMinimizeToSysTray->isChecked();
@ -855,10 +862,14 @@ void options_imp::enableQueueingSystem(int checkBoxValue) {
//Disable //Disable
spinMaxActiveDownloads->setEnabled(false); spinMaxActiveDownloads->setEnabled(false);
label_max_active->setEnabled(false); label_max_active->setEnabled(false);
maxActiveTorrents_lbl->setEnabled(false);
spinMaxActiveTorrents->setEnabled(false);
}else{ }else{
//enable //enable
spinMaxActiveDownloads->setEnabled(true); spinMaxActiveDownloads->setEnabled(true);
label_max_active->setEnabled(true); label_max_active->setEnabled(true);
maxActiveTorrents_lbl->setEnabled(true);
spinMaxActiveTorrents->setEnabled(true);
} }
} }

View file

@ -110,6 +110,7 @@ class options_imp : public QDialog, private Ui::Dialog {
// Queueing system // Queueing system
bool isQueueingSystemEnabled() const; bool isQueueingSystemEnabled() const;
int getMaxActiveDownloads() const; int getMaxActiveDownloads() const;
int getMaxActiveTorrents() const;
bool isWebUiEnabled() const; bool isWebUiEnabled() const;
quint16 webUiPort() const; quint16 webUiPort() const;
QString webUiUsername() const; QString webUiUsername() const;

View file

@ -134,6 +134,11 @@
<string>Buy it</string> <string>Buy it</string>
</property> </property>
</action> </action>
<action name="actionHOSColPriority" >
<property name="text" >
<string>Priority</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="icons.qrc" /> <include location="icons.qrc" />