2014-12-16 22:47:57 -03:00
|
|
|
// Copyright (c) 2011-2013 The Bitcoin Core developers
|
2014-12-13 01:09:33 -03:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-04 12:20:43 -03:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2014-11-03 12:16:40 -03:00
|
|
|
#ifndef BITCOIN_QT_TRANSACTIONTABLEMODEL_H
|
|
|
|
#define BITCOIN_QT_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;
|
2013-04-13 02:13:08 -03:00
|
|
|
class TransactionTablePriv;
|
2011-07-02 07:45:59 -04:00
|
|
|
class WalletModel;
|
2011-05-27 02:20:23 -04:00
|
|
|
|
2013-04-13 02:13:08 -03: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
|
2013-01-23 17:51:02 -03:00
|
|
|
|
2011-05-08 10:30:10 -04:00
|
|
|
public:
|
2011-07-02 07:45:59 -04:00
|
|
|
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,
|
2014-08-09 20:26:04 -04:00
|
|
|
Watchonly = 1,
|
|
|
|
Date = 2,
|
|
|
|
Type = 3,
|
|
|
|
ToAddress = 4,
|
|
|
|
Amount = 5
|
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 */
|
2011-06-10 09:05:51 -04:00
|
|
|
TypeRole = Qt::UserRole,
|
2011-11-13 09:19:52 -03:00
|
|
|
/** Date and time this transaction was created */
|
2011-06-28 15:41:56 -04:00
|
|
|
DateRole,
|
2014-08-09 20:26:04 -04:00
|
|
|
/** Watch-only boolean */
|
|
|
|
WatchonlyRole,
|
|
|
|
/** Watch-only icon */
|
|
|
|
WatchonlyDecorationRole,
|
2011-11-13 09:19:52 -03:00
|
|
|
/** Long description (HTML format) */
|
2011-06-28 15:41:56 -04:00
|
|
|
LongDescriptionRole,
|
2011-11-13 09:19:52 -03:00
|
|
|
/** Address of transaction */
|
2011-06-28 15:41:56 -04:00
|
|
|
AddressRole,
|
2011-11-13 09:19:52 -03:00
|
|
|
/** Label of address related to transaction */
|
2011-06-28 15:41:56 -04:00
|
|
|
LabelRole,
|
2011-11-13 09:19:52 -03:00
|
|
|
/** Net amount of transaction */
|
2011-08-03 14:52:18 -04:00
|
|
|
AmountRole,
|
2011-11-13 09:19:52 -03:00
|
|
|
/** Unique identifier */
|
2011-07-07 08:27:16 -04:00
|
|
|
TxIDRole,
|
2014-04-24 17:21:45 -03:00
|
|
|
/** Transaction hash */
|
|
|
|
TxHashRole,
|
2011-11-13 09:19:52 -03:00
|
|
|
/** Is transaction confirmed? */
|
2011-07-07 08:27:16 -04:00
|
|
|
ConfirmedRole,
|
2011-11-13 09:19:52 -03:00
|
|
|
/** Formatted amount, without brackets when unconfirmed */
|
2014-02-14 03:59:07 -03:00
|
|
|
FormattedAmountRole,
|
|
|
|
/** Transaction status (TransactionRecord::Status) */
|
2014-11-06 16:55:52 -03:00
|
|
|
StatusRole,
|
|
|
|
/** Unprocessed icon */
|
|
|
|
RawDecorationRole,
|
2011-11-13 09:19:52 -03:00
|
|
|
};
|
2011-05-22 13:32:37 -04: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;
|
2011-06-10 14:49:50 -04:00
|
|
|
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
|
2014-10-28 15:52:21 -03:00
|
|
|
bool processingQueuedTransactions() { return fProcessingQueuedTransactions; }
|
2013-01-23 17:51:02 -03:00
|
|
|
|
2011-05-08 10:30:10 -04:00
|
|
|
private:
|
2011-06-26 13:23:24 -04:00
|
|
|
CWallet* wallet;
|
2011-07-02 07:45:59 -04:00
|
|
|
WalletModel *walletModel;
|
2011-05-08 10:30:10 -04:00
|
|
|
QStringList columns;
|
2011-06-01 09:33:33 -04:00
|
|
|
TransactionTablePriv *priv;
|
2014-10-28 15:52:21 -03:00
|
|
|
bool fProcessingQueuedTransactions;
|
|
|
|
|
|
|
|
void subscribeToCoreSignals();
|
|
|
|
void unsubscribeFromCoreSignals();
|
2011-05-27 02:20:23 -04:00
|
|
|
|
2011-07-30 11:42:02 -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;
|
2014-07-07 17:27:09 -04:00
|
|
|
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;
|
2014-08-09 20:26:04 -04:00
|
|
|
QVariant txWatchonlyDecoration(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
|
|
|
|
2012-05-05 10:07:14 -04:00
|
|
|
public slots:
|
2014-10-28 15:52:21 -03:00
|
|
|
/* New transaction, or transaction changed status */
|
|
|
|
void updateTransaction(const QString &hash, int status, bool showTransaction);
|
2012-05-05 10:07:14 -04:00
|
|
|
void updateConfirmations();
|
2012-06-18 16:48:35 -04:00
|
|
|
void updateDisplayUnit();
|
2014-06-07 02:20:22 -04:00
|
|
|
/** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
|
|
|
|
void updateAmountColumnTitle();
|
2014-10-28 15:52:21 -03:00
|
|
|
/* Needed to update fProcessingQueuedTransactions through a QueuedConnection */
|
|
|
|
void setProcessingQueuedTransactions(bool value) { fProcessingQueuedTransactions = value; }
|
2011-06-03 14:48:03 -04:00
|
|
|
|
|
|
|
friend class TransactionTablePriv;
|
2011-05-08 10:30:10 -04:00
|
|
|
};
|
|
|
|
|
2014-11-03 12:16:40 -03:00
|
|
|
#endif // BITCOIN_QT_TRANSACTIONTABLEMODEL_H
|