Browse Source

Added uTP support

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
641b38690c
  1. 1
      Changelog
  2. 9
      src/preferences/advancedsettings.h
  3. 65
      src/preferences/options.ui
  4. 34
      src/preferences/options_imp.cpp
  5. 1
      src/preferences/options_imp.h
  6. 21
      src/preferences/preferences.h
  7. 28
      src/properties/peerlistdelegate.h
  8. 83
      src/properties/peerlistwidget.cpp
  9. 3
      src/properties/peerlistwidget.h
  10. 28
      src/qtlibtorrent/qbtsession.cpp

1
Changelog

@ -1,4 +1,5 @@
* Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.8.0 * Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.8.0
- FEATURE: Added full libtorrent v0.16 support (uTP, ...)
- FEATURE: Added support for secure SMTP connection (SSL) - FEATURE: Added support for secure SMTP connection (SSL)
- FEATURE: Added support for SMTP authentication - FEATURE: Added support for SMTP authentication
- FEATURE: Added UPnP/NAT-PMP port forward for the Web UI port - FEATURE: Added UPnP/NAT-PMP port forward for the Web UI port

9
src/preferences/advancedsettings.h

@ -13,7 +13,7 @@
#include "preferences.h" #include "preferences.h"
enum AdvSettingsCols {PROPERTY, VALUE}; enum AdvSettingsCols {PROPERTY, VALUE};
enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, COUNT_OVERHEAD, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, NETWORK_ADDRESS, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT, enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, NETWORK_ADDRESS, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT,
#if defined(Q_WS_WIN) || defined(Q_WS_MAC) #if defined(Q_WS_WIN) || defined(Q_WS_MAC)
UPDATE_CHECK, UPDATE_CHECK,
#endif #endif
@ -28,7 +28,7 @@ class AdvancedSettings: public QTableWidget {
private: private:
QSpinBox spin_cache, outgoing_ports_min, outgoing_ports_max, spin_list_refresh, spin_maxhalfopen, spin_tracker_port; QSpinBox spin_cache, outgoing_ports_min, outgoing_ports_max, spin_list_refresh, spin_maxhalfopen, spin_tracker_port;
QCheckBox cb_ignore_limits_lan, cb_count_overhead, cb_recheck_completed, cb_resolve_countries, cb_resolve_hosts, QCheckBox cb_ignore_limits_lan, cb_recheck_completed, cb_resolve_countries, cb_resolve_hosts,
cb_super_seeding, cb_program_notifications, cb_tracker_status, cb_confirm_torrent_deletion; cb_super_seeding, cb_program_notifications, cb_tracker_status, cb_confirm_torrent_deletion;
QComboBox combo_iface; QComboBox combo_iface;
#if defined(Q_WS_WIN) || defined(Q_WS_MAC) #if defined(Q_WS_WIN) || defined(Q_WS_MAC)
@ -69,8 +69,6 @@ public slots:
pref.setOutgoingPortsMax(outgoing_ports_max.value()); pref.setOutgoingPortsMax(outgoing_ports_max.value());
// Ignore limits on LAN // Ignore limits on LAN
pref.ignoreLimitsOnLAN(cb_ignore_limits_lan.isChecked()); pref.ignoreLimitsOnLAN(cb_ignore_limits_lan.isChecked());
// Include protocol overhead in transfer limits
pref.includeOverheadInLimits(cb_count_overhead.isChecked());
// Recheck torrents on completion // Recheck torrents on completion
pref.recheckTorrentsOnCompletion(cb_recheck_completed.isChecked()); pref.recheckTorrentsOnCompletion(cb_recheck_completed.isChecked());
// Transfer list refresh interval // Transfer list refresh interval
@ -170,9 +168,6 @@ private slots:
// Ignore transfer limits on local network // Ignore transfer limits on local network
cb_ignore_limits_lan.setChecked(pref.ignoreLimitsOnLAN()); cb_ignore_limits_lan.setChecked(pref.ignoreLimitsOnLAN());
setRow(IGNORE_LIMIT_LAN, tr("Ignore transfer limits on local network"), &cb_ignore_limits_lan); setRow(IGNORE_LIMIT_LAN, tr("Ignore transfer limits on local network"), &cb_ignore_limits_lan);
// Consider protocol overhead in transfer limits
cb_count_overhead.setChecked(pref.includeOverheadInLimits());
setRow(COUNT_OVERHEAD, tr("Include TCP/IP overhead in transfer limits"), &cb_count_overhead);
// Recheck completed torrents // Recheck completed torrents
cb_recheck_completed.setChecked(pref.recheckTorrentsOnCompletion()); cb_recheck_completed.setChecked(pref.recheckTorrentsOnCompletion());
setRow(RECHECK_COMPLETED, tr("Recheck torrents on completion"), &cb_recheck_completed); setRow(RECHECK_COMPLETED, tr("Recheck torrents on completion"), &cb_recheck_completed);

65
src/preferences/options.ui

@ -1405,16 +1405,16 @@ QGroupBox {
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>-16</y>
<width>504</width> <width>489</width>
<height>384</height> <height>425</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_33"> <layout class="QVBoxLayout" name="verticalLayout_33">
<item> <item>
<widget class="QGroupBox" name="bandwidthBox"> <widget class="QGroupBox" name="bandwidthBox">
<property name="title"> <property name="title">
<string>Global Speed Limits</string> <string>Global Rate Limits</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_7"> <layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0"> <item row="0" column="0">
@ -1513,13 +1513,66 @@ QGroupBox {
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="1" colspan="2">
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_27">
<item>
<layout class="QFormLayout" name="formLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="label_23">
<property name="text">
<string>Protocol:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBTProtocol">
<item>
<property name="text">
<string>TCP and uTP</string>
</property>
</item>
<item>
<property name="text">
<string>TCP only</string>
</property>
</item>
<item>
<property name="text">
<string>uTP only</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkLimituTPConnections">
<property name="text">
<string>Apply rate limit to uTP connections</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkLimitTransportOverhead">
<property name="text">
<string>Apply rate limit to transport overhead</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBox_6"> <widget class="QGroupBox" name="groupBox_6">
<property name="title"> <property name="title">
<string>Alternative Global Speed Limits</string> <string>Alternative Global Rate Limits</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_11"> <layout class="QVBoxLayout" name="verticalLayout_11">
<item> <item>
@ -1625,7 +1678,7 @@ QGroupBox {
<item> <item>
<widget class="QGroupBox" name="check_schedule"> <widget class="QGroupBox" name="check_schedule">
<property name="title"> <property name="title">
<string>Schedule the use of alternative speed limits</string> <string>Schedule the use of alternative rate limits</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>

34
src/preferences/options_imp.cpp

@ -113,6 +113,8 @@ options_imp::options_imp(QWidget *parent):
comboTrayIcon->setVisible(false); comboTrayIcon->setVisible(false);
#endif #endif
// Connect signals / slots // Connect signals / slots
// Speeds
connect(comboBTProtocol, SIGNAL(currentIndexChanged(int)), SLOT(updateBTProtocolSettings(int)));
// Proxy tab // Proxy tab
connect(comboProxyType, SIGNAL(currentIndexChanged(int)),this, SLOT(enableProxy(int))); connect(comboProxyType, SIGNAL(currentIndexChanged(int)),this, SLOT(enableProxy(int)));
@ -168,6 +170,9 @@ options_imp::options_imp(QWidget *parent):
connect(schedule_from, SIGNAL(timeChanged(QTime)), this, SLOT(enableApplyButton())); connect(schedule_from, SIGNAL(timeChanged(QTime)), this, SLOT(enableApplyButton()));
connect(schedule_to, SIGNAL(timeChanged(QTime)), this, SLOT(enableApplyButton())); connect(schedule_to, SIGNAL(timeChanged(QTime)), this, SLOT(enableApplyButton()));
connect(schedule_days, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton())); connect(schedule_days, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
connect(comboBTProtocol, SIGNAL(currentIndexChanged(int)), SLOT(enableApplyButton()));
connect(checkLimituTPConnections, SIGNAL(toggled(bool)), SLOT(enableApplyButton()));
connect(checkLimitTransportOverhead, SIGNAL(toggled(bool)), SLOT(enableApplyButton()));
// Bittorrent tab // Bittorrent tab
connect(checkMaxConnecs, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkMaxConnecs, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkMaxConnecsPerTorrent, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkMaxConnecsPerTorrent, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
@ -216,6 +221,10 @@ options_imp::options_imp(QWidget *parent):
connect(tabSelection, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*))); connect(tabSelection, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*)));
#if LIBTORRENT_VERSION_MINOR < 15 #if LIBTORRENT_VERSION_MINOR < 15
checkAppendqB->setVisible(false); checkAppendqB->setVisible(false);
#endif
#if LIBTORRENT_VERSION_MINOR < 16
comboBTProtocol->setVisible(false);
checkLimituTPConnections->setVisible(false);
#endif #endif
// Load Advanced settings // Load Advanced settings
QVBoxLayout *adv_layout = new QVBoxLayout(); QVBoxLayout *adv_layout = new QVBoxLayout();
@ -382,6 +391,9 @@ void options_imp::saveOptions(){
const QPair<int, int> down_up_limit = getGlobalBandwidthLimits(); const QPair<int, int> down_up_limit = getGlobalBandwidthLimits();
pref.setGlobalDownloadLimit(down_up_limit.first); pref.setGlobalDownloadLimit(down_up_limit.first);
pref.setGlobalUploadLimit(down_up_limit.second); pref.setGlobalUploadLimit(down_up_limit.second);
pref.setBTProtocol(comboBTProtocol->currentIndex());
pref.setuTPRateLimited(checkLimituTPConnections->isChecked());
pref.includeOverheadInLimits(checkLimitTransportOverhead->isChecked());
pref.setAltGlobalDownloadLimit(spinDownloadLimitAlt->value()); pref.setAltGlobalDownloadLimit(spinDownloadLimitAlt->value());
pref.setAltGlobalUploadLimit(spinUploadLimitAlt->value()); pref.setAltGlobalUploadLimit(spinUploadLimitAlt->value());
pref.setSchedulerEnabled(check_schedule->isChecked()); pref.setSchedulerEnabled(check_schedule->isChecked());
@ -573,6 +585,10 @@ void options_imp::loadOptions(){
} }
spinUploadLimitAlt->setValue(pref.getAltGlobalUploadLimit()); spinUploadLimitAlt->setValue(pref.getAltGlobalUploadLimit());
spinDownloadLimitAlt->setValue(pref.getAltGlobalDownloadLimit()); spinDownloadLimitAlt->setValue(pref.getAltGlobalDownloadLimit());
// Options
comboBTProtocol->setCurrentIndex((int)pref.getBTProtocol());
checkLimituTPConnections->setChecked(pref.isuTPRateLimited());
checkLimitTransportOverhead->setChecked(pref.includeOverheadInLimits());
// Scheduler // Scheduler
check_schedule->setChecked(pref.isSchedulerEnabled()); check_schedule->setChecked(pref.isSchedulerEnabled());
schedule_from->setTime(pref.getSchedulerStartTime()); schedule_from->setTime(pref.getSchedulerStartTime());
@ -1188,3 +1204,21 @@ QString options_imp::languageToLocalizedString(QLocale::Language language, const
} }
} }
} }
void options_imp::updateBTProtocolSettings(int protocol)
{
switch(protocol) {
case BT::TCP:
checkLimituTPConnections->setEnabled(false);
break;
case BT::TCP_uTP:
checkLimituTPConnections->setEnabled(true);
break;
case BT::uTP:
checkLimituTPConnections->setEnabled(true);
break;
default:
Q_ASSERT(0);
break;
}
}

