Skip to content

Commit 9a9f180

Browse files
committed
qt, refactor: Drop no longer used PeerTableModel::sort function
1 parent 778a64a commit 9a9f180

File tree

2 files changed

+0
-58
lines changed

2 files changed

+0
-58
lines changed

src/qt/peertablemodel.cpp

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,15 @@
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 (static_cast<PeerTableModel::ColumnIndex>(column)) {
27-
case PeerTableModel::NetNodeId:
28-
return pLeft->nodeid < pRight->nodeid;
29-
case PeerTableModel::Address:
30-
return pLeft->addrName.compare(pRight->addrName) < 0;
31-
case PeerTableModel::ConnectionType:
32-
return pLeft->m_conn_type < pRight->m_conn_type;
33-
case PeerTableModel::Network:
34-
return pLeft->m_network < pRight->m_network;
35-
case PeerTableModel::Ping:
36-
return pLeft->m_min_ping_time < pRight->m_min_ping_time;
37-
case PeerTableModel::Sent:
38-
return pLeft->nSendBytes < pRight->nSendBytes;
39-
case PeerTableModel::Received:
40-
return pLeft->nRecvBytes < pRight->nRecvBytes;
41-
case PeerTableModel::Subversion:
42-
return pLeft->cleanSubVer.compare(pRight->cleanSubVer) < 0;
43-
} // no default case, so the compiler can warn about missing cases
44-
assert(false);
45-
}
46-
4717
// private implementation
4818
class PeerTablePriv
4919
{
5020
public:
5121
/** Local cache of peer information */
5222
QList<CNodeCombinedStats> cachedNodeStats;
53-
/** Column to sort nodes by (default to unsorted) */
54-
int sortColumn{-1};
55-
/** Order (ascending or descending) to sort nodes by */
56-
Qt::SortOrder sortOrder;
5723
/** Index of rows by node ID */
5824
std::map<NodeId, int> mapNodeRows;
5925

@@ -76,10 +42,6 @@ class PeerTablePriv
7642
}
7743
}
7844

79-
if (sortColumn >= 0)
80-
// sort cacheNodeStats (use stable sort to prevent rows jumping around unnecessarily)
81-
std::stable_sort(cachedNodeStats.begin(), cachedNodeStats.end(), NodeLessThan(sortColumn, sortOrder));
82-
8345
// build index map
8446
mapNodeRows.clear();
8547
int row = 0;
@@ -245,10 +207,3 @@ int PeerTableModel::getRowByNodeId(NodeId nodeid)
245207

246208
return it->second;
247209
}
248-
249-
void PeerTableModel::sort(int column, Qt::SortOrder order)
250-
{
251-
priv->sortColumn = column;
252-
priv->sortOrder = order;
253-
refresh();
254-
}

src/qt/peertablemodel.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,6 @@ struct CNodeCombinedStats {
3030
};
3131
Q_DECLARE_METATYPE(CNodeCombinedStats*)
3232

33-
class NodeLessThan
34-
{
35-
public:
36-
NodeLessThan(int nColumn, Qt::SortOrder fOrder) :
37-
column(nColumn), order(fOrder) {}
38-
bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const;
39-
40-
private:
41-
int column;
42-
Qt::SortOrder order;
43-
};
44-
4533
/**
4634
Qt model providing information about connected peers, similar to the
4735
"getpeerinfo" RPC call. Used by the rpc console UI.
@@ -80,7 +68,6 @@ class PeerTableModel : public QAbstractTableModel
8068
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
8169
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
8270
Qt::ItemFlags flags(const QModelIndex &index) const override;
83-
void sort(int column, Qt::SortOrder order) override;
8471
/*@}*/
8572

8673
public Q_SLOTS:

0 commit comments

Comments
 (0)