From 1b0db7b984c49f40cf95c6f685c3c5c790f07606 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Mon, 1 Jun 2015 09:09:51 +0200 Subject: [Qt] extend rpc console peers tab - add node id, ping wait, whitelisted and common height - rephrase some labels to make them easier to understand for users --- src/qt/forms/rpcconsole.ui | 122 +++++++++++++++++++++++++++++++++++---------- src/qt/peertablemodel.cpp | 1 + src/qt/rpcconsole.cpp | 18 ++++--- 3 files changed, 110 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/qt/forms/rpcconsole.ui b/src/qt/forms/rpcconsole.ui index c1eb185501..7ae8237476 100644 --- a/src/qt/forms/rpcconsole.ui +++ b/src/qt/forms/rpcconsole.ui @@ -745,13 +745,36 @@ + + + Whitelisted + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + Direction - + IBeamCursor @@ -767,14 +790,14 @@ - + Version - + IBeamCursor @@ -790,14 +813,14 @@ - + User Agent - + IBeamCursor @@ -813,14 +836,14 @@ - + Services - + IBeamCursor @@ -839,7 +862,7 @@ - Starting Height + Starting Block @@ -862,7 +885,7 @@ - Sync Height + Synced Headers @@ -883,13 +906,36 @@ + + + Synced Blocks + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + Ban Score - + IBeamCursor @@ -905,14 +951,14 @@ - + Connection Time - + IBeamCursor @@ -928,14 +974,14 @@ - + Last Send - + IBeamCursor @@ -951,14 +997,14 @@ - + Last Receive - + IBeamCursor @@ -974,14 +1020,14 @@ - + Bytes Sent - + IBeamCursor @@ -997,14 +1043,14 @@ - + Bytes Received - + IBeamCursor @@ -1020,14 +1066,14 @@ - + Ping Time - + IBeamCursor @@ -1043,14 +1089,40 @@ - + + + + The duration of a currently outstanding ping. + + + Ping Wait + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + Time Offset - + IBeamCursor @@ -1066,7 +1138,7 @@ - + Qt::Vertical diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index 220f273d02..06403734e9 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -68,6 +68,7 @@ public: CNodeCombinedStats stats; stats.nodeStateStats.nMisbehavior = 0; stats.nodeStateStats.nSyncHeight = -1; + stats.nodeStateStats.nCommonHeight = -1; stats.fNodeStateStatsAvailable = false; pnode->copyStats(stats.nodeStats); cachedNodeStats.append(stats); diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index e99972d498..73ee33cbd8 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -611,7 +611,8 @@ void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats) cachedNodeid = stats->nodeStats.nodeid; // update the detail ui with latest node information - QString peerAddrDetails(QString::fromStdString(stats->nodeStats.addrName)); + QString peerAddrDetails(QString::fromStdString(stats->nodeStats.addrName) + " "); + peerAddrDetails += tr("(node id: %1)").arg(QString::number(stats->nodeStats.nodeid)); if (!stats->nodeStats.addrLocal.empty()) peerAddrDetails += "
" + tr("via %1").arg(QString::fromStdString(stats->nodeStats.addrLocal)); ui->peerHeading->setText(peerAddrDetails); @@ -622,11 +623,13 @@ void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats) ui->peerBytesRecv->setText(FormatBytes(stats->nodeStats.nRecvBytes)); ui->peerConnTime->setText(GUIUtil::formatDurationStr(GetTime() - stats->nodeStats.nTimeConnected)); ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingTime)); + ui->peerPingWait->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingWait)); ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset)); - ui->peerVersion->setText(QString("%1").arg(stats->nodeStats.nVersion)); + ui->peerVersion->setText(QString("%1").arg(QString::number(stats->nodeStats.nVersion))); ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer)); ui->peerDirection->setText(stats->nodeStats.fInbound ? tr("Inbound") : tr("Outbound")); - ui->peerHeight->setText(QString("%1").arg(stats->nodeStats.nStartingHeight)); + ui->peerHeight->setText(QString("%1").arg(QString::number(stats->nodeStats.nStartingHeight))); + ui->peerWhitelisted->setText(stats->nodeStats.fWhitelisted ? tr("Yes") : tr("No")); // This check fails for example if the lock was busy and // nodeStateStats couldn't be fetched. @@ -639,9 +642,12 @@ void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats) ui->peerSyncHeight->setText(QString("%1").arg(stats->nodeStateStats.nSyncHeight)); else ui->peerSyncHeight->setText(tr("Unknown")); - } else { - ui->peerBanScore->setText(tr("Fetching...")); - ui->peerSyncHeight->setText(tr("Fetching...")); + + // Common height is init to -1 + if (stats->nodeStateStats.nCommonHeight > -1) + ui->peerCommonHeight->setText(QString("%1").arg(stats->nodeStateStats.nCommonHeight)); + else + ui->peerCommonHeight->setText(tr("Unknown")); } ui->detailWidget->show(); -- cgit v1.2.3 From 7211adad85275db24835bb877a29b28adcf06f62 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Mon, 1 Jun 2015 11:39:52 +0200 Subject: [Qt] replace Boost foreach with Qt version peertablemodel.cpp --- src/qt/peertablemodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index 06403734e9..f5904a4d8e 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -63,7 +63,7 @@ public: #if QT_VERSION >= 0x040700 cachedNodeStats.reserve(vNodes.size()); #endif - BOOST_FOREACH(CNode* pnode, vNodes) + foreach (CNode* pnode, vNodes) { CNodeCombinedStats stats; stats.nodeStateStats.nMisbehavior = 0; @@ -92,7 +92,7 @@ public: // build index map mapNodeRows.clear(); int row = 0; - BOOST_FOREACH(CNodeCombinedStats &stats, cachedNodeStats) + foreach (const CNodeCombinedStats& stats, cachedNodeStats) mapNodeRows.insert(std::pair(stats.nodeStats.nodeid, row++)); } -- cgit v1.2.3 From e0597268116cf90d961abeba9d14aaad0ab682d2 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Sat, 6 Jun 2015 10:38:15 +0200 Subject: [Qt] deselect peer when switching away from peers tab in RPC console --- src/qt/rpcconsole.cpp | 32 +++++++++++++++++--------------- src/qt/rpcconsole.h | 4 +++- 2 files changed, 20 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 73ee33cbd8..681617bd81 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -485,10 +485,10 @@ void RPCConsole::startExecutor() void RPCConsole::on_tabWidget_currentChanged(int index) { - if(ui->tabWidget->widget(index) == ui->tab_console) - { + if (ui->tabWidget->widget(index) == ui->tab_console) ui->lineEdit->setFocus(); - } + else if (ui->tabWidget->widget(index) != ui->tab_peers) + clearSelectedNode(); } void RPCConsole::on_openDebugLogfileButton_clicked() @@ -558,12 +558,11 @@ void RPCConsole::peerLayoutChanged() return; // find the currently selected row - int selectedRow; + int selectedRow = -1; QModelIndexList selectedModelIndex = ui->peerWidget->selectionModel()->selectedIndexes(); - if (selectedModelIndex.isEmpty()) - selectedRow = -1; - else + 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) @@ -573,9 +572,6 @@ void RPCConsole::peerLayoutChanged() { // detail node dissapeared from table (node disconnected) fUnselect = true; - cachedNodeid = -1; - ui->detailWidget->hide(); - ui->peerHeading->setText(tr("Select a peer to view detailed information.")); } else { @@ -590,10 +586,8 @@ void RPCConsole::peerLayoutChanged() stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow); } - if (fUnselect && selectedRow >= 0) - { - ui->peerWidget->selectionModel()->select(QItemSelection(selectedModelIndex.first(), selectedModelIndex.last()), - QItemSelectionModel::Deselect); + if (fUnselect && selectedRow >= 0) { + clearSelectedNode(); } if (fReselect) @@ -694,6 +688,14 @@ void RPCConsole::disconnectSelectedNode() // Find the node, disconnect it and clear the selected node if (CNode *bannedNode = FindNode(strNode.toStdString())) { bannedNode->CloseSocketDisconnect(); - ui->peerWidget->selectionModel()->clearSelection(); + clearSelectedNode(); } } + +void RPCConsole::clearSelectedNode() +{ + ui->peerWidget->selectionModel()->clearSelection(); + cachedNodeid = -1; + ui->detailWidget->hide(); + ui->peerHeading->setText(tr("Select a peer to view detailed information.")); +} diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 767e9aaeea..a309df7ba7 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -76,7 +76,7 @@ public slots: void peerSelected(const QItemSelection &selected, const QItemSelection &deselected); /** Handle updated peer information */ void peerLayoutChanged(); - /** Disconnect a selected node on the Peers tab */ + /** Disconnect a selected node on the Peers tab */ void disconnectSelectedNode(); signals: @@ -90,6 +90,8 @@ private: void setTrafficGraphRange(int mins); /** show detailed information on ui about selected node */ void updateNodeDetail(const CNodeCombinedStats *stats); + /** clear the selected node */ + void clearSelectedNode(); enum ColumnWidths { -- cgit v1.2.3