Changeset View
Changeset View
Standalone View
Standalone View
src/qt/transactionfilterproxy.cpp
Show All 21 Lines | : QSortFilterProxyModel(parent), dateFrom(MIN_DATE), dateTo(MAX_DATE), | ||||
m_search_string(), typeFilter(ALL_TYPES), | m_search_string(), typeFilter(ALL_TYPES), | ||||
watchOnlyFilter(WatchOnlyFilter_All), minAmount(), limitRows(-1), | watchOnlyFilter(WatchOnlyFilter_All), minAmount(), limitRows(-1), | ||||
showInactive(true) {} | showInactive(true) {} | ||||
bool TransactionFilterProxy::filterAcceptsRow( | bool TransactionFilterProxy::filterAcceptsRow( | ||||
int sourceRow, const QModelIndex &sourceParent) const { | int sourceRow, const QModelIndex &sourceParent) const { | ||||
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::TxIDRole).toString(); | |||||
Amount amount( | |||||
int64_t( | |||||
llabs(index.data(TransactionTableModel::AmountRole).toLongLong())) * | |||||
SATOSHI); | |||||
int status = index.data(TransactionTableModel::StatusRole).toInt(); | int status = index.data(TransactionTableModel::StatusRole).toInt(); | ||||
if (!showInactive && status == TransactionStatus::Conflicted) { | if (!showInactive && status == TransactionStatus::Conflicted) { | ||||
return false; | return false; | ||||
} | } | ||||
int type = index.data(TransactionTableModel::TypeRole).toInt(); | |||||
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; | ||||
} | } | ||||
QDateTime datetime = | |||||
index.data(TransactionTableModel::DateRole).toDateTime(); | |||||
if (datetime < dateFrom || datetime > dateTo) { | 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; | ||||
} | } | ||||
Amount amount( | |||||
int64_t( | |||||
llabs(index.data(TransactionTableModel::AmountRole).toLongLong())) * | |||||
SATOSHI); | |||||
if (amount < minAmount) { | if (amount < minAmount) { | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
void TransactionFilterProxy::setDateRange(const QDateTime &from, | void TransactionFilterProxy::setDateRange(const QDateTime &from, | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |