Bitcoin Core
31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
src
qt
peertablesortproxy.cpp
Go to the documentation of this file.
1
// Copyright (c) 2020-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#include <
qt/peertablesortproxy.h
>
6
7
#include <
qt/peertablemodel.h
>
8
#include <
util/check.h
>
9
10
#include <QModelIndex>
11
#include <QString>
12
#include <QVariant>
13
14
PeerTableSortProxy::PeerTableSortProxy
(QObject* parent)
15
: QSortFilterProxyModel(parent)
16
{
17
}
18
19
bool
PeerTableSortProxy::lessThan
(
const
QModelIndex& left_index,
const
QModelIndex& right_index)
const
20
{
21
const
CNodeStats
left_stats =
Assert
(sourceModel()->data(left_index,
PeerTableModel::StatsRole
).value<CNodeCombinedStats*>())->nodeStats;
22
const
CNodeStats
right_stats =
Assert
(sourceModel()->data(right_index,
PeerTableModel::StatsRole
).value<CNodeCombinedStats*>())->nodeStats;
23
24
switch
(
static_cast<
PeerTableModel::ColumnIndex
>
(left_index.column())) {
25
case
PeerTableModel::NetNodeId
:
26
return
left_stats.
nodeid
< right_stats.
nodeid
;
27
case
PeerTableModel::Age
:
28
return
left_stats.
m_connected
> right_stats.
m_connected
;
29
case
PeerTableModel::Address
:
30
return
left_stats.
m_addr_name
.compare(right_stats.
m_addr_name
) < 0;
31
case
PeerTableModel::Direction
:
32
return
left_stats.
fInbound
> right_stats.
fInbound
;
// default sort Inbound, then Outbound
33
case
PeerTableModel::ConnectionType
:
34
return
left_stats.
m_conn_type
< right_stats.
m_conn_type
;
35
case
PeerTableModel::Network
:
36
return
left_stats.
m_network
< right_stats.
m_network
;
37
case
PeerTableModel::Ping
:
38
return
left_stats.
m_min_ping_time
< right_stats.
m_min_ping_time
;
39
case
PeerTableModel::Sent
:
40
return
left_stats.
nSendBytes
< right_stats.
nSendBytes
;
41
case
PeerTableModel::Received
:
42
return
left_stats.
nRecvBytes
< right_stats.
nRecvBytes
;
43
case
PeerTableModel::Subversion
:
44
return
left_stats.
cleanSubVer
.compare(right_stats.
cleanSubVer
) < 0;
45
}
// no default case, so the compiler can warn about missing cases
46
assert
(
false
);
47
}
check.h
Assert
#define Assert(val)
Identity function.
Definition
check.h:113
CNodeStats
Definition
net.h:192
CNodeStats::nRecvBytes
uint64_t nRecvBytes
Definition
net.h:211
CNodeStats::fInbound
bool fInbound
Definition
net.h:203
CNodeStats::nSendBytes
uint64_t nSendBytes
Definition
net.h:209
CNodeStats::m_conn_type
ConnectionType m_conn_type
Definition
net.h:225
CNodeStats::m_min_ping_time
std::chrono::microseconds m_min_ping_time
Definition
net.h:215
CNodeStats::m_connected
std::chrono::seconds m_connected
Definition
net.h:199
CNodeStats::m_addr_name
std::string m_addr_name
Definition
net.h:200
CNodeStats::m_network
Network m_network
Definition
net.h:223
CNodeStats::nodeid
NodeId nodeid
Definition
net.h:194
CNodeStats::cleanSubVer
std::string cleanSubVer
Definition
net.h:202
PeerTableModel::ColumnIndex
ColumnIndex
Definition
peertablemodel.h:48
PeerTableModel::Address
@ Address
Definition
peertablemodel.h:51
PeerTableModel::ConnectionType
@ ConnectionType
Definition
peertablemodel.h:53
PeerTableModel::Ping
@ Ping
Definition
peertablemodel.h:55
PeerTableModel::Network
@ Network
Definition
peertablemodel.h:54
PeerTableModel::NetNodeId
@ NetNodeId
Definition
peertablemodel.h:49
PeerTableModel::Sent
@ Sent
Definition
peertablemodel.h:56
PeerTableModel::Subversion
@ Subversion
Definition
peertablemodel.h:58
PeerTableModel::Age
@ Age
Definition
peertablemodel.h:50
PeerTableModel::Direction
@ Direction
Definition
peertablemodel.h:52
PeerTableModel::Received
@ Received
Definition
peertablemodel.h:57
PeerTableModel::StatsRole
@ StatsRole
Definition
peertablemodel.h:62
PeerTableSortProxy::PeerTableSortProxy
PeerTableSortProxy(QObject *parent=nullptr)
Definition
peertablesortproxy.cpp:14
PeerTableSortProxy::lessThan
bool lessThan(const QModelIndex &left_index, const QModelIndex &right_index) const override
Definition
peertablesortproxy.cpp:19
peertablemodel.h
peertablesortproxy.h
assert
assert(!tx.IsCoinBase())
Generated on
for Bitcoin Core by
1.16.1