From 6428fd4ae0617bba35b5ed64e9e34280ff2d1196 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 10 Apr 2007 10:05:04 +0000 Subject: [PATCH] - Added bandwidth allocation to the right click menu on torrents --- src/GUI.cpp | 30 +++++++++++++++++++++++++++--- src/GUI.h | 2 ++ src/allocationDlg.h | 3 +++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/GUI.cpp b/src/GUI.cpp index d408a63e8..393373e0a 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -296,9 +296,31 @@ void GUI::togglePausedState(const QModelIndex& index){ } } -// void GUI::on_actionSet_download_limit_triggered(){ -// new BandwidthAllocationDialog(this, -// } +void GUI::on_actionSet_download_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, 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(){ if(tabs->currentIndex() > 1) return; @@ -350,6 +372,8 @@ void GUI::displayDLListMenu(const QPoint& pos){ } myDLLlistMenu.addAction(actionDelete); myDLLlistMenu.addAction(actionDelete_Permanently); + myDLLlistMenu.addAction(actionSet_download_limit); + myDLLlistMenu.addAction(actionSet_upload_limit); myDLLlistMenu.addAction(actionTorrent_Properties); if(!previewProgram.isEmpty() && BTSession.isFilePreviewPossible(fileHash) && selectedIndexes.size()<=DLListModel->columnCount()){ myDLLlistMenu.addAction(actionPreview_file); diff --git a/src/GUI.h b/src/GUI.h index 658d98db8..0365626d6 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -135,6 +135,8 @@ class GUI : public QMainWindow, private Ui::MainWindow{ void on_actionOpen_triggered(); void on_actionDelete_Permanently_triggered(); void on_actionDelete_triggered(); + void on_actionSet_download_limit_triggered(); + void on_actionSet_upload_limit_triggered(); void checkConnectionStatus(); void configureSession(bool deleteOptions); void processParams(const QStringList& params); diff --git a/src/allocationDlg.h b/src/allocationDlg.h index e84e635ec..cc1f59206 100644 --- a/src/allocationDlg.h +++ b/src/allocationDlg.h @@ -31,6 +31,8 @@ using namespace libtorrent; class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg { + Q_OBJECT + public: BandwidthAllocationDialog(QWidget *parent, bool uploadMode, bittorrent *BTSession, QStringList hashes): QDialog(parent), uploadMode(uploadMode){ setupUi(this); @@ -71,6 +73,7 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg { // bandwidthSlider->setValue(-1); // } connect(buttonBox, SIGNAL(accepted()), this, SLOT(setBandwidth())); + show(); } ~BandwidthAllocationDialog(){