1
src/preferences/options_imp.h

@ -82,6 +82,7 @@ private slots:
void on_removeScanFolderButton_clicked(); void on_removeScanFolderButton_clicked();
void on_registerDNSBtn_clicked(); void on_registerDNSBtn_clicked();
void setLocale(const QString &locale); void setLocale(const QString &locale);
void updateBTProtocolSettings(int protocol);
private: private:
// Methods // Methods

21
src/preferences/preferences.h

@ -62,7 +62,10 @@ namespace TrayIcon {
enum Style { NORMAL = 0, MONO_DARK, MONO_LIGHT }; enum Style { NORMAL = 0, MONO_DARK, MONO_LIGHT };
} }
namespace DNS { namespace DNS {
enum Service { DYNDNS, NOIP }; enum Service { DYNDNS, NOIP };
}
namespace BT {
enum Protocol { TCP_uTP, TCP, uTP };
} }
class Preferences : public QIniSettings { class Preferences : public QIniSettings {
@ -537,6 +540,22 @@ public:
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxUploadsPerTorrent"), val); setValue(QString::fromUtf8("Preferences/Bittorrent/MaxUploadsPerTorrent"), val);
} }
BT::Protocol getBTProtocol() const {
return (BT::Protocol)value(QString::fromUtf8("Preferences/Bittorrent/Protocol"), BT::TCP_uTP).toInt();
}
void setBTProtocol(int protocol) {
setValue("Preferences/Bittorrent/Protocol", protocol);
}
bool isuTPRateLimited() const {
return value(QString::fromUtf8("Preferences/Bittorrent/uTP_rate_limiting"), false).toBool();
}
void setuTPRateLimited(bool enabled) {
setValue("Preferences/Bittorrent/uTP_rate_limiting", enabled);
}
bool isDHTEnabled() const { bool isDHTEnabled() const {
return value(QString::fromUtf8("Preferences/Bittorrent/DHT"), true).toBool(); return value(QString::fromUtf8("Preferences/Bittorrent/DHT"), true).toBool();
} }

