mirror of
https://git.wownero.com/wowlet/wowlet.git
synced 2024-08-15 01:03:14 +00:00
43 lines
1.6 KiB
C++
43 lines
1.6 KiB
C++
|
// SPDX-License-Identifier: BSD-3-Clause
|
||
|
// Copyright (c) 2020, The Monero Project.
|
||
|
|
||
|
#include "TransactionHistoryProxyModel.h"
|
||
|
#include "TransactionHistoryModel.h"
|
||
|
|
||
|
#include "libwalletqt/TransactionInfo.h"
|
||
|
#include <QSet>
|
||
|
|
||
|
TransactionHistoryProxyModel::TransactionHistoryProxyModel(Wallet *wallet, QObject *parent)
|
||
|
: QSortFilterProxyModel(parent),
|
||
|
m_wallet(wallet),
|
||
|
m_searchRegExp("")
|
||
|
{
|
||
|
m_searchRegExp.setCaseSensitivity(Qt::CaseInsensitive);
|
||
|
m_searchRegExp.setPatternSyntax(QRegExp::RegExp);
|
||
|
}
|
||
|
|
||
|
bool TransactionHistoryProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||
|
{
|
||
|
QModelIndex descriptionIndex = sourceModel()->index(sourceRow, TransactionHistoryModel::Description, sourceParent);
|
||
|
QModelIndex txidIndex = sourceModel()->index(sourceRow, TransactionHistoryModel::TxID, sourceParent);
|
||
|
|
||
|
QString descriptionData = sourceModel()->data(descriptionIndex).toString();
|
||
|
QString txidData = sourceModel()->data(txidIndex).toString();
|
||
|
|
||
|
quint32 subaddrAcount;
|
||
|
QSet<quint32> subaddrIndex;
|
||
|
|
||
|
m_wallet->history()->transaction(sourceRow, [&subaddrAcount, &subaddrIndex](TransactionInfo &tInfo){
|
||
|
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 (descriptionData.contains(m_searchRegExp) || txidData.contains(m_searchRegExp)) || addressFound;
|
||
|
}
|