2015-12-13 14:51:43 +01:00
|
|
|
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-04 16:20:43 +01:00
|
|
|
// 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
|
|
|
|
2020-03-19 23:46:56 +01: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>
|
|
|
|
|
2017-04-18 22:42:30 +02:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
namespace interface {
|
|
|
|
class Handler;
|
|
|
|
}
|
|
|
|
|
2011-05-27 08:20:23 +02:00
|
|
|
class TransactionRecord;
|
2013-04-13 07:13:08 +02:00
|
|
|
class TransactionTablePriv;
|
2011-07-02 13:45:59 +02:00
|
|
|
class WalletModel;
|
2011-05-27 08:20:23 +02:00
|
|
|
|
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
|
2013-01-23 21:51:02 +01:00
|
|
|
|
2011-05-08 16:30:10 +02:00
|
|
|
public:
|
2017-04-18 22:42:30 +02:00
|
|
|
explicit TransactionTableModel(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,
|
2014-08-10 02:26:04 +02:00
|
|
|
Watchonly = 1,
|
2020-09-23 08:33:46 +02:00
|
|
|
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 */
|
2011-06-10 15:05:51 +02:00
|
|
|
TypeRole = Qt::UserRole,
|
2011-11-13 13:19:52 +01:00
|
|
|
/** Date and time this transaction was created */
|
2011-06-28 21:41:56 +02:00
|
|
|
DateRole,
|
2019-10-19 12:39:02 +02:00
|
|
|
/** Date and time this transaction was created in MSec since epoch */
|
|
|
|
DateRoleInt,
|
2014-08-10 02:26:04 +02:00
|
|
|
/** Watch-only boolean */
|
|
|
|
WatchonlyRole,
|
|
|
|
/** Watch-only icon */
|
|
|
|
WatchonlyDecorationRole,
|
2011-11-13 13:19:52 +01:00
|
|
|
/** Long description (HTML format) */
|
2011-06-28 21:41:56 +02:00
|
|
|
LongDescriptionRole,
|
2011-11-13 13:19:52 +01:00
|
|
|
/** Address of transaction */
|
2011-06-28 21:41:56 +02:00
|
|
|
AddressRole,
|
2011-11-13 13:19:52 +01:00
|
|
|
/** Label of address related to transaction */
|
2011-06-28 21:41:56 +02:00
|
|
|
LabelRole,
|
2011-11-13 13:19:52 +01:00
|
|
|
/** Net amount of transaction */
|
2011-08-03 20:52:18 +02:00
|
|
|
AmountRole,
|
2014-04-24 22:21:45 +02:00
|
|
|
/** Transaction hash */
|
|
|
|
TxHashRole,
|
2015-11-17 11:17:09 +01:00
|
|
|
/** Transaction data, hex-encoded */
|
|
|
|
TxHexRole,
|
2017-09-07 17:59:00 +02:00
|
|
|
/** Whole transaction as plain text */
|
|
|
|
TxPlainTextRole,
|
2011-11-13 13:19:52 +01:00
|
|
|
/** Is transaction confirmed? */
|
2011-07-07 14:27:16 +02:00
|
|
|
ConfirmedRole,
|
2011-11-13 13:19:52 +01:00
|
|
|
/** Formatted amount, without brackets when unconfirmed */
|
2014-02-14 07:59:07 +01:00
|
|
|
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-22 19:32:37 +02: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;
|
2011-06-10 20:49:50 +02:00
|
|
|
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
|
2017-08-16 02:09:10 +02:00
|
|
|
bool processingQueuedTransactions() const { return fProcessingQueuedTransactions; }
|
2019-04-25 17:37:39 +02:00
|
|
|
void updateChainLockHeight(int chainLockHeight);
|
|
|
|
int getChainLockHeight() const;
|
2013-01-23 21:51:02 +01:00
|
|
|
|
2011-05-08 16:30:10 +02:00
|
|
|
private:
|
2011-07-02 13:45:59 +02:00
|
|
|
WalletModel *walletModel;
|
2017-04-18 22:42:30 +02:00
|
|
|
std::unique_ptr<interface::Handler> m_handler_transaction_changed;
|
|
|
|
std::unique_ptr<interface::Handler> m_handler_address_book_changed;
|
|
|
|
std::unique_ptr<interface::Handler> m_handler_show_progress;
|
2011-05-08 16:30:10 +02:00
|
|
|
QStringList columns;
|
2011-06-01 15:33:33 +02:00
|
|
|
TransactionTablePriv *priv;
|
2014-10-28 19:52:21 +01:00
|
|
|
bool fProcessingQueuedTransactions;
|
2019-04-25 17:37:39 +02:00
|
|
|
int cachedChainLockHeight;
|
2014-10-28 19:52:21 +01:00
|
|
|
|
|
|
|
void subscribeToCoreSignals();
|
|
|
|
void unsubscribeFromCoreSignals();
|
2011-05-27 08:20:23 +02:00
|
|
|
|
2019-10-23 09:56:00 +02:00
|
|
|
QString formatAddressLabel(const std::string &address, const QString& label, bool tooltip) const;
|
2011-07-30 17:42:02 +02:00
|
|
|
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;
|
2014-07-07 23:27:09 +02:00
|
|
|
QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true, BitcoinUnits::SeparatorStyle separators=BitcoinUnits::separatorStandard) const;
|
2020-09-23 08:33:46 +02:00
|
|
|
QVariant amountColor(const TransactionRecord *rec) const;
|
2011-08-05 15:35:52 +02:00
|
|
|
QString formatTooltip(const TransactionRecord *rec) const;
|
|
|
|
QVariant txStatusDecoration(const TransactionRecord *wtx) const;
|
2014-08-10 02:26:04 +02:00
|
|
|
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
|
|
|
|
2015-07-14 13:59:05 +02:00
|
|
|
public Q_SLOTS:
|
2014-10-28 19:52:21 +01:00
|
|
|
/* New transaction, or transaction changed status */
|
|
|
|
void updateTransaction(const QString &hash, int status, bool showTransaction);
|
2019-10-19 12:39:02 +02:00
|
|
|
void updateAddressBook(const QString &address, const QString &label,
|
|
|
|
bool isMine, const QString &purpose, int status);
|
2012-05-05 16:07:14 +02:00
|
|
|
void updateConfirmations();
|
2012-06-18 22:48:35 +02:00
|
|
|
void updateDisplayUnit();
|
2014-06-07 08:20:22 +02:00
|
|
|
/** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
|
|
|
|
void updateAmountColumnTitle();
|
2014-10-28 19:52:21 +01:00
|
|
|
/* 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
|