Fabcoin Core  0.16.2
P2P Digital Currency
transactionfilterproxy.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2017 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
6 
8 #include <transactionrecord.h>
9 
10 #include <cstdlib>
11 
12 #include <QDateTime>
13 
14 // Earliest date that can be represented (far in the past)
15 const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromTime_t(0);
16 // Last date that can be represented (far in the future)
17 const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromTime_t(0xFFFFFFFF);
18 
20  QSortFilterProxyModel(parent),
21  dateFrom(MIN_DATE),
22  dateTo(MAX_DATE),
23  addrPrefix(),
24  typeFilter(ALL_TYPES),
25  watchOnlyFilter(WatchOnlyFilter_All),
26  minAmount(0),
27  limitRows(-1),
28  showInactive(true)
29 {
30 }
31 
32 bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
33 {
34  QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
35 
36  int type = index.data(TransactionTableModel::TypeRole).toInt();
37  QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime();
38  bool involvesWatchAddress = index.data(TransactionTableModel::WatchonlyRole).toBool();
39  QString address = index.data(TransactionTableModel::AddressRole).toString();
40  QString label = index.data(TransactionTableModel::LabelRole).toString();
41  qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong());
42  int status = index.data(TransactionTableModel::StatusRole).toInt();
43 
45  return false;
46  if(!(TYPE(type) & typeFilter))
47  return false;
48  if (involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_No)
49  return false;
50  if (!involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_Yes)
51  return false;
52  if(datetime < dateFrom || datetime > dateTo)
53  return false;
54  if (!address.contains(addrPrefix, Qt::CaseInsensitive) && !label.contains(addrPrefix, Qt::CaseInsensitive))
55  return false;
56  if(amount < minAmount)
57  return false;
58 
59  return true;
60 }
61 
62 void TransactionFilterProxy::setDateRange(const QDateTime &from, const QDateTime &to)
63 {
64  this->dateFrom = from;
65  this->dateTo = to;
66  invalidateFilter();
67 }
68 
69 void TransactionFilterProxy::setAddressPrefix(const QString &_addrPrefix)
70 {
71  this->addrPrefix = _addrPrefix;
72  invalidateFilter();
73 }
74 
76 {
77  this->typeFilter = modes;
78  invalidateFilter();
79 }
80 
82 {
83  this->minAmount = minimum;
84  invalidateFilter();
85 }
86 
88 {
89  this->watchOnlyFilter = filter;
90  invalidateFilter();
91 }
92 
94 {
95  this->limitRows = limit;
96 }
97 
99 {
100  this->showInactive = _showInactive;
101  invalidateFilter();
102 }
103 
104 int TransactionFilterProxy::rowCount(const QModelIndex &parent) const
105 {
106  if(limitRows != -1)
107  {
108  return std::min(QSortFilterProxyModel::rowCount(parent), limitRows);
109  }
110  else
111  {
112  return QSortFilterProxyModel::rowCount(parent);
113  }
114 }
Transaction status (TransactionRecord::Status)
void setTypeFilter(quint32 modes)
ExecStats::duration min
Definition: ExecStats.cpp:35
TransactionFilterProxy(QObject *parent=0)
void setAddressPrefix(const QString &addrPrefix)
static quint32 TYPE(int type)
int64_t CAmount
Amount in lius (Can be negative)
Definition: amount.h:15
static const QDateTime MIN_DATE
Earliest date that can be represented (far in the past)
static const QDateTime MAX_DATE
Last date that can be represented (far in the future)
void setDateRange(const QDateTime &from, const QDateTime &to)
Date and time this transaction was created.
void setWatchOnlyFilter(WatchOnlyFilter filter)
void setMinAmount(const CAmount &minimum)
void setLimit(int limit)
Set maximum number of rows returned, -1 if unlimited.
void setShowInactive(bool showInactive)
Set whether to show conflicted transactions.
int rowCount(const QModelIndex &parent=QModelIndex()) const
PlatformStyle::TableColorType type
Definition: rpcconsole.cpp:61
Conflicts with other transaction or mempool.
Label of address related to transaction.
struct evm_uint160be address(struct evm_env *env)
Definition: capi.c:13
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const