lbrycrd/src/qt/transactiontablemodel.h

121 lines
4.2 KiB
C
Raw Normal View History

// Copyright (c) 2011-2017 The Bitcoin Core developers
2014-12-13 05:09:33 +01:00
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
2014-11-03 16:16:40 +01:00
#ifndef BITCOIN_QT_TRANSACTIONTABLEMODEL_H
#define BITCOIN_QT_TRANSACTIONTABLEMODEL_H
2011-05-08 16:30:10 +02:00
#include <qt/bitcoinunits.h>
2014-07-25 17:43:41 +02:00
2011-05-08 16:30:10 +02:00
#include <QAbstractTableModel>
#include <QStringList>
class PlatformStyle;
2011-05-27 08:20:23 +02:00
class TransactionRecord;
class TransactionTablePriv;
class WalletModel;
2011-05-27 08:20:23 +02:00
class CWallet;
2011-11-13 13:19:52 +01:00
/** UI model for the transaction table of a wallet.
*/
2011-05-08 16:30:10 +02:00
class TransactionTableModel : public QAbstractTableModel
{
Q_OBJECT
2011-05-08 16:30:10 +02:00
public:
explicit TransactionTableModel(const PlatformStyle *platformStyle, CWallet* wallet, WalletModel *parent = 0);
2011-05-27 08:20:23 +02:00
~TransactionTableModel();
2011-05-08 22:23:31 +02:00
2011-11-13 13:19:52 +01:00
enum ColumnIndex {
2011-05-08 22:23:31 +02:00
Status = 0,
Watchonly = 1,
Date = 2,
Type = 3,
ToAddress = 4,
Amount = 5
2011-11-13 13:19:52 +01:00
};
2011-05-08 16:30:10 +02:00
2011-11-13 13:19:52 +01: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 13:19:52 +01:00
/** Date and time this transaction was created */
DateRole,
/** Watch-only boolean */
WatchonlyRole,
/** Watch-only icon */
WatchonlyDecorationRole,
2011-11-13 13:19:52 +01:00
/** Long description (HTML format) */
LongDescriptionRole,
2011-11-13 13:19:52 +01:00
/** Address of transaction */
AddressRole,
2011-11-13 13:19:52 +01:00
/** Label of address related to transaction */
LabelRole,
2011-11-13 13:19:52 +01:00
/** Net amount of transaction */
AmountRole,
2011-11-13 13:19:52 +01:00
/** Unique identifier */
TxIDRole,
/** Transaction hash */
TxHashRole,
/** Transaction data, hex-encoded */
TxHexRole,
/** Whole transaction as plain text */
TxPlainTextRole,
2011-11-13 13:19:52 +01:00
/** Is transaction confirmed? */
ConfirmedRole,
2011-11-13 13:19:52 +01:00
/** Formatted amount, without brackets when unconfirmed */
FormattedAmountRole,
/** Transaction status (TransactionRecord::Status) */
2014-11-06 20:55:52 +01:00
StatusRole,
/** Unprocessed icon */
RawDecorationRole,
2011-11-13 13:19:52 +01:00
};
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;
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
bool processingQueuedTransactions() const { return fProcessingQueuedTransactions; }
2011-05-08 16:30:10 +02:00
private:
CWallet* wallet;
WalletModel *walletModel;
2011-05-08 16:30:10 +02:00
QStringList columns;
2011-06-01 15:33:33 +02:00
TransactionTablePriv *priv;
bool fProcessingQueuedTransactions;
const PlatformStyle *platformStyle;
void subscribeToCoreSignals();
void unsubscribeFromCoreSignals();
2011-05-27 08:20:23 +02:00
QString lookupAddress(const std::string &address, bool tooltip) const;
QVariant addressColor(const TransactionRecord *wtx) const;
2011-08-05 15:35:52 +02:00
QString formatTxStatus(const TransactionRecord *wtx) const;
QString formatTxDate(const TransactionRecord *wtx) const;
2011-07-31 17:05:34 +02: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 15:35:52 +02:00
QString formatTooltip(const TransactionRecord *rec) const;
QVariant txStatusDecoration(const TransactionRecord *wtx) const;
QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const;
2011-07-31 17:05:34 +02:00
QVariant txAddressDecoration(const TransactionRecord *wtx) const;
2011-05-28 20:32:19 +02:00
public Q_SLOTS:
/* New transaction, or transaction changed status */
void updateTransaction(const QString &hash, int status, bool showTransaction);
void updateConfirmations();
void updateDisplayUnit();
/** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
void updateAmountColumnTitle();
/* Needed to update fProcessingQueuedTransactions through a QueuedConnection */
void setProcessingQueuedTransactions(bool value) { fProcessingQueuedTransactions = value; }
2011-06-03 20:48:03 +02:00
friend class TransactionTablePriv;
2011-05-08 16:30:10 +02:00
};
2014-11-03 16:16:40 +01:00
#endif // BITCOIN_QT_TRANSACTIONTABLEMODEL_H