You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wowlet/src/model/TransactionHistoryProxyMode...

41 lines
1.4 KiB

// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020-2021, The Monero Project.
#include "TransactionHistoryProxyModel.h"
#include "TransactionHistoryModel.h"
#include "libwalletqt/TransactionInfo.h"
TransactionHistoryProxyModel::TransactionHistoryProxyModel(Wallet *wallet, QObject *parent)
: QSortFilterProxyModel(parent),
m_wallet(wallet),
m_searchRegExp("")
{
m_searchRegExp.setCaseSensitivity(Qt::CaseInsensitive);
m_searchRegExp.setPatternSyntax(QRegExp::RegExp);
m_history = m_wallet->history();
}
bool TransactionHistoryProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
QString description, txid, subaddrlabel;
quint32 subaddrAcount;
QSet<quint32> subaddrIndex;
m_history->transaction(sourceRow, [&description, &txid, &subaddrlabel, &subaddrAcount, &subaddrIndex](TransactionInfo &tInfo){
description = tInfo.description();
txid = tInfo.hash();
subaddrlabel = tInfo.label();
subaddrAcount = tInfo.subaddrAccount();
subaddrIndex = tInfo.subaddrIndex();
});
bool addressFound;
for (quint32 i : subaddrIndex) {
QString address = m_wallet->address(subaddrAcount, i);
addressFound = address.contains(m_searchRegExp);
if (addressFound) break;
}
return (description.contains(m_searchRegExp) || txid.contains(m_searchRegExp) || subaddrlabel.contains(m_searchRegExp)) || addressFound;
}