FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
bitcoin/src/qt/transactionfilterproxy.cpp at master · blaklite/bitcoin · GitHub
blaklite
/
bitcoin
Public
forked from
bitcoin/bitcoin
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
bitcoin
/
src
/
qt
/
transactionfilterproxy.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
87 lines (72 loc) · 2.36 KB
Breadcrumbs
bitcoin
/
src
/
qt
/
transactionfilterproxy.cpp
Copy path
File metadata and controls
87 lines (72 loc) · 2.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#
include
"
transactionfilterproxy.h
"
#
include
"
transactiontablemodel.h
"
#
include
<
QDateTime
>
#
include
<
cstdlib
>
//
Earliest date that can be represented (far in the past)
const
QDateTime TransactionFilterProxy::
MIN_DATE
= QDateTime::fromTime_t(
0
);
//
Last date that can be represented (far in the future)
const
QDateTime TransactionFilterProxy::
MAX_DATE
= QDateTime::fromTime_t(
0xFFFFFFFF
);
TransactionFilterProxy::TransactionFilterProxy
(QObject *parent) :
QSortFilterProxyModel(parent),
dateFrom(
MIN_DATE
),
dateTo(
MAX_DATE
),
addrPrefix(),
typeFilter(
ALL_TYPES
),
minAmount(
0
),
limitRows(-
1
)
{
}
bool
TransactionFilterProxy::filterAcceptsRow
(
int
sourceRow,
const
QModelIndex &sourceParent)
const
{
QModelIndex index =
sourceModel
()->
index
(sourceRow,
0
, sourceParent);
int
type = index.
data
(TransactionTableModel::TypeRole).
toInt
();
QDateTime datetime = index.
data
(TransactionTableModel::DateRole).
toDateTime
();
QString address = index.
data
(TransactionTableModel::AddressRole).
toString
();
QString label = index.
data
(TransactionTableModel::LabelRole).
toString
();
qint64 amount =
llabs
(index.
data
(TransactionTableModel::AmountRole).
toLongLong
());
if
(!(
TYPE
(type) & typeFilter))
return
false
;
if
(datetime < dateFrom || datetime > dateTo)
return
false
;
if
(!address.
contains
(addrPrefix, Qt::CaseInsensitive) && !label.
contains
(addrPrefix, Qt::CaseInsensitive))
return
false
;
if
(amount < minAmount)
return
false
;
return
true
;
}
void
TransactionFilterProxy::setDateRange
(
const
QDateTime &from,
const
QDateTime &to)
{
this
->
dateFrom
= from;
this
->
dateTo
= to;
invalidateFilter
();
}
void
TransactionFilterProxy::setAddressPrefix
(
const
QString &addrPrefix)
{
this
->
addrPrefix
= addrPrefix;
invalidateFilter
();
}
void
TransactionFilterProxy::setTypeFilter
(quint32 modes)
{
this
->
typeFilter
= modes;
invalidateFilter
();
}
void
TransactionFilterProxy::setMinAmount
(qint64 minimum)
{
this
->
minAmount
= minimum;
invalidateFilter
();
}
void
TransactionFilterProxy::setLimit
(
int
limit)
{
this
->
limitRows
= limit;
}
int
TransactionFilterProxy::rowCount
(
const
QModelIndex &parent)
const
{
if
(limitRows != -
1
)
{
return
std::min
(
QSortFilterProxyModel::rowCount
(parent), limitRows);
}
else
{
return
QSortFilterProxyModel::rowCount
(parent);
}
}
Back
|
FazBrowse Home
|
New Git URL