2011-05-08 22:23:31 +02:00
|
|
|
#ifndef TRANSACTIONTABLEMODEL_H
|
|
|
|
#define TRANSACTIONTABLEMODEL_H
|
2011-05-08 16:30:10 +02:00
|
|
|
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
#include <QStringList>
|
|
|
|
|
2011-06-26 19:23:24 +02:00
|
|
|
class CWallet;
|
2011-06-01 15:33:33 +02:00
|
|
|
class TransactionTablePriv;
|
2011-05-27 08:20:23 +02:00
|
|
|
class TransactionRecord;
|
2011-07-02 13:45:59 +02:00
|
|
|
class WalletModel;
|
2011-05-27 08:20:23 +02:00
|
|
|
|
2011-05-08 16:30:10 +02:00
|
|
|
class TransactionTableModel : public QAbstractTableModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2011-07-02 13:45:59 +02:00
|
|
|
explicit TransactionTableModel(CWallet* wallet, WalletModel *parent = 0);
|
2011-05-27 08:20:23 +02:00
|
|
|
~TransactionTableModel();
|
2011-05-08 22:23:31 +02:00
|
|
|
|
|
|
|
enum {
|
|
|
|
Status = 0,
|
|
|
|
Date = 1,
|
2011-06-26 22:47:02 +02:00
|
|
|
Type = 2,
|
|
|
|
ToAddress = 3,
|
|
|
|
Amount = 4
|
2011-05-08 22:23:31 +02:00
|
|
|
} ColumnIndex;
|
2011-05-08 16:30:10 +02:00
|
|
|
|
2011-06-28 21:41:56 +02:00
|
|
|
// Roles to get specific information from a transaction row
|
2011-07-07 14:27:16 +02:00
|
|
|
// These are independent of column
|
2011-05-22 19:32:37 +02:00
|
|
|
enum {
|
2011-06-28 21:41:56 +02:00
|
|
|
// Type of transaction
|
2011-06-10 15:05:51 +02:00
|
|
|
TypeRole = Qt::UserRole,
|
2011-06-28 21:41:56 +02:00
|
|
|
// Date and time this transaction was created
|
|
|
|
DateRole,
|
|
|
|
// Long description (HTML format)
|
|
|
|
LongDescriptionRole,
|
|
|
|
// Address of transaction
|
|
|
|
AddressRole,
|
|
|
|
// Label of address related to transaction
|
|
|
|
LabelRole,
|
2011-07-07 14:27:16 +02:00
|
|
|
// Absolute net amount of transaction, for filtering
|
|
|
|
AbsoluteAmountRole,
|
|
|
|
// Unique identifier
|
|
|
|
TxIDRole,
|
|
|
|
// Is transaction confirmed?
|
|
|
|
ConfirmedRole,
|
|
|
|
// Formatted amount, without brackets when unconfirmed
|
|
|
|
FormattedAmountRole
|
2011-05-22 19:32:37 +02:00
|
|
|
} RoleIndex;
|
|
|
|
|
2011-05-08 16:30:10 +02:00
|
|
|
int rowCount(const QModelIndex &parent) const;
|
|
|
|
int columnCount(const QModelIndex &parent) const;
|
|
|
|
QVariant data(const QModelIndex &index, int role) const;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
|
|
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
2011-06-10 20:49:50 +02:00
|
|
|
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
|
2011-05-08 16:30:10 +02:00
|
|
|
private:
|
2011-06-26 19:23:24 +02:00
|
|
|
CWallet* wallet;
|
2011-07-02 13:45:59 +02:00
|
|
|
WalletModel *walletModel;
|
2011-05-08 16:30:10 +02:00
|
|
|
QStringList columns;
|
2011-06-01 15:33:33 +02:00
|
|
|
TransactionTablePriv *priv;
|
2011-05-27 08:20:23 +02:00
|
|
|
|
2011-06-28 21:41:56 +02:00
|
|
|
QString lookupAddress(const std::string &address) const;
|
2011-05-27 08:20:23 +02:00
|
|
|
QVariant formatTxStatus(const TransactionRecord *wtx) const;
|
|
|
|
QVariant formatTxDate(const TransactionRecord *wtx) const;
|
2011-06-26 22:47:02 +02:00
|
|
|
QVariant formatTxType(const TransactionRecord *wtx) const;
|
|
|
|
QVariant formatTxToAddress(const TransactionRecord *wtx) const;
|
2011-07-07 14:27:16 +02:00
|
|
|
QVariant formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true) const;
|
2011-06-13 09:05:48 +02:00
|
|
|
QVariant formatTxDecoration(const TransactionRecord *wtx) const;
|
2011-05-28 20:32:19 +02:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void update();
|
2011-06-03 20:48:03 +02:00
|
|
|
|
|
|
|
friend class TransactionTablePriv;
|
2011-05-08 16:30:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|