1111
1212#include < utility>
1313
14- #include < QDebug>
1514#include < QList>
1615#include < QTimer>
1716
18- bool NodeLessThan::operator ()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const
19- {
20- const CNodeStats *pLeft = &(left.nodeStats );
21- const CNodeStats *pRight = &(right.nodeStats );
22-
23- if (order == Qt::DescendingOrder)
24- std::swap (pLeft, pRight);
25-
26- switch (column)
27- {
28- case PeerTableModel::NetNodeId:
29- return pLeft->nodeid < pRight->nodeid ;
30- case PeerTableModel::Address:
31- return pLeft->addrName .compare (pRight->addrName ) < 0 ;
32- case PeerTableModel::ConnectionType:
33- return pLeft->m_conn_type < pRight->m_conn_type ;
34- case PeerTableModel::Network:
35- return pLeft->m_network < pRight->m_network ;
36- case PeerTableModel::Ping:
37- return pLeft->m_min_ping_time < pRight->m_min_ping_time ;
38- case PeerTableModel::Sent:
39- return pLeft->nSendBytes < pRight->nSendBytes ;
40- case PeerTableModel::Received:
41- return pLeft->nRecvBytes < pRight->nRecvBytes ;
42- case PeerTableModel::Subversion:
43- return pLeft->cleanSubVer .compare (pRight->cleanSubVer ) < 0 ;
44- }
45-
46- return false ;
47- }
48-
4917// private implementation
5018class PeerTablePriv
5119{
5220public:
5321 /* * Local cache of peer information */
5422 QList<CNodeCombinedStats> cachedNodeStats;
55- /* * Column to sort nodes by (default to unsorted) */
56- int sortColumn{-1 };
57- /* * Order (ascending or descending) to sort nodes by */
58- Qt::SortOrder sortOrder;
5923 /* * Index of rows by node ID */
6024 std::map<NodeId, int > mapNodeRows;
6125
@@ -78,10 +42,6 @@ class PeerTablePriv
7842 }
7943 }
8044
81- if (sortColumn >= 0 )
82- // sort cacheNodeStats (use stable sort to prevent rows jumping around unnecessarily)
83- std::stable_sort (cachedNodeStats.begin (), cachedNodeStats.end (), NodeLessThan (sortColumn, sortOrder));
84-
8545 // build index map
8646 mapNodeRows.clear ();
8747 int row = 0 ;
@@ -242,10 +202,3 @@ int PeerTableModel::getRowByNodeId(NodeId nodeid)
242202
243203 return it->second ;
244204}
245-
246- void PeerTableModel::sort (int column, Qt::SortOrder order)
247- {
248- priv->sortColumn = column;
249- priv->sortOrder = order;
250- refresh ();
251- }
0 commit comments