LCOV - code coverage report
Current view: top level - src/qt - transactiontablemodel.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 0 3 0.0 %
Date: 2020-09-26 01:30:44 Functions: 0 3 0.0 %

          Line data    Source code
       1             : // Copyright (c) 2011-2018 The Bitcoin Core developers
       2             : // Distributed under the MIT software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : 
       5             : #ifndef BITCOIN_QT_TRANSACTIONTABLEMODEL_H
       6             : #define BITCOIN_QT_TRANSACTIONTABLEMODEL_H
       7             : 
       8             : #include <qt/bitcoinunits.h>
       9             : 
      10             : #include <QAbstractTableModel>
      11             : #include <QStringList>
      12             : 
      13             : #include <memory>
      14             : 
      15             : namespace interfaces {
      16             : class Handler;
      17             : }
      18             : 
      19             : class PlatformStyle;
      20             : class TransactionRecord;
      21             : class TransactionTablePriv;
      22             : class WalletModel;
      23             : 
      24             : /** UI model for the transaction table of a wallet.
      25             :  */
      26             : class TransactionTableModel : public QAbstractTableModel
      27             : {
      28           0 :     Q_OBJECT
      29             : 
      30             : public:
      31             :     explicit TransactionTableModel(const PlatformStyle *platformStyle, WalletModel *parent = nullptr);
      32             :     ~TransactionTableModel();
      33             : 
      34             :     enum ColumnIndex {
      35             :         Status = 0,
      36             :         Watchonly = 1,
      37             :         Date = 2,
      38             :         Type = 3,
      39             :         ToAddress = 4,
      40             :         Amount = 5
      41             :     };
      42             : 
      43             :     /** Roles to get specific information from a transaction row.
      44             :         These are independent of column.
      45             :     */
      46             :     enum RoleIndex {
      47             :         /** Type of transaction */
      48             :         TypeRole = Qt::UserRole,
      49             :         /** Date and time this transaction was created */
      50             :         DateRole,
      51             :         /** Watch-only boolean */
      52             :         WatchonlyRole,
      53             :         /** Watch-only icon */
      54             :         WatchonlyDecorationRole,
      55             :         /** Long description (HTML format) */
      56             :         LongDescriptionRole,
      57             :         /** Address of transaction */
      58             :         AddressRole,
      59             :         /** Label of address related to transaction */
      60             :         LabelRole,
      61             :         /** Net amount of transaction */
      62             :         AmountRole,
      63             :         /** Transaction hash */
      64             :         TxHashRole,
      65             :         /** Transaction data, hex-encoded */
      66             :         TxHexRole,
      67             :         /** Whole transaction as plain text */
      68             :         TxPlainTextRole,
      69             :         /** Is transaction confirmed? */
      70             :         ConfirmedRole,
      71             :         /** Formatted amount, without brackets when unconfirmed */
      72             :         FormattedAmountRole,
      73             :         /** Transaction status (TransactionRecord::Status) */
      74             :         StatusRole,
      75             :         /** Unprocessed icon */
      76             :         RawDecorationRole,
      77             :     };
      78             : 
      79             :     int rowCount(const QModelIndex &parent) const override;
      80             :     int columnCount(const QModelIndex &parent) const override;
      81             :     QVariant data(const QModelIndex &index, int role) const override;
      82             :     QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
      83             :     QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const override;
      84           0 :     bool processingQueuedTransactions() const { return fProcessingQueuedTransactions; }
      85             : 
      86             : private:
      87             :     WalletModel *walletModel;
      88             :     std::unique_ptr<interfaces::Handler> m_handler_transaction_changed;
      89             :     std::unique_ptr<interfaces::Handler> m_handler_show_progress;
      90             :     QStringList columns;
      91             :     TransactionTablePriv *priv;
      92             :     bool fProcessingQueuedTransactions;
      93             :     const PlatformStyle *platformStyle;
      94             : 
      95             :     void subscribeToCoreSignals();
      96             :     void unsubscribeFromCoreSignals();
      97             : 
      98             :     QString lookupAddress(const std::string &address, bool tooltip) const;
      99             :     QVariant addressColor(const TransactionRecord *wtx) const;
     100             :     QString formatTxStatus(const TransactionRecord *wtx) const;
     101             :     QString formatTxDate(const TransactionRecord *wtx) const;
     102             :     QString formatTxType(const TransactionRecord *wtx) const;
     103             :     QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const;
     104             :     QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true, BitcoinUnits::SeparatorStyle separators=BitcoinUnits::SeparatorStyle::STANDARD) const;
     105             :     QString formatTooltip(const TransactionRecord *rec) const;
     106             :     QVariant txStatusDecoration(const TransactionRecord *wtx) const;
     107             :     QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const;
     108             :     QVariant txAddressDecoration(const TransactionRecord *wtx) const;
     109             : 
     110             : public Q_SLOTS:
     111             :     /* New transaction, or transaction changed status */
     112             :     void updateTransaction(const QString &hash, int status, bool showTransaction);
     113             :     void updateConfirmations();
     114             :     void updateDisplayUnit();
     115             :     /** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
     116             :     void updateAmountColumnTitle();
     117             :     /* Needed to update fProcessingQueuedTransactions through a QueuedConnection */
     118           0 :     void setProcessingQueuedTransactions(bool value) { fProcessingQueuedTransactions = value; }
     119             : 
     120             :     friend class TransactionTablePriv;
     121             : };
     122             : 
     123             : #endif // BITCOIN_QT_TRANSACTIONTABLEMODEL_H

Generated by: LCOV version 1.15