Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

transactionfilterproxy.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2014 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 <qt/transactionrecord.h>
9 
10 #include <cstdlib>
11 
12 // Earliest date that can be represented (far in the past)
13 const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromTime_t(0);
14 // Last date that can be represented (far in the future)
15 const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromTime_t(0xFFFFFFFF);
16 
18  QSortFilterProxyModel(parent),
19  dateFrom(MIN_DATE.toTime_t()),
20  dateTo(MAX_DATE.toTime_t()),
21  m_search_string(),
22  typeFilter(COMMON_TYPES),
23  watchOnlyFilter(WatchOnlyFilter_All),
24  minAmount(0),
25  limitRows(-1),
26  showInactive(true)
27 {
28 }
29 
30 bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
31 {
32  QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
33 
34  int type = index.data(TransactionTableModel::TypeRole).toInt();
35  qint64 datetime = index.data(TransactionTableModel::DateRoleInt).toLongLong();
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::TxIDRole).toString();
40  qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong());
41  int status = index.data(TransactionTableModel::StatusRole).toInt();
42 
44  return false;
45  if(!(TYPE(type) & typeFilter))
46  return false;
47  if (involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_No)
48  return false;
49  if (!involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_Yes)
50  return false;
51  if(datetime < dateFrom || datetime > dateTo)
52  return false;
53  if (!address.contains(m_search_string, Qt::CaseInsensitive) &&
54  ! label.contains(m_search_string, Qt::CaseInsensitive) &&
55  ! txid.contains(m_search_string, Qt::CaseInsensitive)) {
56  return false;
57  }
58  if(amount < minAmount)
59  return false;
60 
61  return true;
62 }
63 
64 void TransactionFilterProxy::setDateRange(const QDateTime &from, const QDateTime &to)
65 {
66  this->dateFrom = from.toTime_t();
67  this->dateTo = to.toTime_t();
68  invalidateFilter();
69 }
70 
71 void TransactionFilterProxy::setSearchString(const QString &search_string)
72 {
73  if (m_search_string == search_string) return;
74  m_search_string = search_string;
75  invalidateFilter();
76 }
77 
79 {
80  this->typeFilter = modes;
81  invalidateFilter();
82 }
83 
85 {
86  this->minAmount = minimum;
87  invalidateFilter();
88 }
89 
91 {
92  this->watchOnlyFilter = filter;
93  invalidateFilter();
94 }
95 
97 {
98  Q_EMIT layoutAboutToBeChanged();
99  this->limitRows = limit;
100  Q_EMIT layoutChanged();
101 }
102 
104 {
105  this->showInactive = _showInactive;
106  invalidateFilter();
107 }
108 
109 int TransactionFilterProxy::rowCount(const QModelIndex &parent) const
110 {
111  if(limitRows != -1)
112  {
113  return std::min(QSortFilterProxyModel::rowCount(parent), limitRows);
114  }
115  else
116  {
117  return QSortFilterProxyModel::rowCount(parent);
118  }
119 }
Transaction status (TransactionRecord::Status)
void setTypeFilter(quint32 modes)
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
int rowCount(const QModelIndex &parent=QModelIndex()) const
false true true true
Definition: bls_dkg.cpp:176
Date and time this transaction was created in MSec since epoch.
TransactionFilterProxy(QObject *parent=0)
static quint32 TYPE(int type)
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
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)
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.
Conflicts with other transaction or mempool.
Label of address related to transaction.
void setSearchString(const QString &)
Released under the MIT license