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