- Use libtorrent queueing system (probably buggy and queueing currently does not work for seeds)

This commit is contained in:
Christophe Dumez 2008-11-02 10:47:59 +00:00
parent 0538c9c3e8
commit f3729fbae6
8 changed files with 182 additions and 535 deletions

View file

@ -1031,6 +1031,39 @@ void GUI::configureSession(bool deleteOptions) {
} }
sessionSettings.upnp_ignore_nonrouters = true; sessionSettings.upnp_ignore_nonrouters = true;
sessionSettings.use_dht_as_fallback = false; sessionSettings.use_dht_as_fallback = false;
// Queueing System
if(options->isQueueingSystemEnabled()) {
if(!BTSession->isQueueingEnabled()) {
downloadingTorrentTab->hidePriorityColumn(false);
finishedTorrentTab->hidePriorityColumn(false);
actionDecreasePriority->setVisible(true);
actionIncreasePriority->setVisible(true);
prioSeparator->setVisible(true);
prioSeparator2->setVisible(true);
toolBar->layout()->setSpacing(7);
}
int max_torrents = options->getMaxActiveTorrents();
int max_downloads = options->getMaxActiveDownloads();
int max_seeds = options->getMaxActiveUploads();
sessionSettings.active_limit = max_torrents;
sessionSettings.active_downloads = max_downloads;
sessionSettings.active_seeds = max_seeds;
BTSession->setQueueingEnabled(true);
} else {
if(BTSession->isQueueingEnabled()) {
sessionSettings.active_limit = -1;
sessionSettings.active_downloads = -1;
sessionSettings.active_seeds = -1;
BTSession->setQueueingEnabled(false);
downloadingTorrentTab->hidePriorityColumn(true);
finishedTorrentTab->hidePriorityColumn(true);
actionDecreasePriority->setVisible(false);
actionIncreasePriority->setVisible(false);
prioSeparator->setVisible(false);
prioSeparator2->setVisible(false);
toolBar->layout()->setSpacing(7);
}
}
BTSession->setSessionSettings(sessionSettings); BTSession->setSessionSettings(sessionSettings);
// Bittorrent // Bittorrent
// * Max connections limit // * Max connections limit
@ -1107,36 +1140,6 @@ void GUI::configureSession(bool deleteOptions) {
} else { } else {
displayRSSTab(false); displayRSSTab(false);
} }
// Queueing System
if(options->isQueueingSystemEnabled()) {
if(!BTSession->isQueueingEnabled()) {
downloadingTorrentTab->hidePriorityColumn(false);
finishedTorrentTab->hidePriorityColumn(false);
actionDecreasePriority->setVisible(true);
actionIncreasePriority->setVisible(true);
prioSeparator->setVisible(true);
prioSeparator2->setVisible(true);
toolBar->layout()->setSpacing(7);
}
int max_torrents = options->getMaxActiveTorrents();
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);
} else {
if(BTSession->isQueueingEnabled()) {
BTSession->setQueueingEnabled(false);
downloadingTorrentTab->hidePriorityColumn(true);
finishedTorrentTab->hidePriorityColumn(true);
actionDecreasePriority->setVisible(false);
actionIncreasePriority->setVisible(false);
prioSeparator->setVisible(false);
prioSeparator2->setVisible(false);
toolBar->layout()->setSpacing(7);
}
}
// Clean up // Clean up
if(deleteOptions) { if(deleteOptions) {
delete options; delete options;

View file

@ -70,10 +70,6 @@ bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false
connect(downloader, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString))); connect(downloader, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString)));
BigRatioTimer = 0; BigRatioTimer = 0;
filterParser = 0; filterParser = 0;
downloadQueue = 0;
queuedDownloads = 0;
uploadQueue = 0;
queuedUploads = 0;
qDebug("* BTSession constructed"); qDebug("* BTSession constructed");
} }
@ -99,16 +95,6 @@ bittorrent::~bittorrent() {
if(filterParser) if(filterParser)
delete filterParser; delete filterParser;
delete downloader; delete downloader;
if(queueingEnabled) {
Q_ASSERT(downloadQueue);
delete downloadQueue;
Q_ASSERT(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");
delete s; delete s;
@ -171,161 +157,41 @@ bool bittorrent::isQueueingEnabled() const {
return queueingEnabled; return queueingEnabled;
} }
void bittorrent::setMaxActiveDownloads(int val) {
if(val != maxActiveDownloads) {
maxActiveDownloads = val;
if(queueingEnabled) {
updateDownloadQueue();
updateUploadQueue();
}
}
}
void bittorrent::setMaxActiveTorrents(int val) {
if(val != maxActiveTorrents) {
maxActiveTorrents = val;
if(queueingEnabled) {
updateDownloadQueue();
updateUploadQueue();
}
}
}
void bittorrent::increaseDlTorrentPriority(QString hash) { void bittorrent::increaseDlTorrentPriority(QString hash) {
Q_ASSERT(queueingEnabled); Q_ASSERT(queueingEnabled);
int index = downloadQueue->indexOf(hash); QTorrentHandle h = getTorrentHandle(hash);
Q_ASSERT(index != -1); h.queue_position_up();
if(index > 0) {
downloadQueue->swap(index-1, index);
saveTorrentPriority(hash, index-1);
saveTorrentPriority(downloadQueue->at(index), index);
updateDownloadQueue();
}
} }
void bittorrent::increaseUpTorrentPriority(QString hash) { void bittorrent::increaseUpTorrentPriority(QString hash) {
Q_ASSERT(queueingEnabled); Q_ASSERT(queueingEnabled);
int index = uploadQueue->indexOf(hash); QTorrentHandle h = getTorrentHandle(hash);
Q_ASSERT(index != -1); h.queue_position_up();
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) {
Q_ASSERT(queueingEnabled); Q_ASSERT(queueingEnabled);
int index = downloadQueue->indexOf(hash); QTorrentHandle h = getTorrentHandle(hash);
Q_ASSERT(index != -1); h.queue_position_down();
if(index >= 0 && index < (downloadQueue->size()-1)) {
downloadQueue->swap(index+1, index);
saveTorrentPriority(hash, index+1);
saveTorrentPriority(downloadQueue->at(index), index);
updateDownloadQueue();
}
} }
void bittorrent::decreaseUpTorrentPriority(QString hash) { void bittorrent::decreaseUpTorrentPriority(QString hash) {
Q_ASSERT(queueingEnabled); Q_ASSERT(queueingEnabled);
int index = uploadQueue->indexOf(hash); QTorrentHandle h = getTorrentHandle(hash);
Q_ASSERT(index != -1); h.queue_position_down();
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
QFile prio_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio");
prio_file.open(QIODevice::WriteOnly | QIODevice::Text);
prio_file.write(QByteArray::number(prio));
prio_file.close();
}
void bittorrent::fixTorrentPriorities() {
Q_ASSERT(queueingEnabled);
// Load priorities
QList<QPair<int, QString> > tmp_list;
QStringList noprio;
foreach(QString hash, unfinishedTorrents) {
int prio = loadTorrentPriority(hash);
if(prio != -1) {
misc::insertSort2<QString>(tmp_list, QPair<int,QString>(prio,hash), Qt::AscendingOrder);
} else {
noprio << hash;
}
}
downloadQueue->clear();
QPair<int,QString> couple;
foreach(couple, tmp_list) {
downloadQueue->append(couple.second);
}
(*downloadQueue)<<noprio;
// Cleanup
tmp_list.clear();
noprio.clear();
// save priorities
int i=0;
foreach(QString hash, *downloadQueue) {
saveTorrentPriority(hash, i);
++i;
}
queuedDownloads->clear();
updateDownloadQueue();
foreach(QString hash, finishedTorrents) {
int prio = loadTorrentPriority(hash);
if(prio != -1) {
misc::insertSort2<QString>(tmp_list, QPair<int,QString>(prio,hash), Qt::AscendingOrder);
} else {
noprio << hash;
}
}
uploadQueue->clear();
foreach(couple, tmp_list) {
uploadQueue->append(couple.second);
}
(*uploadQueue)<<noprio;
// save priorities
i=0;
foreach(QString hash, *uploadQueue) {
saveTorrentPriority(hash, i);
++i;
}
queuedUploads->clear();
updateUploadQueue();
}
int bittorrent::loadTorrentPriority(QString hash) {
// Read .prio file
QFile prio_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio");
if(prio_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
bool ok = false;
int prio = prio_file.readAll().toInt(&ok);
prio_file.close();
if(!ok) {
qDebug("Could not convert prio to integer !!!!!!!");
return -1;
}
qDebug("Prio is %d", prio);
return prio;
}
qDebug(".prio file does not exist !!!!!");
return -1;
} }
bool bittorrent::isDownloadQueued(QString hash) const { bool bittorrent::isDownloadQueued(QString hash) const {
Q_ASSERT(queueingEnabled); Q_ASSERT(queueingEnabled);
return queuedDownloads->contains(hash); QTorrentHandle h = getTorrentHandle(hash);
return h.queue_position() >= 0;
} }
bool bittorrent::isUploadQueued(QString hash) const { bool bittorrent::isUploadQueued(QString hash) const {
// FIXME: libtorrent does not support this.
Q_ASSERT(queueingEnabled); Q_ASSERT(queueingEnabled);
return queuedUploads->contains(hash); QTorrentHandle h = getTorrentHandle(hash);
return h.queue_position() >= 0;
} }
void bittorrent::setUploadLimit(QString hash, long val) { void bittorrent::setUploadLimit(QString hash, long val) {
@ -336,14 +202,6 @@ void bittorrent::setUploadLimit(QString hash, long val) {
saveTorrentSpeedLimits(hash); saveTorrentSpeedLimits(hash);
} }
int bittorrent::getMaximumActiveDownloads() const {
return maxActiveDownloads;
}
int bittorrent::getMaximumActiveTorrents() const {
return maxActiveTorrents;
}
void bittorrent::handleDownloadFailure(QString url, QString reason) { void bittorrent::handleDownloadFailure(QString url, QString reason) {
emit downloadFromUrlFailure(url, reason); emit downloadFromUrlFailure(url, reason);
} }
@ -356,171 +214,19 @@ void bittorrent::setQueueingEnabled(bool enable) {
if(queueingEnabled != enable) { if(queueingEnabled != enable) {
qDebug("Queueing system is changing state..."); qDebug("Queueing system is changing state...");
queueingEnabled = enable; queueingEnabled = enable;
if(enable) {
downloadQueue = new QStringList();
uploadQueue = new QStringList();
queuedUploads = new QStringList();
queuedDownloads = new QStringList();
fixTorrentPriorities();
} else {
// Unqueue torrents
foreach(QString hash, *queuedDownloads) {
QTorrentHandle h = getTorrentHandle(hash);
h.resume();
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued")) {
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
}
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio")) {
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio");
}
}
foreach(QString hash, *queuedUploads) {
QTorrentHandle h = getTorrentHandle(hash);
h.resume();
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued")) {
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
}
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio")) {
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio");
}
}
delete downloadQueue;
downloadQueue = 0;
delete queuedDownloads;
queuedDownloads = 0;
delete uploadQueue;
uploadQueue = 0;
delete queuedUploads;
queuedUploads = 0;
}
} }
} }
int bittorrent::getDlTorrentPriority(QString hash) const { int bittorrent::getDlTorrentPriority(QString hash) const {
Q_ASSERT(downloadQueue != 0); Q_ASSERT(queueingEnabled);
return downloadQueue->indexOf(hash); QTorrentHandle h = getTorrentHandle(hash);
return h.queue_position();
} }
int bittorrent::getUpTorrentPriority(QString hash) const { int bittorrent::getUpTorrentPriority(QString hash) const {
Q_ASSERT(uploadQueue != 0);
return uploadQueue->indexOf(hash);
}
void bittorrent::updateUploadQueue() {
Q_ASSERT(queueingEnabled); Q_ASSERT(queueingEnabled);
bool change = false;
int maxActiveUploads = maxActiveTorrents - currentActiveDownloads;
int currentActiveUploads = 0;
// Check if it is necessary to queue uploads
foreach(QString hash, *uploadQueue) {
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
if(!h.is_paused()) { return h.queue_position();
if(currentActiveUploads < maxActiveUploads) {
++currentActiveUploads;
} else {
// Queue it
h.pause();
change = true;
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();
change = true;
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(queuedUploads->contains(hash)) {
QTorrentHandle h = getTorrentHandle(hash);
h.resume();
change = true;
queuedUploads->removeAll(hash);
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
++currentActiveUploads;
}
} else {
break;
}
}
}
if(change) {
emit updateFinishedTorrentNumber();
emit forceFinishedListUpdate();
}
}
void bittorrent::updateDownloadQueue() {
Q_ASSERT(queueingEnabled);
bool change = false;
currentActiveDownloads = 0;
// Check if it is necessary to queue torrents
foreach(QString hash, *downloadQueue) {
QTorrentHandle h = getTorrentHandle(hash);
if(!h.is_paused()) {
if(currentActiveDownloads < maxActiveDownloads) {
++currentActiveDownloads;
} else {
// Queue it
h.pause();
change = true;
if(!queuedDownloads->contains(hash)) {
queuedDownloads->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(currentActiveDownloads < maxActiveDownloads && isDownloadQueued(hash)) {
QTorrentHandle h = getTorrentHandle(hash);
h.resume();
change = true;
queuedDownloads->removeAll(hash);
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
++currentActiveDownloads;
}
}
}
if(currentActiveDownloads < maxActiveDownloads) {
// Could not fill download slots, unqueue torrents
foreach(QString hash, *downloadQueue) {
if(downloadQueue->size() != 0 && currentActiveDownloads < maxActiveDownloads) {
if(queuedDownloads->contains(hash)) {
QTorrentHandle h = getTorrentHandle(hash);
h.resume();
change = true;
queuedDownloads->removeAll(hash);
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
++currentActiveDownloads;
}
} else {
break;
}
}
}
if(change) {
emit updateUnfinishedTorrentNumber();
emit forceUnfinishedListUpdate();
}
} }
// Calculate the ETA using GASA // Calculate the ETA using GASA
@ -632,23 +338,6 @@ 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 or UploadQueue
if(queueingEnabled) {
if(downloadQueue->contains(hash)) {
downloadQueue->removeAll(hash);
queuedDownloads->removeAll(hash);
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) if(permanent)
addConsoleMessage(tr("'%1' was removed permanently.", "'xxx.avi' was removed permanently.").arg(fileName)); addConsoleMessage(tr("'%1' was removed permanently.", "'xxx.avi' was removed permanently.").arg(fileName));
else else
@ -686,24 +375,6 @@ void bittorrent::setUnfinishedTorrent(QString hash) {
TorrentsStartTime[hash] = QDateTime::currentDateTime(); TorrentsStartTime[hash] = QDateTime::currentDateTime();
} }
} }
if(queueingEnabled) {
// Remove it from uploadQueue
if(uploadQueue->contains(hash)) {
uploadQueue->removeAll(hash);
queuedUploads->removeAll(hash);
/*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");*/
updateUploadQueue();
}
// Add it to downloadQueue
if(!downloadQueue->contains(hash)) {
downloadQueue->append(hash);
saveTorrentPriority(hash, downloadQueue->size()-1);
updateDownloadQueue();
}
}
//emit torrentSwitchedtoUnfinished(hash); //emit torrentSwitchedtoUnfinished(hash);
} }
@ -726,20 +397,6 @@ void bittorrent::setFinishedTorrent(QString hash) {
TorrentsStartTime.remove(hash); TorrentsStartTime.remove(hash);
TorrentsStartData.remove(hash); TorrentsStartData.remove(hash);
} }
// Remove it from
if(queueingEnabled) {
downloadQueue->removeAll(hash);
queuedDownloads->removeAll(hash);
/*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");*/
updateDownloadQueue();
if(!uploadQueue->contains(hash)) {
uploadQueue->append(hash);
updateUploadQueue();
}
}
//emit torrentSwitchedtoFinished(hash); //emit torrentSwitchedtoFinished(hash);
} }
@ -752,32 +409,15 @@ bool bittorrent::pauseTorrent(QString hash) {
change = true; change = true;
// Save fast resume data // Save fast resume data
saveFastResumeData(hash); saveFastResumeData(hash);
if(queueingEnabled) {
updateDownloadQueue();
updateUploadQueue();
}
qDebug("Torrent paused successfully"); qDebug("Torrent paused successfully");
emit pausedTorrent(hash); emit pausedTorrent(hash);
}else{ }else{
if(!h.is_valid()) { if(!h.is_valid()) {
qDebug("Could not pause torrent %s, reason: invalid", hash.toUtf8().data()); qDebug("Could not pause torrent %s, reason: invalid", hash.toUtf8().data());
}else{
if(queueingEnabled && (isDownloadQueued(hash)||isUploadQueued(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");
updateDownloadQueue();
updateUploadQueue();
change = true;
}else{ }else{
qDebug("Could not pause torrent %s, reason: already paused", hash.toUtf8().data()); qDebug("Could not pause torrent %s, reason: already paused", hash.toUtf8().data());
} }
} }
}
// Create .paused file if necessary // Create .paused file if necessary
QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused"); QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
paused_file.open(QIODevice::WriteOnly | QIODevice::Text); paused_file.open(QIODevice::WriteOnly | QIODevice::Text);
@ -799,7 +439,6 @@ bool bittorrent::resumeTorrent(QString hash) {
bool change = false; bool change = false;
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
if(h.is_valid() && h.is_paused()) { if(h.is_valid() && h.is_paused()) {
if(!(queueingEnabled && (isDownloadQueued(hash)||isUploadQueued(hash)))) {
// Save Addition DateTime // Save Addition DateTime
if(calculateETA) { if(calculateETA) {
TorrentsStartData[hash] = h.total_payload_download(); TorrentsStartData[hash] = h.total_payload_download();
@ -809,14 +448,9 @@ bool bittorrent::resumeTorrent(QString hash) {
change = true; change = true;
emit resumedTorrent(hash); emit resumedTorrent(hash);
} }
}
// Delete .paused file // Delete .paused file
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused"); QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
if(queueingEnabled) {
updateDownloadQueue();
updateUploadQueue();
}
if(change) { if(change) {
addConsoleMessage(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(h.name())); addConsoleMessage(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(h.name()));
} }
@ -1013,18 +647,8 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
} }
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(!resumed && queueingEnabled) {
uploadQueue->append(hash);
saveTorrentPriority(hash, uploadQueue->size()-1);
updateUploadQueue();
}
}else{ }else{
unfinishedTorrents << hash; unfinishedTorrents << hash;
if(!resumed && queueingEnabled) {
downloadQueue->append(hash);
saveTorrentPriority(hash, downloadQueue->size()-1);
updateDownloadQueue();
}
} }
// If download from url, remove temp file // If download from url, remove temp file
if(!from_url.isNull()) QFile::remove(file); if(!from_url.isNull()) QFile::remove(file);
@ -1864,8 +1488,5 @@ void bittorrent::resumeUnfinishedTorrents() {
foreach(fileName, filePaths) { foreach(fileName, filePaths) {
addTorrent(fileName, false, QString(), true); addTorrent(fileName, false, QString(), true);
} }
if(queueingEnabled) {
fixTorrentPriorities();
}
qDebug("Unfinished torrents resumed"); qDebug("Unfinished torrents resumed");
} }

