diff options
Diffstat (limited to 'src/qt/recentrequeststablemodel.h')
-rw-r--r-- | src/qt/recentrequeststablemodel.h | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/src/qt/recentrequeststablemodel.h b/src/qt/recentrequeststablemodel.h index 3aab7b0a48..6b20402f78 100644 --- a/src/qt/recentrequeststablemodel.h +++ b/src/qt/recentrequeststablemodel.h @@ -13,10 +13,44 @@ class CWallet; -struct RecentRequestEntry +class RecentRequestEntry { +public: + RecentRequestEntry() : nVersion(RecentRequestEntry::CURRENT_VERSION), id(0) { } + + static const int CURRENT_VERSION=1; + int nVersion; + int64_t id; QDateTime date; SendCoinsRecipient recipient; + + 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); + ) +}; + +class RecentRequestEntryLessThan +{ +public: + RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder): + column(nColumn), order(fOrder) {} + bool operator()(RecentRequestEntry &left, RecentRequestEntry &right ) const; + +private: + int column; + Qt::SortOrder order; }; /** Model for list of recently generated payment requests / bitcoin URIs. @@ -34,7 +68,8 @@ public: Date = 0, Label = 1, Message = 2, - Amount = 3 + Amount = 3, + NUMBER_OF_COLUMNS }; /** @name Methods overridden from QAbstractTableModel @@ -51,11 +86,17 @@ public: const RecentRequestEntry &entry(int row) const { return list[row]; } void addNewRequest(const SendCoinsRecipient &recipient); + void addNewRequest(const std::string &recipient); + void addNewRequest(RecentRequestEntry &recipient); + +public slots: + void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); private: WalletModel *walletModel; QStringList columns; QList<RecentRequestEntry> list; + int64_t nReceiveRequestsMaxId; }; #endif |