aboutsummaryrefslogtreecommitdiff
path: root/src/qt/rpcconsole.cpp
diff options
context:
space:
mode:
authorPhilip Kaufmann <phil.kaufmann@t-online.de>2015-06-26 10:23:51 +0200
committerJonas Schnelli <jonas.schnelli@include7.ch>2015-09-16 16:50:19 +0200
commitcdd72cd5fbc2b287559f7230d1616339e9ff2d6d (patch)
treefec12703dc0654e2d1b43768cdde14ac112c689a /src/qt/rpcconsole.cpp
parent43c1f5b8d7accc158dfd6b270cb9bfd0cd900a3e (diff)
downloadbitcoin-cdd72cd5fbc2b287559f7230d1616339e9ff2d6d.tar.xz
[Qt] simplify ban list signal handling
- remove banListChanged signal from client model - directly call clientModel->getBanTableModel()->refresh() without the way over clientModel->updateBanlist() - also fix clearing peer detail window, when selecting (clicking) peers in the ban list
Diffstat (limited to 'src/qt/rpcconsole.cpp')
-rw-r--r--src/qt/rpcconsole.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 380586f610..1b82aada41 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -331,8 +331,7 @@ void RPCConsole::setClientModel(ClientModel *model)
{
clientModel = model;
ui->trafficGraph->setClientModel(model);
- if(model)
- {
+ if (model && clientModel->getPeerTableModel() && clientModel->getBanTableModel()) {
// Keep up to date with client
setNumConnections(model->getNumConnections());
connect(model, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
@@ -404,19 +403,23 @@ void RPCConsole::setClientModel(ClientModel *model)
ui->banlistWidget->setContextMenuPolicy(Qt::CustomContextMenu);
ui->banlistWidget->horizontalHeader()->setStretchLastSection(true);
- // ensure ban table is shown or hidden (if empty)
- connect(model, SIGNAL(banListChanged()), this, SLOT(showOrHideBanTableIfRequired()));
- showOrHideBanTableIfRequired();
-
- // create banlist context menu actions
+ // create ban table context menu action
QAction* unbanAction = new QAction(tr("&Unban Node"), this);
+
+ // create ban table context menu
banTableContextMenu = new QMenu();
banTableContextMenu->addAction(unbanAction);
- // context menu signals
+ // ban table context menu signals
connect(ui->banlistWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showBanTableContextMenu(const QPoint&)));
connect(unbanAction, SIGNAL(triggered()), this, SLOT(unbanSelectedNode()));
+ // ban table signal handling - clear peer details when clicking a peer in the ban table
+ connect(ui->banlistWidget, SIGNAL(clicked(const QModelIndex&)), this, SLOT(clearSelectedNode()));
+ // ban table signal handling - ensure ban table is shown or hidden (if empty)
+ connect(model->getBanTableModel(), SIGNAL(layoutChanged()), this, SLOT(showOrHideBanTableIfRequired()));
+ showOrHideBanTableIfRequired();
+
// Provide initial values
ui->clientVersion->setText(model->formatFullVersion());
ui->clientUserAgent->setText(model->formatSubVersion());
@@ -790,6 +793,9 @@ void RPCConsole::disconnectSelectedNode()
void RPCConsole::banSelectedNode(int bantime)
{
+ if (!clientModel)
+ return;
+
// Get currently selected peer address
QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address);
// Find possible nodes, ban it and clear the selected node
@@ -803,14 +809,15 @@ void RPCConsole::banSelectedNode(int bantime)
bannedNode->fDisconnect = true;
clearSelectedNode();
- ui->banlistWidget->setVisible(true);
- ui->banHeading->setVisible(true);
- clientModel->updateBanlist();
+ clientModel->getBanTableModel()->refresh();
}
}
void RPCConsole::unbanSelectedNode()
{
+ if (!clientModel)
+ return;
+
// Get currently selected ban address
QString strNode = GUIUtil::getEntryData(ui->banlistWidget, 0, BanTableModel::Address);
CSubNet possibleSubnet(strNode.toStdString());
@@ -818,8 +825,7 @@ void RPCConsole::unbanSelectedNode()
if (possibleSubnet.IsValid())
{
CNode::Unban(possibleSubnet);
- clientModel->updateBanlist();
- showOrHideBanTableIfRequired();
+ clientModel->getBanTableModel()->refresh();
}
}