Bitcoin ABC  0.24.7
P2P Digital Currency
transactiontablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2016 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 
27 class TransactionTableModel : public QAbstractTableModel {
28  Q_OBJECT
29 
30 public:
32  WalletModel *parent = nullptr);
34 
35  enum ColumnIndex {
36  Status = 0,
37  Watchonly = 1,
38  Date = 2,
39  Type = 3,
40  ToAddress = 4,
41  Amount = 5
42  };
43 
48  enum RoleIndex {
50  TypeRole = Qt::UserRole,
81  };
82 
83  int rowCount(const QModelIndex &parent) const override;
84  int columnCount(const QModelIndex &parent) const override;
85  QVariant data(const QModelIndex &index, int role) const override;
86  QVariant headerData(int section, Qt::Orientation orientation,
87  int role) const override;
88  QModelIndex index(int row, int column,
89  const QModelIndex &parent = QModelIndex()) const override;
92  }
93 
94 private:
96  std::unique_ptr<interfaces::Handler> m_handler_transaction_changed;
97  std::unique_ptr<interfaces::Handler> m_handler_show_progress;
98  QStringList columns;
102 
103  void subscribeToCoreSignals();
105 
106  QString lookupAddress(const std::string &address, bool tooltip) const;
107  QVariant addressColor(const TransactionRecord *wtx) const;
108  QString formatTxStatus(const TransactionRecord *wtx) const;
109  QString formatTxDate(const TransactionRecord *wtx) const;
110  QString formatTxType(const TransactionRecord *wtx) const;
111  QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const;
112  QString formatTxAmount(const TransactionRecord *wtx,
113  bool showUnconfirmed = true,
114  BitcoinUnits::SeparatorStyle separators =
116  QString formatTooltip(const TransactionRecord *rec) const;
117  QVariant txStatusDecoration(const TransactionRecord *wtx) const;
118  QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const;
119  QVariant txAddressDecoration(const TransactionRecord *wtx) const;
120 
121 public Q_SLOTS:
125  void updateTransaction(const QString &hash, int status,
126  bool showTransaction);
127  void updateConfirmations();
128  void updateDisplayUnit();
140  }
141 
142  friend class TransactionTablePriv;
143 };
144 
145 #endif // BITCOIN_QT_TRANSACTIONTABLEMODEL_H
interfaces
Definition: dummywallet.cpp:12
TransactionTableModel::txAddressDecoration
QVariant txAddressDecoration(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:356
TransactionTableModel::formatTxStatus
QString formatTxStatus(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:267
TransactionTableModel::TxHexRole
@ TxHexRole
Transaction data, hex-encoded.
Definition: transactiontablemodel.h:70
TransactionTableModel::updateConfirmations
void updateConfirmations()
Definition: transactiontablemodel.cpp:247
TransactionTableModel::txStatusDecoration
QVariant txStatusDecoration(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:435
TransactionTableModel::Date
@ Date
Definition: transactiontablemodel.h:38
WalletModel
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:47
TransactionTableModel::AddressRole
@ AddressRole
Address of transaction.
Definition: transactiontablemodel.h:60
TransactionTableModel::fProcessingQueuedTransactions
bool fProcessingQueuedTransactions
Definition: transactiontablemodel.h:100
TransactionTableModel::formatTxDate
QString formatTxDate(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:310
TransactionTableModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Definition: transactiontablemodel.cpp:639
TransactionTableModel::TxPlainTextRole
@ TxPlainTextRole
Whole transaction as plain text.
Definition: transactiontablemodel.h:72
TransactionTableModel::WatchonlyRole
@ WatchonlyRole
Watch-only boolean.
Definition: transactiontablemodel.h:54
TransactionTableModel::txWatchonlyDecoration
QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:473
TransactionRecord
UI model for a transaction.
Definition: transactionrecord.h:91
TransactionTableModel::ColumnIndex
ColumnIndex
Definition: transactiontablemodel.h:35
TransactionTableModel::TxIDRole
@ TxIDRole
Unique identifier.
Definition: transactiontablemodel.h:66
TransactionTableModel::updateDisplayUnit
void updateDisplayUnit()
Definition: transactiontablemodel.cpp:682
TransactionTableModel::updateTransaction
void updateTransaction(const QString &hash, int status, bool showTransaction)
New transaction, or transaction changed status.
Definition: transactiontablemodel.cpp:239
TransactionTableModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition: transactiontablemodel.cpp:671
TransactionTableModel::RawDecorationRole
@ RawDecorationRole
Unprocessed icon.
Definition: transactiontablemodel.h:80
TransactionTableModel::AmountRole
@ AmountRole
Net amount of transaction.
Definition: transactiontablemodel.h:64
TransactionTableModel::subscribeToCoreSignals
void subscribeToCoreSignals()
Definition: transactiontablemodel.cpp:764
TransactionTableModel::m_handler_show_progress
std::unique_ptr< interfaces::Handler > m_handler_show_progress
Definition: transactiontablemodel.h:97
TransactionTableModel::unsubscribeFromCoreSignals
void unsubscribeFromCoreSignals()
Definition: transactiontablemodel.cpp:775
TransactionTableModel::ToAddress
@ ToAddress
Definition: transactiontablemodel.h:40
TransactionTableModel::formatTxToAddress
QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
Definition: transactiontablemodel.cpp:371
TransactionTableModel::RoleIndex
RoleIndex
Roles to get specific information from a transaction row.
Definition: transactiontablemodel.h:48
TransactionTableModel::rowCount
int rowCount(const QModelIndex &parent) const override
Definition: transactiontablemodel.cpp:256
TransactionTableModel::priv
TransactionTablePriv * priv
Definition: transactiontablemodel.h:99
TransactionTableModel::columnCount
int columnCount(const QModelIndex &parent) const override
Definition: transactiontablemodel.cpp:261
BitcoinUnits::SeparatorStyle
SeparatorStyle
Definition: bitcoinunits.h:44
TransactionTableModel::StatusRole
@ StatusRole
Transaction status (TransactionRecord::Status)
Definition: transactiontablemodel.h:78
TransactionTableModel::columns
QStringList columns
Definition: transactiontablemodel.h:98
TransactionTableModel::m_handler_transaction_changed
std::unique_ptr< interfaces::Handler > m_handler_transaction_changed
Definition: transactiontablemodel.h:96
Amount
Definition: amount.h:19
TransactionTableModel::processingQueuedTransactions
bool processingQueuedTransactions() const
Definition: transactiontablemodel.h:90
TransactionTableModel::FormattedAmountRole
@ FormattedAmountRole
Formatted amount, without brackets when unconfirmed.
Definition: transactiontablemodel.h:76
TransactionTableModel::LongDescriptionRole
@ LongDescriptionRole
Long description (HTML format)
Definition: transactiontablemodel.h:58
TransactionTableModel::addressColor
QVariant addressColor(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:399
TransactionTableModel::TransactionTableModel
TransactionTableModel(const PlatformStyle *platformStyle, WalletModel *parent=nullptr)
Definition: transactiontablemodel.cpp:210
TransactionTableModel
UI model for the transaction table of a wallet.
Definition: transactiontablemodel.h:27
TransactionTableModel::formatTxType
QString formatTxType(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:337
TransactionTablePriv
Definition: transactiontablemodel.cpp:53
TransactionTableModel::~TransactionTableModel
~TransactionTableModel()
Definition: transactiontablemodel.cpp:226
TransactionTableModel::WatchonlyDecorationRole
@ WatchonlyDecorationRole
Watch-only icon.
Definition: transactiontablemodel.h:56
TransactionTableModel::Type
@ Type
Definition: transactiontablemodel.h:39
TransactionTableModel::lookupAddress
QString lookupAddress(const std::string &address, bool tooltip) const
Look up address in address book, if found return label (address) otherwise just return (address)
Definition: transactiontablemodel.cpp:321
TransactionTableModel::TxHashRole
@ TxHashRole
Transaction hash.
Definition: transactiontablemodel.h:68
bitcoinunits.h
TransactionTableModel::Status
@ Status
Definition: transactiontablemodel.h:36
TransactionTableModel::formatTxAmount
QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true, BitcoinUnits::SeparatorStyle separators=BitcoinUnits::SeparatorStyle::STANDARD) const
Definition: transactiontablemodel.cpp:420
TransactionTableModel::platformStyle
const PlatformStyle * platformStyle
Definition: transactiontablemodel.h:101
TransactionTableModel::DateRole
@ DateRole
Date and time this transaction was created.
Definition: transactiontablemodel.h:52
TransactionTableModel::TypeRole
@ TypeRole
Type of transaction.
Definition: transactiontablemodel.h:50
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:233
TransactionTableModel::setProcessingQueuedTransactions
void setProcessingQueuedTransactions(bool value)
Needed to update fProcessingQueuedTransactions through a QueuedConnection.
Definition: transactiontablemodel.h:138
TransactionTableModel::LabelRole
@ LabelRole
Label of address related to transaction.
Definition: transactiontablemodel.h:62
TransactionTableModel::Watchonly
@ Watchonly
Definition: transactiontablemodel.h:37
TransactionTableModel::formatTooltip
QString formatTooltip(const TransactionRecord *rec) const
Definition: transactiontablemodel.cpp:483
TransactionTableModel::walletModel
WalletModel * walletModel
Definition: transactiontablemodel.h:95
BitcoinUnits::SeparatorStyle::STANDARD
@ STANDARD
TransactionTableModel::ConfirmedRole
@ ConfirmedRole
Is transaction confirmed?
Definition: transactiontablemodel.h:74
TransactionTableModel::data
QVariant data(const QModelIndex &index, int role) const override
Definition: transactiontablemodel.cpp:494