Browse Source

Copy selected peers (IP:Port)

adaptive-webui-19844
ngosang 10 years ago
parent
commit
17eb2dd3cc
  1. 13
      src/properties/peerlistwidget.cpp

13
src/properties/peerlistwidget.cpp

@ -153,10 +153,13 @@ void PeerListWidget::showPeerListMenu(const QPoint&)
if (!h.is_valid()) return; if (!h.is_valid()) return;
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); QModelIndexList selectedIndexes = selectionModel()->selectedRows();
QStringList selectedPeerIPs; QStringList selectedPeerIPs;
QStringList selectedPeerIPPort;
foreach (const QModelIndex &index, selectedIndexes) { foreach (const QModelIndex &index, selectedIndexes) {
int row = m_proxyModel->mapToSource(index).row(); int row = m_proxyModel->mapToSource(index).row();
QString myip = m_listModel->data(m_listModel->index(row, PeerListDelegate::IP_HIDDEN)).toString(); QString myip = m_listModel->data(m_listModel->index(row, PeerListDelegate::IP_HIDDEN)).toString();
QString myport = m_listModel->data(m_listModel->index(row, PeerListDelegate::PORT)).toString();
selectedPeerIPs << myip; selectedPeerIPs << myip;
selectedPeerIPPort << myip + ":" + myport;
} }
// Add Peer Action // Add Peer Action
QAction *addPeerAct = 0; QAction *addPeerAct = 0;
@ -170,9 +173,9 @@ void PeerListWidget::showPeerListMenu(const QPoint&)
QAction *dlLimitAct = 0; QAction *dlLimitAct = 0;
#endif #endif
QAction *banAct = 0; QAction *banAct = 0;
QAction *copyIPAct = 0; QAction *copyPeerAct = 0;
if (!selectedPeerIPs.isEmpty()) { if (!selectedPeerIPs.isEmpty()) {
copyIPAct = menu.addAction(IconProvider::instance()->getIcon("edit-copy"), tr("Copy IP")); copyPeerAct = menu.addAction(IconProvider::instance()->getIcon("edit-copy"), tr("Copy selected"));
menu.addSeparator(); menu.addSeparator();
#if LIBTORRENT_VERSION_NUM < 10000 #if LIBTORRENT_VERSION_NUM < 10000
dlLimitAct = menu.addAction(QIcon(":/Icons/skin/download.png"), tr("Limit download rate...")); dlLimitAct = menu.addAction(QIcon(":/Icons/skin/download.png"), tr("Limit download rate..."));
@ -213,11 +216,11 @@ void PeerListWidget::showPeerListMenu(const QPoint&)
banSelectedPeers(selectedPeerIPs); banSelectedPeers(selectedPeerIPs);
return; return;
} }
if (act == copyIPAct) { if (act == copyPeerAct) {
#if defined(Q_OS_WIN) || defined(Q_OS_OS2) #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
QApplication::clipboard()->setText(selectedPeerIPs.join("\r\n")); QApplication::clipboard()->setText(selectedPeerIPPort.join("\r\n"));
#else #else
QApplication::clipboard()->setText(selectedPeerIPs.join("\n")); QApplication::clipboard()->setText(selectedPeerIPPort.join("\n"));
#endif #endif
} }
} }

Loading…
Cancel
Save