Master Core  v0.0.9 - 49a5c0d97abf09ef2911ddfe8d9551df59f9efd3-dirty
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
recentrequeststablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2014 The Bitcoin developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef RECENTREQUESTSTABLEMODEL_H
6 #define 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  RecentRequestEntry* pthis = const_cast<RecentRequestEntry*>(this);
30 
31  unsigned int nDate = date.toTime_t();
32 
33  READWRITE(pthis->nVersion);
34  nVersion = pthis->nVersion;
35  READWRITE(id);
36  READWRITE(nDate);
37  READWRITE(recipient);
38 
39  if (fRead)
40  pthis->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 
60 {
61  Q_OBJECT
62 
63 public:
64  explicit RecentRequestsTableModel(CWallet *wallet, WalletModel *parent);
66 
67  enum ColumnIndex {
68  Date = 0,
69  Label = 1,
70  Message = 2,
71  Amount = 3,
72  NUMBER_OF_COLUMNS
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 slots:
93  void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
94 
95 private:
97  QStringList columns;
98  QList<RecentRequestEntry> list;
100 };
101 
102 #endif
Model for list of recently generated payment requests / bitcoin: URIs.
#define READWRITE(obj)
Definition: serialize.h:92
RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder)
#define IMPLEMENT_SERIALIZE(statements)
Definition: serialize.h:54
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 Bitcoin wallet from Qt view code.
Definition: walletmodel.h:96
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:100
int column
static const CCheckpointData data
Definition: checkpoints.cpp:56
RecentRequestEntry()