coincontroldialog.h
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_COINCONTROLDIALOG_H 6 #define BITCOIN_QT_COINCONTROLDIALOG_H 7 8 #include <consensus/amount.h> 9 10 #include <QAbstractButton> 11 #include <QAction> 12 #include <QDialog> 13 #include <QList> 14 #include <QMenu> 15 #include <QPoint> 16 #include <QString> 17 #include <QTreeWidgetItem> 18 19 class PlatformStyle; 20 class WalletModel; 21 22 namespace wallet { 23 class CCoinControl; 24 } // namespace wallet 25 26 namespace Ui { 27 class CoinControlDialog; 28 } 29 30 #define ASYMP_UTF8 "\xE2\x89\x88" 31 32 class CCoinControlWidgetItem : public QTreeWidgetItem 33 { 34 public: 35 explicit CCoinControlWidgetItem(QTreeWidget *parent, int type = Type) : QTreeWidgetItem(parent, type) {} 36 explicit CCoinControlWidgetItem(QTreeWidgetItem *parent, int type = Type) : QTreeWidgetItem(parent, type) {} 37 38 bool operator<(const QTreeWidgetItem &other) const override; 39 }; 40 41 42 class CoinControlDialog : public QDialog 43 { 44 Q_OBJECT 45 46 public: 47 explicit CoinControlDialog(wallet::CCoinControl& coin_control, WalletModel* model, const PlatformStyle *platformStyle, QWidget *parent = nullptr); 48 ~CoinControlDialog(); 49 50 // static because also called from sendcoinsdialog 51 static void updateLabels(wallet::CCoinControl& m_coin_control, WalletModel*, QDialog*); 52 53 static QList<CAmount> payAmounts; 54 static bool fSubtractFeeFromAmount; 55 56 protected: 57 void changeEvent(QEvent* e) override; 58 59 private: 60 Ui::CoinControlDialog *ui; 61 wallet::CCoinControl& m_coin_control; 62 WalletModel *model; 63 int sortColumn; 64 Qt::SortOrder sortOrder; 65 66 QMenu *contextMenu; 67 QTreeWidgetItem *contextMenuItem; 68 QAction* m_copy_transaction_outpoint_action; 69 QAction *lockAction; 70 QAction *unlockAction; 71 72 const PlatformStyle *platformStyle; 73 74 void sortView(int, Qt::SortOrder); 75 void updateView(); 76 77 enum 78 { 79 COLUMN_CHECKBOX = 0, 80 COLUMN_AMOUNT, 81 COLUMN_LABEL, 82 COLUMN_ADDRESS, 83 COLUMN_DATE, 84 COLUMN_CONFIRMATIONS, 85 }; 86 87 enum 88 { 89 TxHashRole = Qt::UserRole, 90 VOutRole 91 }; 92 93 friend class CCoinControlWidgetItem; 94 95 private Q_SLOTS: 96 void showMenu(const QPoint &); 97 void copyAmount(); 98 void copyLabel(); 99 void copyAddress(); 100 void copyTransactionOutpoint(); 101 void lockCoin(); 102 void unlockCoin(); 103 void clipboardQuantity(); 104 void clipboardAmount(); 105 void clipboardFee(); 106 void clipboardAfterFee(); 107 void clipboardBytes(); 108 void clipboardChange(); 109 void radioTreeMode(bool); 110 void radioListMode(bool); 111 void viewItemChanged(QTreeWidgetItem*, int); 112 void headerSectionClicked(int); 113 void buttonBoxClicked(QAbstractButton*); 114 void buttonSelectAllClicked(); 115 void updateLabelLocked(); 116 }; 117 118 #endif // BITCOIN_QT_COINCONTROLDIALOG_H