Bitcoin Core  31.0.0
P2P Digital Currency
transactiontablemodel.h
Go to the documentation of this file.
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_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  Date = 1,
37  Type = 2,
38  ToAddress = 3,
39  Amount = 4
40  };
41 
45  enum RoleIndex {
47  TypeRole = Qt::UserRole,
72  };
73 
74  int rowCount(const QModelIndex &parent) const override;
75  int columnCount(const QModelIndex &parent) const override;
76  QVariant data(const QModelIndex &index, int role) const override;
77  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
78  QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const override;
80 
81 private:
83  std::unique_ptr<interfaces::Handler> m_handler_transaction_changed;
84  std::unique_ptr<interfaces::Handler> m_handler_show_progress;
85  QStringList columns;
89 
92 
93  QString lookupAddress(const std::string &address, bool tooltip) const;
94  QVariant addressColor(const TransactionRecord *wtx) const;
95  QString formatTxStatus(const TransactionRecord *wtx) const;
96  QString formatTxDate(const TransactionRecord *wtx) const;
97  QString formatTxType(const TransactionRecord *wtx) const;
98  QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const;
99  QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true, BitcoinUnits::SeparatorStyle separators=BitcoinUnits::SeparatorStyle::STANDARD) const;
100  QString formatTooltip(const TransactionRecord *rec) const;
101  QVariant txStatusDecoration(const TransactionRecord *wtx) const;
102  QVariant txAddressDecoration(const TransactionRecord *wtx) const;
103 
104 public Q_SLOTS:
105  /* New transaction, or transaction changed status */
106  void updateTransaction(const QString &hash, int status, bool showTransaction);
107  void updateConfirmations();
108  void updateDisplayUnit();
111  /* Needed to update fProcessingQueuedTransactions through a QueuedConnection */
113 
114  friend class TransactionTablePriv;
115 };
116 
117 #endif // BITCOIN_QT_TRANSACTIONTABLEMODEL_H
void updateAmountColumnTitle()
Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table hea...
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Transaction status (TransactionRecord::Status)
QString formatTooltip(const TransactionRecord *rec) const
void updateTransaction(const QString &hash, int status, bool showTransaction)
QVariant txStatusDecoration(const TransactionRecord *wtx) const
int columnCount(const QModelIndex &parent) const override
Transaction data, hex-encoded.
int rowCount(const QModelIndex &parent) const override
TransactionTablePriv * priv
bool processingQueuedTransactions() const
UI model for a transaction.
QString formatTxType(const TransactionRecord *wtx) const
Whole transaction as plain text.
std::unique_ptr< interfaces::Handler > m_handler_transaction_changed
TransactionTableModel(const PlatformStyle *platformStyle, WalletModel *parent=nullptr)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Date and time this transaction was created.
UI model for the transaction table of a wallet.
QString lookupAddress(const std::string &address, bool tooltip) const
std::unique_ptr< interfaces::Handler > m_handler_show_progress
RoleIndex
Roles to get specific information from a transaction row.
void setProcessingQueuedTransactions(bool value)
QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:48
Label of address related to transaction.
QString formatTxStatus(const TransactionRecord *wtx) const
QVariant addressColor(const TransactionRecord *wtx) const
QVariant txAddressDecoration(const TransactionRecord *wtx) const
Formatted amount, without brackets when unconfirmed.
QVariant data(const QModelIndex &index, int role) const override
const PlatformStyle * platformStyle
QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true, BitcoinUnits::SeparatorStyle separators=BitcoinUnits::SeparatorStyle::STANDARD) const
QString formatTxDate(const TransactionRecord *wtx) const