bitcoin/src/qt/transactiontablemodel.h

99 lines
3.2 KiB
C
Raw Normal View History

// Copyright (c) 2011-2013 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
2011-05-08 16:23:31 -04:00
#ifndef TRANSACTIONTABLEMODEL_H
#define TRANSACTIONTABLEMODEL_H
2011-05-08 10:30:10 -04:00
2014-07-25 11:43:41 -04:00
#include "bitcoinunits.h"
2011-05-08 10:30:10 -04:00
#include <QAbstractTableModel>
#include <QStringList>
2011-05-27 02:20:23 -04:00
class TransactionRecord;
class TransactionTablePriv;
class WalletModel;
2011-05-27 02:20:23 -04:00
class CWallet;
2011-11-13 09:19:52 -03:00
/** UI model for the transaction table of a wallet.
*/
2011-05-08 10:30:10 -04:00
class TransactionTableModel : public QAbstractTableModel
{
Q_OBJECT
2011-05-08 10:30:10 -04:00
public:
explicit TransactionTableModel(CWallet* wallet, WalletModel *parent = 0);
2011-05-27 02:20:23 -04:00
~TransactionTableModel();
2011-05-08 16:23:31 -04:00
2011-11-13 09:19:52 -03:00
enum ColumnIndex {
2011-05-08 16:23:31 -04:00
Status = 0,
Date = 1,
Type = 2,
ToAddress = 3,
Amount = 4
2011-11-13 09:19:52 -03:00
};
2011-05-08 10:30:10 -04:00
2011-11-13 09:19:52 -03:00
/** Roles to get specific information from a transaction row.
These are independent of column.
*/
enum RoleIndex {
/** Type of transaction */
TypeRole = Qt::UserRole,
2011-11-13 09:19:52 -03:00
/** Date and time this transaction was created */
DateRole,
2011-11-13 09:19:52 -03:00
/** Long description (HTML format) */
LongDescriptionRole,
2011-11-13 09:19:52 -03:00
/** Address of transaction */
AddressRole,
2011-11-13 09:19:52 -03:00
/** Label of address related to transaction */
LabelRole,
2011-11-13 09:19:52 -03:00
/** Net amount of transaction */
AmountRole,
2011-11-13 09:19:52 -03:00
/** Unique identifier */
TxIDRole,
/** Transaction hash */
TxHashRole,
2011-11-13 09:19:52 -03:00
/** Is transaction confirmed? */
ConfirmedRole,
2011-11-13 09:19:52 -03:00
/** Formatted amount, without brackets when unconfirmed */
FormattedAmountRole,
/** Transaction status (TransactionRecord::Status) */
StatusRole
2011-11-13 09:19:52 -03:00
};
2011-05-08 10:30:10 -04: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;
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
2011-05-08 10:30:10 -04:00
private:
CWallet* wallet;
WalletModel *walletModel;
2011-05-08 10:30:10 -04:00
QStringList columns;
2011-06-01 09:33:33 -04:00
TransactionTablePriv *priv;
2011-05-27 02:20:23 -04:00
QString lookupAddress(const std::string &address, bool tooltip) const;
QVariant addressColor(const TransactionRecord *wtx) const;
2011-08-05 09:35:52 -04:00
QString formatTxStatus(const TransactionRecord *wtx) const;
QString formatTxDate(const TransactionRecord *wtx) const;
2011-07-31 11:05:34 -04:00
QString formatTxType(const TransactionRecord *wtx) const;
QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const;
QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true, BitcoinUnits::SeparatorStyle separators=BitcoinUnits::separatorStandard) const;
2011-08-05 09:35:52 -04:00
QString formatTooltip(const TransactionRecord *rec) const;
QVariant txStatusDecoration(const TransactionRecord *wtx) const;
2011-07-31 11:05:34 -04:00
QVariant txAddressDecoration(const TransactionRecord *wtx) const;
2011-05-28 14:32:19 -04:00
public slots:
void updateTransaction(const QString &hash, int status);
void updateConfirmations();
void updateDisplayUnit();
/** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
void updateAmountColumnTitle();
2011-06-03 14:48:03 -04:00
friend class TransactionTablePriv;
2011-05-08 10:30:10 -04:00
};
#endif // TRANSACTIONTABLEMODEL_H