23 if (
order == Qt::DescendingOrder)
24 std::swap(pLeft, pRight);
55 cachedBanlist.clear();
56 #if QT_VERSION >= 0x040700 57 cachedBanlist.reserve(banMap.size());
59 for (banmap_t::iterator it = banMap.begin(); it != banMap.end(); it++)
62 banEntry.
subnet = (*it).first;
64 cachedBanlist.append(banEntry);
69 qStableSort(cachedBanlist.begin(), cachedBanlist.end(),
BannedNodeLessThan(sortColumn, sortOrder));
74 return cachedBanlist.size();
79 if (idx >= 0 && idx < cachedBanlist.size())
80 return &cachedBanlist[idx];
87 QAbstractTableModel(parent),
90 columns << tr(
"IP/Netmask") << tr(
"Banned Until");
93 priv->sortColumn = -1;
123 if (role == Qt::DisplayRole) {
124 switch(index.column())
129 QDateTime date = QDateTime::fromMSecsSinceEpoch(0);
131 return date.toString(Qt::SystemLocaleLongDate);
140 if(orientation == Qt::Horizontal)
142 if(role == Qt::DisplayRole && section <
columns.size())
155 Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
165 return createIndex(row, column, data);
166 return QModelIndex();
171 Q_EMIT layoutAboutToBeChanged();
172 priv->refreshBanlist();
173 Q_EMIT layoutChanged();
178 priv->sortColumn = column;
179 priv->sortOrder = order;
185 return priv->size() > 0;
void refreshBanlist()
Pull a full list of banned nodes from CNode into our cache.
int columnCount(const QModelIndex &parent) const
int sortColumn
Column to sort nodes by.
QVariant data(const QModelIndex &index, int role) const
QVariant headerData(int section, Qt::Orientation orientation, int role) const
std::map< CSubNet, CBanEntry > banmap_t
std::unique_ptr< BanTablePriv > priv
bool operator()(const CCombinedBan &left, const CCombinedBan &right) const
Qt::SortOrder sortOrder
Order (ascending or descending) to sort nodes by.
Model for Raven network client.
BannedNodeLessThan(int nColumn, Qt::SortOrder fOrder)
std::string ToString() const
int rowCount(const QModelIndex &parent) const
std::unique_ptr< CConnman > g_connman
BanTableModel(ClientModel *parent=0)
QList< CCombinedBan > cachedBanlist
Local cache of peer information.
QModelIndex index(int row, int column, const QModelIndex &parent) const
void sort(int column, Qt::SortOrder order)
CCombinedBan * index(int idx)
Qt::ItemFlags flags(const QModelIndex &index) const