- Added bandwidth allocation to the right click menu on torrents

This commit is contained in:
Christophe Dumez 2007-04-10 10:05:04 +00:00
parent b08d08512f
commit 6428fd4ae0
3 changed files with 32 additions and 3 deletions

View File

@ -296,9 +296,31 @@ void GUI::togglePausedState(const QModelIndex& index){
} }
} }
// void GUI::on_actionSet_download_limit_triggered(){ void GUI::on_actionSet_download_limit_triggered(){
// new BandwidthAllocationDialog(this, QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
// } QModelIndex index;
QStringList hashes;
foreach(index, selectedIndexes){
if(index.column() == NAME){
// Get the file hash
hashes << DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
}
}
new BandwidthAllocationDialog(this, false, &BTSession, hashes);
}
void GUI::on_actionSet_upload_limit_triggered(){
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
QModelIndex index;
QStringList hashes;
foreach(index, selectedIndexes){
if(index.column() == NAME){
// Get the file hash
hashes << DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
}
}
new BandwidthAllocationDialog(this, true, &BTSession, hashes);
}
void GUI::on_actionPreview_file_triggered(){ void GUI::on_actionPreview_file_triggered(){
if(tabs->currentIndex() > 1) return; if(tabs->currentIndex() > 1) return;
@ -350,6 +372,8 @@ void GUI::displayDLListMenu(const QPoint& pos){
} }
myDLLlistMenu.addAction(actionDelete); myDLLlistMenu.addAction(actionDelete);
myDLLlistMenu.addAction(actionDelete_Permanently); myDLLlistMenu.addAction(actionDelete_Permanently);
myDLLlistMenu.addAction(actionSet_download_limit);
myDLLlistMenu.addAction(actionSet_upload_limit);
myDLLlistMenu.addAction(actionTorrent_Properties); myDLLlistMenu.addAction(actionTorrent_Properties);
if(!previewProgram.isEmpty() && BTSession.isFilePreviewPossible(fileHash) && selectedIndexes.size()<=DLListModel->columnCount()){ if(!previewProgram.isEmpty() && BTSession.isFilePreviewPossible(fileHash) && selectedIndexes.size()<=DLListModel->columnCount()){
myDLLlistMenu.addAction(actionPreview_file); myDLLlistMenu.addAction(actionPreview_file);

View File

@ -135,6 +135,8 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void on_actionOpen_triggered(); void on_actionOpen_triggered();
void on_actionDelete_Permanently_triggered(); void on_actionDelete_Permanently_triggered();
void on_actionDelete_triggered(); void on_actionDelete_triggered();
void on_actionSet_download_limit_triggered();
void on_actionSet_upload_limit_triggered();
void checkConnectionStatus(); void checkConnectionStatus();
void configureSession(bool deleteOptions); void configureSession(bool deleteOptions);
void processParams(const QStringList& params); void processParams(const QStringList& params);

View File

@ -31,6 +31,8 @@
using namespace libtorrent; using namespace libtorrent;
class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg { class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg {
Q_OBJECT
public: public:
BandwidthAllocationDialog(QWidget *parent, bool uploadMode, bittorrent *BTSession, QStringList hashes): QDialog(parent), uploadMode(uploadMode){ BandwidthAllocationDialog(QWidget *parent, bool uploadMode, bittorrent *BTSession, QStringList hashes): QDialog(parent), uploadMode(uploadMode){
setupUi(this); setupUi(this);
@ -71,6 +73,7 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg {
// bandwidthSlider->setValue(-1); // bandwidthSlider->setValue(-1);
// } // }
connect(buttonBox, SIGNAL(accepted()), this, SLOT(setBandwidth())); connect(buttonBox, SIGNAL(accepted()), this, SLOT(setBandwidth()));
show();
} }
~BandwidthAllocationDialog(){ ~BandwidthAllocationDialog(){