Update CMakeLists.txt - play with openssl
[novacoin.git] / src / qt / transactiontablemodel.h
1 #ifndef TRANSACTIONTABLEMODEL_H
2 #define TRANSACTIONTABLEMODEL_H
3
4 #include <QAbstractTableModel>
5 #include <QStringList>
6
7 class CWallet;
8 class TransactionTablePriv;
9 class TransactionRecord;
10 class WalletModel;
11
12 /** UI model for the transaction table of a wallet.
13  */
14 class TransactionTableModel : public QAbstractTableModel
15 {
16     Q_OBJECT
17 public:
18     explicit TransactionTableModel(CWallet* wallet, WalletModel *parent = 0);
19     ~TransactionTableModel();
20
21     enum ColumnIndex {
22         Status = 0,
23         Date = 1,
24         Type = 2,
25         ToAddress = 3,
26         Amount = 4
27     };
28
29     /** Roles to get specific information from a transaction row.
30         These are independent of column.
31     */
32     enum RoleIndex {
33         /** Type of transaction */
34         TypeRole = Qt::UserRole,
35         /** Date and time this transaction was created */
36         DateRole,
37         /** Long description (HTML format) */
38         LongDescriptionRole,
39         /** Address of transaction */
40         AddressRole,
41         /** Label of address related to transaction */
42         LabelRole,
43         /** Net amount of transaction */
44         AmountRole,
45         /** Unique identifier */
46         TxIDRole,
47         /** Transaction hash */
48         TxHashRole,
49         /** Is transaction confirmed? */
50         ConfirmedRole,
51         /** Formatted amount, without brackets when unconfirmed */
52         FormattedAmountRole
53     };
54
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;
60     void refresh();
61 private:
62     CWallet* wallet;
63     WalletModel *walletModel;
64     QStringList columns;
65     TransactionTablePriv *priv;
66     int cachedNumBlocks;
67
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;
78
79 public slots:
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();
85
86     friend class TransactionTablePriv;
87 };
88
89 #endif
90