transactionfilterproxy.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // ECOin - Copyright (c) - 2014/2021 - GPLv3 - epsylon@riseup.net (https://03c8.net)
  2. #ifndef TRANSACTIONFILTERPROXY_H
  3. #define TRANSACTIONFILTERPROXY_H
  4. #include <QSortFilterProxyModel>
  5. #include <QDateTime>
  6. /** Filter the transaction list according to pre-specified rules. */
  7. class TransactionFilterProxy : public QSortFilterProxyModel
  8. {
  9. Q_OBJECT
  10. public:
  11. explicit TransactionFilterProxy(QObject *parent = 0);
  12. /** Earliest date that can be represented (far in the past) */
  13. static const QDateTime MIN_DATE;
  14. /** Last date that can be represented (far in the future) */
  15. static const QDateTime MAX_DATE;
  16. /** Type filter bit field (all types) */
  17. static const quint32 ALL_TYPES = 0xFFFFFFFF;
  18. static quint32 TYPE(int type) { return 1<<type; }
  19. void setDateRange(const QDateTime &from, const QDateTime &to);
  20. void setAddressPrefix(const QString &addrPrefix);
  21. void setTypeFilter(quint32 modes);
  22. void setMinAmount(qint64 minimum);
  23. /** Set maximum number of rows returned, -1 if unlimited. */
  24. void setLimit(int limit);
  25. int rowCount(const QModelIndex &parent = QModelIndex()) const;
  26. protected:
  27. bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const;
  28. private:
  29. QDateTime dateFrom;
  30. QDateTime dateTo;
  31. QString addrPrefix;
  32. quint32 typeFilter;
  33. qint64 minAmount;
  34. int limitRows;
  35. signals:
  36. public slots:
  37. };
  38. #endif // TRANSACTIONFILTERPROXY_H