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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
crate::ix!();
//-------------------------------------------[.cpp/bitcoin/src/qt/transactionfilterproxy.h]
/**
| Filter the transaction list according
| to pre-specified rules.
|
*/
#[Q_OBJECT]
pub struct TransactionFilterProxy {
base: QSortFilterProxyModel,
date_from: Option<QDateTime>,
date_to: Option<QDateTime>,
search_string: String,
type_filter: u32,
watch_only_filter: transaction_filter_proxy::WatchOnlyFilter,
min_amount: Amount,
limit_rows: i32,
show_inactive: bool,
}
pub mod transaction_filter_proxy {
/**
| Type filter bit field (all types)
|
*/
pub const ALL_TYPES: u32 = 0xFFFFFFFF;
pub enum WatchOnlyFilter
{
WatchOnlyFilter_All,
WatchOnlyFilter_Yes,
WatchOnlyFilter_No
}
}
//-------------------------------------------[.cpp/bitcoin/src/qt/transactionfilterproxy.cpp]
impl TransactionFilterProxy {
pub fn ty(ty: i32) -> u32 {
todo!();
/*
return 1<<type;
*/
}
pub fn new(parent: *mut QObject) -> Self {
todo!();
/*
:
QSortFilterProxyModel(parent),
m_search_string(),
typeFilter(ALL_TYPES),
watchOnlyFilter(WatchOnlyFilter_All),
minAmount(0),
limitRows(-1),
showInactive(true)
*/
}
pub fn filter_accepts_row(&self,
source_row: i32,
source_parent: &QModelIndex) -> bool {
todo!();
/*
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
int status = index.data(TransactionTableModel::StatusRole).toInt();
if (!showInactive && status == TransactionStatus::Conflicted)
return false;
int type = index.data(TransactionTableModel::TypeRole).toInt();
if (!(TYPE(type) & typeFilter))
return false;
bool involvesWatchAddress = index.data(TransactionTableModel::WatchonlyRole).toBool();
if (involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_No)
return false;
if (!involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_Yes)
return false;
QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime();
if (dateFrom && datetime < *dateFrom) return false;
if (dateTo && datetime > *dateTo) return false;
QString address = index.data(TransactionTableModel::AddressRole).toString();
QString label = index.data(TransactionTableModel::LabelRole).toString();
QString txid = index.data(TransactionTableModel::TxHashRole).toString();
if (!address.contains(m_search_string, QtCaseInsensitive) &&
! label.contains(m_search_string, QtCaseInsensitive) &&
! txid.contains(m_search_string, QtCaseInsensitive)) {
return false;
}
i64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong());
if (amount < minAmount)
return false;
return true;
*/
}
/**
| Filter transactions between date range.
| Use std::nullopt for open range.
|
*/
pub fn set_date_range(&mut self,
from: &Option<QDateTime>,
to: &Option<QDateTime>) {
todo!();
/*
dateFrom = from;
dateTo = to;
invalidateFilter();
*/
}
pub fn set_search_string(&mut self, search_string: &String) {
todo!();
/*
if (m_search_string == search_string) return;
m_search_string = search_string;
invalidateFilter();
*/
}
/**
| @note
|
| Type filter takes a bit field created
| with TYPE() or ALL_TYPES
|
*/
pub fn set_type_filter(&mut self, modes: u32) {
todo!();
/*
this->typeFilter = modes;
invalidateFilter();
*/
}
pub fn set_min_amount(&mut self, minimum: &Amount) {
todo!();
/*
this->minAmount = minimum;
invalidateFilter();
*/
}
pub fn set_watch_only_filter(&mut self, filter: transaction_filter_proxy::WatchOnlyFilter) {
todo!();
/*
this->watchOnlyFilter = filter;
invalidateFilter();
*/
}
/**
| Set maximum number of rows returned,
| -1 if unlimited.
|
*/
pub fn set_limit(&mut self, limit: i32) {
todo!();
/*
this->limitRows = limit;
*/
}
/**
| Set whether to show conflicted transactions.
|
*/
pub fn set_show_inactive(&mut self, show_inactive: bool) {
todo!();
/*
this->showInactive = _showInactive;
invalidateFilter();
*/
}
pub fn row_count(&self, parent: Option<&QModelIndex>) -> i32 {
let parent: &QModelIndex = unsafe { parent.unwrap_or(&QModelIndex::new()) };
todo!();
/*
if(limitRows != -1)
{
return std::min(QSortFilterProxyModel::rowCount(parent), limitRows);
}
else
{
return QSortFilterProxyModel::rowCount(parent);
}
*/
}
}