Browse Source

- Started to work on bandwidth allocation per torrent

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
3933d78da2
  1. 1
      src/GUI.cpp
  2. 84
      src/allocationDlg.h
  3. 129
      src/bandwidth_limit.ui
  4. 5
      src/src.pro

1
src/GUI.cpp

@ -42,6 +42,7 @@ @@ -42,6 +42,7 @@
#include "searchEngine.h"
#include "rss_imp.h"
#include "FinishedTorrents.h"
#include "allocationDlg.h"
/*****************************************************
* *

84
src/allocationDlg.h

@ -0,0 +1,84 @@ @@ -0,0 +1,84 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contact : chris@qbittorrent.org
*/
#ifndef BANDWIDTH_ALLOCATION_H
#define BANDWIDTH_ALLOCATION_H
#include <QDialog>
#include "ui_bandwidth_limit.h"
#include "misc.h"
#include "bittorrent.h"
using namespace libtorrent;
class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg {
public:
BandwidthAllocationDialog(QWidget *parent, bool uploadMode, bittorrent *BTSession, QString hash): QDialog(parent), uploadMode(uploadMode){
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
this->BTSession = BTSession;
if(uploadMode)
lblTitle->setText(tr("Upload limit:"));
else
lblTitle->setText(tr("Download limit:"));
connect(bandwidthSlider, SIGNAL(valueChanged(int)), this, SLOT(updateBandwidthLabel(int)));
h = BTSession->getTorrentHandle(hash);
if(!h.is_valid()){
qDebug("Error: Invalid Handle!");
close();
}
// TODO: Uncomment the following lines as soon as we upgrade
// to libtorrent svn to correctly initialize the bandwidth slider.
// if(uploadMode) {
// int val = h.upload_limit();
// if(val > bandwidthSlider->maximum() || val < bandwidthSlider->minimum())
// val = -1;
// bandwidthSlider->setValue(val);
// } else {
// int val = h.download_limit();
// if(val > bandwidthSlider->maximum() || val < bandwidthSlider->minimum())
// val = -1;
// bandwidthSlider->setValue(val);
// }
}
~BandwidthAllocationDialog(){
qDebug("Deleting bandwidth allocation dialog");
}
protected slots:
void updateBandwidthLabel(int val){
if(val == -1){
limit_lbl->setText(tr("Unlimited", "Unlimited (bandwidth)"));
kb_lbl->setText("");
}else{
limit_lbl->setText(QString(misc::toString(val).c_str()));
kb_lbl->setText(tr("KiB/s"));
}
}
private:
bool uploadMode;
bittorrent *BTSession;
torrent_handle h;
};
#endif

129
src/bandwidth_limit.ui

@ -0,0 +1,129 @@ @@ -0,0 +1,129 @@
<ui version="4.0" >
<class>bandwidth_dlg</class>
<widget class="QDialog" name="bandwidth_dlg" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>222</width>
<height>99</height>
</rect>
</property>
<property name="windowTitle" >
<string>Bandwidth allocation</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="lblTitle" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="limit_lbl" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="kb_lbl" >
<property name="text" >
<string>KiB/s</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QSlider" name="bandwidthSlider" >
<property name="minimum" >
<number>-1</number>
</property>
<property name="maximum" >
<number>1000</number>
</property>
<property name="sliderPosition" >
<number>-1</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>bandwidth_dlg</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>212</x>
<y>77</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>98</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>bandwidth_dlg</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>212</x>
<y>83</y>
</hint>
<hint type="destinationlabel" >
<x>221</x>
<y>98</y>
</hint>
</hints>
</connection>
</connections>
</ui>

5
src/src.pro

@ -117,11 +117,12 @@ HEADERS += GUI.h misc.h options_imp.h about_imp.h \ @@ -117,11 +117,12 @@ HEADERS += GUI.h misc.h options_imp.h about_imp.h \
downloadThread.h downloadFromURLImp.h \
torrentAddition.h deleteThread.h \
bittorrent.h searchEngine.h \
rss.h rss_imp.h FinishedTorrents.h
rss.h rss_imp.h FinishedTorrents.h \
allocationDlg.h
FORMS += MainWindow.ui options.ui about.ui \
properties.ui createtorrent.ui preview.ui \
login.ui downloadFromURL.ui addTorrentDialog.ui \
search.ui rss.ui seeding.ui
search.ui rss.ui seeding.ui bandwidth_limit.ui
SOURCES += GUI.cpp \
main.cpp \
options_imp.cpp \

Loading…
Cancel
Save