Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
transactionfilterproxy.cpp
Go to the documentation of this file.
1// Copyright (c) 2011-2016 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
9
10#include <cstdlib>
11
12// Earliest date that can be represented (far in the past)
13const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromTime_t(0);
14// Last date that can be represented (far in the future)
16 QDateTime::fromTime_t(0xFFFFFFFF);
17
19 : QSortFilterProxyModel(parent), dateFrom(MIN_DATE), dateTo(MAX_DATE),
20 m_search_string(), typeFilter(ALL_TYPES),
21 watchOnlyFilter(WatchOnlyFilter_All), minAmount(), limitRows(-1),
22 showInactive(true) {}
23
25 int sourceRow, const QModelIndex &sourceParent) const {
26 QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
27
28 int status = index.data(TransactionTableModel::StatusRole).toInt();
30 return false;
31 }
32
33 int type = index.data(TransactionTableModel::TypeRole).toInt();
34 if (!(TYPE(type) & typeFilter)) {
35 return false;
36 }
37
38 bool involvesWatchAddress =
39 index.data(TransactionTableModel::WatchonlyRole).toBool();
40 if (involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_No) {
41 return false;
42 }
43 if (!involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_Yes) {
44 return false;
45 }
46
48 index.data(TransactionTableModel::DateRole).toDateTime();
50 return false;
51 }
52
53 QString address = index.data(TransactionTableModel::AddressRole).toString();
54 QString label = index.data(TransactionTableModel::LabelRole).toString();
55 QString txid = index.data(TransactionTableModel::TxHashRole).toString();
56 if (!address.contains(m_search_string, Qt::CaseInsensitive) &&
57 !label.contains(m_search_string, Qt::CaseInsensitive) &&
58 !txid.contains(m_search_string, Qt::CaseInsensitive)) {
59 return false;
60 }
61
62 Amount amount(
63 int64_t(
64 llabs(index.data(TransactionTableModel::AmountRole).toLongLong())) *
65 SATOSHI);
66 if (amount < minAmount) {
67 return false;
68 }
69
70 return true;
71}
72
74 const QDateTime &to) {
75 this->dateFrom = from;
76 this->dateTo = to;
78}
79
81 if (m_search_string == search_string) {
82 return;
83 }
86}
87
92
97
102
106
111
113 if (limitRows != -1) {
114 return std::min(QSortFilterProxyModel::rowCount(parent), limitRows);
115 } else {
116 return QSortFilterProxyModel::rowCount(parent);
117 }
118}
static constexpr Amount SATOSHI
Definition amount.h:143
void setLimit(int limit)
Set maximum number of rows returned, -1 if unlimited.
static const QDateTime MAX_DATE
Last date that can be represented (far in the future).
void setWatchOnlyFilter(WatchOnlyFilter filter)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
static quint32 TYPE(int type)
static const QDateTime MIN_DATE
Earliest date that can be represented (far in the past).
void setShowInactive(bool showInactive)
Set whether to show conflicted transactions.
void setSearchString(const QString &)
void setMinAmount(const Amount minimum)
void setDateRange(const QDateTime &from, const QDateTime &to)
void setTypeFilter(quint32 modes)
TransactionFilterProxy(QObject *parent=nullptr)
@ Conflicted
Conflicts with other transaction or mempool.
@ LabelRole
Label of address related to transaction.
@ TypeRole
Type of transaction.
@ StatusRole
Transaction status (TransactionRecord::Status)
@ DateRole
Date and time this transaction was created.
@ TxHashRole
Transaction hash.
@ AddressRole
Address of transaction.
@ WatchonlyRole
Watch-only boolean.
@ AmountRole
Net amount of transaction.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85