28
src/properties/peerlistdelegate.h

@ -35,11 +35,13 @@
#include <QPainter> #include <QPainter>
#include "misc.h" #include "misc.h"
enum PeerListColumns {IP, CLIENT, PROGRESS, DOWN_SPEED, UP_SPEED, TOT_DOWN, TOT_UP, IP_HIDDEN};
class PeerListDelegate: public QItemDelegate { class PeerListDelegate: public QItemDelegate {
Q_OBJECT Q_OBJECT
public:
enum PeerListColumns {IP, CONNECTION, CLIENT, PROGRESS, DOWN_SPEED, UP_SPEED,
TOT_DOWN, TOT_UP, IP_HIDDEN, COL_COUNT};
public: public:
PeerListDelegate(QObject *parent) : QItemDelegate(parent){} PeerListDelegate(QObject *parent) : QItemDelegate(parent){}
@ -56,18 +58,18 @@ public:
break; break;
case DOWN_SPEED: case DOWN_SPEED:
case UP_SPEED:{ case UP_SPEED:{
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
qreal speed = index.data().toDouble(); qreal speed = index.data().toDouble();
if (speed > 0.0) if (speed > 0.0)
QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (i.e. per second)")); QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (i.e. per second)"));
break; break;
} }
case PROGRESS:{ case PROGRESS:{
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
qreal progress = index.data().toDouble(); qreal progress = index.data().toDouble();
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(progress*100., 'f', 1)+"%"); QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(progress*100., 'f', 1)+"%");
break; break;
} }
default: default:
QItemDelegate::paint(painter, option, index); QItemDelegate::paint(painter, option, index);
} }