View file

@ -74,13 +74,6 @@ class bittorrent : public QObject {
QString filterPath; QString filterPath;
int folderScanInterval; // in seconds int folderScanInterval; // in seconds
bool queueingEnabled; bool queueingEnabled;
int maxActiveDownloads;
int maxActiveTorrents;
int currentActiveDownloads;
QStringList *downloadQueue;
QStringList *queuedDownloads;
QStringList *uploadQueue;
QStringList *queuedUploads;
bool calculateETA; bool calculateETA;
QStringList url_skippingDlg; QStringList url_skippingDlg;
@ -145,13 +138,10 @@ class bittorrent : public QObject {
void loadTorrentSpeedLimits(QString hash); void loadTorrentSpeedLimits(QString hash);
void handleDownloadFailure(QString url, QString reason); void handleDownloadFailure(QString url, QString reason);
void loadWebSeeds(QString fileHash); void loadWebSeeds(QString fileHash);
void updateDownloadQueue();
void updateUploadQueue();
void increaseDlTorrentPriority(QString hash); void increaseDlTorrentPriority(QString hash);
void decreaseDlTorrentPriority(QString hash); void decreaseDlTorrentPriority(QString hash);
void increaseUpTorrentPriority(QString hash); void increaseUpTorrentPriority(QString hash);
void decreaseUpTorrentPriority(QString hash); void decreaseUpTorrentPriority(QString hash);
void saveTorrentPriority(QString hash, int prio);
void downloadUrlAndSkipDialog(QString); void downloadUrlAndSkipDialog(QString);
// Session configuration - Setters // Session configuration - Setters
void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports); void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports);
@ -178,12 +168,9 @@ class bittorrent : public QObject {
void enableLSD(bool b); void enableLSD(bool b);
bool enableDHT(bool b); bool enableDHT(bool b);
void setTimerScanInterval(int secs); void setTimerScanInterval(int secs);
void setMaxActiveDownloads(int val);
void setMaxActiveTorrents(int val);
void setETACalculation(bool enable); void setETACalculation(bool enable);
void addConsoleMessage(QString msg, QColor color=QApplication::palette().color(QPalette::WindowText)); void addConsoleMessage(QString msg, QColor color=QApplication::palette().color(QPalette::WindowText));
void addPeerBanMessage(QString msg, bool from_ipfilter); void addPeerBanMessage(QString msg, bool from_ipfilter);
void fixTorrentPriorities();
protected slots: protected slots:
void scanDirectory(); void scanDirectory();

View file

@ -22,16 +22,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<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>
@ -87,7 +78,8 @@
<string>General</string> <string>General</string>
</attribute> </attribute>
<attribute name="icon" > <attribute name="icon" >
<iconset resource="icons.qrc" >:/Icons/star.png</iconset> <iconset resource="icons.qrc" >
<normaloff>:/Icons/star.png</normaloff>:/Icons/star.png</iconset>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<item> <item>
@ -120,7 +112,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -189,7 +181,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -260,7 +252,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -328,7 +320,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>623</width> <width>623</width>
<height>20</height> <height>20</height>
@ -343,7 +335,8 @@
<string>Downloads</string> <string>Downloads</string>
</attribute> </attribute>
<attribute name="icon" > <attribute name="icon" >
<iconset resource="icons.qrc" >:/Icons/download.png</iconset> <iconset resource="icons.qrc" >
<normaloff>:/Icons/download.png</normaloff>:/Icons/download.png</iconset>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<item> <item>
@ -370,16 +363,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<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>
@ -387,16 +371,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<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>
@ -456,7 +431,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -500,16 +475,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<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>
@ -619,7 +585,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -662,7 +628,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -682,7 +648,8 @@
<string>Connection</string> <string>Connection</string>
</attribute> </attribute>
<attribute name="icon" > <attribute name="icon" >
<iconset resource="icons.qrc" >:/Icons/connection.png</iconset> <iconset resource="icons.qrc" >
<normaloff>:/Icons/connection.png</normaloff>:/Icons/connection.png</iconset>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<item> <item>
@ -745,7 +712,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>20</width> <width>20</width>
<height>20</height> <height>20</height>
@ -904,7 +871,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -922,7 +889,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>623</width> <width>623</width>
<height>121</height> <height>121</height>
@ -937,7 +904,8 @@
<string>Bittorrent</string> <string>Bittorrent</string>
</attribute> </attribute>
<attribute name="icon" > <attribute name="icon" >
<iconset resource="icons.qrc" >:/Icons/bt_settings.png</iconset> <iconset resource="icons.qrc" >
<normaloff>:/Icons/bt_settings.png</normaloff>:/Icons/bt_settings.png</iconset>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<item> <item>
@ -984,7 +952,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1029,7 +997,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1071,7 +1039,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1160,7 +1128,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1223,7 +1191,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1277,7 +1245,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1295,7 +1263,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>20</width> <width>20</width>
<height>40</height> <height>40</height>
@ -1310,7 +1278,8 @@
<string>Proxy</string> <string>Proxy</string>
</attribute> </attribute>
<attribute name="icon" > <attribute name="icon" >
<iconset resource="icons.qrc" >:/Icons/proxy.png</iconset> <iconset resource="icons.qrc" >
<normaloff>:/Icons/proxy.png</normaloff>:/Icons/proxy.png</iconset>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<item> <item>
@ -1396,7 +1365,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>21</width> <width>21</width>
<height>29</height> <height>29</height>
@ -1485,7 +1454,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1591,7 +1560,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>21</width> <width>21</width>
<height>29</height> <height>29</height>
@ -1680,7 +1649,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1784,9 +1753,10 @@
<string>Misc</string> <string>Misc</string>
</attribute> </attribute>
<attribute name="icon" > <attribute name="icon" >
<iconset resource="icons.qrc" >:/Icons/configure.png</iconset> <iconset resource="icons.qrc" >
<normaloff>:/Icons/configure.png</normaloff>:/Icons/configure.png</iconset>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" name="verticalLayout_2" >
<item> <item>
<widget class="QGroupBox" name="filterBox" > <widget class="QGroupBox" name="filterBox" >
<property name="enabled" > <property name="enabled" >
@ -1802,7 +1772,8 @@
<string>Activate IP Filtering</string> <string>Activate IP Filtering</string>
</property> </property>
<property name="icon" > <property name="icon" >
<iconset resource="icons.qrc" >:/Icons/filter.png</iconset> <iconset resource="icons.qrc" >
<normaloff>:/Icons/filter.png</normaloff>:/Icons/filter.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
@ -1925,7 +1896,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1959,7 +1930,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1984,7 +1955,7 @@
<property name="title" > <property name="title" >
<string>Torrent queueing</string> <string>Torrent queueing</string>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" name="verticalLayout" >
<item> <item>
<widget class="QCheckBox" name="checkEnableQueueing" > <widget class="QCheckBox" name="checkEnableQueueing" >
<property name="text" > <property name="text" >
@ -1995,7 +1966,7 @@
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<item> <item>
<widget class="QLabel" name="label_max_active" > <widget class="QLabel" name="label_max_active_dl" >
<property name="enabled" > <property name="enabled" >
<bool>false</bool> <bool>false</bool>
</property> </property>
@ -2025,7 +1996,50 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="_2" >
<item>
<widget class="QLabel" name="label_max_active_up" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Maximum active uploads:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinMaxActiveUploads" >
<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>3</number>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -2068,7 +2082,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>381</width> <width>381</width>
<height>20</height> <height>20</height>
@ -2086,7 +2100,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>623</width> <width>623</width>
<height>20</height> <height>20</height>
@ -2101,7 +2115,8 @@
<string>Web UI</string> <string>Web UI</string>
</attribute> </attribute>
<attribute name="icon" > <attribute name="icon" >
<iconset resource="icons.qrc" >:/Icons/password.png</iconset> <iconset resource="icons.qrc" >
<normaloff>:/Icons/password.png</normaloff>:/Icons/password.png</iconset>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<item> <item>
@ -2154,7 +2169,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>21</width> <width>21</width>
<height>29</height> <height>29</height>
@ -2239,7 +2254,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>198</width> <width>198</width>
<height>57</height> <height>57</height>
@ -2255,7 +2270,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>623</width> <width>623</width>
<height>41</height> <height>41</height>
@ -2272,16 +2287,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<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>
@ -2290,7 +2296,7 @@
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="standardButtons" > <property name="standardButtons" >
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property> </property>
<property name="centerButtons" > <property name="centerButtons" >
<bool>true</bool> <bool>true</bool>

View file

@ -385,6 +385,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("MaxActiveUploads"), spinMaxActiveUploads->value());
settings.setValue(QString::fromUtf8("MaxActiveTorrents"), spinMaxActiveTorrents->value()); settings.setValue(QString::fromUtf8("MaxActiveTorrents"), spinMaxActiveTorrents->value());
// End Queueing system preferences // End Queueing system preferences
settings.endGroup(); settings.endGroup();
@ -703,6 +704,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());
spinMaxActiveUploads->setValue(settings.value(QString::fromUtf8("MaxActiveUploads"), 3).toInt());
spinMaxActiveTorrents->setValue(settings.value(QString::fromUtf8("MaxActiveTorrents"), 5).toInt()); spinMaxActiveTorrents->setValue(settings.value(QString::fromUtf8("MaxActiveTorrents"), 5).toInt());
} else { } else {
enableQueueingSystem(0); // Disable enableQueueingSystem(0); // Disable
@ -734,6 +736,10 @@ int options_imp::getMaxActiveDownloads() const {
return spinMaxActiveDownloads->value(); return spinMaxActiveDownloads->value();
} }
int options_imp::getMaxActiveUploads() const {
return spinMaxActiveUploads->value();
}
int options_imp::getMaxActiveTorrents() const { int options_imp::getMaxActiveTorrents() const {
return spinMaxActiveTorrents->value(); return spinMaxActiveTorrents->value();
} }
@ -927,13 +933,17 @@ void options_imp::enableQueueingSystem(int checkBoxValue) {
if(checkBoxValue != 2) { if(checkBoxValue != 2) {
//Disable //Disable
spinMaxActiveDownloads->setEnabled(false); spinMaxActiveDownloads->setEnabled(false);
label_max_active->setEnabled(false); spinMaxActiveUploads->setEnabled(false);
label_max_active_dl->setEnabled(false);
label_max_active_up->setEnabled(false);
maxActiveTorrents_lbl->setEnabled(false); maxActiveTorrents_lbl->setEnabled(false);
spinMaxActiveTorrents->setEnabled(false); spinMaxActiveTorrents->setEnabled(false);
}else{ }else{
//enable //enable
spinMaxActiveDownloads->setEnabled(true); spinMaxActiveDownloads->setEnabled(true);
label_max_active->setEnabled(true); spinMaxActiveUploads->setEnabled(true);
label_max_active_dl->setEnabled(true);
label_max_active_up->setEnabled(true);
maxActiveTorrents_lbl->setEnabled(true); maxActiveTorrents_lbl->setEnabled(true);
spinMaxActiveTorrents->setEnabled(true); spinMaxActiveTorrents->setEnabled(true);
} }

View file

@ -119,6 +119,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 getMaxActiveUploads() const;
int getMaxActiveTorrents() const; int getMaxActiveTorrents() const;
bool isWebUiEnabled() const; bool isWebUiEnabled() const;
quint16 webUiPort() const; quint16 webUiPort() const;

View file

@ -266,6 +266,11 @@ QStringList QTorrentHandle::files_path() const {
return res; return res;
} }
int QTorrentHandle::queue_position() const {
Q_ASSERT(h.is_valid());
return h.queue_position();
}
int QTorrentHandle::num_uploads() const { int QTorrentHandle::num_uploads() const {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
return h.status().num_uploads; return h.status().num_uploads;
@ -335,6 +340,17 @@ void QTorrentHandle::replace_trackers(std::vector<announce_entry> const& v) cons
h.replace_trackers(v); h.replace_trackers(v);
} }
void QTorrentHandle::queue_position_down() const {
Q_ASSERT(h.is_valid());
h.queue_position_down();
}
void QTorrentHandle::queue_position_up() const {
Q_ASSERT(h.is_valid());
h.queue_position_up();
}
void QTorrentHandle::force_reannounce() { void QTorrentHandle::force_reannounce() {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
h.force_reannounce(); h.force_reannounce();

View file

@ -77,6 +77,7 @@ class QTorrentHandle {
int num_files() const; int num_files() const;
bool has_metadata() const; bool has_metadata() const;
void save_resume_data() const; void save_resume_data() const;
int queue_position() const;
QString file_at(unsigned int index) const; QString file_at(unsigned int index) const;
size_type filesize_at(unsigned int index) const; size_type filesize_at(unsigned int index) const;
std::vector<announce_entry> const& trackers() const; std::vector<announce_entry> const& trackers() const;
@ -111,6 +112,8 @@ class QTorrentHandle {
void force_reannounce(); void force_reannounce();
void set_sequential_download(bool); void set_sequential_download(bool);
void set_tracker_login(QString username, QString password); void set_tracker_login(QString username, QString password);
void queue_position_down() const;
void queue_position_up() const;
// //
// Operators // Operators