PIVX Core  5.6.99
P2P Digital Currency
addressfilterproxymodel.cpp
Go to the documentation of this file.
1 // Copyright (c) 2019-2021 The PIVX Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
6 #include "qt/addresstablemodel.h"
7 
8 bool AddressFilterProxyModel::filterAcceptsRow(int row, const QModelIndex& parent) const
9 {
10  auto model = sourceModel();
11  auto label = model->index(row, AddressTableModel::Label, parent);
12 
13  auto type = model->data(label, AddressTableModel::TypeRole).toString();
14  if (!m_types.contains(type))
15  return false;
16 
17  auto address = model->index(row, AddressTableModel::Address, parent);
18 
19  if (filterRegExp().indexIn(model->data(address).toString()) < 0 &&
20  filterRegExp().indexIn(model->data(label).toString()) < 0) {
21  return false;
22  }
23 
24  return true;
25 }
26 
27 void AddressFilterProxyModel::setType(const QString& type)
28 {
29  setType(QStringList(type));
30 }
31 
32 void AddressFilterProxyModel::setType(const QStringList& types)
33 {
34  this->m_types = types;
35  invalidateFilter();
36 }
37 
38 int AddressFilterProxyModel::rowCount(const QModelIndex& parent) const
39 {
40  return QSortFilterProxyModel::rowCount(parent);
41 }
int rowCount(const QModelIndex &parent=QModelIndex()) const override
bool filterAcceptsRow(int row, const QModelIndex &parent) const override
void setType(const QString &type)
@ TypeRole
Type of address (Send, Receive, ColdStaking, ColdStakingSend, Delegator, Delegable)
@ Address
Bitcoin address.
@ Label
User specified label.