]> Git Repo - VerusCoin.git/blame - src/qt/recentrequeststablemodel.h
komodo strings
[VerusCoin.git] / src / qt / recentrequeststablemodel.h
CommitLineData
f914f1a7 1// Copyright (c) 2011-2014 The Bitcoin Core developers
78253fcb 2// Distributed under the MIT software license, see the accompanying
666893b1
WL
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
84738627
PJ
5#ifndef BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H
6#define BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H
666893b1 7
7df07b3f
PK
8#include "walletmodel.h"
9
666893b1
WL
10#include <QAbstractTableModel>
11#include <QStringList>
12#include <QDateTime>
13
666893b1
WL
14class CWallet;
15
8476d5d4 16class RecentRequestEntry
666893b1 17{
8476d5d4
CL
18public:
19 RecentRequestEntry() : nVersion(RecentRequestEntry::CURRENT_VERSION), id(0) { }
20
4bee715b 21 static const int CURRENT_VERSION = 1;
8476d5d4
CL
22 int nVersion;
23 int64_t id;
666893b1
WL
24 QDateTime date;
25 SendCoinsRecipient recipient;
8476d5d4 26
3f6540ad 27 ADD_SERIALIZE_METHODS;
8476d5d4 28
84881f8c 29 template <typename Stream, typename Operation>
31e9a838 30 inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
84881f8c 31 unsigned int nDate = date.toTime_t();
8476d5d4 32
47eb7659
PW
33 READWRITE(this->nVersion);
34 nVersion = this->nVersion;
84881f8c 35 READWRITE(id);
8476d5d4 36 READWRITE(nDate);
84881f8c 37 READWRITE(recipient);
8476d5d4 38
47eb7659 39 if (ser_action.ForRead())
31e9a838 40 date = QDateTime::fromTime_t(nDate);
3d796f89 41 }
666893b1
WL
42};
43
4d901023
CL
44class RecentRequestEntryLessThan
45{
46public:
47 RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder):
48 column(nColumn), order(fOrder) {}
4bee715b 49 bool operator()(RecentRequestEntry &left, RecentRequestEntry &right) const;
4d901023
CL
50
51private:
52 int column;
53 Qt::SortOrder order;
54};
55
d7aa1ec8 56/** Model for list of recently generated payment requests / bitcoin: URIs.
666893b1
WL
57 * Part of wallet model.
58 */
59class RecentRequestsTableModel: public QAbstractTableModel
60{
61 Q_OBJECT
62
63public:
7df07b3f 64 explicit RecentRequestsTableModel(CWallet *wallet, WalletModel *parent);
666893b1
WL
65 ~RecentRequestsTableModel();
66
67 enum ColumnIndex {
68 Date = 0,
69 Label = 1,
70 Message = 2,
4d901023
CL
71 Amount = 3,
72 NUMBER_OF_COLUMNS
666893b1
WL
73 };
74
75 /** @name Methods overridden from QAbstractTableModel
76 @{*/
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;
85 /*@}*/
86
87 const RecentRequestEntry &entry(int row) const { return list[row]; }
88 void addNewRequest(const SendCoinsRecipient &recipient);
8476d5d4
CL
89 void addNewRequest(const std::string &recipient);
90 void addNewRequest(RecentRequestEntry &recipient);
666893b1 91
e092f229 92public Q_SLOTS:
4d901023 93 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
8969828d 94 void updateDisplayUnit();
4d901023 95
666893b1
WL
96private:
97 WalletModel *walletModel;
98 QStringList columns;
99 QList<RecentRequestEntry> list;
8476d5d4 100 int64_t nReceiveRequestsMaxId;
8969828d 101
102 /** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
103 void updateAmountColumnTitle();
104 /** Gets title for amount column including current display unit if optionsModel reference available. */
105 QString getAmountTitle();
666893b1
WL
106};
107
84738627 108#endif // BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H
This page took 0.157083 seconds and 4 git commands to generate.