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.
5 #ifndef BITCOIN_QT_TRANSACTIONTABLEMODEL_H
6 #define BITCOIN_QT_TRANSACTIONTABLEMODEL_H
8 #include "bitcoinunits.h"
10 #include <QAbstractTableModel>
11 #include <QStringList>
14 class TransactionRecord
;
15 class TransactionTablePriv
;
20 /** UI model for the transaction table of a wallet.
22 class TransactionTableModel
: public QAbstractTableModel
27 explicit TransactionTableModel(const PlatformStyle
*platformStyle
, CWallet
* wallet
, WalletModel
*parent
= 0);
28 ~TransactionTableModel();
39 /** Roles to get specific information from a transaction row.
40 These are independent of column.
43 /** Type of transaction */
44 TypeRole
= Qt::UserRole
,
45 /** Date and time this transaction was created */
47 /** Watch-only boolean */
49 /** Watch-only icon */
50 WatchonlyDecorationRole
,
51 /** Long description (HTML format) */
53 /** Address of transaction */
55 /** Label of address related to transaction */
57 /** Net amount of transaction */
59 /** Unique identifier */
61 /** Transaction hash */
63 /** Transaction data, hex-encoded */
65 /** Whole transaction as plain text */
67 /** Is transaction confirmed? */
69 /** Formatted amount, without brackets when unconfirmed */
71 /** Transaction status (TransactionRecord::Status) */
73 /** Unprocessed icon */
77 int rowCount(const QModelIndex
&parent
) const;
78 int columnCount(const QModelIndex
&parent
) const;
79 QVariant
data(const QModelIndex
&index
, int role
) const;
80 QVariant
headerData(int section
, Qt::Orientation orientation
, int role
) const;
81 QModelIndex
index(int row
, int column
, const QModelIndex
& parent
= QModelIndex()) const;
82 bool processingQueuedTransactions() { return fProcessingQueuedTransactions
; }
86 WalletModel
*walletModel
;
88 TransactionTablePriv
*priv
;
89 bool fProcessingQueuedTransactions
;
90 const PlatformStyle
*platformStyle
;
92 void subscribeToCoreSignals();
93 void unsubscribeFromCoreSignals();
95 QString
lookupAddress(const std::string
&address
, bool tooltip
) const;
96 QVariant
addressColor(const TransactionRecord
*wtx
) const;
97 QString
formatTxStatus(const TransactionRecord
*wtx
) const;
98 QString
formatTxDate(const TransactionRecord
*wtx
) const;
99 QString
formatTxType(const TransactionRecord
*wtx
) const;
100 QString
formatTxToAddress(const TransactionRecord
*wtx
, bool tooltip
) const;
101 QString
formatTxAmount(const TransactionRecord
*wtx
, bool showUnconfirmed
=true, BitcoinUnits::SeparatorStyle separators
=BitcoinUnits::separatorStandard
) const;
102 QString
formatTooltip(const TransactionRecord
*rec
) const;
103 QVariant
txStatusDecoration(const TransactionRecord
*wtx
) const;
104 QVariant
txWatchonlyDecoration(const TransactionRecord
*wtx
) const;
105 QVariant
txAddressDecoration(const TransactionRecord
*wtx
) const;
108 /* New transaction, or transaction changed status */
109 void updateTransaction(const QString
&hash
, int status
, bool showTransaction
);
110 void updateConfirmations();
111 void updateDisplayUnit();
112 /** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
113 void updateAmountColumnTitle();
114 /* Needed to update fProcessingQueuedTransactions through a QueuedConnection */
115 void setProcessingQueuedTransactions(bool value
) { fProcessingQueuedTransactions
= value
; }
117 friend class TransactionTablePriv
;
120 #endif // BITCOIN_QT_TRANSACTIONTABLEMODEL_H