Dash Core  0.12.2.1
P2P Digital Currency
recentrequeststablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2015 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 
17 {
18 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, int nType, int nVersion) {
31  unsigned int nDate = date.toTime_t();
32 
33  READWRITE(this->nVersion);
34  nVersion = this->nVersion;
35  READWRITE(id);
36  READWRITE(nDate);
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:
66 
67  enum ColumnIndex {
68  Date = 0,
69  Label = 1,
70  Message = 2,
71  Amount = 3,
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 
105  QString getAmountTitle();
106 };
107 
108 #endif // BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H
int rowCount(const QModelIndex &parent) const
RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder)
#define READWRITE(obj)
Definition: serialize.h:175
QVariant headerData(int section, Qt::Orientation orientation, int role) const
static const int CURRENT_VERSION
RecentRequestsTableModel(CWallet *wallet, WalletModel *parent)
void addNewRequest(const SendCoinsRecipient &recipient)
QVariant data(const QModelIndex &index, int role) const
const RecentRequestEntry & entry(int row) const
Qt::ItemFlags flags(const QModelIndex &index) const
QModelIndex index(int row, int column, const QModelIndex &parent) const
int columnCount(const QModelIndex &parent) const
Definition: wallet.py:1
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
bool setData(const QModelIndex &index, const QVariant &value, int role)
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
static int count
Definition: tests.c:41
SendCoinsRecipient recipient
bool operator()(RecentRequestEntry &left, RecentRequestEntry &right) const
QList< RecentRequestEntry > list
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder)