-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathAddressBookProxyModel.cpp
More file actions
23 lines (18 loc) · 945 Bytes
/
AddressBookProxyModel.cpp
File metadata and controls
23 lines (18 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: The Monero Project
#include "AddressBookProxyModel.h"
#include "AddressBookModel.h"
AddressBookProxyModel::AddressBookProxyModel(QObject *parent)
: QSortFilterProxyModel(parent),
m_searchRegExp("")
{
m_searchRegExp.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
}
bool AddressBookProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
QModelIndex addressIndex = sourceModel()->index(sourceRow, AddressBookModel::Address, sourceParent);
QModelIndex descriptionIndex = sourceModel()->index(sourceRow, AddressBookModel::Description, sourceParent);
QString addressData = sourceModel()->data(addressIndex, Qt::UserRole).toString();
QString descriptionData = sourceModel()->data(descriptionIndex).toString();
return (addressData.contains(m_searchRegExp) || descriptionData.contains(m_searchRegExp));
}