Master Core  v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
transactiontablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2013 The Bitcoin developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef TRANSACTIONTABLEMODEL_H
6 #define TRANSACTIONTABLEMODEL_H
7 
8 #include <QAbstractTableModel>
9 #include <QStringList>
10 
11 class TransactionRecord;
13 class WalletModel;
14 
15 class CWallet;
16 
18 
22 {
23  Q_OBJECT
24 
25 public:
26  explicit TransactionTableModel(CWallet* wallet, WalletModel *parent = 0);
28 
29  enum ColumnIndex {
30  Status = 0,
31  Date = 1,
32  Type = 2,
33  ToAddress = 3,
34  Amount = 4
35  };
36 
40  enum RoleIndex {
42  TypeRole = Qt::UserRole,
63  };
64 
65  int rowCount(const QModelIndex &parent) const;
66  int columnCount(const QModelIndex &parent) const;
67  QVariant data(const QModelIndex &index, int role) const;
68  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
69  QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
70 
71 private:
74  QStringList columns;
76 
77  QString lookupAddress(const std::string &address, bool tooltip) const;
78  QVariant addressColor(const TransactionRecord *wtx) const;
79  QString formatTxStatus(const TransactionRecord *wtx) const;
80  QString formatTxDate(const TransactionRecord *wtx) const;
81  QString formatTxType(const TransactionRecord *wtx) const;
82  QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const;
83  QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true) const;
84  QString formatTooltip(const TransactionRecord *rec) const;
85  QVariant txStatusDecoration(const TransactionRecord *wtx) const;
86  QVariant txAddressDecoration(const TransactionRecord *wtx) const;
87 
88 public slots:
89  void updateTransaction(const QString &hash, int status);
90  void updateConfirmations();
91  void updateDisplayUnit();
92 
93  friend class TransactionTablePriv;
94 };
95 
97 {
98 public:
99  QString label;
100  QString address;
101  QString msc_value;
102  QString tmsc_value;
103 
105  msc_AddressTableEntry(const QString &label, const QString &address):
106  label(label), address(address) {}
107 };
108 
110 {
111 public:
113  {
114  return a.address < b.address;
115  }
116  bool operator()(const msc_AddressTableEntry &a, const QString &b) const
117  {
118  return a.address < b;
119  }
120  bool operator()(const QString &a, const msc_AddressTableEntry &b) const
121  {
122  return a < b.address;
123  }
124 };
125 
126 
128 {
129  Q_OBJECT
130 private:
133  uint* m_data;
134  QStringList columns;
136  QList<QString> ql_lab;
137  QList<QString> ql_addr;
138  QList<QString> ql_avl;
139  QList<QString> ql_res;
140 public:
141  friend class msc_AddressTablePriv;
143 
144  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
145  MatrixModel(CWallet* wallet, WalletModel *parent = 0);
146  MatrixModel(int numRows, int numColumns, uint* data, unsigned int propertyId);
147  ~MatrixModel();
148  int rowCount(const QModelIndex& parent = QModelIndex()) const;
149  int columnCount(const QModelIndex& parent = QModelIndex()) const;
150  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
151  void updateConfirmations(void);
152  void emitDataChanged(int idx);
153 
154  int fillin(unsigned int propertyId);
155 };
156 
157 #endif // TRANSACTIONTABLEMODEL_H
QVariant addressColor(const TransactionRecord *wtx) const
int columnCount(const QModelIndex &parent) const
QString tmsc_value
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
int fillin(unsigned int propertyId)
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
msc_AddressTableEntry(const QString &label, const QString &address)
TransactionTablePriv * priv
int rowCount(const QModelIndex &parent=QModelIndex()) const
QString formatTxStatus(const TransactionRecord *wtx) const
QString address
QList< QString > ql_avl
UI model for a transaction.
int columnCount(const QModelIndex &parent=QModelIndex()) const
QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true) const
bool operator()(const msc_AddressTableEntry &a, const QString &b) const
QVariant headerData(int section, Qt::Orientation orientation, int role) const
void emitDataChanged(int idx)
bool operator()(const msc_AddressTableEntry &a, const msc_AddressTableEntry &b) const
Date and time this transaction was created.
void updateConfirmations(void)
QList< QString > ql_lab
UI model for the transaction table of a wallet.
bool operator()(const QString &a, const msc_AddressTableEntry &b) const
QString formatTxType(const TransactionRecord *wtx) const
QString formatTooltip(const TransactionRecord *rec) const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
RoleIndex
Roles to get specific information from a transaction row.
QString label
msc_AddressTableEntry()
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:96
QString msc_value
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:100
Label of address related to transaction.
QList< QString > ql_res
msc_AddressTablePriv * priv
Formatted amount, without brackets when unconfirmed.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QList< QString > ql_addr
MatrixModel(CWallet *wallet, WalletModel *parent=0)
QString formatTxDate(const TransactionRecord *wtx) const