25 if (
order == Qt::DescendingOrder)
26 std::swap(pLeft, pRight);
64 cachedNodeStats.clear();
65 #if QT_VERSION >= 0x040700
66 cachedNodeStats.reserve(
vNodes.size());
75 cachedNodeStats.append(stats);
91 qStableSort(cachedNodeStats.begin(), cachedNodeStats.end(),
NodeLessThan(sortColumn, sortOrder));
97 mapNodeRows.insert(std::pair<NodeId, int>(stats.
nodeStats.
nodeid, row++));
102 return cachedNodeStats.size();
107 if(idx >= 0 && idx < cachedNodeStats.size()) {
108 return &cachedNodeStats[idx];
116 QAbstractTableModel(parent),
120 columns << tr(
"Address/Hostname") << tr(
"User Agent") << tr(
"Ping Time");
126 timer =
new QTimer();
128 timer->setInterval(MODEL_UPDATE_DELAY);
163 if (role == Qt::DisplayRole) {
164 switch(index.column())
173 }
else if (role == Qt::TextAlignmentRole) {
174 if (index.column() ==
Ping)
175 return (
int)(Qt::AlignRight | Qt::AlignVCenter);
183 if(orientation == Qt::Horizontal)
185 if(role == Qt::DisplayRole && section <
columns.size())
198 Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
209 return createIndex(row, column, data);
213 return QModelIndex();
224 emit layoutAboutToBeChanged();
226 emit layoutChanged();
int getRowByNodeId(NodeId nodeid)
int rowCount(const QModelIndex &parent) const
CNodeStateStats nodeStateStats
#define TRY_LOCK(cs, name)
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)
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.
Qt::ItemFlags flags(const QModelIndex &index) const
const CNodeCombinedStats * getNodeStats(int idx)
bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const
Model for Anoncoin network client.
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
Get statistics from node state.
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
void sort(int column, Qt::SortOrder order)
Information about a peer.
void copyStats(CNodeStats &stats)
PeerTableModel(ClientModel *parent=0)
CCriticalSection cs_vNodes