LCOV - code coverage report
Current view: top level - src/qt - recentrequeststablemodel.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 0 17 0.0 %
Date: 2015-10-12 22:39:14 Functions: 0 7 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2011-2014 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_RECENTREQUESTSTABLEMODEL_H
       6             : #define BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H
       7             : 
       8             : #include "walletmodel.h"
       9             : 
      10             : #include <QAbstractTableModel>
      11             : #include <QStringList>
      12             : #include <QDateTime>
      13             : 
      14             : class CWallet;
      15             : 
      16           0 : class RecentRequestEntry
      17             : {
      18             : public:
      19           0 :     RecentRequestEntry() : nVersion(RecentRequestEntry::CURRENT_VERSION), id(0) { }
      20             : 
      21             :     static const int CURRENT_VERSION = 1;
      22             :     int nVersion;
      23             :     int64_t id;
      24             :     QDateTime date;
      25             :     SendCoinsRecipient recipient;
      26             : 
      27           0 :     ADD_SERIALIZE_METHODS;
      28             : 
      29             :     template <typename Stream, typename Operation>
      30           0 :     inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
      31           0 :         unsigned int nDate = date.toTime_t();
      32             : 
      33           0 :         READWRITE(this->nVersion);
      34           0 :         nVersion = this->nVersion;
      35           0 :         READWRITE(id);
      36           0 :         READWRITE(nDate);
      37           0 :         READWRITE(recipient);
      38             : 
      39           0 :         if (ser_action.ForRead())
      40           0 :             date = QDateTime::fromTime_t(nDate);
      41           0 :     }
      42             : };
      43             : 
      44             : class RecentRequestEntryLessThan
      45             : {
      46             : public:
      47           0 :     RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder):
      48           0 :         column(nColumn), order(fOrder) {}
      49             :     bool operator()(RecentRequestEntry &left, RecentRequestEntry &right) const;
      50             : 
      51             : private:
      52             :     int column;
      53             :     Qt::SortOrder order;
      54             : };
      55             : 
      56             : /** Model for list of recently generated payment requests / bitcoin: URIs.
      57             :  * Part of wallet model.
      58             :  */
      59             : class RecentRequestsTableModel: public QAbstractTableModel
      60             : {
      61           0 :     Q_OBJECT
      62             : 
      63             : public:
      64             :     explicit RecentRequestsTableModel(CWallet *wallet, WalletModel *parent);
      65             :     ~RecentRequestsTableModel();
      66             : 
      67             :     enum ColumnIndex {
      68             :         Date = 0,
      69             :         Label = 1,
      70             :         Message = 2,
      71             :         Amount = 3,
      72             :         NUMBER_OF_COLUMNS
      73             :     };
      74             : 
      75             :     /** @name Methods overridden from QAbstractTableModel
      76             :         @{*/
      77             :     int rowCount(const QModelIndex &parent) const;
      78             :     int columnCount(const QModelIndex &parent) const;
      79             :     QVariant data(const QModelIndex &index, int role) const;
      80             :     bool setData(const QModelIndex &index, const QVariant &value, int role);
      81             :     QVariant headerData(int section, Qt::Orientation orientation, int role) const;
      82             :     QModelIndex index(int row, int column, const QModelIndex &parent) const;
      83             :     bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
      84             :     Qt::ItemFlags flags(const QModelIndex &index) const;
      85             :     /*@}*/
      86             : 
      87           0 :     const RecentRequestEntry &entry(int row) const { return list[row]; }
      88             :     void addNewRequest(const SendCoinsRecipient &recipient);
      89             :     void addNewRequest(const std::string &recipient);
      90             :     void addNewRequest(RecentRequestEntry &recipient);
      91             : 
      92             : public Q_SLOTS:
      93             :     void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
      94             :     void updateDisplayUnit();
      95             : 
      96             : private:
      97             :     WalletModel *walletModel;
      98             :     QStringList columns;
      99             :     QList<RecentRequestEntry> list;
     100             :     int64_t nReceiveRequestsMaxId;
     101             : 
     102             :     /** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
     103             :     void updateAmountColumnTitle();
     104             :     /** Gets title for amount column including current display unit if optionsModel reference available. */
     105             :     QString getAmountTitle();
     106             : };
     107             : 
     108             : #endif // BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H

Generated by: LCOV version 1.11