Remove includes in .cpp files for things the corresponding .h file already included
[bitcoinplatinum.git] / src / qt / transactiontablemodel.h
bloba7697071638dae7bef8d627a58ed2433f3cb6231
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 <qt/bitcoinunits.h>
10 #include <QAbstractTableModel>
11 #include <QStringList>
13 class PlatformStyle;
14 class TransactionRecord;
15 class TransactionTablePriv;
16 class WalletModel;
18 class CWallet;
20 /** UI model for the transaction table of a wallet.
22 class TransactionTableModel : public QAbstractTableModel
24 Q_OBJECT
26 public:
27 explicit TransactionTableModel(const PlatformStyle *platformStyle, CWallet* wallet, WalletModel *parent = 0);
28 ~TransactionTableModel();
30 enum ColumnIndex {
31 Status = 0,
32 Watchonly = 1,
33 Date = 2,
34 Type = 3,
35 ToAddress = 4,
36 Amount = 5
39 /** Roles to get specific information from a transaction row.
40 These are independent of column.
42 enum RoleIndex {
43 /** Type of transaction */
44 TypeRole = Qt::UserRole,
45 /** Date and time this transaction was created */
46 DateRole,
47 /** Watch-only boolean */
48 WatchonlyRole,
49 /** Watch-only icon */
50 WatchonlyDecorationRole,
51 /** Long description (HTML format) */
52 LongDescriptionRole,
53 /** Address of transaction */
54 AddressRole,
55 /** Label of address related to transaction */
56 LabelRole,
57 /** Net amount of transaction */
58 AmountRole,
59 /** Unique identifier */
60 TxIDRole,
61 /** Transaction hash */
62 TxHashRole,
63 /** Transaction data, hex-encoded */
64 TxHexRole,
65 /** Whole transaction as plain text */
66 TxPlainTextRole,
67 /** Is transaction confirmed? */
68 ConfirmedRole,
69 /** Formatted amount, without brackets when unconfirmed */
70 FormattedAmountRole,
71 /** Transaction status (TransactionRecord::Status) */
72 StatusRole,
73 /** Unprocessed icon */
74 RawDecorationRole,
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() const { return fProcessingQueuedTransactions; }
84 private:
85 CWallet* wallet;
86 WalletModel *walletModel;
87 QStringList columns;
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;
107 public Q_SLOTS:
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