|
|
@ -28,6 +28,8 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "peerlistwidget.h" |
|
|
|
#include "peerlistwidget.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <algorithm> |
|
|
|
|
|
|
|
|
|
|
|
#include <QApplication> |
|
|
|
#include <QApplication> |
|
|
|
#include <QClipboard> |
|
|
|
#include <QClipboard> |
|
|
|
#include <QHeaderView> |
|
|
|
#include <QHeaderView> |
|
|
@ -242,16 +244,10 @@ void PeerListWidget::showPeerListMenu(const QPoint &) |
|
|
|
connect(addPeerAct, &QAction::triggered, this, [this, torrent]() |
|
|
|
connect(addPeerAct, &QAction::triggered, this, [this, torrent]() |
|
|
|
{ |
|
|
|
{ |
|
|
|
const QVector<BitTorrent::PeerAddress> peersList = PeersAdditionDialog::askForPeers(this); |
|
|
|
const QVector<BitTorrent::PeerAddress> peersList = PeersAdditionDialog::askForPeers(this); |
|
|
|
int peerCount = 0; |
|
|
|
const int peerCount = std::count_if(peersList.cbegin(), peersList.cend(), [torrent](const BitTorrent::PeerAddress &peer) |
|
|
|
for (const BitTorrent::PeerAddress &addr : peersList) { |
|
|
|
{ |
|
|
|
if (torrent->connectPeer(addr)) { |
|
|
|
return torrent->connectPeer(peer); |
|
|
|
++peerCount; |
|
|
|
}); |
|
|
|
LogMsg(tr("Peer \"%1\" added to \"%2\"").arg(addr.ip.toString(), torrent->name())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
LogMsg(tr("Failed to add peer \"%1\" to \"%2\".").arg(addr.ip.toString(), torrent->name()), Log::WARNING); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (peerCount < peersList.length()) |
|
|
|
if (peerCount < peersList.length()) |
|
|
|
QMessageBox::information(this, tr("Adding peers"), tr("Some peers cannot be added. Check the Log for details.")); |
|
|
|
QMessageBox::information(this, tr("Adding peers"), tr("Some peers cannot be added. Check the Log for details.")); |
|
|
|
else if (peerCount > 0) |
|
|
|
else if (peerCount > 0) |
|
|
|