Anoncoin  0.9.4
P2P Digital Currency
transactiontablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2013 The Bitcoin developers
2 // Copyright (c) 2013-2014 The Anoncoin Core developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef TRANSACTIONTABLEMODEL_H
7 #define TRANSACTIONTABLEMODEL_H
8 
9 #include <QAbstractTableModel>
10 #include <QStringList>
11 
12 class TransactionRecord;
14 class WalletModel;
15 
16 class CWallet;
17 
20 class TransactionTableModel : public QAbstractTableModel
21 {
22  Q_OBJECT
23 
24 public:
25  explicit TransactionTableModel(CWallet* wallet, WalletModel *parent = 0);
27 
28  enum ColumnIndex {
29  Status = 0,
30  Watchonly = 1,
31  Date = 2,
32  Type = 3,
33  ToAddress = 4,
34  Amount = 5
35  };
36 
40  enum RoleIndex {
42  TypeRole = Qt::UserRole,
67  };
68 
69  int rowCount(const QModelIndex &parent) const;
70  int columnCount(const QModelIndex &parent) const;
71  QVariant data(const QModelIndex &index, int role) const;
72  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
73  QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
74 
75 private:
78  QStringList columns;
80 
81  QString lookupAddress(const std::string &address, bool tooltip) const;
82  QVariant addressColor(const TransactionRecord *wtx) const;
83  QString formatTxStatus(const TransactionRecord *wtx) const;
84  QString formatTxDate(const TransactionRecord *wtx) const;
85  QString formatTxType(const TransactionRecord *wtx) const;
86  QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const;
87  QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true) const;
88  QString formatTooltip(const TransactionRecord *rec) const;
89  QVariant txStatusDecoration(const TransactionRecord *wtx) const;
90  QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const;
91  QVariant txAddressDecoration(const TransactionRecord *wtx) const;
92 
93 public slots:
94  void updateTransaction(const QString &hash, int status);
95  void updateConfirmations();
96  void updateDisplayUnit();
99 
100  friend class TransactionTablePriv;
101 };
102 
103 #endif // TRANSACTIONTABLEMODEL_H
QVariant addressColor(const TransactionRecord *wtx) const
void updateAmountColumnTitle()
Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table hea...
int columnCount(const QModelIndex &parent) const
QVariant data(const QModelIndex &index, int role) const
QVariant txStatusDecoration(const TransactionRecord *wtx) const
TransactionTableModel(CWallet *wallet, WalletModel *parent=0)
Transaction status (TransactionRecord::Status)
QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
QVariant txAddressDecoration(const TransactionRecord *wtx) const
QString lookupAddress(const std::string &address, bool tooltip) const
void updateTransaction(const QString &hash, int status)
QVariant headerData(int section, Qt::Orientation orientation, int role) const
TransactionTablePriv * priv
QString formatTxStatus(const TransactionRecord *wtx) const
UI model for a transaction.
QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true) const
Date and time this transaction was created.
UI model for the transaction table of a wallet.
QString formatTxType(const TransactionRecord *wtx) const
QString formatTooltip(const TransactionRecord *rec) const
QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const
RoleIndex
Roles to get specific information from a transaction row.
Interface to Anoncoin wallet from Qt view code.
Definition: walletmodel.h:97
int rowCount(const QModelIndex &parent) const
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:101
Label of address related to transaction.
Formatted amount, without brackets when unconfirmed.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QString formatTxDate(const TransactionRecord *wtx) const