mirror of
https://github.com/monero-project/monero-gui.git
synced 2026-04-08 15:57:26 -04:00
Simple transaction history
This commit is contained in:
@@ -2,11 +2,18 @@
|
||||
#include "TransactionInfo.h"
|
||||
#include <wallet/wallet2_api.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
TransactionInfo *TransactionHistory::transaction(int index)
|
||||
{
|
||||
// box up Bitmonero::TransactionInfo
|
||||
Bitmonero::TransactionInfo * impl = m_pimpl->transaction(index);
|
||||
if (!impl) {
|
||||
qCritical("%s: no transaction info for index %d", __FUNCTION__, index);
|
||||
qCritical("%s: there's %d transactions in backend", __FUNCTION__, m_pimpl->count());
|
||||
return nullptr;
|
||||
}
|
||||
TransactionInfo * result = new TransactionInfo(impl, this);
|
||||
return result;
|
||||
}
|
||||
@@ -34,6 +41,7 @@ QList<TransactionInfo *> TransactionHistory::getAll() const
|
||||
void TransactionHistory::refresh()
|
||||
{
|
||||
// XXX this invalidates previously saved history that might be used by clients
|
||||
|
||||
emit refreshStarted();
|
||||
m_pimpl->refresh();
|
||||
emit refreshFinished();
|
||||
|
||||
@@ -39,13 +39,23 @@ QString TransactionInfo::hash() const
|
||||
return QString::fromStdString(m_pimpl->hash());
|
||||
}
|
||||
|
||||
QString TransactionInfo::timestamp()
|
||||
QDateTime TransactionInfo::timestamp() const
|
||||
{
|
||||
QString result = QDateTime::fromTime_t(m_pimpl->timestamp()).toString(Qt::ISODate);
|
||||
QDateTime result = QDateTime::fromTime_t(m_pimpl->timestamp());
|
||||
return result;
|
||||
}
|
||||
|
||||
QString TransactionInfo::paymentId()
|
||||
QString TransactionInfo::date() const
|
||||
{
|
||||
return timestamp().date().toString(Qt::ISODate);
|
||||
}
|
||||
|
||||
QString TransactionInfo::time() const
|
||||
{
|
||||
return timestamp().time().toString(Qt::ISODate);
|
||||
}
|
||||
|
||||
QString TransactionInfo::paymentId() const
|
||||
{
|
||||
return QString::fromStdString(m_pimpl->paymentId());
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#ifndef TRANSACTIONINFO_H
|
||||
#define TRANSACTIONINFO_H
|
||||
|
||||
#include <QObject>
|
||||
#include <wallet/wallet2_api.h>
|
||||
#include <QObject>
|
||||
#include <QDateTime>
|
||||
|
||||
class TransactionInfo : public QObject
|
||||
{
|
||||
@@ -14,7 +15,9 @@ class TransactionInfo : public QObject
|
||||
Q_PROPERTY(QString fee READ fee)
|
||||
Q_PROPERTY(quint64 blockHeight READ blockHeight)
|
||||
Q_PROPERTY(QString hash READ hash)
|
||||
Q_PROPERTY(QString timestamp READ timestamp)
|
||||
Q_PROPERTY(QDateTime timestamp READ timestamp)
|
||||
Q_PROPERTY(QString date READ date)
|
||||
Q_PROPERTY(QString time READ time)
|
||||
Q_PROPERTY(QString paymentId READ paymentId)
|
||||
|
||||
public:
|
||||
@@ -41,8 +44,11 @@ public:
|
||||
quint64 blockHeight() const;
|
||||
//! transaction_id
|
||||
QString hash() const;
|
||||
QString timestamp();
|
||||
QString paymentId();
|
||||
QDateTime timestamp() const;
|
||||
QString date() const;
|
||||
QString time() const;
|
||||
QString paymentId() const;
|
||||
|
||||
|
||||
// TODO: implement it
|
||||
//! only applicable for output transactions
|
||||
@@ -57,4 +63,5 @@ private:
|
||||
// in order to wrap it to QVariant
|
||||
Q_DECLARE_METATYPE(TransactionInfo*)
|
||||
|
||||
|
||||
#endif // TRANSACTIONINFO_H
|
||||
|
||||
@@ -40,12 +40,14 @@ public:
|
||||
virtual void newBlock(uint64_t height)
|
||||
{
|
||||
// qDebug() << __FUNCTION__;
|
||||
m_wallet->m_history->refresh();
|
||||
emit m_wallet->newBlock(height);
|
||||
}
|
||||
|
||||
virtual void updated()
|
||||
{
|
||||
qDebug() << __FUNCTION__;
|
||||
m_wallet->m_history->refresh();
|
||||
emit m_wallet->updated();
|
||||
}
|
||||
|
||||
@@ -53,6 +55,7 @@ public:
|
||||
virtual void refreshed()
|
||||
{
|
||||
qDebug() << __FUNCTION__;
|
||||
|
||||
emit m_wallet->refreshed();
|
||||
}
|
||||
|
||||
@@ -166,6 +169,7 @@ quint64 Wallet::daemonBlockChainTargetHeight() const
|
||||
bool Wallet::refresh()
|
||||
{
|
||||
bool result = m_walletImpl->refresh();
|
||||
m_history->refresh();
|
||||
if (result)
|
||||
emit updated();
|
||||
return result;
|
||||
@@ -205,10 +209,10 @@ void Wallet::disposeTransaction(PendingTransaction *t)
|
||||
|
||||
TransactionHistory *Wallet::history()
|
||||
{
|
||||
if (!m_history) {
|
||||
Bitmonero::TransactionHistory * impl = m_walletImpl->history();
|
||||
m_history = new TransactionHistory(impl, this);
|
||||
}
|
||||
// if (m_history->count() == 0) {
|
||||
// m_history->refresh();
|
||||
// }
|
||||
|
||||
return m_history;
|
||||
}
|
||||
|
||||
@@ -252,6 +256,7 @@ Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent)
|
||||
, m_daemonBlockChainHeight(0)
|
||||
, m_daemonBlockChainHeightTtl(DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS)
|
||||
{
|
||||
m_history = new TransactionHistory(m_walletImpl->history(), this);
|
||||
m_walletImpl->setListener(new WalletListenerImpl(this));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user