Browse Source

- Queueing system should work fine now (port is complete, needs testing)

adaptive-webui-19844
Christophe Dumez 16 years ago
parent
commit
9b67807926
  1. 3
      src/FinishedListDelegate.h
  2. 48
      src/FinishedTorrents.cpp
  3. 2
      src/FinishedTorrents.h
  4. 11
      src/GUI.cpp
  5. 24
      src/bittorrent.cpp
  6. 6
      src/bittorrent.h
  7. 4
      src/downloadingTorrents.cpp
  8. 14
      src/eventmanager.cpp
  9. 19
      src/qtorrenthandle.cpp
  10. 3
      src/qtorrenthandle.h
  11. 38
      src/seeding.ui

3
src/FinishedListDelegate.h

@ -37,8 +37,7 @@
#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_PRIORITY 5 #define F_HASH 5
#define F_HASH 6
class FinishedListDelegate: public QItemDelegate { class FinishedListDelegate: public QItemDelegate {
Q_OBJECT Q_OBJECT

48
src/FinishedTorrents.cpp

@ -38,17 +38,14 @@ 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(QTorrentHandle&)), this, SLOT(torrentAdded(QTorrentHandle&))); connect(BTSession, SIGNAL(addedTorrent(QTorrentHandle&)), this, SLOT(torrentAdded(QTorrentHandle&)));
finishedListModel = new QStandardItemModel(0,7); finishedListModel = new QStandardItemModel(0,6);
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
@ -74,8 +71,6 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par
connect(actionPause, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionPause_triggered())); connect(actionPause, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionPause_triggered()));
connect(actionStart, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionStart_triggered())); connect(actionStart, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionStart_triggered()));
connect(actionDelete, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_triggered())); connect(actionDelete, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_triggered()));
connect(actionIncreasePriority, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionIncreasePriority_triggered()));
connect(actionDecreasePriority, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDecreasePriority_triggered()));
connect(actionPreview_file, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionPreview_file_triggered())); connect(actionPreview_file, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionPreview_file_triggered()));
connect(actionDelete_Permanently, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_Permanently_triggered())); connect(actionDelete_Permanently, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_Permanently_triggered()));
connect(actionOpen_destination_folder, SIGNAL(triggered()), (GUI*)parent, SLOT(openDestinationFolder())); connect(actionOpen_destination_folder, SIGNAL(triggered()), (GUI*)parent, SLOT(openDestinationFolder()));
@ -87,7 +82,6 @@ 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(){
@ -103,14 +97,6 @@ void FinishedTorrents::notifyTorrentDoubleClicked(const QModelIndex& index) {
emit torrentDoubleClicked(hash, true); emit torrentDoubleClicked(hash, true);
} }
void FinishedTorrents::hidePriorityColumn(bool hide) {
finishedList->setColumnHidden(F_PRIORITY, hide);
if(hide)
getActionHoSCol(F_PRIORITY)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_cancel.png")));
else
getActionHoSCol(F_PRIORITY)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_ok.png")));
}
void FinishedTorrents::addTorrent(QString hash){ void FinishedTorrents::addTorrent(QString hash){
if(!BTSession->isFinished(hash)){ if(!BTSession->isFinished(hash)){
BTSession->setFinishedTorrent(hash); BTSession->setFinishedTorrent(hash);
@ -126,8 +112,6 @@ 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);
@ -271,15 +255,12 @@ void FinishedTorrents::updateFinishedList(){
row = getRowFromHash(hash); row = getRowFromHash(hash);
} }
Q_ASSERT(row != -1); Q_ASSERT(row != -1);
// Update priority // Update queued torrent
if(BTSession->isQueueingEnabled()) { if(BTSession->isQueueingEnabled() && BTSession->isTorrentQueued(hash)) {
finishedListModel->setData(finishedListModel->index(row, F_PRIORITY), QVariant((int)BTSession->getUpTorrentPriority(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); finishedListModel->setData(finishedListModel->index(row, F_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/queued.png"))), Qt::DecorationRole);
setRowColor(row, QString::fromUtf8("grey")); setRowColor(row, QString::fromUtf8("grey"));
} }
} if(h.is_paused() || h.is_queued()) continue;
if(h.is_paused()) continue;
if(h.state() == torrent_status::downloading || (h.state() != torrent_status::checking_files && h.state() != torrent_status::queued_for_checking && h.progress() < 1.)) { if(h.state() == torrent_status::downloading || (h.state() != torrent_status::checking_files && h.state() != torrent_status::queued_for_checking && h.progress() < 1.)) {
// What are you doing here? go back to download tab! // What are you doing here? go back to download tab!
int reponse = QMessageBox::question(this, tr("Incomplete torrent in seeding list"), tr("It appears that the state of '%1' torrent changed from 'seeding' to 'downloading'. Would you like to move it back to download list? (otherwise the torrent will simply be deleted)").arg(h.name()), QMessageBox::Yes | QMessageBox::No); int reponse = QMessageBox::question(this, tr("Incomplete torrent in seeding list"), tr("It appears that the state of '%1' torrent changed from 'seeding' to 'downloading'. Would you like to move it back to download list? (otherwise the torrent will simply be deleted)").arg(h.name()), QMessageBox::Yes | QMessageBox::No);
@ -428,11 +409,6 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint& pos){
myFinishedListMenu.addSeparator(); myFinishedListMenu.addSeparator();
myFinishedListMenu.addAction(actionOpen_destination_folder); myFinishedListMenu.addAction(actionOpen_destination_folder);
myFinishedListMenu.addAction(actionTorrent_Properties); myFinishedListMenu.addAction(actionTorrent_Properties);
if(BTSession->isQueueingEnabled()) {
myFinishedListMenu.addSeparator();
myFinishedListMenu.addAction(actionIncreasePriority);
myFinishedListMenu.addAction(actionDecreasePriority);
}
myFinishedListMenu.addSeparator(); myFinishedListMenu.addSeparator();
myFinishedListMenu.addAction(actionBuy_it); myFinishedListMenu.addAction(actionBuy_it);
@ -450,12 +426,7 @@ 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; int lastCol = F_RATIO;
if(BTSession->isQueueingEnabled()) {
lastCol = F_PRIORITY;
} else {
lastCol = F_RATIO;
}
for(int i=0; i<=lastCol; i++) { for(int i=0; i<=lastCol; i++) {
hideshowColumn.addAction(getActionHoSCol(i)); hideshowColumn.addAction(getActionHoSCol(i));
} }
@ -514,10 +485,6 @@ 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;
@ -579,9 +546,6 @@ 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;
} }
@ -600,7 +564,6 @@ void FinishedTorrents::toggleFinishedListSortOrder(int index) {
switch(index) { switch(index) {
case F_SIZE: case F_SIZE:
case F_UPSPEED: case F_UPSPEED:
case F_PRIORITY:
sortFinishedListFloat(index, sortOrder); sortFinishedListFloat(index, sortOrder);
break; break;
default: default:
@ -625,7 +588,6 @@ void FinishedTorrents::sortFinishedList(int index, Qt::SortOrder sortOrder){
switch(index) { switch(index) {
case F_SIZE: case F_SIZE:
case F_UPSPEED: case F_UPSPEED:
case F_PRIORITY:
sortFinishedListFloat(index, sortOrder); sortFinishedListFloat(index, sortOrder);
break; break;
default: default:

2
src/FinishedTorrents.h

@ -74,7 +74,6 @@ 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);
@ -84,7 +83,6 @@ 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);

11
src/GUI.cpp

@ -1035,7 +1035,6 @@ void GUI::configureSession(bool deleteOptions) {
if(options->isQueueingSystemEnabled()) { if(options->isQueueingSystemEnabled()) {
if(!BTSession->isQueueingEnabled()) { if(!BTSession->isQueueingEnabled()) {
downloadingTorrentTab->hidePriorityColumn(false); downloadingTorrentTab->hidePriorityColumn(false);
finishedTorrentTab->hidePriorityColumn(false);
actionDecreasePriority->setVisible(true); actionDecreasePriority->setVisible(true);
actionIncreasePriority->setVisible(true); actionIncreasePriority->setVisible(true);
prioSeparator->setVisible(true); prioSeparator->setVisible(true);
@ -1056,8 +1055,6 @@ void GUI::configureSession(bool deleteOptions) {
sessionSettings.active_seeds = -1; sessionSettings.active_seeds = -1;
BTSession->setQueueingEnabled(false); BTSession->setQueueingEnabled(false);
downloadingTorrentTab->hidePriorityColumn(true); downloadingTorrentTab->hidePriorityColumn(true);
finishedTorrentTab->hidePriorityColumn(true);
actionDecreasePriority->setVisible(false);
actionIncreasePriority->setVisible(false); actionIncreasePriority->setVisible(false);
prioSeparator->setVisible(false); prioSeparator->setVisible(false);
prioSeparator2->setVisible(false); prioSeparator2->setVisible(false);
@ -1208,7 +1205,7 @@ void GUI::togglePausedState(QString hash) {
if(tabs->currentIndex() == 1) if(tabs->currentIndex() == 1)
inDownloadList = false; inDownloadList = false;
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(BTSession->isPaused(hash) && !(BTSession->isQueueingEnabled() && (BTSession->isDownloadQueued(hash) || BTSession->isUploadQueued(hash)))) { if(BTSession->isPaused(hash)) {
BTSession->resumeTorrent(hash); BTSession->resumeTorrent(hash);
if(inDownloadList) { if(inDownloadList) {
downloadingTorrentTab->resumeTorrent(hash); downloadingTorrentTab->resumeTorrent(hash);
@ -1268,9 +1265,6 @@ void GUI::on_actionIncreasePriority_triggered() {
if(inDownloadList) { if(inDownloadList) {
BTSession->increaseDlTorrentPriority(hash); BTSession->increaseDlTorrentPriority(hash);
downloadingTorrentTab->updateDlList(); downloadingTorrentTab->updateDlList();
} else {
BTSession->increaseUpTorrentPriority(hash);
finishedTorrentTab->updateFinishedList();
} }
} }
} }
@ -1291,9 +1285,6 @@ void GUI::on_actionDecreasePriority_triggered() {
if(inDownloadList) { if(inDownloadList) {
BTSession->decreaseDlTorrentPriority(hash); BTSession->decreaseDlTorrentPriority(hash);
downloadingTorrentTab->updateDlList(); downloadingTorrentTab->updateDlList();
} else {
BTSession->decreaseUpTorrentPriority(hash);
finishedTorrentTab->updateFinishedList();
} }
} }
} }

24
src/bittorrent.cpp

@ -163,35 +163,16 @@ void bittorrent::increaseDlTorrentPriority(QString hash) {
h.queue_position_up(); h.queue_position_up();
} }
void bittorrent::increaseUpTorrentPriority(QString hash) {
Q_ASSERT(queueingEnabled);
QTorrentHandle h = getTorrentHandle(hash);
h.queue_position_up();
}
void bittorrent::decreaseDlTorrentPriority(QString hash) { void bittorrent::decreaseDlTorrentPriority(QString hash) {
Q_ASSERT(queueingEnabled); Q_ASSERT(queueingEnabled);
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
h.queue_position_down(); h.queue_position_down();
} }
void bittorrent::decreaseUpTorrentPriority(QString hash) { bool bittorrent::isTorrentQueued(QString hash) const {
Q_ASSERT(queueingEnabled);
QTorrentHandle h = getTorrentHandle(hash);
h.queue_position_down();
}
bool bittorrent::isDownloadQueued(QString hash) const {
Q_ASSERT(queueingEnabled);
QTorrentHandle h = getTorrentHandle(hash);
return h.queue_position() >= 0;
}
bool bittorrent::isUploadQueued(QString hash) const {
// FIXME: libtorrent does not support this.
Q_ASSERT(queueingEnabled); Q_ASSERT(queueingEnabled);
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
return h.queue_position() >= 0; return h.is_queued();
} }
void bittorrent::setUploadLimit(QString hash, long val) { void bittorrent::setUploadLimit(QString hash, long val) {
@ -220,6 +201,7 @@ void bittorrent::setQueueingEnabled(bool enable) {
int bittorrent::getDlTorrentPriority(QString hash) const { int bittorrent::getDlTorrentPriority(QString hash) const {
Q_ASSERT(queueingEnabled); Q_ASSERT(queueingEnabled);
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
qDebug("Priority for %s is %d", h.name().toUtf8().data(), h.queue_position());
return h.queue_position(); return h.queue_position();
} }

6
src/bittorrent.h

@ -107,8 +107,8 @@ class bittorrent : public QObject {
int getUpTorrentPriority(QString hash) const; int getUpTorrentPriority(QString hash) const;
int getMaximumActiveDownloads() const; int getMaximumActiveDownloads() const;
int getMaximumActiveTorrents() const; int getMaximumActiveTorrents() const;
bool isDownloadQueued(QString hash) const; bool isTorrentQueued(QString hash) const;
bool isUploadQueued(QString hash) const; bool is_auto_managed() const;
int loadTorrentPriority(QString hash); int loadTorrentPriority(QString hash);
QStringList getConsoleMessages() const; QStringList getConsoleMessages() const;
QStringList getPeerBanMessages() const; QStringList getPeerBanMessages() const;
@ -140,8 +140,6 @@ class bittorrent : public QObject {
void loadWebSeeds(QString fileHash); void loadWebSeeds(QString fileHash);
void increaseDlTorrentPriority(QString hash); void increaseDlTorrentPriority(QString hash);
void decreaseDlTorrentPriority(QString hash); void decreaseDlTorrentPriority(QString hash);
void increaseUpTorrentPriority(QString hash);
void decreaseUpTorrentPriority(QString hash);
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);

4
src/downloadingTorrents.cpp

@ -501,7 +501,7 @@ void DownloadingTorrents::updateDlList() {
// Update Priority // Update Priority
if(BTSession->isQueueingEnabled()) { 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(BTSession->isTorrentQueued(hash)) {
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));
@ -510,7 +510,7 @@ void DownloadingTorrents::updateDlList() {
} }
} }
// No need to update a paused torrent // No need to update a paused torrent
if(h.is_paused()) continue; if(h.is_paused() || h.is_queued()) continue;
// Parse download state // Parse download state
// Setting download state // Setting download state
switch(h.state()) { switch(h.state()) {

14
src/eventmanager.cpp

@ -51,10 +51,10 @@ void EventManager::addedTorrent(QTorrentHandle& h)
} }
event["upspeed"] = QVariant(h.upload_payload_rate()); event["upspeed"] = QVariant(h.upload_payload_rate());
if(h.is_paused()) { if(h.is_paused()) {
if(BTSession->isQueueingEnabled() && (BTSession->isDownloadQueued(hash) || BTSession->isUploadQueued(hash)))
event["state"] = QVariant("queued");
else
event["state"] = QVariant("paused"); event["state"] = QVariant("paused");
} else {
if(BTSession->isQueueingEnabled() && h.is_queued()) {
event["state"] = QVariant("queued");
} else{ } else{
switch(h.state()) switch(h.state())
{ {
@ -78,6 +78,7 @@ void EventManager::addedTorrent(QTorrentHandle& h)
event["state"] = QVariant(); event["state"] = QVariant();
} }
} }
}
event_list[hash] = event; event_list[hash] = event;
} }
@ -92,10 +93,10 @@ void EventManager::modifiedTorrent(QTorrentHandle h)
QVariantMap event; QVariantMap event;
if(h.is_paused()) { if(h.is_paused()) {
if(BTSession->isQueueingEnabled() && (BTSession->isDownloadQueued(hash) || BTSession->isUploadQueued(hash)))
event["state"] = QVariant("queued");
else
event["state"] = QVariant("paused"); event["state"] = QVariant("paused");
} else {
if(BTSession->isQueueingEnabled() && h.is_queued()) {
event["state"] = QVariant("queued");
} else { } else {
switch(h.state()) switch(h.state())
{ {
@ -119,6 +120,7 @@ void EventManager::modifiedTorrent(QTorrentHandle h)
event["state"] = QVariant(); event["state"] = QVariant();
} }
} }
}
event["name"] = QVariant(h.name()); event["name"] = QVariant(h.name());
event["size"] = QVariant((qlonglong)h.actual_size()); event["size"] = QVariant((qlonglong)h.actual_size());
if(!h.is_seed()) { if(!h.is_seed()) {

19
src/qtorrenthandle.cpp

@ -85,7 +85,12 @@ bool QTorrentHandle::is_valid() const {
bool QTorrentHandle::is_paused() const { bool QTorrentHandle::is_paused() const {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
return h.is_paused(); return h.is_paused() && !h.is_auto_managed();
}
bool QTorrentHandle::is_queued() const {
Q_ASSERT(h.is_valid());
return h.is_paused() && h.is_auto_managed();
} }
size_type QTorrentHandle::total_size() const { size_type QTorrentHandle::total_size() const {
@ -281,6 +286,11 @@ bool QTorrentHandle::is_seed() const {
return h.is_seed(); return h.is_seed();
} }
bool QTorrentHandle::is_auto_managed() const {
Q_ASSERT(h.is_valid());
return h.is_auto_managed();
}
// //
// Setters // Setters
// //
@ -297,11 +307,13 @@ void QTorrentHandle::set_upload_limit(int limit) {
void QTorrentHandle::pause() { void QTorrentHandle::pause() {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
h.auto_managed(false);
h.pause(); h.pause();
} }
void QTorrentHandle::resume() { void QTorrentHandle::resume() {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
h.auto_managed(true);
h.resume(); h.resume();
} }
@ -340,6 +352,11 @@ void QTorrentHandle::replace_trackers(std::vector<announce_entry> const& v) cons
h.replace_trackers(v); h.replace_trackers(v);
} }
void QTorrentHandle::auto_managed(bool b) const {
Q_ASSERT(h.is_valid());
h.auto_managed(b);
}
void QTorrentHandle::queue_position_down() const { void QTorrentHandle::queue_position_down() const {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
h.queue_position_down(); h.queue_position_down();

3
src/qtorrenthandle.h

@ -78,6 +78,7 @@ class QTorrentHandle {
bool has_metadata() const; bool has_metadata() const;
void save_resume_data() const; void save_resume_data() const;
int queue_position() const; int queue_position() const;
bool is_queued() 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;
@ -93,6 +94,7 @@ class QTorrentHandle {
QStringList files_path() const; QStringList files_path() const;
int num_uploads() const; int num_uploads() const;
bool is_seed() const; bool is_seed() const;
bool is_auto_managed() const;
// //
// Setters // Setters
@ -114,6 +116,7 @@ class QTorrentHandle {
void set_tracker_login(QString username, QString password); void set_tracker_login(QString username, QString password);
void queue_position_down() const; void queue_position_down() const;
void queue_position_up() const; void queue_position_up() const;
void auto_managed(bool) const;
// //
// Operators // Operators

38
src/seeding.ui

@ -16,16 +16,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>
@ -88,7 +79,8 @@
</action> </action>
<action name="actionOpen_destination_folder" > <action name="actionOpen_destination_folder" >
<property name="icon" > <property name="icon" >
<iconset resource="icons.qrc" >:/Icons/folder.png</iconset> <iconset resource="icons.qrc" >
<normaloff>:/Icons/folder.png</normaloff>:/Icons/folder.png</iconset>
</property> </property>
<property name="text" > <property name="text" >
<string>Open destination folder</string> <string>Open destination folder</string>
@ -121,33 +113,13 @@
</action> </action>
<action name="actionBuy_it" > <action name="actionBuy_it" >
<property name="icon" > <property name="icon" >
<iconset resource="icons.qrc" >:/Icons/money.png</iconset> <iconset resource="icons.qrc" >
<normaloff>:/Icons/money.png</normaloff>:/Icons/money.png</iconset>
</property> </property>
<property name="text" > <property name="text" >
<string>Buy it</string> <string>Buy it</string>
</property> </property>
</action> </action>
<action name="actionHOSColPriority" >
<property name="text" >
<string>Priority</string>
</property>
</action>
<action name="actionIncreasePriority" >
<property name="icon" >
<iconset resource="icons.qrc" >:/Icons/skin/increase.png</iconset>
</property>
<property name="text" >
<string>Increase priority</string>
</property>
</action>
<action name="actionDecreasePriority" >
<property name="icon" >
<iconset resource="icons.qrc" >:/Icons/skin/decrease.png</iconset>
</property>
<property name="text" >
<string>Decrease priority</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="icons.qrc" /> <include location="icons.qrc" />

Loading…
Cancel
Save