Bitcoin Core  0.18.99
P2P Digital Currency
recentrequeststablemodel.h
Go to the documentation of this file.
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_RECENTREQUESTSTABLEMODEL_H
6 #define BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H
7 
8 #include <qt/walletmodel.h>
9 
10 #include <QAbstractTableModel>
11 #include <QStringList>
12 #include <QDateTime>
13 
15 {
16 public:
18 
19  static const int CURRENT_VERSION = 1;
20  int nVersion;
21  int64_t id;
22  QDateTime date;
24 
26 
27  template <typename Stream, typename Operation>
28  inline void SerializationOp(Stream& s, Operation ser_action) {
29  unsigned int nDate = date.toTime_t();
30 
31  READWRITE(this->nVersion);
32  READWRITE(id);
33  READWRITE(nDate);
34  READWRITE(recipient);
35 
36  if (ser_action.ForRead())
37  date = QDateTime::fromTime_t(nDate);
38  }
39 };
40 
42 {
43 public:
44  RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder):
45  column(nColumn), order(fOrder) {}
46  bool operator()(RecentRequestEntry &left, RecentRequestEntry &right) const;
47 
48 private:
49  int column;
50  Qt::SortOrder order;
51 };
52 
56 class RecentRequestsTableModel: public QAbstractTableModel
57 {
58  Q_OBJECT
59 
60 public:
61  explicit RecentRequestsTableModel(WalletModel *parent);
63 
64  enum ColumnIndex {
65  Date = 0,
66  Label = 1,
67  Message = 2,
68  Amount = 3,
69  NUMBER_OF_COLUMNS
70  };
71 
74  int rowCount(const QModelIndex &parent) const;
75  int columnCount(const QModelIndex &parent) const;
76  QVariant data(const QModelIndex &index, int role) const;
77  bool setData(const QModelIndex &index, const QVariant &value, int role);
78  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
79  QModelIndex index(int row, int column, const QModelIndex &parent) const;
80  bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
81  Qt::ItemFlags flags(const QModelIndex &index) const;
84  const RecentRequestEntry &entry(int row) const { return list[row]; }
85  void addNewRequest(const SendCoinsRecipient &recipient);
86  void addNewRequest(const std::string &recipient);
87  void addNewRequest(RecentRequestEntry &recipient);
88 
89 public Q_SLOTS:
90  void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
91  void updateDisplayUnit();
92 
93 private:
95  QStringList columns;
96  QList<RecentRequestEntry> list;
97  int64_t nReceiveRequestsMaxId{0};
98 
100  void updateAmountColumnTitle();
102  QString getAmountTitle();
103 };
104 
105 #endif // BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H
Model for list of recently generated payment requests / bitcoin: URIs.
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
int flags
Definition: bitcoin-tx.cpp:507
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:125
int column
#define READWRITE(...)
Definition: serialize.h:184
RecentRequestEntry()