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