Line data Source code
1 : // Copyright (c) 2011-2018 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 : 5 : #ifndef BITCOIN_QT_TRANSACTIONFILTERPROXY_H 6 : #define BITCOIN_QT_TRANSACTIONFILTERPROXY_H 7 : 8 : #include <amount.h> 9 : 10 : #include <QDateTime> 11 : #include <QSortFilterProxyModel> 12 : 13 : /** Filter the transaction list according to pre-specified rules. */ 14 0 : class TransactionFilterProxy : public QSortFilterProxyModel 15 : { 16 : Q_OBJECT 17 : 18 : public: 19 : explicit TransactionFilterProxy(QObject *parent = nullptr); 20 : 21 : /** Earliest date that can be represented (far in the past) */ 22 : static const QDateTime MIN_DATE; 23 : /** Last date that can be represented (far in the future) */ 24 : static const QDateTime MAX_DATE; 25 : /** Type filter bit field (all types) */ 26 : static const quint32 ALL_TYPES = 0xFFFFFFFF; 27 : 28 0 : static quint32 TYPE(int type) { return 1<<type; } 29 : 30 : enum WatchOnlyFilter 31 : { 32 : WatchOnlyFilter_All, 33 : WatchOnlyFilter_Yes, 34 : WatchOnlyFilter_No 35 : }; 36 : 37 : void setDateRange(const QDateTime &from, const QDateTime &to); 38 : void setSearchString(const QString &); 39 : /** 40 : @note Type filter takes a bit field created with TYPE() or ALL_TYPES 41 : */ 42 : void setTypeFilter(quint32 modes); 43 : void setMinAmount(const CAmount& minimum); 44 : void setWatchOnlyFilter(WatchOnlyFilter filter); 45 : 46 : /** Set maximum number of rows returned, -1 if unlimited. */ 47 : void setLimit(int limit); 48 : 49 : /** Set whether to show conflicted transactions. */ 50 : void setShowInactive(bool showInactive); 51 : 52 : int rowCount(const QModelIndex &parent = QModelIndex()) const override; 53 : 54 : protected: 55 : bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const override; 56 : 57 : private: 58 : QDateTime dateFrom; 59 : QDateTime dateTo; 60 : QString m_search_string; 61 : quint32 typeFilter; 62 : WatchOnlyFilter watchOnlyFilter; 63 : CAmount minAmount; 64 : int limitRows; 65 : bool showInactive; 66 : }; 67 : 68 : #endif // BITCOIN_QT_TRANSACTIONFILTERPROXY_H