Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

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 <qt/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) {
31  unsigned int nDate = date.toTime_t();
32 
33  READWRITE(this->nVersion);
34  READWRITE(id);
35  READWRITE(nDate);
37 
38  if (ser_action.ForRead())
39  date = QDateTime::fromTime_t(nDate);
40  }
41 };
42 
44 {
45 public:
46  RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder):
47  column(nColumn), order(fOrder) {}
48  bool operator()(RecentRequestEntry &left, RecentRequestEntry &right) const;
49 
50 private:
51  int column;
52  Qt::SortOrder order;
53 };
54 
58 class RecentRequestsTableModel: public QAbstractTableModel
59 {
60  Q_OBJECT
61 
62 public:
63  explicit RecentRequestsTableModel(CWallet *wallet, WalletModel *parent);
65 
66  enum ColumnIndex {
67  Date = 0,
68  Label = 1,
69  Message = 2,
70  Amount = 3,
72  };
73 
76  int rowCount(const QModelIndex &parent) const;
77  int columnCount(const QModelIndex &parent) const;
78  QVariant data(const QModelIndex &index, int role) const;
79  bool setData(const QModelIndex &index, const QVariant &value, int role);
80  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
81  QModelIndex index(int row, int column, const QModelIndex &parent) const;
82  bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
83  Qt::ItemFlags flags(const QModelIndex &index) const;
86  const RecentRequestEntry &entry(int row) const { return list[row]; }
87  void addNewRequest(const SendCoinsRecipient &recipient);
88  void addNewRequest(const std::string &recipient);
89  void addNewRequest(RecentRequestEntry &recipient);
90 
91 public Q_SLOTS:
92  void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
93  void updateDisplayUnit();
94 
95 private:
97  QStringList columns;
98  QList<RecentRequestEntry> list;
100 
104  QString getAmountTitle();
105 };
106 
107 #endif // BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H
bool setData(const QModelIndex &index, const QVariant &value, int role)
Model for list of recently generated payment requests / dash: 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())
#define READWRITE(obj)
Definition: serialize.h:165
void SerializationOp(Stream &s, Operation ser_action)
RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder)
RecentRequestsTableModel(CWallet *wallet, WalletModel *parent)
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:100
void updateAmountColumnTitle()
Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table hea...
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:715
static int count
Definition: tests.c:45
int columnCount(const QModelIndex &parent) const
int column
QString getAmountTitle()
Gets title for amount column including current display unit if optionsModel reference available...
RecentRequestEntry()
Qt::ItemFlags flags(const QModelIndex &index) const
Released under the MIT license