Bitcoin Core 28.99.0
P2P Digital Currency
recentrequeststablemodel.h
Go to the documentation of this file.
1// Copyright (c) 2011-2021 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
9
10#include <string>
11
12#include <QAbstractTableModel>
13#include <QStringList>
14#include <QDateTime>
15
16class WalletModel;
17
19{
20public:
22
23 static const int CURRENT_VERSION = 1;
25 int64_t id{0};
26 QDateTime date;
28
30 unsigned int date_timet;
31 SER_WRITE(obj, date_timet = obj.date.toSecsSinceEpoch());
32 READWRITE(obj.nVersion, obj.id, date_timet, obj.recipient);
33 SER_READ(obj, obj.date = QDateTime::fromSecsSinceEpoch(date_timet));
34 }
35};
36
38{
39public:
40 RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder):
41 column(nColumn), order(fOrder) {}
42 bool operator()(const RecentRequestEntry& left, const RecentRequestEntry& right) const;
43
44private:
45 int column;
46 Qt::SortOrder order;
47};
48
52class RecentRequestsTableModel: public QAbstractTableModel
53{
54 Q_OBJECT
55
56public:
57 explicit RecentRequestsTableModel(WalletModel *parent);
59
61 Date = 0,
62 Label = 1,
64 Amount = 3,
66 };
67
70 int rowCount(const QModelIndex &parent) const override;
71 int columnCount(const QModelIndex &parent) const override;
72 QVariant data(const QModelIndex &index, int role) const override;
73 bool setData(const QModelIndex &index, const QVariant &value, int role) override;
74 QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
75 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
76 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
77 Qt::ItemFlags flags(const QModelIndex &index) const override;
78 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
81 const RecentRequestEntry &entry(int row) const { return list[row]; }
82 void addNewRequest(const SendCoinsRecipient &recipient);
83 void addNewRequest(const std::string &recipient);
84 void addNewRequest(RecentRequestEntry &recipient);
85
86public Q_SLOTS:
87 void updateDisplayUnit();
88
89private:
91 QStringList columns;
92 QList<RecentRequestEntry> list;
94
98 QString getAmountTitle();
99};
100
101#endif // BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H
static const int CURRENT_VERSION
SERIALIZE_METHODS(RecentRequestEntry, obj)
RecentRequestEntry()
SendCoinsRecipient recipient
int nVersion
QDateTime date
Qt::SortOrder order
bool operator()(const RecentRequestEntry &left, const RecentRequestEntry &right) const
RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder)
int column
Model for list of recently generated payment requests / bitcoin: URIs.
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
bool setData(const QModelIndex &index, const QVariant &value, int role) override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role) const override
const RecentRequestEntry & entry(int row) const
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override
QList< RecentRequestEntry > list
int rowCount(const QModelIndex &parent) const override
void updateAmountColumnTitle()
Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table hea...
QString getAmountTitle()
Gets title for amount column including current display unit if optionsModel reference available.
Qt::ItemFlags flags(const QModelIndex &index) const override
void addNewRequest(const SendCoinsRecipient &recipient)
RecentRequestsTableModel(WalletModel *parent)
int columnCount(const QModelIndex &parent) const override
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:48
#define SER_WRITE(obj, code)
Definition: serialize.h:158
#define SER_READ(obj, code)
Definition: serialize.h:157
#define READWRITE(...)
Definition: serialize.h:156
static int count