2013-11-05 18:03:05 +01:00
|
|
|
// Copyright (c) 2011-2013 The Bitcoin developers
|
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#ifndef RECENTREQUESTSTABLEMODEL_H
|
|
|
|
#define RECENTREQUESTSTABLEMODEL_H
|
|
|
|
|
2013-12-10 11:57:57 +01:00
|
|
|
#include "walletmodel.h"
|
|
|
|
|
2013-11-05 18:03:05 +01:00
|
|
|
#include <QAbstractTableModel>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QDateTime>
|
|
|
|
|
|
|
|
class CWallet;
|
|
|
|
|
2014-01-14 05:05:43 +01:00
|
|
|
class RecentRequestEntry
|
2013-11-05 18:03:05 +01:00
|
|
|
{
|
2014-01-14 05:05:43 +01:00
|
|
|
public:
|
|
|
|
RecentRequestEntry() : nVersion(RecentRequestEntry::CURRENT_VERSION), id(0) { }
|
|
|
|
|
|
|
|
static const int CURRENT_VERSION=1;
|
|
|
|
int nVersion;
|
|
|
|
int64_t id;
|
2013-11-05 18:03:05 +01:00
|
|
|
QDateTime date;
|
|
|
|
SendCoinsRecipient recipient;
|
2014-01-14 05:05:43 +01:00
|
|
|
|
|
|
|
IMPLEMENT_SERIALIZE
|
|
|
|
(
|
|
|
|
RecentRequestEntry* pthis = const_cast<RecentRequestEntry*>(this);
|
|
|
|
|
|
|
|
unsigned int nDate = date.toTime_t();
|
|
|
|
|
|
|
|
READWRITE(pthis->nVersion);
|
|
|
|
nVersion = pthis->nVersion;
|
|
|
|
READWRITE(id);
|
|
|
|
READWRITE(nDate);
|
|
|
|
READWRITE(recipient);
|
|
|
|
|
|
|
|
if (fRead)
|
|
|
|
pthis->date = QDateTime::fromTime_t(nDate);
|
|
|
|
)
|
2013-11-05 18:03:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Model for list of recently generated payment requests / bitcoin URIs.
|
|
|
|
* Part of wallet model.
|
|
|
|
*/
|
|
|
|
class RecentRequestsTableModel: public QAbstractTableModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2013-12-10 11:57:57 +01:00
|
|
|
explicit RecentRequestsTableModel(CWallet *wallet, WalletModel *parent);
|
2013-11-05 18:03:05 +01:00
|
|
|
~RecentRequestsTableModel();
|
|
|
|
|
|
|
|
enum ColumnIndex {
|
|
|
|
Date = 0,
|
|
|
|
Label = 1,
|
|
|
|
Message = 2,
|
|
|
|
Amount = 3
|
|
|
|
};
|
|
|
|
|
|
|
|
/** @name Methods overridden from QAbstractTableModel
|
|
|
|
@{*/
|
|
|
|
int rowCount(const QModelIndex &parent) const;
|
|
|
|
int columnCount(const QModelIndex &parent) const;
|
|
|
|
QVariant data(const QModelIndex &index, int role) const;
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
|
|
|
QModelIndex index(int row, int column, const QModelIndex &parent) const;
|
|
|
|
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
|
|
|
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
const RecentRequestEntry &entry(int row) const { return list[row]; }
|
|
|
|
void addNewRequest(const SendCoinsRecipient &recipient);
|
2014-01-14 05:05:43 +01:00
|
|
|
void addNewRequest(const std::string &recipient);
|
|
|
|
void addNewRequest(RecentRequestEntry &recipient);
|
2013-11-05 18:03:05 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
WalletModel *walletModel;
|
|
|
|
QStringList columns;
|
|
|
|
QList<RecentRequestEntry> list;
|
2014-01-14 05:05:43 +01:00
|
|
|
int64_t nReceiveRequestsMaxId;
|
2013-11-05 18:03:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|