transactionview.h raw

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