Bitcoin Core  22.99.0
P2P Digital Currency
transactiontablemodel.h
Go to the documentation of this file.
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_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 override;
80  int columnCount(const QModelIndex &parent) const override;
81  QVariant data(const QModelIndex &index, int role) const override;
82  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
83  QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const override;
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 
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::SeparatorStyle::STANDARD) 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();
117  /* Needed to update fProcessingQueuedTransactions through a QueuedConnection */
119 
120  friend class TransactionTablePriv;
121 };
122 
123 #endif // BITCOIN_QT_TRANSACTIONTABLEMODEL_H
interfaces
Definition: dummywallet.cpp:11
TransactionTableModel::txAddressDecoration
QVariant txAddressDecoration(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:398
TransactionTableModel::formatTxStatus
QString formatTxStatus(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:313
TransactionTableModel::TxHexRole
@ TxHexRole
Transaction data, hex-encoded.
Definition: transactiontablemodel.h:66
TransactionTableModel::updateConfirmations
void updateConfirmations()
Definition: transactiontablemodel.cpp:287
TransactionTableModel::txStatusDecoration
QVariant txStatusDecoration(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:474
TransactionTableModel::Date
@ Date
Definition: transactiontablemodel.h:37
WalletModel
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:51
TransactionTableModel::AddressRole
@ AddressRole
Address of transaction.
Definition: transactiontablemodel.h:58
TransactionTableModel::fProcessingQueuedTransactions
bool fProcessingQueuedTransactions
Definition: transactiontablemodel.h:92
TransactionTableModel::formatTxDate
QString formatTxDate(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:351
TransactionTableModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Definition: transactiontablemodel.cpp:669
TransactionTableModel::TxPlainTextRole
@ TxPlainTextRole
Whole transaction as plain text.
Definition: transactiontablemodel.h:68
TransactionTableModel::WatchonlyRole
@ WatchonlyRole
Watch-only boolean.
Definition: transactiontablemodel.h:52
TransactionTableModel::txWatchonlyDecoration
QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:510
TransactionRecord
UI model for a transaction.
Definition: transactionrecord.h:72
TransactionTableModel::ColumnIndex
ColumnIndex
Definition: transactiontablemodel.h:34
TransactionTableModel::updateDisplayUnit
void updateDisplayUnit()
Definition: transactiontablemodel.cpp:713
TransactionTableModel::updateTransaction
void updateTransaction(const QString &hash, int status, bool showTransaction)
Definition: transactiontablemodel.cpp:279
TransactionTableModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition: transactiontablemodel.cpp:702
TransactionTableModel::RawDecorationRole
@ RawDecorationRole
Unprocessed icon.
Definition: transactiontablemodel.h:76
TransactionTableModel::AmountRole
@ AmountRole
Net amount of transaction.
Definition: transactiontablemodel.h:62
TransactionTableModel::subscribeToCoreSignals
void subscribeToCoreSignals()
Definition: transactiontablemodel.cpp:756
TransactionTableModel::m_handler_show_progress
std::unique_ptr< interfaces::Handler > m_handler_show_progress
Definition: transactiontablemodel.h:89
TransactionTableModel::unsubscribeFromCoreSignals
void unsubscribeFromCoreSignals()
Definition: transactiontablemodel.cpp:766
TransactionTableModel::ToAddress
@ ToAddress
Definition: transactiontablemodel.h:39
TransactionTableModel::formatTxToAddress
QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
Definition: transactiontablemodel.cpp:415
TransactionTableModel::RoleIndex
RoleIndex
Roles to get specific information from a transaction row.
Definition: transactiontablemodel.h:46
TransactionTableModel::rowCount
int rowCount(const QModelIndex &parent) const override
Definition: transactiontablemodel.cpp:297
TransactionTableModel::priv
TransactionTablePriv * priv
Definition: transactiontablemodel.h:91
TransactionTableModel::columnCount
int columnCount(const QModelIndex &parent) const override
Definition: transactiontablemodel.cpp:305
BitcoinUnits::SeparatorStyle
SeparatorStyle
Definition: bitcoinunits.h:49
TransactionTableModel::StatusRole
@ StatusRole
Transaction status (TransactionRecord::Status)
Definition: transactiontablemodel.h:74
TransactionTableModel::Amount
@ Amount
Definition: transactiontablemodel.h:40
TransactionTableModel::columns
QStringList columns
Definition: transactiontablemodel.h:90
TransactionTableModel::m_handler_transaction_changed
std::unique_ptr< interfaces::Handler > m_handler_transaction_changed
Definition: transactiontablemodel.h:88
TransactionTableModel::processingQueuedTransactions
bool processingQueuedTransactions() const
Definition: transactiontablemodel.h:84
TransactionTableModel::FormattedAmountRole
@ FormattedAmountRole
Formatted amount, without brackets when unconfirmed.
Definition: transactiontablemodel.h:72
TransactionTableModel::LongDescriptionRole
@ LongDescriptionRole
Long description (HTML format)
Definition: transactiontablemodel.h:56
TransactionTableModel::addressColor
QVariant addressColor(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:440
TransactionTableModel::TransactionTableModel
TransactionTableModel(const PlatformStyle *platformStyle, WalletModel *parent=nullptr)
Definition: transactiontablemodel.cpp:251
TransactionTableModel
UI model for the transaction table of a wallet.
Definition: transactiontablemodel.h:26
TransactionTableModel::formatTxType
QString formatTxType(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:378
TransactionTablePriv
Definition: transactiontablemodel.cpp:85
TransactionTableModel::~TransactionTableModel
~TransactionTableModel()
Definition: transactiontablemodel.cpp:266
TransactionTableModel::WatchonlyDecorationRole
@ WatchonlyDecorationRole
Watch-only icon.
Definition: transactiontablemodel.h:54
TransactionTableModel::Type
@ Type
Definition: transactiontablemodel.h:38
TransactionTableModel::lookupAddress
QString lookupAddress(const std::string &address, bool tooltip) const
Definition: transactiontablemodel.cpp:363
TransactionTableModel::TxHashRole
@ TxHashRole
Transaction hash.
Definition: transactiontablemodel.h:64
bitcoinunits.h
TransactionTableModel::Status
@ Status
Definition: transactiontablemodel.h:35
TransactionTableModel::formatTxAmount
QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true, BitcoinUnits::SeparatorStyle separators=BitcoinUnits::SeparatorStyle::STANDARD) const
Definition: transactiontablemodel.cpp:461
TransactionTableModel::platformStyle
const PlatformStyle * platformStyle
Definition: transactiontablemodel.h:93
TransactionTableModel::DateRole
@ DateRole
Date and time this transaction was created.
Definition: transactiontablemodel.h:50
TransactionTableModel::TypeRole
@ TypeRole
Type of transaction.
Definition: transactiontablemodel.h:48
PlatformStyle
Definition: platformstyle.h:13
TransactionTableModel::updateAmountColumnTitle
void updateAmountColumnTitle()
Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table hea...
Definition: transactiontablemodel.cpp:273
TransactionTableModel::setProcessingQueuedTransactions
void setProcessingQueuedTransactions(bool value)
Definition: transactiontablemodel.h:118
TransactionTableModel::LabelRole
@ LabelRole
Label of address related to transaction.
Definition: transactiontablemodel.h:60
TransactionTableModel::Watchonly
@ Watchonly
Definition: transactiontablemodel.h:36
TransactionTableModel::formatTooltip
QString formatTooltip(const TransactionRecord *rec) const
Definition: transactiontablemodel.cpp:518
TransactionTableModel::walletModel
WalletModel * walletModel
Definition: transactiontablemodel.h:87
BitcoinUnits::SeparatorStyle::STANDARD
@ STANDARD
TransactionTableModel::ConfirmedRole
@ ConfirmedRole
Is transaction confirmed?
Definition: transactiontablemodel.h:70
TransactionTableModel::data
QVariant data(const QModelIndex &index, int role) const override
Definition: transactiontablemodel.cpp:529