11 #include "validation.h"
23 if (
order == Qt::DescendingOrder)
24 std::swap(pLeft, pRight);
59 std::vector<CNodeStats> vstats;
62 #if QT_VERSION >= 0x040700
65 Q_FOREACH (
const CNodeStats& nodestats, vstats)
113 QAbstractTableModel(parent),
117 columns << tr(
"NodeId") << tr(
"Node/Service") << tr(
"User Agent") << tr(
"Ping");
120 priv->sortColumn = -1;
123 timer =
new QTimer(
this);
125 timer->setInterval(MODEL_UPDATE_DELAY);
165 if (role == Qt::DisplayRole) {
166 switch(
index.column())
177 }
else if (role == Qt::TextAlignmentRole) {
179 return (QVariant)(Qt::AlignRight | Qt::AlignVCenter);
187 if(orientation == Qt::Horizontal)
189 if(role == Qt::DisplayRole && section <
columns.size())
202 Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
212 return createIndex(row, column,
data);
213 return QModelIndex();
218 return priv->index(idx);
223 Q_EMIT layoutAboutToBeChanged();
224 priv->refreshPeers();
225 Q_EMIT layoutChanged();
230 std::map<NodeId, int>::iterator it =
priv->mapNodeRows.find(nodeid);
231 if (it ==
priv->mapNodeRows.end())
239 priv->sortColumn = column;
240 priv->sortOrder = order;
Model for Bitcoin network client.
bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const
QModelIndex index(int row, int column, const QModelIndex &parent) const
QVariant data(const QModelIndex &index, int role) const
int rowCount(const QModelIndex &parent) const
PeerTableModel(ClientModel *parent=0)
const CNodeCombinedStats * getNodeStats(int idx)
int getRowByNodeId(NodeId nodeid)
QVariant headerData(int section, Qt::Orientation orientation, int role) const
void sort(int column, Qt::SortOrder order)
Qt::ItemFlags flags(const QModelIndex &index) const
std::unique_ptr< PeerTablePriv > priv
int columnCount(const QModelIndex &parent) const
void refreshPeers()
Pull a full list of peers from vNodes into our cache.
int sortColumn
Column to sort nodes by.
CNodeCombinedStats * index(int idx)
QList< CNodeCombinedStats > cachedNodeStats
Local cache of peer information.
Qt::SortOrder sortOrder
Order (ascending or descending) to sort nodes by.
std::map< NodeId, int > mapNodeRows
Index of rows by node ID.
std::unique_ptr< CConnman > g_connman
QString formatPingTime(double dPingTime)
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
Get statistics from node state.
CNodeStateStats nodeStateStats
bool fNodeStateStatsAvailable
#define TRY_LOCK(cs, name)
CCriticalSection cs_main
Global state.