Bitcoin Core  0.18.99
P2P Digital Currency
transactiontablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2018 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_TRANSACTIONTABLEMODEL_H
6 #define BITCOIN_QT_TRANSACTIONTABLEMODEL_H
7 
8 #include <qt/bitcoinunits.h>
9 
10 #include <QAbstractTableModel>
11 #include <QStringList>
12 
13 #include <memory>
14 
15 namespace interfaces {
16 class Handler;
17 }
18 
19 class PlatformStyle;
20 class TransactionRecord;
22 class WalletModel;
23 
26 class TransactionTableModel : public QAbstractTableModel
27 {
28  Q_OBJECT
29 
30 public:
31  explicit TransactionTableModel(const PlatformStyle *platformStyle, WalletModel *parent = nullptr);
33 
34  enum ColumnIndex {
35  Status = 0,
36  Watchonly = 1,
37  Date = 2,
38  Type = 3,
39  ToAddress = 4,
40  Amount = 5
41  };
42 
46  enum RoleIndex {
48  TypeRole = Qt::UserRole,
77  };
78 
79  int rowCount(const QModelIndex &parent) const;
80  int columnCount(const QModelIndex &parent) const;
81  QVariant data(const QModelIndex &index, int role) const;
82  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
83  QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
84  bool processingQueuedTransactions() const { return fProcessingQueuedTransactions; }
85 
86 private:
88  std::unique_ptr<interfaces::Handler> m_handler_transaction_changed;
89  std::unique_ptr<interfaces::Handler> m_handler_show_progress;
90  QStringList columns;
94 
95  void subscribeToCoreSignals();
96  void unsubscribeFromCoreSignals();
97 
98  QString lookupAddress(const std::string &address, bool tooltip) const;
99  QVariant addressColor(const TransactionRecord *wtx) const;
100  QString formatTxStatus(const TransactionRecord *wtx) const;
101  QString formatTxDate(const TransactionRecord *wtx) const;
102  QString formatTxType(const TransactionRecord *wtx) const;
103  QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const;
104  QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true, BitcoinUnits::SeparatorStyle separators=BitcoinUnits::separatorStandard) const;
105  QString formatTooltip(const TransactionRecord *rec) const;
106  QVariant txStatusDecoration(const TransactionRecord *wtx) const;
107  QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const;
108  QVariant txAddressDecoration(const TransactionRecord *wtx) const;
109 
110 public Q_SLOTS:
111  /* New transaction, or transaction changed status */
112  void updateTransaction(const QString &hash, int status, bool showTransaction);
113  void updateConfirmations();
114  void updateDisplayUnit();
116  void updateAmountColumnTitle();
117  /* Needed to update fProcessingQueuedTransactions through a QueuedConnection */
118  void setProcessingQueuedTransactions(bool value) { fProcessingQueuedTransactions = value; }
119 
120  friend class TransactionTablePriv;
121 };
122 
123 #endif // BITCOIN_QT_TRANSACTIONTABLEMODEL_H
Transaction status (TransactionRecord::Status)
Transaction data, hex-encoded.
TransactionTablePriv * priv
bool processingQueuedTransactions() const
UI model for a transaction.
Whole transaction as plain text.
std::unique_ptr< interfaces::Handler > m_handler_transaction_changed
Date and time this transaction was created.
UI model for the transaction table of a wallet.
std::unique_ptr< interfaces::Handler > m_handler_show_progress
RoleIndex
Roles to get specific information from a transaction row.
void setProcessingQueuedTransactions(bool value)
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:125
Label of address related to transaction.
Formatted amount, without brackets when unconfirmed.
const PlatformStyle * platformStyle