83
src/properties/peerlistwidget.cpp

@ -57,20 +57,21 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent): QTreeView(parent), pro
setAllColumnsShowFocus(true); setAllColumnsShowFocus(true);
setSelectionMode(QAbstractItemView::ExtendedSelection); setSelectionMode(QAbstractItemView::ExtendedSelection);
// List Model // List Model
listModel = new QStandardItemModel(0, 8); listModel = new QStandardItemModel(0, PeerListDelegate::COL_COUNT);
listModel->setHeaderData(IP, Qt::Horizontal, tr("IP")); listModel->setHeaderData(PeerListDelegate::IP, Qt::Horizontal, tr("IP"));
listModel->setHeaderData(CLIENT, Qt::Horizontal, tr("Client", "i.e.: Client application")); listModel->setHeaderData(PeerListDelegate::CONNECTION, Qt::Horizontal, tr("Connection"));
listModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress", "i.e: % downloaded")); listModel->setHeaderData(PeerListDelegate::CLIENT, Qt::Horizontal, tr("Client", "i.e.: Client application"));
listModel->setHeaderData(DOWN_SPEED, Qt::Horizontal, tr("Down Speed", "i.e: Download speed")); listModel->setHeaderData(PeerListDelegate::PROGRESS, Qt::Horizontal, tr("Progress", "i.e: % downloaded"));
listModel->setHeaderData(UP_SPEED, Qt::Horizontal, tr("Up Speed", "i.e: Upload speed")); listModel->setHeaderData(PeerListDelegate::DOWN_SPEED, Qt::Horizontal, tr("Down Speed", "i.e: Download speed"));
listModel->setHeaderData(TOT_DOWN, Qt::Horizontal, tr("Downloaded", "i.e: total data downloaded")); listModel->setHeaderData(PeerListDelegate::UP_SPEED, Qt::Horizontal, tr("Up Speed", "i.e: Upload speed"));
listModel->setHeaderData(TOT_UP, Qt::Horizontal, tr("Uploaded", "i.e: total data uploaded")); listModel->setHeaderData(PeerListDelegate::TOT_DOWN, Qt::Horizontal, tr("Downloaded", "i.e: total data downloaded"));
listModel->setHeaderData(PeerListDelegate::TOT_UP, Qt::Horizontal, tr("Uploaded", "i.e: total data uploaded"));
// Proxy model to support sorting without actually altering the underlying model // Proxy model to support sorting without actually altering the underlying model
proxyModel = new QSortFilterProxyModel(); proxyModel = new QSortFilterProxyModel();
proxyModel->setDynamicSortFilter(true); proxyModel->setDynamicSortFilter(true);
proxyModel->setSourceModel(listModel); proxyModel->setSourceModel(listModel);
setModel(proxyModel); setModel(proxyModel);
hideColumn(IP_HIDDEN); hideColumn(PeerListDelegate::IP_HIDDEN);
// Context menu // Context menu
setContextMenuPolicy(Qt::CustomContextMenu); setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showPeerListMenu(QPoint))); connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showPeerListMenu(QPoint)));
@ -129,7 +130,7 @@ void PeerListWidget::showPeerListMenu(QPoint) {
QStringList selectedPeerIPs; QStringList selectedPeerIPs;
foreach(const QModelIndex &index, selectedIndexes) { foreach(const QModelIndex &index, selectedIndexes) {
int row = proxyModel->mapToSource(index).row(); int row = proxyModel->mapToSource(index).row();
QString myip = listModel->data(listModel->index(row, IP_HIDDEN)).toString(); QString myip = listModel->data(listModel->index(row, PeerListDelegate::IP_HIDDEN)).toString();
selectedPeerIPs << myip; selectedPeerIPs << myip;
} }
// Add Peer Action // Add Peer Action
@ -320,30 +321,31 @@ QStandardItem* PeerListWidget::addPeer(QString ip, peer_info peer) {
host = resolver->getHostFromCache(peer.ip); host = resolver->getHostFromCache(peer.ip);
} }
if(host.isNull()) if(host.isNull())
listModel->setData(listModel->index(row, IP), ip); listModel->setData(listModel->index(row, PeerListDelegate::IP), ip);
else else
listModel->setData(listModel->index(row, IP), host); listModel->setData(listModel->index(row, PeerListDelegate::IP), host);
listModel->setData(listModel->index(row, IP_HIDDEN), ip); listModel->setData(listModel->index(row, PeerListDelegate::IP_HIDDEN), ip);
// Resolve peer host name is asked // Resolve peer host name is asked
if(resolver && host.isNull()) if(resolver && host.isNull())
resolver->resolve(peer.ip); resolver->resolve(peer.ip);
if(display_flags) { if(display_flags) {
const QIcon ico = GeoIPManager::CountryISOCodeToIcon(peer.country); const QIcon ico = GeoIPManager::CountryISOCodeToIcon(peer.country);
if(!ico.isNull()) { if(!ico.isNull()) {
listModel->setData(listModel->index(row, IP), ico, Qt::DecorationRole); listModel->setData(listModel->index(row, PeerListDelegate::IP), ico, Qt::DecorationRole);
const QString country_name = GeoIPManager::CountryISOCodeToName(peer.country); const QString country_name = GeoIPManager::CountryISOCodeToName(peer.country);
listModel->setData(listModel->index(row, IP), country_name, Qt::ToolTipRole); listModel->setData(listModel->index(row, PeerListDelegate::IP), country_name, Qt::ToolTipRole);
} else { } else {
missingFlags.insert(ip); missingFlags.insert(ip);
} }
} }
listModel->setData(listModel->index(row, CLIENT), misc::toQStringU(peer.client)); listModel->setData(listModel->index(row, PeerListDelegate::CONNECTION), getConnectionString(peer.connection_type));
listModel->setData(listModel->index(row, PROGRESS), peer.progress); listModel->setData(listModel->index(row, PeerListDelegate::CLIENT), misc::toQStringU(peer.client));
listModel->setData(listModel->index(row, DOWN_SPEED), peer.payload_down_speed); listModel->setData(listModel->index(row, PeerListDelegate::PROGRESS), peer.progress);
listModel->setData(listModel->index(row, UP_SPEED), peer.payload_up_speed); listModel->setData(listModel->index(row, PeerListDelegate::DOWN_SPEED), peer.payload_down_speed);
listModel->setData(listModel->index(row, TOT_DOWN), (qulonglong)peer.total_download); listModel->setData(listModel->index(row, PeerListDelegate::UP_SPEED), peer.payload_up_speed);
listModel->setData(listModel->index(row, TOT_UP), (qulonglong)peer.total_upload); listModel->setData(listModel->index(row, PeerListDelegate::TOT_DOWN), (qulonglong)peer.total_download);
return listModel->item(row, IP); listModel->setData(listModel->index(row, PeerListDelegate::TOT_UP), (qulonglong)peer.total_upload);
return listModel->item(row, PeerListDelegate::IP);
} }
void PeerListWidget::updatePeer(QString ip, peer_info peer) { void PeerListWidget::updatePeer(QString ip, peer_info peer) {
@ -352,18 +354,19 @@ void PeerListWidget::updatePeer(QString ip, peer_info peer) {
if(display_flags) { if(display_flags) {
const QIcon ico = GeoIPManager::CountryISOCodeToIcon(peer.country); const QIcon ico = GeoIPManager::CountryISOCodeToIcon(peer.country);
if(!ico.isNull()) { if(!ico.isNull()) {
listModel->setData(listModel->index(row, IP), ico, Qt::DecorationRole); listModel->setData(listModel->index(row, PeerListDelegate::IP), ico, Qt::DecorationRole);
const QString country_name = GeoIPManager::CountryISOCodeToName(peer.country); const QString country_name = GeoIPManager::CountryISOCodeToName(peer.country);
listModel->setData(listModel->index(row, IP), country_name, Qt::ToolTipRole); listModel->setData(listModel->index(row, PeerListDelegate::IP), country_name, Qt::ToolTipRole);
missingFlags.remove(ip); missingFlags.remove(ip);
} }
} }
listModel->setData(listModel->index(row, CLIENT), misc::toQStringU(peer.client)); listModel->setData(listModel->index(row, PeerListDelegate::CONNECTION), getConnectionString(peer.connection_type));
listModel->setData(listModel->index(row, PROGRESS), peer.progress); listModel->setData(listModel->index(row, PeerListDelegate::CLIENT), misc::toQStringU(peer.client));
listModel->setData(listModel->index(row, DOWN_SPEED), peer.payload_down_speed); listModel->setData(listModel->index(row, PeerListDelegate::PROGRESS), peer.progress);
listModel->setData(listModel->index(row, UP_SPEED), peer.payload_up_speed); listModel->setData(listModel->index(row, PeerListDelegate::DOWN_SPEED), peer.payload_down_speed);
listModel->setData(listModel->index(row, TOT_DOWN), (qulonglong)peer.total_download); listModel->setData(listModel->index(row, PeerListDelegate::UP_SPEED), peer.payload_up_speed);
listModel->setData(listModel->index(row, TOT_UP), (qulonglong)peer.total_upload); listModel->setData(listModel->index(row, PeerListDelegate::TOT_DOWN), (qulonglong)peer.total_download);
listModel->setData(listModel->index(row, PeerListDelegate::TOT_UP), (qulonglong)peer.total_upload);
} }
void PeerListWidget::handleResolved(const QString &ip, const QString &hostname) { void PeerListWidget::handleResolved(const QString &ip, const QString &hostname) {
@ -384,3 +387,23 @@ void PeerListWidget::handleSortColumnChanged(int col)
proxyModel->setSortRole(Qt::DisplayRole); proxyModel->setSortRole(Qt::DisplayRole);
} }
} }
QString PeerListWidget::getConnectionString(int connection_type)
{
QString connection;
switch(connection_type) {
#if LIBTORRENT_VERSION_MINOR > 15
case peer_info::bittorrent_utp:
connection = "uTP";
break;
case peer_info::http_seed:
#endif
case peer_info::web_seed:
connection = "Web";
break;
default:
connection = "BT";
break;
}
return connection;
}

