@@ -469,19 +469,19 @@ void RPCConsole::setClientModel(ClientModel *model)
469
469
ui->peerWidget ->verticalHeader ()->hide ();
470
470
ui->peerWidget ->setEditTriggers (QAbstractItemView::NoEditTriggers);
471
471
ui->peerWidget ->setSelectionBehavior (QAbstractItemView::SelectRows);
472
- ui->peerWidget ->setSelectionMode (QAbstractItemView::SingleSelection );
472
+ ui->peerWidget ->setSelectionMode (QAbstractItemView::ExtendedSelection );
473
473
ui->peerWidget ->setContextMenuPolicy (Qt::CustomContextMenu);
474
474
ui->peerWidget ->setColumnWidth (PeerTableModel::Address, ADDRESS_COLUMN_WIDTH);
475
475
ui->peerWidget ->setColumnWidth (PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH);
476
476
ui->peerWidget ->setColumnWidth (PeerTableModel::Ping, PING_COLUMN_WIDTH);
477
477
ui->peerWidget ->horizontalHeader ()->setStretchLastSection (true );
478
478
479
479
// create peer table context menu actions
480
- QAction* disconnectAction = new QAction (tr (" &Disconnect Node " ), this );
481
- QAction* banAction1h = new QAction (tr (" Ban Node for" ) + " " + tr (" 1 &hour" ), this );
482
- QAction* banAction24h = new QAction (tr (" Ban Node for" ) + " " + tr (" 1 &day" ), this );
483
- QAction* banAction7d = new QAction (tr (" Ban Node for" ) + " " + tr (" 1 &week" ), this );
484
- QAction* banAction365d = new QAction (tr (" Ban Node for" ) + " " + tr (" 1 &year" ), this );
480
+ QAction* disconnectAction = new QAction (tr (" &Disconnect" ), this );
481
+ QAction* banAction1h = new QAction (tr (" Ban for" ) + " " + tr (" 1 &hour" ), this );
482
+ QAction* banAction24h = new QAction (tr (" Ban for" ) + " " + tr (" 1 &day" ), this );
483
+ QAction* banAction7d = new QAction (tr (" Ban for" ) + " " + tr (" 1 &week" ), this );
484
+ QAction* banAction365d = new QAction (tr (" Ban for" ) + " " + tr (" 1 &year" ), this );
485
485
486
486
// create peer table context menu
487
487
peersTableContextMenu = new QMenu ();
@@ -527,7 +527,7 @@ void RPCConsole::setClientModel(ClientModel *model)
527
527
ui->banlistWidget ->horizontalHeader ()->setStretchLastSection (true );
528
528
529
529
// create ban table context menu action
530
- QAction* unbanAction = new QAction (tr (" &Unban Node " ), this );
530
+ QAction* unbanAction = new QAction (tr (" &Unban" ), this );
531
531
532
532
// create ban table context menu
533
533
banTableContextMenu = new QMenu ();
@@ -973,49 +973,65 @@ void RPCConsole::disconnectSelectedNode()
973
973
{
974
974
if (!g_connman)
975
975
return ;
976
- // Get currently selected peer address
977
- NodeId id = GUIUtil::getEntryData (ui->peerWidget , 0 , PeerTableModel::NetNodeId).toInt ();
978
- // Find the node, disconnect it and clear the selected node
979
- if (g_connman->DisconnectNode (id))
980
- clearSelectedNode ();
976
+
977
+ // Get selected peer addresses
978
+ QList<QModelIndex> nodes = GUIUtil::getEntryData (ui->peerWidget , 0 );
979
+ for (int i = 0 ; i < nodes.count (); i++)
980
+ {
981
+ // Get currently selected peer address
982
+ NodeId id = nodes.at (i).data (PeerTableModel::NetNodeId).toInt ();
983
+ // Find the node, disconnect it and clear the selected node
984
+ if (g_connman->DisconnectNode (id))
985
+ clearSelectedNode ();
986
+ }
981
987
}
982
988
983
989
void RPCConsole::banSelectedNode (int bantime)
984
990
{
985
991
if (!clientModel || !g_connman)
986
992
return ;
987
-
988
- if (cachedNodeid == -1 )
989
- return ;
990
-
991
- // Get currently selected peer address
992
- int detailNodeRow = clientModel->getPeerTableModel ()->getRowByNodeId (cachedNodeid);
993
- if (detailNodeRow < 0 )
994
- return ;
995
-
996
- // Find possible nodes, ban it and clear the selected node
997
- const CNodeCombinedStats *stats = clientModel->getPeerTableModel ()->getNodeStats (detailNodeRow);
998
- if (stats) {
999
- g_connman->Ban (stats->nodeStats .addr , BanReasonManuallyAdded, bantime);
1000
- clearSelectedNode ();
1001
- clientModel->getBanTableModel ()->refresh ();
993
+
994
+ // Get selected peer addresses
995
+ QList<QModelIndex> nodes = GUIUtil::getEntryData (ui->peerWidget , 0 );
996
+ for (int i = 0 ; i < nodes.count (); i++)
997
+ {
998
+ // Get currently selected peer address
999
+ NodeId id = nodes.at (i).data (PeerTableModel::NetNodeId).toInt ();
1000
+
1001
+ // Get currently selected peer address
1002
+ int detailNodeRow = clientModel->getPeerTableModel ()->getRowByNodeId (id);
1003
+ if (detailNodeRow < 0 )
1004
+ return ;
1005
+
1006
+ // Find possible nodes, ban it and clear the selected node
1007
+ const CNodeCombinedStats *stats = clientModel->getPeerTableModel ()->getNodeStats (detailNodeRow);
1008
+ if (stats) {
1009
+ g_connman->Ban (stats->nodeStats .addr , BanReasonManuallyAdded, bantime);
1010
+ }
1002
1011
}
1012
+ clearSelectedNode ();
1013
+ clientModel->getBanTableModel ()->refresh ();
1003
1014
}
1004
1015
1005
1016
void RPCConsole::unbanSelectedNode ()
1006
1017
{
1007
1018
if (!clientModel)
1008
1019
return ;
1009
1020
1010
- // Get currently selected ban address
1011
- QString strNode = GUIUtil::getEntryData (ui->banlistWidget , 0 , BanTableModel::Address).toString ();
1012
- CSubNet possibleSubnet;
1013
-
1014
- LookupSubNet (strNode.toStdString ().c_str (), possibleSubnet);
1015
- if (possibleSubnet.IsValid () && g_connman)
1021
+ // Get selected ban addresses
1022
+ QList<QModelIndex> nodes = GUIUtil::getEntryData (ui->banlistWidget , 0 );
1023
+ for (int i = 0 ; i < nodes.count (); i++)
1016
1024
{
1017
- g_connman->Unban (possibleSubnet);
1018
- clientModel->getBanTableModel ()->refresh ();
1025
+ // Get currently selected ban address
1026
+ QString strNode = nodes.at (i).data (BanTableModel::Address).toString ();
1027
+ CSubNet possibleSubnet;
1028
+
1029
+ LookupSubNet (strNode.toStdString ().c_str (), possibleSubnet);
1030
+ if (possibleSubnet.IsValid () && g_connman)
1031
+ {
1032
+ g_connman->Unban (possibleSubnet);
1033
+ clientModel->getBanTableModel ()->refresh ();
1034
+ }
1019
1035
}
1020
1036
}
1021
1037
0 commit comments