From ffd7879096708602c69d0f0de5941ed604828c12 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Wed, 3 Feb 2021 19:36:03 +0100 Subject: [PATCH] History: filter by subaddress label --- src/model/TransactionHistoryProxyModel.cpp | 15 +++++++-------- src/model/TransactionHistoryProxyModel.h | 4 +++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/model/TransactionHistoryProxyModel.cpp b/src/model/TransactionHistoryProxyModel.cpp index a73fb2c..538c5aa 100644 --- a/src/model/TransactionHistoryProxyModel.cpp +++ b/src/model/TransactionHistoryProxyModel.cpp @@ -13,20 +13,19 @@ TransactionHistoryProxyModel::TransactionHistoryProxyModel(Wallet *wallet, QObje { m_searchRegExp.setCaseSensitivity(Qt::CaseInsensitive); m_searchRegExp.setPatternSyntax(QRegExp::RegExp); + m_history = m_wallet->history(); } 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(); - + QString description, txid, subaddrlabel; quint32 subaddrAcount; QSet subaddrIndex; - m_wallet->history()->transaction(sourceRow, [&subaddrAcount, &subaddrIndex](TransactionInfo &tInfo){ + 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(); }); @@ -38,5 +37,5 @@ bool TransactionHistoryProxyModel::filterAcceptsRow(int sourceRow, const QModelI if (addressFound) break; } - return (descriptionData.contains(m_searchRegExp) || txidData.contains(m_searchRegExp)) || addressFound; + return (description.contains(m_searchRegExp) || txid.contains(m_searchRegExp) || subaddrlabel.contains(m_searchRegExp)) || addressFound; } \ No newline at end of file diff --git a/src/model/TransactionHistoryProxyModel.h b/src/model/TransactionHistoryProxyModel.h index 481f2b9..019976a 100644 --- a/src/model/TransactionHistoryProxyModel.h +++ b/src/model/TransactionHistoryProxyModel.h @@ -6,6 +6,7 @@ #include "libwalletqt/TransactionHistory.h" #include "libwalletqt/Wallet.h" +#include "libwalletqt/TransactionHistory.h" #include @@ -23,7 +24,8 @@ public slots: } private: - Wallet * m_wallet; + Wallet *m_wallet; + TransactionHistory *m_history; QRegExp m_searchRegExp; };