PIVX Core  5.6.99
P2P Digital Currency
addressfilterproxymodel.h
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 
5 #ifndef PIVX_QT_ADDRESSFILTERPROXYMODEL_H
6 #define PIVX_QT_ADDRESSFILTERPROXYMODEL_H
7 
8 #include <QSortFilterProxyModel>
9 
10 class AddressFilterProxyModel final : public QSortFilterProxyModel
11 {
12 
13 public:
14  AddressFilterProxyModel(const QString& type, QObject* parent)
15  : QSortFilterProxyModel(parent)
16  , m_types({type}) {
17  init();
18  }
19 
20  AddressFilterProxyModel(const QStringList& types, QObject* parent)
21  : QSortFilterProxyModel(parent)
22  , m_types(types) {
23  init();
24  }
25 
26  void init() {
27  setDynamicSortFilter(true);
28  setFilterCaseSensitivity(Qt::CaseInsensitive);
29  setSortCaseSensitivity(Qt::CaseInsensitive);
30  }
31 
32  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
33 
34  void setType(const QString& type);
35  void setType(const QStringList& types);
36 
37 protected:
38  bool filterAcceptsRow(int row, const QModelIndex& parent) const override;
39 
40 private:
41  QStringList m_types;
42 };
43 
44 
45 #endif // PIVX_QT_ADDRESSFILTERPROXYMODEL_H
int rowCount(const QModelIndex &parent=QModelIndex()) const override
AddressFilterProxyModel(const QString &type, QObject *parent)
bool filterAcceptsRow(int row, const QModelIndex &parent) const override
void setType(const QString &type)
AddressFilterProxyModel(const QStringList &types, QObject *parent)