|
|
|
@ -9,13 +9,14 @@
|
|
|
|
|
#include <qt/rpcconsole.h>
|
|
|
|
|
#include <qt/forms/ui_debugwindow.h>
|
|
|
|
|
|
|
|
|
|
#include <chainparams.h>
|
|
|
|
|
#include <interfaces/node.h>
|
|
|
|
|
#include <netbase.h>
|
|
|
|
|
#include <qt/bantablemodel.h>
|
|
|
|
|
#include <qt/clientmodel.h>
|
|
|
|
|
#include <qt/peertablesortproxy.h>
|
|
|
|
|
#include <qt/platformstyle.h>
|
|
|
|
|
#include <qt/walletmodel.h>
|
|
|
|
|
#include <chainparams.h>
|
|
|
|
|
#include <interfaces/node.h>
|
|
|
|
|
#include <netbase.h>
|
|
|
|
|
#include <rpc/client.h>
|
|
|
|
|
#include <rpc/server.h>
|
|
|
|
|
#include <util/strencodings.h>
|
|
|
|
@ -606,7 +607,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
|
|
|
|
|
connect(model, &ClientModel::mempoolSizeChanged, this, &RPCConsole::setMempoolSize);
|
|
|
|
|
|
|
|
|
|
// set up peer table
|
|
|
|
|
ui->peerWidget->setModel(model->getPeerTableModel());
|
|
|
|
|
ui->peerWidget->setModel(model->peerTableSortProxy());
|
|
|
|
|
ui->peerWidget->verticalHeader()->hide();
|
|
|
|
|
ui->peerWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
|
ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
|
|
@ -643,10 +644,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
|
|
|
|
|
|
|
|
|
|
// peer table signal handling - update peer details when selecting new node
|
|
|
|
|
connect(ui->peerWidget->selectionModel(), &QItemSelectionModel::selectionChanged, this, &RPCConsole::updateDetailWidget);
|
|
|
|
|
// peer table signal handling - update peer details when new nodes are added to the model
|
|
|
|
|
connect(model->getPeerTableModel(), &PeerTableModel::layoutChanged, this, &RPCConsole::peerLayoutChanged);
|
|
|
|
|
// peer table signal handling - cache selected node ids
|
|
|
|
|
connect(model->getPeerTableModel(), &PeerTableModel::layoutAboutToBeChanged, this, &RPCConsole::peerLayoutAboutToChange);
|
|
|
|
|
connect(model->getPeerTableModel(), &PeerTableModel::layoutChanged, this, &RPCConsole::updateDetailWidget);
|
|
|
|
|
|
|
|
|
|
// set up ban table
|
|
|
|
|
ui->banlistWidget->setModel(model->getBanTableModel());
|
|
|
|
@ -1037,67 +1035,6 @@ void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
|
|
|
|
|
ui->lblBytesOut->setText(GUIUtil::formatBytes(totalBytesOut));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RPCConsole::peerLayoutAboutToChange()
|
|
|
|
|
{
|
|
|
|
|
cachedNodeids.clear();
|
|
|
|
|
for (const QModelIndex& peer : GUIUtil::getEntryData(ui->peerWidget, PeerTableModel::NetNodeId)) {
|
|
|
|
|
const auto stats = peer.data(PeerTableModel::StatsRole).value<CNodeCombinedStats*>();
|
|
|
|
|
cachedNodeids.append(stats->nodeStats.nodeid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RPCConsole::peerLayoutChanged()
|
|
|
|
|
{
|
|
|
|
|
if (!clientModel || !clientModel->getPeerTableModel())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bool fUnselect = false;
|
|
|
|
|
bool fReselect = false;
|
|
|
|
|
|
|
|
|
|
if (cachedNodeids.empty()) // no node selected yet
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// find the currently selected row
|
|
|
|
|
int selectedRow = -1;
|
|
|
|
|
QModelIndexList selectedModelIndex = ui->peerWidget->selectionModel()->selectedIndexes();
|
|
|
|
|
if (!selectedModelIndex.isEmpty()) {
|
|
|
|
|
selectedRow = selectedModelIndex.first().row();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check if our detail node has a row in the table (it may not necessarily
|
|
|
|
|
// be at selectedRow since its position can change after a layout change)
|
|
|
|
|
int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeids.first());
|
|
|
|
|
|
|
|
|
|
if (detailNodeRow < 0)
|
|
|
|
|
{
|
|
|
|
|
// detail node disappeared from table (node disconnected)
|
|
|
|
|
fUnselect = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (detailNodeRow != selectedRow)
|
|
|
|
|
{
|
|
|
|
|
// detail node moved position
|
|
|
|
|
fUnselect = true;
|
|
|
|
|
fReselect = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fUnselect && selectedRow >= 0) {
|
|
|
|
|
clearSelectedNode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fReselect)
|
|
|
|
|
{
|
|
|
|
|
for(int i = 0; i < cachedNodeids.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
ui->peerWidget->selectRow(clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeids.at(i)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateDetailWidget();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RPCConsole::updateDetailWidget()
|
|
|
|
|
{
|
|
|
|
|
const QList<QModelIndex> selected_peers = GUIUtil::getEntryData(ui->peerWidget, PeerTableModel::NetNodeId);
|
|
|
|
|