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: 2015-10-12 22:39:14 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11