Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bantablemodel.cpp
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <qt/bantablemodel.h> | #include <qt/bantablemodel.h> | ||||
#include <qt/clientmodel.h> | #include <qt/clientmodel.h> | ||||
#include <qt/guiconstants.h> | #include <qt/guiconstants.h> | ||||
#include <qt/guiutil.h> | #include <qt/guiutil.h> | ||||
#include <interfaces/node.h> | #include <interfaces/node.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <util/time.h> | #include <util/time.h> | ||||
#include <algorithm> | |||||
#include <QDebug> | #include <QDebug> | ||||
#include <QList> | #include <QList> | ||||
bool BannedNodeLessThan::operator()(const CCombinedBan &left, | bool BannedNodeLessThan::operator()(const CCombinedBan &left, | ||||
const CCombinedBan &right) const { | const CCombinedBan &right) const { | ||||
const CCombinedBan *pLeft = &left; | const CCombinedBan *pLeft = &left; | ||||
const CCombinedBan *pRight = &right; | const CCombinedBan *pRight = &right; | ||||
Show All 29 Lines | void refreshBanlist(interfaces::Node &node) { | ||||
cachedBanlist.reserve(banMap.size()); | cachedBanlist.reserve(banMap.size()); | ||||
for (const auto &entry : banMap) { | for (const auto &entry : banMap) { | ||||
CCombinedBan banEntry; | CCombinedBan banEntry; | ||||
banEntry.subnet = entry.first; | banEntry.subnet = entry.first; | ||||
banEntry.banEntry = entry.second; | banEntry.banEntry = entry.second; | ||||
cachedBanlist.append(banEntry); | cachedBanlist.append(banEntry); | ||||
} | } | ||||
if (sortColumn >= 0) | if (sortColumn >= 0) { | ||||
// sort cachedBanlist (use stable sort to prevent rows jumping | // sort cachedBanlist (use stable sort to prevent rows jumping | ||||
// around unnecessarily) | // around unnecessarily) | ||||
qStableSort(cachedBanlist.begin(), cachedBanlist.end(), | std::stable_sort(cachedBanlist.begin(), cachedBanlist.end(), | ||||
BannedNodeLessThan(sortColumn, sortOrder)); | BannedNodeLessThan(sortColumn, sortOrder)); | ||||
} | } | ||||
} | |||||
int size() const { return cachedBanlist.size(); } | int size() const { return cachedBanlist.size(); } | ||||
CCombinedBan *index(int idx) { | CCombinedBan *index(int idx) { | ||||
if (idx >= 0 && idx < cachedBanlist.size()) return &cachedBanlist[idx]; | if (idx >= 0 && idx < cachedBanlist.size()) return &cachedBanlist[idx]; | ||||
return 0; | return 0; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |