mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
Merge #12621: Avoid querying unnecessary model data when filtering transactions
1ee72a819f
qt: Avoid querying unnecessary model data when filtering transactions (João Barbosa)
Pull request description:
This change moves down model data querying to where it's needed. The worst case remains the same (all data is queried and the row passes) but for the average case it improves the filter performance.
Tree-SHA512: 3bcaced029cb39dfbc5377246ce76634f9050ee3a3053db4d358fcbf4d8107c649e75841f21d69f1aebcaf1bbffe3eac784e6b03b366fdbbfec1e0da8f78d8ef
This commit is contained in:
commit
2bac3e4841
1 changed files with 16 additions and 12 deletions
|
@ -31,31 +31,35 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &
|
||||||
{
|
{
|
||||||
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||||
|
|
||||||
int type = index.data(TransactionTableModel::TypeRole).toInt();
|
|
||||||
QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime();
|
|
||||||
bool involvesWatchAddress = index.data(TransactionTableModel::WatchonlyRole).toBool();
|
|
||||||
QString address = index.data(TransactionTableModel::AddressRole).toString();
|
|
||||||
QString label = index.data(TransactionTableModel::LabelRole).toString();
|
|
||||||
QString txid = index.data(TransactionTableModel::TxHashRole).toString();
|
|
||||||
qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong());
|
|
||||||
int status = index.data(TransactionTableModel::StatusRole).toInt();
|
int status = index.data(TransactionTableModel::StatusRole).toInt();
|
||||||
|
if (!showInactive && status == TransactionStatus::Conflicted)
|
||||||
|
return false;
|
||||||
|
|
||||||
if(!showInactive && status == TransactionStatus::Conflicted)
|
int type = index.data(TransactionTableModel::TypeRole).toInt();
|
||||||
return false;
|
if (!(TYPE(type) & typeFilter))
|
||||||
if(!(TYPE(type) & typeFilter))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
bool involvesWatchAddress = index.data(TransactionTableModel::WatchonlyRole).toBool();
|
||||||
if (involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_No)
|
if (involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_No)
|
||||||
return false;
|
return false;
|
||||||
if (!involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_Yes)
|
if (!involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_Yes)
|
||||||
return false;
|
return false;
|
||||||
if(datetime < dateFrom || datetime > dateTo)
|
|
||||||
|
QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime();
|
||||||
|
if (datetime < dateFrom || datetime > dateTo)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
QString address = index.data(TransactionTableModel::AddressRole).toString();
|
||||||
|
QString label = index.data(TransactionTableModel::LabelRole).toString();
|
||||||
|
QString txid = index.data(TransactionTableModel::TxHashRole).toString();
|
||||||
if (!address.contains(m_search_string, Qt::CaseInsensitive) &&
|
if (!address.contains(m_search_string, Qt::CaseInsensitive) &&
|
||||||
! label.contains(m_search_string, Qt::CaseInsensitive) &&
|
! label.contains(m_search_string, Qt::CaseInsensitive) &&
|
||||||
! txid.contains(m_search_string, Qt::CaseInsensitive)) {
|
! txid.contains(m_search_string, Qt::CaseInsensitive)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(amount < minAmount)
|
|
||||||
|
qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong());
|
||||||
|
if (amount < minAmount)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue