Browse Source

- FEATURE: Added per-torrent super seeding mode

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
e423285d88
  1. 3
      Changelog
  2. 63
      src/FinishedTorrents.cpp
  3. 1
      src/FinishedTorrents.h
  4. 10
      src/qtorrenthandle.cpp
  5. 2
      src/qtorrenthandle.h
  6. 2
      src/src.pro

3
Changelog

@ -1,3 +1,6 @@
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.6.0
- FEATURE: Added per-torrent super seeding mode
* Thu Sep 3 2009 - Christophe Dumez <chris@qbittorrent.org> - v1.5.0 * Thu Sep 3 2009 - Christophe Dumez <chris@qbittorrent.org> - v1.5.0
- FEATURE: Added Magnet URI support - FEATURE: Added Magnet URI support
- FEATURE: Search engine supports category-based requests - FEATURE: Search engine supports category-based requests

63
src/FinishedTorrents.cpp

@ -447,7 +447,8 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint&){
QMenu myFinishedListMenu(this); QMenu myFinishedListMenu(this);
// Enable/disable pause/start action given the DL state // Enable/disable pause/start action given the DL state
QModelIndexList selectedIndexes = finishedList->selectionModel()->selectedIndexes(); 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) { foreach(const QModelIndex &index, selectedIndexes) {
if(index.column() == F_NAME) { if(index.column() == F_NAME) {
// Get the file name // Get the file name
@ -470,13 +471,34 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint&){
myFinishedListMenu.addAction(actionPreview_file); myFinishedListMenu.addAction(actionPreview_file);
has_preview = true; 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.addSeparator();
myFinishedListMenu.addAction(actionDelete); myFinishedListMenu.addAction(actionDelete);
myFinishedListMenu.addAction(actionDelete_Permanently); myFinishedListMenu.addAction(actionDelete_Permanently);
myFinishedListMenu.addSeparator(); 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.addAction(actionSet_upload_limit);
myFinishedListMenu.addSeparator(); myFinishedListMenu.addSeparator();
myFinishedListMenu.addAction(actionForce_recheck); myFinishedListMenu.addAction(actionForce_recheck);
@ -508,6 +530,43 @@ void FinishedTorrents::displayFinishedHoSMenu(const QPoint&){
hideshowColumn.exec(QCursor::pos()); 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 // toggle hide/show a column
void FinishedTorrents::hideOrShowColumn(int index) { void FinishedTorrents::hideOrShowColumn(int index) {
unsigned int nbVisibleColumns = 0; unsigned int nbVisibleColumns = 0;

1
src/FinishedTorrents.h

@ -82,6 +82,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding {
void hideOrShowColumnUpload(); void hideOrShowColumnUpload();
void hideOrShowColumnRatio(); void hideOrShowColumnRatio();
void forceRecheck(); void forceRecheck();
void toggleSuperSeedingMode();
public slots: public slots:
void addTorrent(QString hash); void addTorrent(QString hash);

10
src/qtorrenthandle.cpp

@ -168,6 +168,11 @@ fs::path QTorrentHandle::save_path_boost() const {
return h.save_path(); return h.save_path();
} }
bool QTorrentHandle::super_seeding() const {
Q_ASSERT(h.is_valid());
return h.super_seeding();
}
QStringList QTorrentHandle::url_seeds() const { QStringList QTorrentHandle::url_seeds() const {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
QStringList res; QStringList res;
@ -446,6 +451,11 @@ void QTorrentHandle::file_priority(int index, int priority) const {
h.file_priority(index, priority); h.file_priority(index, priority);
} }
void QTorrentHandle::super_seeding(bool on) const {
Q_ASSERT(h.is_valid());
h.super_seeding(on);
}
// //
// Operators // Operators
// //

2
src/qtorrenthandle.h

@ -110,6 +110,7 @@ class QTorrentHandle {
int active_time() const; int active_time() const;
std::vector<int> file_priorities() const; std::vector<int> file_priorities() const;
bool is_sequential_download() const; bool is_sequential_download() const;
bool super_seeding() const;
// //
// Setters // Setters
@ -135,6 +136,7 @@ class QTorrentHandle {
void auto_managed(bool) const; void auto_managed(bool) const;
void force_recheck() const; void force_recheck() const;
void move_storage(QString path) const; void move_storage(QString path) const;
void super_seeding(bool on) const;
// //
// Operators // Operators

2
src/src.pro

@ -14,7 +14,7 @@ CONFIG += qt \
network network
# Update this VERSION for each release # Update this VERSION for each release
DEFINES += VERSION=\\\"v1.6.0alpha1\\\" DEFINES += VERSION=\\\"v1.6.0alpha2\\\"
DEFINES += VERSION_MAJOR=1 DEFINES += VERSION_MAJOR=1
DEFINES += VERSION_MINOR=6 DEFINES += VERSION_MINOR=6
DEFINES += VERSION_BUGFIX=0 DEFINES += VERSION_BUGFIX=0

Loading…
Cancel
Save