1 #include "transactionfilterproxy.h"
2 #include "transactiontablemodel.h"
7 // Earliest date that can be represented (far in the past)
8 const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromTime_t(0);
9 // Last date that can be represented (far in the future)
10 const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromTime_t(0xFFFFFFFF);
12 TransactionFilterProxy::TransactionFilterProxy(QObject *parent) :
13 QSortFilterProxyModel(parent),
17 typeFilter(ALL_TYPES),
22 bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
24 QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
26 int type = index.data(TransactionTableModel::TypeRole).toInt();
27 QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime();
28 QString address = index.data(TransactionTableModel::AddressRole).toString();
29 QString label = index.data(TransactionTableModel::LabelRole).toString();
30 qint64 amount = index.data(TransactionTableModel::AbsoluteAmountRole).toLongLong();
32 if(!(TYPE(type) & typeFilter))
34 if(datetime < dateFrom || datetime > dateTo)
36 if(!address.startsWith(addrPrefix) && !label.startsWith(addrPrefix))
38 if(amount < minAmount)
44 void TransactionFilterProxy::setDateRange(const QDateTime &from, const QDateTime &to)
46 this->dateFrom = from;
51 void TransactionFilterProxy::setAddressPrefix(const QString &addrPrefix)
53 this->addrPrefix = addrPrefix;
57 void TransactionFilterProxy::setTypeFilter(quint32 modes)
59 this->typeFilter = modes;
63 void TransactionFilterProxy::setMinAmount(qint64 minimum)
65 this->minAmount = minimum;