You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

transactionfilterproxy.h 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright (c) 2011-2014 The Starwels developers
  2. // Distributed under the MIT software license, see the accompanying
  3. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  4. #ifndef STARWELS_QT_TRANSACTIONFILTERPROXY_H
  5. #define STARWELS_QT_TRANSACTIONFILTERPROXY_H
  6. #include "amount.h"
  7. #include <QDateTime>
  8. #include <QSortFilterProxyModel>
  9. /** Filter the transaction list according to pre-specified rules. */
  10. class TransactionFilterProxy : public QSortFilterProxyModel
  11. {
  12. Q_OBJECT
  13. public:
  14. explicit TransactionFilterProxy(QObject *parent = 0);
  15. /** Earliest date that can be represented (far in the past) */
  16. static const QDateTime MIN_DATE;
  17. /** Last date that can be represented (far in the future) */
  18. static const QDateTime MAX_DATE;
  19. /** Type filter bit field (all types) */
  20. static const quint32 ALL_TYPES = 0xFFFFFFFF;
  21. static quint32 TYPE(int type) { return 1<<type; }
  22. enum WatchOnlyFilter
  23. {
  24. WatchOnlyFilter_All,
  25. WatchOnlyFilter_Yes,
  26. WatchOnlyFilter_No
  27. };
  28. void setDateRange(const QDateTime &from, const QDateTime &to);
  29. void setAddressPrefix(const QString &addrPrefix);
  30. /**
  31. @note Type filter takes a bit field created with TYPE() or ALL_TYPES
  32. */
  33. void setTypeFilter(quint32 modes);
  34. void setMinAmount(const CAmount& minimum);
  35. void setWatchOnlyFilter(WatchOnlyFilter filter);
  36. /** Set maximum number of rows returned, -1 if unlimited. */
  37. void setLimit(int limit);
  38. /** Set whether to show conflicted transactions. */
  39. void setShowInactive(bool showInactive);
  40. int rowCount(const QModelIndex &parent = QModelIndex()) const;
  41. protected:
  42. bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const;
  43. private:
  44. QDateTime dateFrom;
  45. QDateTime dateTo;
  46. QString addrPrefix;
  47. quint32 typeFilter;
  48. WatchOnlyFilter watchOnlyFilter;
  49. CAmount minAmount;
  50. int limitRows;
  51. bool showInactive;
  52. };
  53. #endif // STARWELS_QT_TRANSACTIONFILTERPROXY_H