mirror of
https://github.com/monero-project/monero-gui.git
synced 2026-04-13 13:07:51 -04:00
added TransactionHistoryModel; renamings
This commit is contained in:
@@ -3,11 +3,6 @@
|
||||
#include <wallet/wallet2_api.h>
|
||||
|
||||
|
||||
int TransactionHistory::count() const
|
||||
{
|
||||
return m_pimpl->count();
|
||||
}
|
||||
|
||||
TransactionInfo *TransactionHistory::transaction(int index)
|
||||
{
|
||||
// box up Bitmonero::TransactionInfo
|
||||
@@ -39,10 +34,17 @@ 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 invalidated();
|
||||
emit refreshFinished();
|
||||
}
|
||||
|
||||
quint64 TransactionHistory::count() const
|
||||
{
|
||||
return m_pimpl->count();
|
||||
}
|
||||
|
||||
|
||||
TransactionHistory::TransactionHistory(Bitmonero::TransactionHistory *pimpl, QObject *parent)
|
||||
: QObject(parent), m_pimpl(pimpl)
|
||||
{
|
||||
|
||||
@@ -16,14 +16,15 @@ class TransactionHistory : public QObject
|
||||
Q_PROPERTY(int count READ count)
|
||||
|
||||
public:
|
||||
int count() const;
|
||||
Q_INVOKABLE TransactionInfo *transaction(int index);
|
||||
Q_INVOKABLE TransactionInfo * transaction(const QString &id);
|
||||
Q_INVOKABLE QList<TransactionInfo*> getAll() const;
|
||||
Q_INVOKABLE void refresh();
|
||||
quint64 count() const;
|
||||
|
||||
signals:
|
||||
void invalidated();
|
||||
void refreshStarted();
|
||||
void refreshFinished();
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "TransactionInfo.h"
|
||||
#include "WalletManager.h"
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
TransactionInfo::Direction TransactionInfo::direction() const
|
||||
@@ -16,15 +18,15 @@ bool TransactionInfo::isFailed() const
|
||||
return m_pimpl->isFailed();
|
||||
}
|
||||
|
||||
quint64 TransactionInfo::amount() const
|
||||
|
||||
QString TransactionInfo::amount() const
|
||||
{
|
||||
return m_pimpl->amount();
|
||||
return WalletManager::instance()->displayAmount(m_pimpl->amount());
|
||||
}
|
||||
|
||||
quint64 TransactionInfo::fee() const
|
||||
QString TransactionInfo::fee() const
|
||||
{
|
||||
return m_pimpl->fee();
|
||||
|
||||
return WalletManager::instance()->displayAmount(m_pimpl->fee());
|
||||
}
|
||||
|
||||
quint64 TransactionInfo::blockHeight() const
|
||||
|
||||
@@ -10,8 +10,8 @@ class TransactionInfo : public QObject
|
||||
Q_PROPERTY(Direction direction READ direction)
|
||||
Q_PROPERTY(bool isPending READ isPending)
|
||||
Q_PROPERTY(bool isFailed READ isFailed)
|
||||
Q_PROPERTY(quint64 amount READ amount)
|
||||
Q_PROPERTY(quint64 fee READ fee)
|
||||
Q_PROPERTY(QString amount READ amount)
|
||||
Q_PROPERTY(QString fee READ fee)
|
||||
Q_PROPERTY(quint64 blockHeight READ blockHeight)
|
||||
Q_PROPERTY(QString hash READ hash)
|
||||
Q_PROPERTY(QString timestamp READ timestamp)
|
||||
@@ -23,6 +23,8 @@ public:
|
||||
Direction_Out = Bitmonero::TransactionInfo::Direction_Out
|
||||
};
|
||||
|
||||
Q_ENUM(Direction)
|
||||
|
||||
// TODO: implement as separate class;
|
||||
|
||||
// struct Transfer {
|
||||
@@ -30,11 +32,12 @@ public:
|
||||
// const uint64_t amount;
|
||||
// const std::string address;
|
||||
// };
|
||||
|
||||
Direction direction() const;
|
||||
bool isPending() const;
|
||||
bool isFailed() const;
|
||||
quint64 amount() const;
|
||||
quint64 fee() const;
|
||||
QString amount() const;
|
||||
QString fee() const;
|
||||
quint64 blockHeight() const;
|
||||
//! transaction_id
|
||||
QString hash() const;
|
||||
@@ -51,4 +54,7 @@ private:
|
||||
Bitmonero::TransactionInfo * m_pimpl;
|
||||
};
|
||||
|
||||
// in order to wrap it to QVariant
|
||||
Q_DECLARE_METATYPE(TransactionInfo*)
|
||||
|
||||
#endif // TRANSACTIONINFO_H
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "Wallet.h"
|
||||
#include "PendingTransaction.h"
|
||||
#include "TransactionHistory.h"
|
||||
#include "model/TransactionHistoryModel.h"
|
||||
#include "wallet/wallet2_api.h"
|
||||
|
||||
#include <QFile>
|
||||
@@ -59,7 +60,10 @@ private:
|
||||
Wallet * m_wallet;
|
||||
};
|
||||
|
||||
|
||||
Wallet::Wallet(QObject * parent)
|
||||
: Wallet(nullptr, parent)
|
||||
{
|
||||
}
|
||||
|
||||
QString Wallet::getSeed() const
|
||||
{
|
||||
@@ -202,6 +206,16 @@ TransactionHistory *Wallet::history()
|
||||
return m_history;
|
||||
}
|
||||
|
||||
TransactionHistoryModel *Wallet::historyModel()
|
||||
{
|
||||
if (!m_historyModel) {
|
||||
m_historyModel = new TransactionHistoryModel(this);
|
||||
m_historyModel->setTransactionHistory(this->history());
|
||||
}
|
||||
|
||||
return m_historyModel;
|
||||
}
|
||||
|
||||
|
||||
QString Wallet::generatePaymentId() const
|
||||
{
|
||||
@@ -228,6 +242,7 @@ Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_walletImpl(w)
|
||||
, m_history(nullptr)
|
||||
, m_historyModel(nullptr)
|
||||
, m_daemonBlockChainHeight(0)
|
||||
, m_daemonBlockChainHeightTtl(DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS)
|
||||
{
|
||||
@@ -236,5 +251,6 @@ Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent)
|
||||
|
||||
Wallet::~Wallet()
|
||||
{
|
||||
|
||||
Bitmonero::WalletManagerFactory::getWalletManager()->closeWallet(m_walletImpl);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Bitmonero {
|
||||
|
||||
|
||||
class TransactionHistory;
|
||||
class TransactionHistoryModel;
|
||||
|
||||
class Wallet : public QObject
|
||||
{
|
||||
@@ -27,8 +28,11 @@ class Wallet : public QObject
|
||||
Q_PROPERTY(quint64 unlockedBalance READ unlockedBalance)
|
||||
Q_PROPERTY(TransactionHistory * history READ history)
|
||||
Q_PROPERTY(QString paymentId READ paymentId WRITE setPaymentId)
|
||||
Q_PROPERTY(TransactionHistoryModel * historyModel READ historyModel)
|
||||
|
||||
public:
|
||||
|
||||
|
||||
enum Status {
|
||||
Status_Ok = Bitmonero::Wallet::Status_Ok,
|
||||
Status_Error = Bitmonero::Wallet::Status_Error
|
||||
@@ -111,6 +115,9 @@ public:
|
||||
//! returns transaction history
|
||||
TransactionHistory * history();
|
||||
|
||||
//! returns transaction history model
|
||||
TransactionHistoryModel * historyModel();
|
||||
|
||||
//! generate payment id
|
||||
Q_INVOKABLE QString generatePaymentId() const;
|
||||
|
||||
@@ -139,9 +146,9 @@ signals:
|
||||
|
||||
|
||||
private:
|
||||
Wallet(QObject * parent = nullptr);
|
||||
Wallet(Bitmonero::Wallet *w, QObject * parent = 0);
|
||||
~Wallet();
|
||||
|
||||
private:
|
||||
friend class WalletManager;
|
||||
friend class WalletListenerImpl;
|
||||
@@ -149,6 +156,8 @@ private:
|
||||
Bitmonero::Wallet * m_walletImpl;
|
||||
// history lifetime managed by wallet;
|
||||
TransactionHistory * m_history;
|
||||
// Used for UI history view
|
||||
TransactionHistoryModel * m_historyModel;
|
||||
QString m_paymentId;
|
||||
mutable QTime m_daemonBlockChainHeightTime;
|
||||
mutable quint64 m_daemonBlockChainHeight;
|
||||
@@ -156,4 +165,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // WALLET_H
|
||||
|
||||
Reference in New Issue
Block a user