LCOV - code coverage report
Current view: top level - src/qt - addresstablemodel.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 0 2 0.0 %
Date: 2020-09-26 01:30:44 Functions: 0 2 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_ADDRESSTABLEMODEL_H
       6             : #define BITCOIN_QT_ADDRESSTABLEMODEL_H
       7             : 
       8             : #include <QAbstractTableModel>
       9             : #include <QStringList>
      10             : 
      11             : enum class OutputType;
      12             : 
      13             : class AddressTablePriv;
      14             : class WalletModel;
      15             : 
      16             : namespace interfaces {
      17             : class Wallet;
      18             : }
      19             : 
      20             : /**
      21             :    Qt model of the address book in the core. This allows views to access and modify the address book.
      22             :  */
      23             : class AddressTableModel : public QAbstractTableModel
      24             : {
      25           0 :     Q_OBJECT
      26             : 
      27             : public:
      28             :     explicit AddressTableModel(WalletModel *parent = nullptr, bool pk_hash_only = false);
      29             :     ~AddressTableModel();
      30             : 
      31             :     enum ColumnIndex {
      32             :         Label = 0,   /**< User specified label */
      33             :         Address = 1  /**< Bitcoin address */
      34             :     };
      35             : 
      36             :     enum RoleIndex {
      37             :         TypeRole = Qt::UserRole /**< Type of address (#Send or #Receive) */
      38             :     };
      39             : 
      40             :     /** Return status of edit/insert operation */
      41             :     enum EditStatus {
      42             :         OK,                     /**< Everything ok */
      43             :         NO_CHANGES,             /**< No changes were made during edit operation */
      44             :         INVALID_ADDRESS,        /**< Unparseable address */
      45             :         DUPLICATE_ADDRESS,      /**< Address already in address book */
      46             :         WALLET_UNLOCK_FAILURE,  /**< Wallet could not be unlocked to create new receiving address */
      47             :         KEY_GENERATION_FAILURE  /**< Generating a new public key for a receiving address failed */
      48             :     };
      49             : 
      50             :     static const QString Send;      /**< Specifies send address */
      51             :     static const QString Receive;   /**< Specifies receive address */
      52             : 
      53             :     /** @name Methods overridden from QAbstractTableModel
      54             :         @{*/
      55             :     int rowCount(const QModelIndex &parent) const override;
      56             :     int columnCount(const QModelIndex &parent) const override;
      57             :     QVariant data(const QModelIndex &index, int role) const override;
      58             :     bool setData(const QModelIndex &index, const QVariant &value, int role) override;
      59             :     QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
      60             :     QModelIndex index(int row, int column, const QModelIndex &parent) const override;
      61             :     bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
      62             :     Qt::ItemFlags flags(const QModelIndex &index) const override;
      63             :     /*@}*/
      64             : 
      65             :     /* Add an address to the model.
      66             :        Returns the added address on success, and an empty string otherwise.
      67             :      */
      68             :     QString addRow(const QString &type, const QString &label, const QString &address, const OutputType address_type);
      69             : 
      70             :     /** Look up label for address in address book, if not found return empty string. */
      71             :     QString labelForAddress(const QString &address) const;
      72             : 
      73             :     /** Look up purpose for address in address book, if not found return empty string. */
      74             :     QString purposeForAddress(const QString &address) const;
      75             : 
      76             :     /* Look up row index of an address in the model.
      77             :        Return -1 if not found.
      78             :      */
      79             :     int lookupAddress(const QString &address) const;
      80             : 
      81           0 :     EditStatus getEditStatus() const { return editStatus; }
      82             : 
      83             :     OutputType GetDefaultAddressType() const;
      84             : 
      85             : private:
      86             :     WalletModel* const walletModel;
      87             :     AddressTablePriv *priv = nullptr;
      88             :     QStringList columns;
      89             :     EditStatus editStatus = OK;
      90             : 
      91             :     /** Look up address book data given an address string. */
      92             :     bool getAddressData(const QString &address, std::string* name, std::string* purpose) const;
      93             : 
      94             :     /** Notify listeners that data changed. */
      95             :     void emitDataChanged(int index);
      96             : 
      97             : public Q_SLOTS:
      98             :     /* Update address list from core.
      99             :      */
     100             :     void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status);
     101             : 
     102             :     friend class AddressTablePriv;
     103             : };
     104             : 
     105             : #endif // BITCOIN_QT_ADDRESSTABLEMODEL_H

Generated by: LCOV version 1.15