11 #include <validation.h> 23 if (
order == Qt::DescendingOrder)
58 cachedNodeStats.clear();
59 std::vector<CNodeStats> vstats;
62 #if QT_VERSION >= 0x040700 63 cachedNodeStats.reserve(vstats.size());
73 cachedNodeStats.append(stats);
83 stats.fNodeStateStatsAvailable =
GetNodeStateStats(stats.nodeStats.nodeid, stats.nodeStateStats);
89 qStableSort(cachedNodeStats.begin(), cachedNodeStats.end(),
NodeLessThan(sortColumn, sortOrder));
95 mapNodeRows.insert(std::pair<NodeId, int>(stats.nodeStats.nodeid, row++));
100 return cachedNodeStats.size();
105 if (idx >= 0 && idx < cachedNodeStats.size())
106 return &cachedNodeStats[idx];
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) {
178 if (index.column() ==
Ping)
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;
int getRowByNodeId(NodeId nodeid)
int rowCount(const QModelIndex &parent) const
CNodeStateStats nodeStateStats
#define TRY_LOCK(cs, name)
int columnCount(const QModelIndex &parent) const
void swap(dev::eth::Watch &_a, dev::eth::Watch &_b)
void refreshPeers()
Pull a full list of peers from vNodes into our cache.
int sortColumn
Column to sort nodes by.
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
Get statistics from node state.
CNodeCombinedStats * index(int idx)
NodeLessThan(int nColumn, Qt::SortOrder fOrder)
Qt::SortOrder sortOrder
Order (ascending or descending) to sort nodes by.
QVariant headerData(int section, Qt::Orientation orientation, int role) const
bool fNodeStateStatsAvailable
QList< CNodeCombinedStats > cachedNodeStats
Local cache of peer information.
std::unique_ptr< PeerTablePriv > priv
Qt::ItemFlags flags(const QModelIndex &index) const
const CNodeCombinedStats * getNodeStats(int idx)
bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const
Model for Fabcoin network client.
QString formatPingTime(double dPingTime)
std::map< NodeId, int > mapNodeRows
Index of rows by node ID.
QVariant data(const QModelIndex &index, int role) const
QModelIndex index(int row, int column, const QModelIndex &parent) const
std::unique_ptr< CConnman > g_connman
void sort(int column, Qt::SortOrder order)
PeerTableModel(ClientModel *parent=0)