-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathSubaddressProxyModel.cpp
More file actions
50 lines (39 loc) · 1.45 KB
/
SubaddressProxyModel.cpp
File metadata and controls
50 lines (39 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: The Monero Project
#include "SubaddressProxyModel.h"
#include "utils/config.h"
SubaddressProxyModel::SubaddressProxyModel(QObject *parent, Subaddress *subaddress)
: QSortFilterProxyModel(parent)
, m_subaddress(subaddress)
, m_searchRegExp("")
, m_searchCaseSensitiveRegExp("")
{
m_searchRegExp.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
this->setSortRole(Qt::UserRole);
this->sort(0);
}
bool SubaddressProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
bool showUsed = conf()->get(Config::showUsedAddresses).toBool();
bool showHidden = conf()->get(Config::showHiddenAddresses).toBool();
bool showChange = conf()->get(Config::showChangeAddresses).toBool();
if (sourceRow < 0 || sourceRow >= m_subaddress->count()) {
return false;
}
const SubaddressRow& subaddress = m_subaddress->row(sourceRow);
// Pinned addresses are always shown
if (subaddress.pinned) {
return true;
}
// Hide primary/change addresses
if (!showChange && sourceRow == 0) {
return false;
}
if (!showHidden && subaddress.hidden) {
return false;
}
if (!m_searchRegExp.pattern().isEmpty()) {
return subaddress.address.contains(m_searchCaseSensitiveRegExp) || subaddress.label.contains(m_searchRegExp);
}
return (showUsed || !subaddress.used);
}