From a5b2d9c82e985fa8df4457072b4fa30781f1d53a Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Wed, 4 Jun 2014 12:06:18 +0200 Subject: [PATCH] [Qt] tweak new peers tab in console window - remove starting height as table header and replace with ping time - remove columnResizingFixer - add local address (if available) in detailed node view (on top of the right view below the remote address) - remove some .c_str() by using QString::fromStdString() - rename Address to Address/Hostname - rename secs to just s for ping time - use MODEL_UPDATE_DELAY from guiconstants.h for the peer refresh time - make PeerTableModel::columnCount() return no hard-coded value - remove and cleanup dup private: section in RPCConsole header - add new defaults for column sizes - remove behaviour which keeps disconnected peers selected and also remove code which keeps track of last selected peer stats - add sync height to detail view - add some additional NULL pointer checks for clientModel in rpcconsole.cpp --- src/qt/forms/rpcconsole.ui | 536 +++++++++++++++++++++++-------------- src/qt/guiutil.cpp | 5 + src/qt/guiutil.h | 3 + src/qt/peertablemodel.cpp | 64 +++-- src/qt/peertablemodel.h | 9 +- src/qt/rpcconsole.cpp | 155 ++++------- src/qt/rpcconsole.h | 29 +- 7 files changed, 445 insertions(+), 356 deletions(-) diff --git a/src/qt/forms/rpcconsole.ui b/src/qt/forms/rpcconsole.ui index 7158b65c2..b9b90aa84 100644 --- a/src/qt/forms/rpcconsole.ui +++ b/src/qt/forms/rpcconsole.ui @@ -428,7 +428,7 @@ - + &Network Traffic @@ -683,6 +683,19 @@ &Peers + + + + Qt::ScrollBarAlwaysOff + + + true + + + false + + + @@ -691,262 +704,377 @@ 0 + + + 300 + 32 + + + + + 10 + + + + IBeamCursor + Select a peer to view detailed information. - - 3 + + Qt::AlignHCenter|Qt::AlignTop - - - - - - - 0 - 0 - - - - Qt::ScrollBarAlwaysOff - - - QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed - - + true + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + - - - 0 - 0 - + + + 300 + 0 + - - 3 - - - + + - Version: + Direction - - + + + + IBeamCursor + N/A + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Version + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + User Agent + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Services + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Sync Node + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + - + - Last Receive: + Starting Height - - - - User Agent: - - - - - - - N/A - - - - - - - - 160 - 0 - + + + + IBeamCursor N/A - - - - - - Ping Time: + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - 0 - 0 - + + + + Sync Height + + + + + + + IBeamCursor N/A + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Ban Score + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + - Connection Time: + Connection Time - - + + + + IBeamCursor + N/A + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Last Send + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Last Receive + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Bytes Sent + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Bytes Received + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Ping Time + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + - - - N/A + + + Qt::Vertical - - - - - - Starting Height: + + + 20 + 40 + - - - - - - N/A - - - - - - - Bytes Sent: - - - - - - - Bytes Received: - - - - - - - N/A - - - - - - - Ban Score: - - - - - - - N/A - - - - - - - Direction: - - - - - - - N/A - - - - - - - Sync Node: - - - - - - - N/A - - - - - - - Last Send: - - - - - - - Services: - - - - - - - IP Address/port: - - - - - - - N/A - - - - - - - N/A - - - - - - - N/A - - - - - - - - 0 - 0 - - - + diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 33a50a078..6258c4160 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -804,4 +804,9 @@ QString formatServicesStr(uint64_t mask) return QObject::tr("None"); } +QString formatPingTime(double dPingTime) +{ + return dPingTime == 0 ? QObject::tr("N/A") : QString(QObject::tr("%1 s")).arg(QString::number(dPingTime, 'f', 3)); +} + } // namespace GUIUtil diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 45c78b4e1..dd31d051e 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -178,6 +178,9 @@ namespace GUIUtil /* Format CNodeStats.nServices bitmask into a user-readable string */ QString formatServicesStr(uint64_t mask); + + /* Format a CNodeCombinedStats.dPingTime into a user-readable string or display N/A, if 0*/ + QString formatPingTime(double dPingTime); } // namespace GUIUtil #endif // GUIUTIL_H diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index 981d063c4..4c650bdec 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -5,6 +5,8 @@ #include "peertablemodel.h" #include "clientmodel.h" +#include "guiconstants.h" +#include "guiutil.h" #include "net.h" #include "sync.h" @@ -15,8 +17,8 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const { - const CNodeStats *pLeft = &(left.nodestats); - const CNodeStats *pRight = &(right.nodestats); + const CNodeStats *pLeft = &(left.nodeStats); + const CNodeStats *pRight = &(right.nodeStats); if (order == Qt::DescendingOrder) std::swap(pLeft, pRight); @@ -27,8 +29,8 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine return pLeft->addrName.compare(pRight->addrName) < 0; case PeerTableModel::Subversion: return pLeft->cleanSubVer.compare(pRight->cleanSubVer) < 0; - case PeerTableModel::Height: - return pLeft->nStartingHeight < pRight->nStartingHeight; + case PeerTableModel::Ping: + return pLeft->dPingTime < pRight->dPingTime; } return false; @@ -48,7 +50,8 @@ public: std::map mapNodeRows; /** Pull a full list of peers from vNodes into our cache */ - void refreshPeers() { + void refreshPeers() + { { TRY_LOCK(cs_vNodes, lockNodes); if (!lockNodes) @@ -63,23 +66,17 @@ public: BOOST_FOREACH(CNode* pnode, vNodes) { CNodeCombinedStats stats; - stats.statestats.nMisbehavior = -1; - pnode->copyStats(stats.nodestats); + stats.nodeStateStats.nMisbehavior = 0; + stats.nodeStateStats.nSyncHeight = -1; + stats.fNodeStateStatsAvailable = false; + pnode->copyStats(stats.nodeStats); cachedNodeStats.append(stats); } } - // if we can, retrieve the CNodeStateStats for each node. - { - TRY_LOCK(cs_main, lockMain); - if (lockMain) - { - BOOST_FOREACH(CNodeCombinedStats &stats, cachedNodeStats) - { - GetNodeStateStats(stats.nodestats.nodeid, stats.statestats); - } - } - } + // Try to retrieve the CNodeStateStats for each node. + BOOST_FOREACH(CNodeCombinedStats &stats, cachedNodeStats) + stats.fNodeStateStatsAvailable = GetNodeStateStats(stats.nodeStats.nodeid, stats.nodeStateStats); if (sortColumn >= 0) // sort cacheNodeStats (use stable sort to prevent rows jumping around unneceesarily) @@ -89,9 +86,7 @@ public: mapNodeRows.clear(); int row = 0; BOOST_FOREACH(CNodeCombinedStats &stats, cachedNodeStats) - { - mapNodeRows.insert(std::pair(stats.nodestats.nodeid, row++)); - } + mapNodeRows.insert(std::pair(stats.nodeStats.nodeid, row++)); } int size() @@ -103,18 +98,18 @@ public: { if(idx >= 0 && idx < cachedNodeStats.size()) { return &cachedNodeStats[idx]; - } - else - { + } else { return 0; } } }; PeerTableModel::PeerTableModel(ClientModel *parent) : - QAbstractTableModel(parent),clientModel(parent),timer(0) + QAbstractTableModel(parent), + clientModel(parent), + timer(0) { - columns << tr("Address") << tr("User Agent") << tr("Start Height"); + columns << tr("Address/Hostname") << tr("User Agent") << tr("Ping Time"); priv = new PeerTablePriv(); // default to unsorted priv->sortColumn = -1; @@ -122,14 +117,14 @@ PeerTableModel::PeerTableModel(ClientModel *parent) : // set up timer for auto refresh timer = new QTimer(); connect(timer, SIGNAL(timeout()), SLOT(refresh())); + timer->setInterval(MODEL_UPDATE_DELAY); // load initial data refresh(); } -void PeerTableModel::startAutoRefresh(int msecs) +void PeerTableModel::startAutoRefresh() { - timer->setInterval(1000); timer->start(); } @@ -147,7 +142,7 @@ int PeerTableModel::rowCount(const QModelIndex &parent) const int PeerTableModel::columnCount(const QModelIndex &parent) const { Q_UNUSED(parent); - return 3; + return columns.length();; } QVariant PeerTableModel::data(const QModelIndex &index, int role) const @@ -162,11 +157,11 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const switch(index.column()) { case Address: - return QVariant(rec->nodestats.addrName.c_str()); + return QString::fromStdString(rec->nodeStats.addrName); case Subversion: - return QVariant(rec->nodestats.cleanSubVer.c_str()); - case Height: - return rec->nodestats.nStartingHeight; + return QString::fromStdString(rec->nodeStats.cleanSubVer); + case Ping: + return GUIUtil::formatPingTime(rec->nodeStats.dPingTime); } } return QVariant(); @@ -208,7 +203,8 @@ QModelIndex PeerTableModel::index(int row, int column, const QModelIndex &parent } } -const CNodeCombinedStats *PeerTableModel::getNodeStats(int idx) { +const CNodeCombinedStats *PeerTableModel::getNodeStats(int idx) +{ return priv->index(idx); } diff --git a/src/qt/peertablemodel.h b/src/qt/peertablemodel.h index 385bf0e0c..38f2662f8 100644 --- a/src/qt/peertablemodel.h +++ b/src/qt/peertablemodel.h @@ -19,8 +19,9 @@ class QTimer; QT_END_NAMESPACE struct CNodeCombinedStats { - CNodeStats nodestats; - CNodeStateStats statestats; + CNodeStats nodeStats; + CNodeStateStats nodeStateStats; + bool fNodeStateStatsAvailable; }; class NodeLessThan @@ -47,13 +48,13 @@ public: explicit PeerTableModel(ClientModel *parent = 0); const CNodeCombinedStats *getNodeStats(int idx); int getRowByNodeId(NodeId nodeid); - void startAutoRefresh(int msecs); + void startAutoRefresh(); void stopAutoRefresh(); enum ColumnIndex { Address = 0, Subversion = 1, - Height = 2 + Ping = 2 }; /** @name Methods overridden from QAbstractTableModel diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 9b67f8125..11089b249 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -10,6 +10,7 @@ #include "peertablemodel.h" #include "main.h" +#include "chainparams.h" #include "rpcserver.h" #include "rpcclient.h" #include "util.h" @@ -200,12 +201,9 @@ RPCConsole::RPCConsole(QWidget *parent) : QDialog(parent), ui(new Ui::RPCConsole), clientModel(0), - historyPtr(0) + historyPtr(0), + cachedNodeid(-1) { - detailNodeStats = CNodeCombinedStats(); - detailNodeStats.nodestats.nodeid = -1; - detailNodeStats.statestats.nMisbehavior = -1; - ui->setupUi(this); GUIUtil::restoreWindowGeometry("nRPCConsoleWindow", this->size(), this); @@ -233,6 +231,7 @@ RPCConsole::RPCConsole(QWidget *parent) : setTrafficGraphRange(INITIAL_TRAFFIC_GRAPH_MINS); ui->detailWidget->hide(); + ui->peerHeading->setText(tr("Select a peer to view detailed information.")); clear(); } @@ -303,11 +302,11 @@ void RPCConsole::setClientModel(ClientModel *model) ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows); ui->peerWidget->setSelectionMode(QAbstractItemView::SingleSelection); ui->peerWidget->setColumnWidth(PeerTableModel::Address, ADDRESS_COLUMN_WIDTH); - columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(ui->peerWidget, MINIMUM_COLUMN_WIDTH, MINIMUM_COLUMN_WIDTH); + ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH); + ui->peerWidget->setColumnWidth(PeerTableModel::Ping, PING_COLUMN_WIDTH); - // connect the peerWidget's selection model to our peerSelected() handler - QItemSelectionModel *peerSelectModel = ui->peerWidget->selectionModel(); - connect(peerSelectModel, SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), + // 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 &))); connect(model->getPeerTableModel(), SIGNAL(layoutChanged()), this, SLOT(peerLayoutChanged())); @@ -473,10 +472,6 @@ void RPCConsole::on_tabWidget_currentChanged(int index) { ui->lineEdit->setFocus(); } - else if(ui->tabWidget->widget(index) == ui->tab_peers) - { - initPeerTable(); - } } void RPCConsole::on_openDebugLogfileButton_clicked() @@ -525,30 +520,24 @@ void RPCConsole::peerSelected(const QItemSelection &selected, const QItemSelecti { Q_UNUSED(deselected); - if (selected.indexes().isEmpty()) + if (!clientModel || selected.indexes().isEmpty()) return; - // mark the cached banscore as unknown - detailNodeStats.statestats.nMisbehavior = -1; - const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(selected.indexes().first().row()); - if (stats) - { - detailNodeStats.nodestats.nodeid = stats->nodestats.nodeid; updateNodeDetail(stats); - ui->detailWidget->show(); - ui->detailWidget->setDisabled(false); - } } void RPCConsole::peerLayoutChanged() { - const CNodeCombinedStats *stats = NULL; - bool fUnselect = false, fReselect = false, fDisconnected = false; + if (!clientModel) + return; - if (detailNodeStats.nodestats.nodeid == -1) - // no node selected yet + const CNodeCombinedStats *stats = NULL; + bool fUnselect = false; + bool fReselect = false; + + if (cachedNodeid == -1) // no node selected yet return; // find the currently selected row @@ -561,14 +550,15 @@ void RPCConsole::peerLayoutChanged() // 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(detailNodeStats.nodestats.nodeid); + int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeid); if (detailNodeRow < 0) { // detail node dissapeared from table (node disconnected) fUnselect = true; - fDisconnected = true; - detailNodeStats.nodestats.nodeid = 0; + cachedNodeid = -1; + ui->detailWidget->hide(); + ui->peerHeading->setText(tr("Select a peer to view detailed information.")); } else { @@ -596,91 +586,64 @@ void RPCConsole::peerLayoutChanged() if (stats) updateNodeDetail(stats); - - if (fDisconnected) - { - ui->peerHeading->setText(QString(tr("Peer Disconnected"))); - ui->detailWidget->setDisabled(true); - QDateTime dt = QDateTime::fromTime_t(detailNodeStats.nodestats.nLastSend); - if (detailNodeStats.nodestats.nLastSend) - ui->peerLastSend->setText(dt.toString("yyyy-MM-dd hh:mm:ss")); - dt.setTime_t(detailNodeStats.nodestats.nLastRecv); - if (detailNodeStats.nodestats.nLastRecv) - ui->peerLastRecv->setText(dt.toString("yyyy-MM-dd hh:mm:ss")); - dt.setTime_t(detailNodeStats.nodestats.nTimeConnected); - ui->peerConnTime->setText(dt.toString("yyyy-MM-dd hh:mm:ss")); - } } -void RPCConsole::updateNodeDetail(const CNodeCombinedStats *combinedStats) +void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats) { - CNodeStats stats = combinedStats->nodestats; - - // keep a copy of timestamps, used to display dates upon disconnect - detailNodeStats.nodestats.nLastSend = stats.nLastSend; - detailNodeStats.nodestats.nLastRecv = stats.nLastRecv; - detailNodeStats.nodestats.nTimeConnected = stats.nTimeConnected; + // Update cached nodeid + cachedNodeid = stats->nodeStats.nodeid; // update the detail ui with latest node information - ui->peerHeading->setText(QString("%1").arg(tr("Node Detail"))); - ui->peerAddr->setText(QString(stats.addrName.c_str())); - ui->peerServices->setText(GUIUtil::formatServicesStr(stats.nServices)); - ui->peerLastSend->setText(stats.nLastSend ? GUIUtil::formatDurationStr(GetTime() - stats.nLastSend) : tr("never")); - ui->peerLastRecv->setText(stats.nLastRecv ? GUIUtil::formatDurationStr(GetTime() - stats.nLastRecv) : tr("never")); - ui->peerBytesSent->setText(FormatBytes(stats.nSendBytes)); - ui->peerBytesRecv->setText(FormatBytes(stats.nRecvBytes)); - ui->peerConnTime->setText(GUIUtil::formatDurationStr(GetTime() - stats.nTimeConnected)); - ui->peerPingTime->setText(stats.dPingTime == 0 ? tr("N/A") : QString(tr("%1 secs")).arg(QString::number(stats.dPingTime, 'f', 3))); - ui->peerVersion->setText(QString("%1").arg(stats.nVersion)); - ui->peerSubversion->setText(QString(stats.cleanSubVer.c_str())); - ui->peerDirection->setText(stats.fInbound ? tr("Inbound") : tr("Outbound")); - ui->peerHeight->setText(QString("%1").arg(stats.nStartingHeight)); - ui->peerSyncNode->setText(stats.fSyncNode ? tr("Yes") : tr("No")); + QString peerAddrDetails(QString::fromStdString(stats->nodeStats.addrName)); + if (!stats->nodeStats.addrLocal.empty()) + peerAddrDetails += "
" + tr("via %1").arg(QString::fromStdString(stats->nodeStats.addrLocal)); + ui->peerHeading->setText(peerAddrDetails); + ui->peerServices->setText(GUIUtil::formatServicesStr(stats->nodeStats.nServices)); + ui->peerLastSend->setText(stats->nodeStats.nLastSend ? GUIUtil::formatDurationStr(GetTime() - stats->nodeStats.nLastSend) : tr("never")); + ui->peerLastRecv->setText(stats->nodeStats.nLastRecv ? GUIUtil::formatDurationStr(GetTime() - stats->nodeStats.nLastRecv) : tr("never")); + ui->peerBytesSent->setText(FormatBytes(stats->nodeStats.nSendBytes)); + 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->peerVersion->setText(QString("%1").arg(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->peerSyncNode->setText(stats->nodeStats.fSyncNode ? tr("Yes") : tr("No")); - // if we can, display the peer's ban score - CNodeStateStats statestats = combinedStats->statestats; - if (statestats.nMisbehavior >= 0) - { - // we have a new nMisbehavor value - update the cache - detailNodeStats.statestats.nMisbehavior = statestats.nMisbehavior; + // This check fails for example if the lock was busy and + // nodeStateStats couldn't be fetched. + if (stats->fNodeStateStatsAvailable) { + // Ban score is init to 0 + ui->peerBanScore->setText(QString("%1").arg(stats->nodeStateStats.nMisbehavior)); + + // Sync height is init to -1 + if (stats->nodeStateStats.nSyncHeight > -1) + 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...")); } - // pull the ban score from cache. -1 means it hasn't been retrieved yet (lock busy). - if (detailNodeStats.statestats.nMisbehavior >= 0) - ui->peerBanScore->setText(QString("%1").arg(detailNodeStats.statestats.nMisbehavior)); - else - ui->peerBanScore->setText(tr("Fetching...")); + ui->detailWidget->show(); } -void RPCConsole::initPeerTable() -{ - if (!clientModel) - return; - - // peerWidget needs a resize in case the dialog has non-default geometry - columnResizingFixer->stretchColumnWidth(PeerTableModel::Address); - - // start PeerTableModel auto refresh - clientModel->getPeerTableModel()->startAutoRefresh(1000); -} - -// We override the virtual resizeEvent of the QWidget to adjust tables column -// sizes as the tables width is proportional to the dialogs width. void RPCConsole::resizeEvent(QResizeEvent *event) { QWidget::resizeEvent(event); - - if (!clientModel) - return; - - columnResizingFixer->stretchColumnWidth(PeerTableModel::Address); } void RPCConsole::showEvent(QShowEvent *event) { QWidget::showEvent(event); - initPeerTable(); + if (!clientModel) + return; + + // start PeerTableModel auto refresh + clientModel->getPeerTableModel()->startAutoRefresh(); } void RPCConsole::hideEvent(QHideEvent *event) diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 94672b30c..64bb5c29b 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -44,21 +44,6 @@ public: protected: virtual bool eventFilter(QObject* obj, QEvent *event); -private: - /** show detailed information on ui about selected node */ - void updateNodeDetail(const CNodeCombinedStats *combinedStats); - /** initialize peer table */ - void initPeerTable(); - - enum ColumnWidths - { - ADDRESS_COLUMN_WIDTH = 250, - MINIMUM_COLUMN_WIDTH = 120 - }; - - /** track the node that we are currently viewing detail on in the peers tab */ - CNodeCombinedStats detailNodeStats; - private slots: void on_lineEdit_returnPressed(); void on_tabWidget_currentChanged(int index); @@ -96,15 +81,23 @@ signals: private: static QString FormatBytes(quint64 bytes); + void startExecutor(); void setTrafficGraphRange(int mins); + /** show detailed information on ui about selected node */ + void updateNodeDetail(const CNodeCombinedStats *stats); + + enum ColumnWidths + { + ADDRESS_COLUMN_WIDTH = 200, + SUBVERSION_COLUMN_WIDTH = 100, + PING_COLUMN_WIDTH = 80 + }; Ui::RPCConsole *ui; ClientModel *clientModel; QStringList history; - GUIUtil::TableViewLastColumnResizingFixer *columnResizingFixer; int historyPtr; - - void startExecutor(); + NodeId cachedNodeid; }; #endif // RPCCONSOLE_H