Raven Core  3.0.0
P2P Digital Currency
recentrequeststablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2016 The Bitcoin Core developers
2 // Copyright (c) 2017-2019 The Raven Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef RAVEN_QT_RECENTREQUESTSTABLEMODEL_H
7 #define RAVEN_QT_RECENTREQUESTSTABLEMODEL_H
8 
9 #include "walletmodel.h"
10 
11 #include <QAbstractTableModel>
12 #include <QStringList>
13 #include <QDateTime>
14 
15 class CWallet;
16 
18 {
19 public:
21 
22  static const int CURRENT_VERSION = 1;
23  int nVersion;
24  int64_t id;
25  QDateTime date;
27 
29 
30  template <typename Stream, typename Operation>
31  inline void SerializationOp(Stream& s, Operation ser_action) {
32  unsigned int nDate = date.toTime_t();
33 
34  READWRITE(this->nVersion);
35  READWRITE(id);
36  READWRITE(nDate);
37  READWRITE(recipient);
38 
39  if (ser_action.ForRead())
40  date = QDateTime::fromTime_t(nDate);
41  }
42 };
43 
45 {
46 public:
47  RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder):
48  column(nColumn), order(fOrder) {}
49  bool operator()(RecentRequestEntry &left, RecentRequestEntry &right) const;
50 
51 private:
52  int column;
53  Qt::SortOrder order;
54 };
55 
59 class RecentRequestsTableModel: public QAbstractTableModel
60 {
61  Q_OBJECT
62 
63 public:
64  explicit RecentRequestsTableModel(CWallet *wallet, WalletModel *parent);
66 
67  enum ColumnIndex {
68  Date = 0,
69  Label = 1,
70  Message = 2,
71  Amount = 3,
72  NUMBER_OF_COLUMNS
73  };
74 
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;
87  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:
98  QStringList columns;
99  QList<RecentRequestEntry> list;
101 
103  void updateAmountColumnTitle();
105  QString getAmountTitle();
106 };
107 
108 #endif // RAVEN_QT_RECENTREQUESTSTABLEMODEL_H
Model for list of recently generated payment requests / raven: URIs.
#define READWRITE(obj)
Definition: serialize.h:163
int flags
Definition: raven-tx.cpp:500
void SerializationOp(Stream &s, Operation ser_action)
RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder)
int64_t id
QDateTime date
QList< RecentRequestEntry > list
static const int CURRENT_VERSION
SendCoinsRecipient recipient
ADD_SERIALIZE_METHODS
Qt::SortOrder order
const RecentRequestEntry & entry(int row) const
int nVersion
Interface to Raven wallet from Qt view code.
Definition: walletmodel.h:165
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:673
int column
RecentRequestEntry()