BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
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);
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,
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;
98 
102  QString getAmountTitle();
103 };
104 
105 #endif // BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H
bool setData(const QModelIndex &index, const QVariant &value, int role)
Model for list of recently generated payment requests / bitcoin: URIs.
void addNewRequest(const SendCoinsRecipient &recipient)
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder)
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
void SerializationOp(Stream &s, Operation ser_action)
RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder)
int64_t id
QDateTime date
QList< RecentRequestEntry > list
QVariant headerData(int section, Qt::Orientation orientation, int role) const
static const int CURRENT_VERSION
int rowCount(const QModelIndex &parent) const
QModelIndex index(int row, int column, const QModelIndex &parent) const
SendCoinsRecipient recipient
ADD_SERIALIZE_METHODS
Qt::SortOrder order
const RecentRequestEntry & entry(int row) const
bool operator()(RecentRequestEntry &left, RecentRequestEntry &right) const
int nVersion
QVariant data(const QModelIndex &index, int role) const
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:125
void updateAmountColumnTitle()
Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table hea...
int columnCount(const QModelIndex &parent) const
int column
#define READWRITE(...)
Definition: serialize.h:173
RecentRequestsTableModel(WalletModel *parent)
QString getAmountTitle()
Gets title for amount column including current display unit if optionsModel reference available...
RecentRequestEntry()
Qt::ItemFlags flags(const QModelIndex &index) const