1 #ifndef TRANSACTIONTABLEMODEL_H
2 #define TRANSACTIONTABLEMODEL_H
4 #include <QAbstractTableModel>
8 class TransactionTablePriv;
9 class TransactionRecord;
12 /** UI model for the transaction table of a wallet.
14 class TransactionTableModel : public QAbstractTableModel
18 explicit TransactionTableModel(CWallet* wallet, WalletModel *parent = 0);
19 ~TransactionTableModel();
29 /** Roles to get specific information from a transaction row.
30 These are independent of column.
33 /** Type of transaction */
34 TypeRole = Qt::UserRole,
35 /** Date and time this transaction was created */
37 /** Long description (HTML format) */
39 /** Address of transaction */
41 /** Label of address related to transaction */
43 /** Net amount of transaction */
45 /** Unique identifier */
47 /** Transaction hash */
49 /** Is transaction confirmed? */
51 /** Formatted amount, without brackets when unconfirmed */
55 int rowCount(const QModelIndex &parent) const;
56 int columnCount(const QModelIndex &parent) const;
57 QVariant data(const QModelIndex &index, int role) const;
58 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
59 QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
63 WalletModel *walletModel;
65 TransactionTablePriv *priv;
68 QString lookupAddress(const std::string &address, bool tooltip) const;
69 QVariant addressColor(const TransactionRecord *wtx) const;
70 QString formatTxStatus(const TransactionRecord *wtx) const;
71 QString formatTxDate(const TransactionRecord *wtx) const;
72 QString formatTxType(const TransactionRecord *wtx) const;
73 QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const;
74 QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true) const;
75 QString formatTooltip(const TransactionRecord *rec) const;
76 QVariant txStatusDecoration(const TransactionRecord *wtx) const;
77 QVariant txAddressDecoration(const TransactionRecord *wtx) const;
80 void updateTransaction(const QString &hash, int status);
81 void updateConfirmations();
82 void updateDisplayUnit();
83 /** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
84 void updateAmountColumnTitle();
86 friend class TransactionTablePriv;