2020-10-07 10:36:04 +00:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2020-12-26 19:56:06 +00:00
|
|
|
// Copyright (c) 2020-2021, The Monero Project.
|
2020-10-07 10:36:04 +00:00
|
|
|
|
|
|
|
#include "AddressBookProxyModel.h"
|
|
|
|
#include "AddressBookModel.h"
|
|
|
|
|
|
|
|
AddressBookProxyModel::AddressBookProxyModel(QObject *parent)
|
|
|
|
: QSortFilterProxyModel(parent),
|
|
|
|
m_searchRegExp("")
|
|
|
|
{
|
|
|
|
m_searchRegExp.setCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
m_searchRegExp.setPatternSyntax(QRegExp::RegExp);
|
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
|
|
|
}
|