3
src/properties/peerlistwidget.h

@ -82,6 +82,9 @@ protected slots:
void banSelectedPeers(QStringList peer_ips); void banSelectedPeers(QStringList peer_ips);
void handleSortColumnChanged(int col); void handleSortColumnChanged(int col);
private:
static QString getConnectionString(int connection_type);
private: private:
QStandardItemModel *listModel; QStandardItemModel *listModel;
PeerListDelegate *listDelegate; PeerListDelegate *listDelegate;

28
src/qtlibtorrent/qbtsession.cpp

@ -453,6 +453,34 @@ void QBtSession::configureSession() {
s->set_max_half_open_connections(pref.getMaxHalfOpenConnections()); s->set_max_half_open_connections(pref.getMaxHalfOpenConnections());
// * Max connections limit // * Max connections limit
setMaxConnections(pref.getMaxConnecs()); setMaxConnections(pref.getMaxConnecs());
#endif
#if LIBTORRENT_VERSION_MINOR > 15
// uTP
switch((int)pref.getBTProtocol()) {
case BT::TCP_uTP:
sessionSettings.enable_incoming_tcp = true;
sessionSettings.enable_outgoing_tcp = true;
sessionSettings.enable_incoming_utp = true;
sessionSettings.enable_outgoing_utp = true;
break;
case BT::TCP:
sessionSettings.enable_incoming_tcp = true;
sessionSettings.enable_outgoing_tcp = true;
sessionSettings.enable_incoming_utp = false;
sessionSettings.enable_outgoing_utp = false;
break;
case BT::uTP:
sessionSettings.enable_incoming_tcp = false;
sessionSettings.enable_outgoing_tcp = false;
sessionSettings.enable_incoming_utp = true;
sessionSettings.enable_outgoing_utp = true;
break;
default:
Q_ASSERT(0);
break;
}
// uTP rate limiting
sessionSettings.rate_limit_utp = pref.isuTPRateLimited();
#endif #endif
qDebug() << "Settings SessionSettings"; qDebug() << "Settings SessionSettings";
setSessionSettings(sessionSettings); setSessionSettings(sessionSettings);

Loading…
Cancel
Save