From 6a012766ddeff7a45e1174ab3f3b4c72049e8c9f Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 1 Jul 2020 19:17:38 +0300 Subject: [PATCH] refactor: Drop unused PeerTableModel::sort() --- src/qt/peertablemodel.cpp | 43 --------------------------------------- src/qt/peertablemodel.h | 13 ------------ 2 files changed, 56 deletions(-) diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index bcd6367be3b..2505c08687e 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -11,47 +11,15 @@ #include -#include #include #include -bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const -{ - const CNodeStats *pLeft = &(left.nodeStats); - const CNodeStats *pRight = &(right.nodeStats); - - if (order == Qt::DescendingOrder) - std::swap(pLeft, pRight); - - switch(column) - { - case PeerTableModel::NetNodeId: - return pLeft->nodeid < pRight->nodeid; - case PeerTableModel::Address: - return pLeft->addrName.compare(pRight->addrName) < 0; - case PeerTableModel::Subversion: - return pLeft->cleanSubVer.compare(pRight->cleanSubVer) < 0; - case PeerTableModel::Ping: - return pLeft->m_min_ping_usec < pRight->m_min_ping_usec; - case PeerTableModel::Sent: - return pLeft->nSendBytes < pRight->nSendBytes; - case PeerTableModel::Received: - return pLeft->nRecvBytes < pRight->nRecvBytes; - } - - return false; -} - // private implementation class PeerTablePriv { public: /** Local cache of peer information */ QList cachedNodeStats; - /** Column to sort nodes by (default to unsorted) */ - int sortColumn{-1}; - /** Order (ascending or descending) to sort nodes by */ - Qt::SortOrder sortOrder; /** Index of rows by node ID */ std::map mapNodeRows; @@ -74,10 +42,6 @@ class PeerTablePriv } } - if (sortColumn >= 0) - // sort cacheNodeStats (use stable sort to prevent rows jumping around unnecessarily) - std::stable_sort(cachedNodeStats.begin(), cachedNodeStats.end(), NodeLessThan(sortColumn, sortOrder)); - // build index map mapNodeRows.clear(); int row = 0; @@ -246,10 +210,3 @@ int PeerTableModel::getRowByNodeId(NodeId nodeid) return it->second; } - -void PeerTableModel::sort(int column, Qt::SortOrder order) -{ - priv->sortColumn = column; - priv->sortOrder = order; - refresh(); -} diff --git a/src/qt/peertablemodel.h b/src/qt/peertablemodel.h index 99de772ac02..6a305ee1a44 100644 --- a/src/qt/peertablemodel.h +++ b/src/qt/peertablemodel.h @@ -29,18 +29,6 @@ struct CNodeCombinedStats { bool fNodeStateStatsAvailable; }; -class NodeLessThan -{ -public: - NodeLessThan(int nColumn, Qt::SortOrder fOrder) : - column(nColumn), order(fOrder) {} - bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const; - -private: - int column; - Qt::SortOrder order; -}; - /** Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call. Used by the rpc console UI. @@ -74,7 +62,6 @@ class PeerTableModel : public QAbstractTableModel QVariant headerData(int section, Qt::Orientation orientation, int role) const override; QModelIndex index(int row, int column, const QModelIndex &parent) const override; Qt::ItemFlags flags(const QModelIndex &index) const override; - void sort(int column, Qt::SortOrder order) override; /*@}*/ public Q_SLOTS: