diff --git a/Changelog b/Changelog index 6d2bde3e3..b46191c76 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,6 @@ +* Unknown - Christophe Dumez - v1.6.0 + - FEATURE: Added per-torrent super seeding mode + * Thu Sep 3 2009 - Christophe Dumez - v1.5.0 - FEATURE: Added Magnet URI support - FEATURE: Search engine supports category-based requests diff --git a/src/FinishedTorrents.cpp b/src/FinishedTorrents.cpp index 50e801860..9feace584 100644 --- a/src/FinishedTorrents.cpp +++ b/src/FinishedTorrents.cpp @@ -447,7 +447,8 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint&){ QMenu myFinishedListMenu(this); // Enable/disable pause/start action given the DL state QModelIndexList selectedIndexes = finishedList->selectionModel()->selectedIndexes(); - bool has_pause = false, has_start = false, has_preview = false; + bool has_pause = false, has_start = false, has_preview = false, hide_uper_seeding = false, super_seeding_enabled = false; + bool first_torrent = true; foreach(const QModelIndex &index, selectedIndexes) { if(index.column() == F_NAME) { // Get the file name @@ -470,13 +471,34 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint&){ myFinishedListMenu.addAction(actionPreview_file); has_preview = true; } - if(has_pause && has_start && has_preview) break; + if(h.super_seeding()) { + if(first_torrent) { + super_seeding_enabled = true; + } else { + if(!super_seeding_enabled) hide_uper_seeding = true; + } + } else { + if(!first_torrent) { + if(super_seeding_enabled) hide_uper_seeding = true; + } + } + first_torrent = false; + if(has_pause && has_start && has_preview && hide_uper_seeding) break; } } myFinishedListMenu.addSeparator(); myFinishedListMenu.addAction(actionDelete); myFinishedListMenu.addAction(actionDelete_Permanently); myFinishedListMenu.addSeparator(); + if(!hide_uper_seeding) { + QAction *act; + if(super_seeding_enabled) + act = myFinishedListMenu.addAction(QIcon(":/Icons/oxygen/button_ok.png"), tr("Super seeding mode")); + else + act = myFinishedListMenu.addAction(QIcon(":/Icons/oxygen/button_cancel.png"), tr("Super seeding mode")); + // Bind signal / slot + connect(act, SIGNAL(triggered()), this, SLOT(toggleSuperSeedingMode())); + } myFinishedListMenu.addAction(actionSet_upload_limit); myFinishedListMenu.addSeparator(); myFinishedListMenu.addAction(actionForce_recheck); @@ -508,6 +530,43 @@ void FinishedTorrents::displayFinishedHoSMenu(const QPoint&){ hideshowColumn.exec(QCursor::pos()); } +void FinishedTorrents::toggleSuperSeedingMode() { + QModelIndexList selectedIndexes = finishedList->selectionModel()->selectedIndexes(); + bool super_seeding_enabled = false, first_torrent=true; + // Check whether we should disable or enable super seeding mode + foreach(const QModelIndex &index, selectedIndexes) { + if(index.column() == F_NAME) { + // Get the file name + QString hash = getHashFromRow(index.row()); + // Get handle and pause the torrent + QTorrentHandle h = BTSession->getTorrentHandle(hash); + if(!h.is_valid()) continue; + if(h.super_seeding()) { + if(first_torrent) { + super_seeding_enabled = true; + } + } else { + if(!first_torrent) { + if(super_seeding_enabled) super_seeding_enabled = false; + } + } + first_torrent = false; + } + } + // Toggling super seeding mode + foreach(const QModelIndex &index, selectedIndexes) { + if(index.column() == F_NAME) { + // Get the file name + QString hash = getHashFromRow(index.row()); + // Get handle and pause the torrent + QTorrentHandle h = BTSession->getTorrentHandle(hash); + if(!h.is_valid()) continue; + qDebug("Seeding mode=%d for torrent %s",!super_seeding_enabled, h.name().toLocal8Bit().data()); + h.super_seeding(!super_seeding_enabled); + } + } +} + // toggle hide/show a column void FinishedTorrents::hideOrShowColumn(int index) { unsigned int nbVisibleColumns = 0; diff --git a/src/FinishedTorrents.h b/src/FinishedTorrents.h index c220b26e5..f28cac0a7 100644 --- a/src/FinishedTorrents.h +++ b/src/FinishedTorrents.h @@ -82,6 +82,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding { void hideOrShowColumnUpload(); void hideOrShowColumnRatio(); void forceRecheck(); + void toggleSuperSeedingMode(); public slots: void addTorrent(QString hash); diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index 2e4316a83..e51389244 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -168,6 +168,11 @@ fs::path QTorrentHandle::save_path_boost() const { return h.save_path(); } +bool QTorrentHandle::super_seeding() const { + Q_ASSERT(h.is_valid()); + return h.super_seeding(); +} + QStringList QTorrentHandle::url_seeds() const { Q_ASSERT(h.is_valid()); QStringList res; @@ -446,6 +451,11 @@ void QTorrentHandle::file_priority(int index, int priority) const { h.file_priority(index, priority); } +void QTorrentHandle::super_seeding(bool on) const { + Q_ASSERT(h.is_valid()); + h.super_seeding(on); +} + // // Operators // diff --git a/src/qtorrenthandle.h b/src/qtorrenthandle.h index 4e2928ab0..fa10bf54e 100644 --- a/src/qtorrenthandle.h +++ b/src/qtorrenthandle.h @@ -110,6 +110,7 @@ class QTorrentHandle { int active_time() const; std::vector file_priorities() const; bool is_sequential_download() const; + bool super_seeding() const; // // Setters @@ -135,6 +136,7 @@ class QTorrentHandle { void auto_managed(bool) const; void force_recheck() const; void move_storage(QString path) const; + void super_seeding(bool on) const; // // Operators diff --git a/src/src.pro b/src/src.pro index fe71cbcb6..2d4ae7815 100644 --- a/src/src.pro +++ b/src/src.pro @@ -14,7 +14,7 @@ CONFIG += qt \ network # Update this VERSION for each release -DEFINES += VERSION=\\\"v1.6.0alpha1\\\" +DEFINES += VERSION=\\\"v1.6.0alpha2\\\" DEFINES += VERSION_MAJOR=1 DEFINES += VERSION_MINOR=6 DEFINES += VERSION_BUGFIX=0