Skip to content

Commit 1ee72a8

Browse files
committed
qt: Avoid querying unnecessary model data when filtering transactions
1 parent d8d9162 commit 1ee72a8

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/qt/transactionfilterproxy.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,35 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &
3131
{
3232
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
3333

34-
int type = index.data(TransactionTableModel::TypeRole).toInt();
35-
QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime();
36-
bool involvesWatchAddress = index.data(TransactionTableModel::WatchonlyRole).toBool();
37-
QString address = index.data(TransactionTableModel::AddressRole).toString();
38-
QString label = index.data(TransactionTableModel::LabelRole).toString();
39-
QString txid = index.data(TransactionTableModel::TxHashRole).toString();
40-
qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong());
4134
int status = index.data(TransactionTableModel::StatusRole).toInt();
42-
43-
if(!showInactive && status == TransactionStatus::Conflicted)
35+
if (!showInactive && status == TransactionStatus::Conflicted)
4436
return false;
45-
if(!(TYPE(type) & typeFilter))
37+
38+
int type = index.data(TransactionTableModel::TypeRole).toInt();
39+
if (!(TYPE(type) & typeFilter))
4640
return false;
41+
42+
bool involvesWatchAddress = index.data(TransactionTableModel::WatchonlyRole).toBool();
4743
if (involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_No)
4844
return false;
4945
if (!involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_Yes)
5046
return false;
51-
if(datetime < dateFrom || datetime > dateTo)
47+
48+
QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime();
49+
if (datetime < dateFrom || datetime > dateTo)
5250
return false;
51+
52+
QString address = index.data(TransactionTableModel::AddressRole).toString();
53+
QString label = index.data(TransactionTableModel::LabelRole).toString();
54+
QString txid = index.data(TransactionTableModel::TxHashRole).toString();
5355
if (!address.contains(m_search_string, Qt::CaseInsensitive) &&
5456
! label.contains(m_search_string, Qt::CaseInsensitive) &&
5557
! txid.contains(m_search_string, Qt::CaseInsensitive)) {
5658
return false;
5759
}
58-
if(amount < minAmount)
60+
61+
qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong());
62+
if (amount < minAmount)
5963
return false;
6064

6165
return true;

0 commit comments

Comments
 (0)