Changeset View
Changeset View
Standalone View
Standalone View
src/qt/peertablemodel.cpp
Show All 25 Lines | switch (column) { | ||||
case PeerTableModel::NetNodeId: | case PeerTableModel::NetNodeId: | ||||
return pLeft->nodeid < pRight->nodeid; | return pLeft->nodeid < pRight->nodeid; | ||||
case PeerTableModel::Address: | case PeerTableModel::Address: | ||||
return pLeft->addrName.compare(pRight->addrName) < 0; | return pLeft->addrName.compare(pRight->addrName) < 0; | ||||
case PeerTableModel::Subversion: | case PeerTableModel::Subversion: | ||||
return pLeft->cleanSubVer.compare(pRight->cleanSubVer) < 0; | return pLeft->cleanSubVer.compare(pRight->cleanSubVer) < 0; | ||||
case PeerTableModel::Ping: | case PeerTableModel::Ping: | ||||
return pLeft->dMinPing < pRight->dMinPing; | return pLeft->dMinPing < pRight->dMinPing; | ||||
case PeerTableModel::Sent: | |||||
return pLeft->nSendBytes < pRight->nSendBytes; | |||||
case PeerTableModel::Received: | |||||
return pLeft->nRecvBytes < pRight->nRecvBytes; | |||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
// private implementation | // private implementation | ||||
class PeerTablePriv { | class PeerTablePriv { | ||||
public: | public: | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | CNodeCombinedStats *index(int idx) { | ||||
return &cachedNodeStats[idx]; | return &cachedNodeStats[idx]; | ||||
return 0; | return 0; | ||||
} | } | ||||
}; | }; | ||||
PeerTableModel::PeerTableModel(ClientModel *parent) | PeerTableModel::PeerTableModel(ClientModel *parent) | ||||
: QAbstractTableModel(parent), clientModel(parent), timer(0) { | : QAbstractTableModel(parent), clientModel(parent), timer(0) { | ||||
columns << tr("NodeId") << tr("Node/Service") << tr("User Agent") | columns << tr("NodeId") << tr("Node/Service") << tr("Ping") << tr("Sent") | ||||
<< tr("Ping"); | << tr("Received") << tr("User Agent"); | ||||
priv.reset(new PeerTablePriv()); | priv.reset(new PeerTablePriv()); | ||||
// default to unsorted | // default to unsorted | ||||
priv->sortColumn = -1; | priv->sortColumn = -1; | ||||
// set up timer for auto refresh | // set up timer for auto refresh | ||||
timer = new QTimer(this); | timer = new QTimer(this); | ||||
connect(timer, SIGNAL(timeout()), SLOT(refresh())); | connect(timer, SIGNAL(timeout()), SLOT(refresh())); | ||||
timer->setInterval(MODEL_UPDATE_DELAY); | timer->setInterval(MODEL_UPDATE_DELAY); | ||||
Show All 35 Lines | if (role == Qt::DisplayRole) { | ||||
case NetNodeId: | case NetNodeId: | ||||
return (qint64)rec->nodeStats.nodeid; | return (qint64)rec->nodeStats.nodeid; | ||||
case Address: | case Address: | ||||
return QString::fromStdString(rec->nodeStats.addrName); | return QString::fromStdString(rec->nodeStats.addrName); | ||||
case Subversion: | case Subversion: | ||||
return QString::fromStdString(rec->nodeStats.cleanSubVer); | return QString::fromStdString(rec->nodeStats.cleanSubVer); | ||||
case Ping: | case Ping: | ||||
return GUIUtil::formatPingTime(rec->nodeStats.dMinPing); | return GUIUtil::formatPingTime(rec->nodeStats.dMinPing); | ||||
case Sent: | |||||
return GUIUtil::formatBytes(rec->nodeStats.nSendBytes); | |||||
case Received: | |||||
return GUIUtil::formatBytes(rec->nodeStats.nRecvBytes); | |||||
} | } | ||||
} else if (role == Qt::TextAlignmentRole) { | } else if (role == Qt::TextAlignmentRole) { | ||||
if (index.column() == Ping) | switch (index.column()) { | ||||
return (QVariant)(Qt::AlignRight | Qt::AlignVCenter); | case Ping: | ||||
case Sent: | |||||
case Received: | |||||
return QVariant(Qt::AlignRight | Qt::AlignVCenter); | |||||
default: | |||||
return QVariant(); | |||||
} | |||||
} | } | ||||
return QVariant(); | return QVariant(); | ||||
} | } | ||||
QVariant PeerTableModel::headerData(int section, Qt::Orientation orientation, | QVariant PeerTableModel::headerData(int section, Qt::Orientation orientation, | ||||
int role) const { | int role) const { | ||||
if (orientation == Qt::Horizontal) { | if (orientation == Qt::Horizontal) { | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |