|
|
@ -25,6 +25,7 @@ |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#include <QKeyEvent> |
|
|
|
#include <QKeyEvent> |
|
|
|
|
|
|
|
#include <QMenu> |
|
|
|
#include <QScrollBar> |
|
|
|
#include <QScrollBar> |
|
|
|
#include <QThread> |
|
|
|
#include <QThread> |
|
|
|
#include <QTime> |
|
|
|
#include <QTime> |
|
|
@ -205,7 +206,8 @@ RPCConsole::RPCConsole(QWidget *parent) : |
|
|
|
ui(new Ui::RPCConsole), |
|
|
|
ui(new Ui::RPCConsole), |
|
|
|
clientModel(0), |
|
|
|
clientModel(0), |
|
|
|
historyPtr(0), |
|
|
|
historyPtr(0), |
|
|
|
cachedNodeid(-1) |
|
|
|
cachedNodeid(-1), |
|
|
|
|
|
|
|
contextMenu(0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ui->setupUi(this); |
|
|
|
ui->setupUi(this); |
|
|
|
GUIUtil::restoreWindowGeometry("nRPCConsoleWindow", this->size(), this); |
|
|
|
GUIUtil::restoreWindowGeometry("nRPCConsoleWindow", this->size(), this); |
|
|
@ -305,10 +307,22 @@ void RPCConsole::setClientModel(ClientModel *model) |
|
|
|
ui->peerWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); |
|
|
|
ui->peerWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); |
|
|
|
ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows); |
|
|
|
ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows); |
|
|
|
ui->peerWidget->setSelectionMode(QAbstractItemView::SingleSelection); |
|
|
|
ui->peerWidget->setSelectionMode(QAbstractItemView::SingleSelection); |
|
|
|
|
|
|
|
ui->peerWidget->setContextMenuPolicy(Qt::CustomContextMenu); |
|
|
|
ui->peerWidget->setColumnWidth(PeerTableModel::Address, ADDRESS_COLUMN_WIDTH); |
|
|
|
ui->peerWidget->setColumnWidth(PeerTableModel::Address, ADDRESS_COLUMN_WIDTH); |
|
|
|
ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH); |
|
|
|
ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH); |
|
|
|
ui->peerWidget->setColumnWidth(PeerTableModel::Ping, PING_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 the peerWidget selection model to our peerSelected() handler
|
|
|
|
connect(ui->peerWidget->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), |
|
|
|
connect(ui->peerWidget->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), |
|
|
|
this, SLOT(peerSelected(const QItemSelection &, const QItemSelection &))); |
|
|
|
this, SLOT(peerSelected(const QItemSelection &, const QItemSelection &))); |
|
|
@ -659,3 +673,21 @@ void RPCConsole::hideEvent(QHideEvent *event) |
|
|
|
// stop PeerTableModel auto refresh
|
|
|
|
// stop PeerTableModel auto refresh
|
|
|
|
clientModel->getPeerTableModel()->stopAutoRefresh(); |
|
|
|
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(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|