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