|
|
|
@ -25,6 +25,7 @@
@@ -25,6 +25,7 @@
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#include <QKeyEvent> |
|
|
|
|
#include <QMenu> |
|
|
|
|
#include <QScrollBar> |
|
|
|
|
#include <QThread> |
|
|
|
|
#include <QTime> |
|
|
|
@ -205,7 +206,8 @@ RPCConsole::RPCConsole(QWidget *parent) :
@@ -205,7 +206,8 @@ RPCConsole::RPCConsole(QWidget *parent) :
|
|
|
|
|
ui(new Ui::RPCConsole), |
|
|
|
|
clientModel(0), |
|
|
|
|
historyPtr(0), |
|
|
|
|
cachedNodeid(-1) |
|
|
|
|
cachedNodeid(-1), |
|
|
|
|
contextMenu(0) |
|
|
|
|
{ |
|
|
|
|
ui->setupUi(this); |
|
|
|
|
GUIUtil::restoreWindowGeometry("nRPCConsoleWindow", this->size(), this); |
|
|
|
@ -305,10 +307,22 @@ void RPCConsole::setClientModel(ClientModel *model)
@@ -305,10 +307,22 @@ void RPCConsole::setClientModel(ClientModel *model)
|
|
|
|
|
ui->peerWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); |
|
|
|
|
ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows); |
|
|
|
|
ui->peerWidget->setSelectionMode(QAbstractItemView::SingleSelection); |
|
|
|
|
ui->peerWidget->setContextMenuPolicy(Qt::CustomContextMenu); |
|
|
|
|
ui->peerWidget->setColumnWidth(PeerTableModel::Address, ADDRESS_COLUMN_WIDTH); |
|
|
|
|
ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH); |
|
|
|
|
ui->peerWidget->setColumnWidth(PeerTableModel::Ping, PING_COLUMN_WIDTH); |
|
|
|
|
|
|
|
|
|
// create context menu actions
|
|
|
|
|
QAction* disconnectAction = new QAction(tr("&Disconnect Node"), this); |
|
|
|
|
|
|
|
|
|
// create context menu
|
|
|
|
|
contextMenu = new QMenu(); |
|
|
|
|
contextMenu->addAction(disconnectAction); |
|
|
|
|
|
|
|
|
|
// context menu signals
|
|
|
|
|
connect(ui->peerWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showMenu(const QPoint&))); |
|
|
|
|
connect(disconnectAction, SIGNAL(triggered()), this, SLOT(disconnectSelectedNode())); |
|
|
|
|
|
|
|
|
|
// connect the peerWidget selection model to our peerSelected() handler
|
|
|
|
|
connect(ui->peerWidget->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), |
|
|
|
|
this, SLOT(peerSelected(const QItemSelection &, const QItemSelection &))); |
|
|
|
@ -659,3 +673,21 @@ void RPCConsole::hideEvent(QHideEvent *event)
@@ -659,3 +673,21 @@ void RPCConsole::hideEvent(QHideEvent *event)
|
|
|
|
|
// stop PeerTableModel auto refresh
|
|
|
|
|
clientModel->getPeerTableModel()->stopAutoRefresh(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void RPCConsole::showMenu(const QPoint& point) |
|
|
|
|
{ |
|
|
|
|
QModelIndex index = ui->peerWidget->indexAt(point); |
|
|
|
|
if (index.isValid()) |
|
|
|
|
contextMenu->exec(QCursor::pos()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void RPCConsole::disconnectSelectedNode() |
|
|
|
|
{ |
|
|
|
|
// Get currently selected peer address
|
|
|
|
|
QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address); |
|
|
|
|
// Find the node, disconnect it and clear the selected node
|
|
|
|
|
if (CNode *bannedNode = FindNode(strNode.toStdString())) { |
|
|
|
|
bannedNode->CloseSocketDisconnect(); |
|
|
|
|
ui->peerWidget->selectionModel()->clearSelection(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|