Anoncoin  0.9.4
P2P Digital Currency
recentrequeststablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2014 The Bitcoin developers
2 // Copyright (c) 2013-2014 The Anoncoin Core developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef RECENTREQUESTSTABLEMODEL_H
7 #define RECENTREQUESTSTABLEMODEL_H
8 
9 #include "walletmodel.h"
10 
11 #include <QAbstractTableModel>
12 #include <QStringList>
13 #include <QDateTime>
14 
15 class CWallet;
16 
18 {
19 public:
21 
22  static const int CURRENT_VERSION = 1;
23  int nVersion;
24  int64_t id;
25  QDateTime date;
27 
29  (
30  RecentRequestEntry* pthis = const_cast<RecentRequestEntry*>(this);
31 
32  unsigned int nDate = date.toTime_t();
33 
34  READWRITE(pthis->nVersion);
35  nVersion = pthis->nVersion;
36  READWRITE(id);
37  READWRITE(nDate);
38  READWRITE(recipient);
39 
40  if (fRead)
41  pthis->date = QDateTime::fromTime_t(nDate);
42  )
43 };
44 
46 {
47 public:
48  RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder):
49  column(nColumn), order(fOrder) {}
50  bool operator()(RecentRequestEntry &left, RecentRequestEntry &right) const;
51 
52 private:
53  int column;
54  Qt::SortOrder order;
55 };
56 
60 class RecentRequestsTableModel: public QAbstractTableModel
61 {
62  Q_OBJECT
63 
64 public:
65  explicit RecentRequestsTableModel(CWallet *wallet, WalletModel *parent);
67 
68  enum ColumnIndex {
69  Date = 0,
70  Label = 1,
71  Message = 2,
72  Amount = 3,
73  NUMBER_OF_COLUMNS
74  };
75 
78  int rowCount(const QModelIndex &parent) const;
79  int columnCount(const QModelIndex &parent) const;
80  QVariant data(const QModelIndex &index, int role) const;
81  bool setData(const QModelIndex &index, const QVariant &value, int role);
82  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
83  QModelIndex index(int row, int column, const QModelIndex &parent) const;
84  bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
85  Qt::ItemFlags flags(const QModelIndex &index) const;
88  const RecentRequestEntry &entry(int row) const { return list[row]; }
89  void addNewRequest(const SendCoinsRecipient &recipient);
90  void addNewRequest(const std::string &recipient);
91  void addNewRequest(RecentRequestEntry &recipient);
92 
93 public slots:
94  void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
95  void updateDisplayUnit();
96 
97 private:
99  QStringList columns;
100  QList<RecentRequestEntry> list;
102 
104  void updateAmountColumnTitle();
106  QString getAmountTitle();
107 };
108 
109 #endif
Model for list of recently generated payment requests / anoncoin: URIs.
#define READWRITE(obj)
Definition: serialize.h:101
RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder)
#define IMPLEMENT_SERIALIZE(statements)
Definition: serialize.h:63
const RecentRequestEntry & entry(int row) const
int64_t id
QDateTime date
QList< RecentRequestEntry > list
static const int CURRENT_VERSION
SendCoinsRecipient recipient
Qt::SortOrder order
int nVersion
Interface to Anoncoin wallet from Qt view code.
Definition: walletmodel.h:97
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:101
int column
RecentRequestEntry()