MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / data

Method data

src/qt/peertablemodel.cpp:58–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58QVariant PeerTableModel::data(const QModelIndex& index, int role) const
59{
60 if(!index.isValid())
61 return QVariant();
62
63 CNodeCombinedStats *rec = static_cast<CNodeCombinedStats*>(index.internalPointer());
64
65 const auto column = static_cast<ColumnIndex>(index.column());
66 if (role == Qt::DisplayRole) {
67 switch (column) {
68 case NetNodeId:
69 return (qint64)rec->nodeStats.nodeid;
70 case Age:
71 return GUIUtil::FormatPeerAge(rec->nodeStats.m_connected);
72 case Address:
73 return QString::fromStdString(rec->nodeStats.m_addr_name);
74 case Direction:
75 return QString(rec->nodeStats.fInbound ?
76 //: An Inbound Connection from a Peer.
77 tr("Inbound") :
78 //: An Outbound Connection to a Peer.
79 tr("Outbound"));
80 case ConnectionType:
81 return GUIUtil::ConnectionTypeToQString(rec->nodeStats.m_conn_type, /*prepend_direction=*/false);
82 case Network:
83 return GUIUtil::NetworkToQString(rec->nodeStats.m_network);
84 case Ping:
85 return GUIUtil::formatPingTime(rec->nodeStats.m_min_ping_time);
86 case Sent:
87 return GUIUtil::formatBytes(rec->nodeStats.nSendBytes);
88 case Received:
89 return GUIUtil::formatBytes(rec->nodeStats.nRecvBytes);
90 case Subversion:
91 return QString::fromStdString(rec->nodeStats.cleanSubVer);
92 } // no default case, so the compiler can warn about missing cases
93 assert(false);
94 } else if (role == Qt::TextAlignmentRole) {
95 switch (column) {
96 case NetNodeId:
97 case Age:
98 return QVariant(Qt::AlignRight | Qt::AlignVCenter);
99 case Address:
100 return {};
101 case Direction:
102 case ConnectionType:
103 case Network:
104 return QVariant(Qt::AlignCenter);
105 case Ping:
106 case Sent:
107 case Received:
108 return QVariant(Qt::AlignRight | Qt::AlignVCenter);
109 case Subversion:
110 return {};
111 } // no default case, so the compiler can warn about missing cases
112 assert(false);
113 } else if (role == StatsRole) {
114 return QVariant::fromValue(rec);
115 }

Callers

nothing calls this directly

Calls 6

FormatPeerAgeFunction · 0.85
ConnectionTypeToQStringFunction · 0.85
NetworkToQStringFunction · 0.85
formatPingTimeFunction · 0.85
formatBytesFunction · 0.85
isValidMethod · 0.45

Tested by

no test coverage detected