mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 11:49:01 +03:00
- Bandwidth allocation per torrent class should be almost ready now
This commit is contained in:
parent
a25cc14af4
commit
b08d08512f
1 changed files with 36 additions and 20 deletions
|
@ -23,6 +23,7 @@
|
||||||
#define BANDWIDTH_ALLOCATION_H
|
#define BANDWIDTH_ALLOCATION_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QList>
|
||||||
#include "ui_bandwidth_limit.h"
|
#include "ui_bandwidth_limit.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "bittorrent.h"
|
#include "bittorrent.h"
|
||||||
|
@ -31,7 +32,7 @@ using namespace libtorrent;
|
||||||
|
|
||||||
class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg {
|
class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg {
|
||||||
public:
|
public:
|
||||||
BandwidthAllocationDialog(QWidget *parent, bool uploadMode, bittorrent *BTSession, QString hash): QDialog(parent), uploadMode(uploadMode){
|
BandwidthAllocationDialog(QWidget *parent, bool uploadMode, bittorrent *BTSession, QStringList hashes): QDialog(parent), uploadMode(uploadMode){
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
this->BTSession = BTSession;
|
this->BTSession = BTSession;
|
||||||
|
@ -40,13 +41,21 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg {
|
||||||
else
|
else
|
||||||
lblTitle->setText(tr("Download limit:"));
|
lblTitle->setText(tr("Download limit:"));
|
||||||
connect(bandwidthSlider, SIGNAL(valueChanged(int)), this, SLOT(updateBandwidthLabel(int)));
|
connect(bandwidthSlider, SIGNAL(valueChanged(int)), this, SLOT(updateBandwidthLabel(int)));
|
||||||
h = BTSession->getTorrentHandle(hash);
|
QString hash;
|
||||||
|
foreach(hash, hashes){
|
||||||
|
torrent_handle h = BTSession->getTorrentHandle(hash);
|
||||||
if(!h.is_valid()){
|
if(!h.is_valid()){
|
||||||
qDebug("Error: Invalid Handle!");
|
qDebug("Error: Invalid Handle!");
|
||||||
close();
|
continue;
|
||||||
|
}else{
|
||||||
|
handles << h;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
unsigned int nbTorrents = handles.size();
|
||||||
|
if(!nbTorrents) close();
|
||||||
// TODO: Uncomment the following lines as soon as we upgrade
|
// TODO: Uncomment the following lines as soon as we upgrade
|
||||||
// to libtorrent svn to correctly initialize the bandwidth slider.
|
// to libtorrent svn to correctly initialize the bandwidth slider.
|
||||||
|
// if(nbTorrents == 1){
|
||||||
// if(uploadMode) {
|
// if(uploadMode) {
|
||||||
// int val = h.upload_limit();
|
// int val = h.upload_limit();
|
||||||
// if(val > bandwidthSlider->maximum() || val < bandwidthSlider->minimum())
|
// if(val > bandwidthSlider->maximum() || val < bandwidthSlider->minimum())
|
||||||
|
@ -57,6 +66,9 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg {
|
||||||
// if(val > bandwidthSlider->maximum() || val < bandwidthSlider->minimum())
|
// if(val > bandwidthSlider->maximum() || val < bandwidthSlider->minimum())
|
||||||
// val = -1;
|
// val = -1;
|
||||||
// bandwidthSlider->setValue(val);
|
// bandwidthSlider->setValue(val);
|
||||||
|
// }
|
||||||
|
// }else{
|
||||||
|
// bandwidthSlider->setValue(-1);
|
||||||
// }
|
// }
|
||||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(setBandwidth()));
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(setBandwidth()));
|
||||||
}
|
}
|
||||||
|
@ -78,17 +90,21 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg {
|
||||||
|
|
||||||
void setBandwidth(){
|
void setBandwidth(){
|
||||||
int val = bandwidthSlider->value();
|
int val = bandwidthSlider->value();
|
||||||
if(uploadMode)
|
torrent_handle h;
|
||||||
|
if(uploadMode) {
|
||||||
|
foreach(h, handles)
|
||||||
h.set_upload_limit(val);
|
h.set_upload_limit(val);
|
||||||
else
|
} else {
|
||||||
|
foreach(h, handles)
|
||||||
h.set_download_limit(val);
|
h.set_download_limit(val);
|
||||||
|
}
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool uploadMode;
|
bool uploadMode;
|
||||||
bittorrent *BTSession;
|
bittorrent *BTSession;
|
||||||
torrent_handle h;
|
QList<torrent_handle> handles;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue