transactionview.h raw

   1  // Copyright (c) 2011-present 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_TRANSACTIONVIEW_H
   6  #define BITCOIN_QT_TRANSACTIONVIEW_H
   7  
   8  #include <qt/guiutil.h>
   9  
  10  #include <primitives/transaction_identifier.h>
  11  #include <uint256.h>
  12  
  13  #include <QWidget>
  14  #include <QKeyEvent>
  15  
  16  class PlatformStyle;
  17  class TransactionDescDialog;
  18  class TransactionFilterProxy;
  19  class WalletModel;
  20  
  21  QT_BEGIN_NAMESPACE
  22  class QComboBox;
  23  class QDateTimeEdit;
  24  class QFrame;
  25  class QLineEdit;
  26  class QMenu;
  27  class QModelIndex;
  28  class QTableView;
  29  QT_END_NAMESPACE
  30  
  31  /** Widget showing the transaction list for a wallet, including a filter row.
  32      Using the filter row, the user can view or export a subset of the transactions.
  33    */
  34  class TransactionView : public QWidget
  35  {
  36      Q_OBJECT
  37  
  38  public:
  39      explicit TransactionView(const PlatformStyle *platformStyle, QWidget *parent = nullptr);
  40      ~TransactionView();
  41  
  42      void setModel(WalletModel *model);
  43  
  44      // Date ranges for filter
  45      enum DateEnum
  46      {
  47          All,
  48          Today,
  49          ThisWeek,
  50          ThisMonth,
  51          LastMonth,
  52          ThisYear,
  53          Range
  54      };
  55  
  56      enum ColumnWidths {
  57          STATUS_COLUMN_WIDTH = 30,
  58          DATE_COLUMN_WIDTH = 120,
  59          TYPE_COLUMN_WIDTH = 113,
  60          AMOUNT_MINIMUM_COLUMN_WIDTH = 120,
  61          MINIMUM_COLUMN_WIDTH = 23
  62      };
  63  
  64  protected:
  65      void changeEvent(QEvent* e) override;
  66  
  67  private:
  68      WalletModel *model{nullptr};
  69      TransactionFilterProxy *transactionProxyModel{nullptr};
  70      QTableView *transactionView{nullptr};
  71  
  72      QComboBox *dateWidget;
  73      QComboBox *typeWidget;
  74      QLineEdit *search_widget;
  75      QLineEdit *amountWidget;
  76  
  77      QMenu *contextMenu;
  78  
  79      QFrame *dateRangeWidget;
  80      QDateTimeEdit *dateFrom;
  81      QDateTimeEdit *dateTo;
  82      QAction *abandonAction{nullptr};
  83      QAction *bumpFeeAction{nullptr};
  84      QAction *copyAddressAction{nullptr};
  85      QAction *copyLabelAction{nullptr};
  86  
  87      QWidget *createDateRangeWidget();
  88  
  89      bool eventFilter(QObject *obj, QEvent *event) override;
  90  
  91      const PlatformStyle* m_platform_style;
  92  
  93      QList<TransactionDescDialog*> m_opened_dialogs;
  94  
  95  private Q_SLOTS:
  96      void contextualMenu(const QPoint &);
  97      void dateRangeChanged();
  98      void showDetails();
  99      void copyAddress();
 100      void editLabel();
 101      void copyLabel();
 102      void copyAmount();
 103      void copyTxID();
 104      void copyTxHex();
 105      void copyTxPlainText();
 106      void openThirdPartyTxUrl(QString url);
 107      void abandonTx();
 108      void bumpFee(bool checked);
 109  
 110  Q_SIGNALS:
 111      void doubleClicked(const QModelIndex&);
 112  
 113      /**  Fired when a message should be reported to the user */
 114      void message(const QString &title, const QString &message, unsigned int style);
 115  
 116      void bumpedFee(const Txid& txid);
 117  
 118  public Q_SLOTS:
 119      void chooseDate(int idx);
 120      void chooseType(int idx);
 121      void changedAmount();
 122      void changedSearch();
 123      void exportClicked();
 124      void closeOpenedDialogs();
 125      void focusTransaction(const QModelIndex&);
 126      void focusTransaction(const Txid& txid);
 127  };
 128  
 129  #endif // BITCOIN_QT_TRANSACTIONVIEW_H
 130