mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-23 19:15:56 +00:00
Transaction history is not crashing and refreshing properly
This commit is contained in:
parent
defc2a414a
commit
0498c3ba64
8 changed files with 74 additions and 45 deletions
|
@ -80,6 +80,7 @@ ListView {
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- description aka recepient name from address book (TODO)
|
// -- description aka recepient name from address book (TODO)
|
||||||
|
/*
|
||||||
Text {
|
Text {
|
||||||
id: descriptionText
|
id: descriptionText
|
||||||
width: text.length ? (descriptionArea.containsMouse ? parent.width - x - 12 : 120) : 0
|
width: text.length ? (descriptionArea.containsMouse ? parent.width - x - 12 : 120) : 0
|
||||||
|
@ -97,12 +98,14 @@ ListView {
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
/*
|
||||||
Item { //separator
|
Item { //separator
|
||||||
width: descriptionText.width ? 12 : 0
|
width: descriptionText.width ? 12 : 0
|
||||||
height: 14
|
height: 14
|
||||||
visible: !descriptionArea.containsMouse
|
visible: !descriptionArea.containsMouse
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// -- address (in case outgoing transaction) - N/A in case of incoming
|
// -- address (in case outgoing transaction) - N/A in case of incoming
|
||||||
Text {
|
Text {
|
||||||
id: addressText
|
id: addressText
|
||||||
|
@ -113,7 +116,7 @@ ListView {
|
||||||
font.pixelSize: 14
|
font.pixelSize: 14
|
||||||
color: "#545454"
|
color: "#545454"
|
||||||
text: hash
|
text: hash
|
||||||
visible: !descriptionArea.containsMouse
|
// visible: !descriptionArea.containsMouse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// -- "PaymentID" title
|
// -- "PaymentID" title
|
||||||
|
|
6
main.cpp
6
main.cpp
|
@ -40,6 +40,7 @@
|
||||||
#include "PendingTransaction.h"
|
#include "PendingTransaction.h"
|
||||||
#include "TranslationManager.h"
|
#include "TranslationManager.h"
|
||||||
#include "TransactionInfo.h"
|
#include "TransactionInfo.h"
|
||||||
|
#include "TransactionHistory.h"
|
||||||
#include "model/TransactionHistoryModel.h"
|
#include "model/TransactionHistoryModel.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,6 +58,7 @@ int main(int argc, char *argv[])
|
||||||
filter *eventFilter = new filter;
|
filter *eventFilter = new filter;
|
||||||
app.installEventFilter(eventFilter);
|
app.installEventFilter(eventFilter);
|
||||||
|
|
||||||
|
// registering types for QML
|
||||||
qmlRegisterType<clipboardAdapter>("moneroComponents.Clipboard", 1, 0, "Clipboard");
|
qmlRegisterType<clipboardAdapter>("moneroComponents.Clipboard", 1, 0, "Clipboard");
|
||||||
|
|
||||||
qmlRegisterUncreatableType<Wallet>("moneroComponents.Wallet", 1, 0, "Wallet", "Wallet can't be instantiated directly");
|
qmlRegisterUncreatableType<Wallet>("moneroComponents.Wallet", 1, 0, "Wallet", "Wallet can't be instantiated directly");
|
||||||
|
@ -77,7 +79,9 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
|
|
||||||
qmlRegisterUncreatableType<TransactionHistoryModel>("moneroComponents", 1, 0, "TransactionHistoryModel",
|
qmlRegisterUncreatableType<TransactionHistoryModel>("moneroComponents", 1, 0, "TransactionHistoryModel",
|
||||||
"TranslationManager can't be instantiated directly");
|
"TransactionHistoryModel can't be instantiated directly");
|
||||||
|
qmlRegisterUncreatableType<TransactionHistory>("moneroComponents", 1, 0, "TransactionHistory",
|
||||||
|
"TransactionHistory can't be instantiated directly");
|
||||||
|
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
|
|
26
main.qml
26
main.qml
|
@ -55,6 +55,8 @@ ApplicationWindow {
|
||||||
property alias password : passwordDialog.password
|
property alias password : passwordDialog.password
|
||||||
property int splashCounter: 0
|
property int splashCounter: 0
|
||||||
property bool isNewWallet: false
|
property bool isNewWallet: false
|
||||||
|
// true if wallet ever synchronized
|
||||||
|
property bool walletInitialized : false
|
||||||
|
|
||||||
function altKeyReleased() { ctrlPressed = false; }
|
function altKeyReleased() { ctrlPressed = false; }
|
||||||
|
|
||||||
|
@ -168,11 +170,10 @@ ApplicationWindow {
|
||||||
currentWallet.refreshed.connect(onWalletRefresh)
|
currentWallet.refreshed.connect(onWalletRefresh)
|
||||||
currentWallet.updated.connect(onWalletUpdate)
|
currentWallet.updated.connect(onWalletUpdate)
|
||||||
currentWallet.newBlock.connect(onWalletNewBlock)
|
currentWallet.newBlock.connect(onWalletNewBlock)
|
||||||
|
currentWallet.moneySpent.connect(onWalletMoneySent)
|
||||||
|
currentWallet.moneyReceived.connect(onWalletMoneyReceived)
|
||||||
console.log("initializing with daemon address: ", persistentSettings.daemon_address)
|
console.log("initializing with daemon address: ", persistentSettings.daemon_address)
|
||||||
|
|
||||||
currentWallet.initAsync(persistentSettings.daemon_address, 0);
|
currentWallet.initAsync(persistentSettings.daemon_address, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function walletPath() {
|
function walletPath() {
|
||||||
|
@ -241,6 +242,13 @@ ApplicationWindow {
|
||||||
console.log("wallet stored after first successfull refresh")
|
console.log("wallet stored after first successfull refresh")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initialize transaction history once wallet is initializef first time;
|
||||||
|
if (!walletInitialized) {
|
||||||
|
currentWallet.history.refresh()
|
||||||
|
walletInitialized = true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
leftPanel.networkStatus.connected = currentWallet.connected
|
leftPanel.networkStatus.connected = currentWallet.connected
|
||||||
|
|
||||||
onWalletUpdate();
|
onWalletUpdate();
|
||||||
|
@ -258,6 +266,18 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onWalletMoneyReceived(txId, amount) {
|
||||||
|
// refresh transaction history here
|
||||||
|
currentWallet.refresh()
|
||||||
|
currentWallet.history.refresh() // this will refresh model
|
||||||
|
}
|
||||||
|
|
||||||
|
function onWalletMoneySent(txId, amount) {
|
||||||
|
// refresh transaction history here
|
||||||
|
currentWallet.refresh()
|
||||||
|
currentWallet.history.refresh() // this will refresh model
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function walletsFound() {
|
function walletsFound() {
|
||||||
|
|
|
@ -33,7 +33,7 @@ import moneroComponents.WalletManager 1.0
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: root
|
id: root
|
||||||
property var model: testModel
|
property var model
|
||||||
|
|
||||||
color: "#F0EEEE"
|
color: "#F0EEEE"
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ Rectangle {
|
||||||
offset: 20
|
offset: 20
|
||||||
onSortRequest: console.log("column: " + column + " desc: " + desc)
|
onSortRequest: console.log("column: " + column + " desc: " + desc)
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
ListModel {
|
ListModel {
|
||||||
id: testModel
|
id: testModel
|
||||||
ListElement { paymentId: "faef56b9acf67a7dba75ec01f403497049d7cff111628edfe7b57278554dc798"; address: "faef56b9acf67a7dba75ec01f403497049d7cff111628edfe7b57278554dc798"; date: "Jan 12, 2014"; time: "12:23 <font size='2'>AM</font>"; amount: "0.<font size='2'>000709159241</font>"; balance: "19301.<font size='2'>870709159241</font>"; description: "Client from Australia"; out: false }
|
ListElement { paymentId: "faef56b9acf67a7dba75ec01f403497049d7cff111628edfe7b57278554dc798"; address: "faef56b9acf67a7dba75ec01f403497049d7cff111628edfe7b57278554dc798"; date: "Jan 12, 2014"; time: "12:23 <font size='2'>AM</font>"; amount: "0.<font size='2'>000709159241</font>"; balance: "19301.<font size='2'>870709159241</font>"; description: "Client from Australia"; out: false }
|
||||||
|
@ -354,6 +354,7 @@ Rectangle {
|
||||||
ListElement { paymentId: "faef56b9acf67a7dba75ec01f403497049d7cff111628edfe7b57278554dc798"; address: "faef56b9acf67a7dba75ec01f403497049d7cff111628edfe7b57278554dc798"; date: "Jan 12, 2014"; time: "12:23 <font size='2'>AM</font>"; amount: "0.<font size='2'>000709159241</font>"; balance: "19301.<font size='2'>870709159241</font>"; description: "Client from Australia"; out: false }
|
ListElement { paymentId: "faef56b9acf67a7dba75ec01f403497049d7cff111628edfe7b57278554dc798"; address: "faef56b9acf67a7dba75ec01f403497049d7cff111628edfe7b57278554dc798"; date: "Jan 12, 2014"; time: "12:23 <font size='2'>AM</font>"; amount: "0.<font size='2'>000709159241</font>"; balance: "19301.<font size='2'>870709159241</font>"; description: "Client from Australia"; out: false }
|
||||||
ListElement { paymentId: "faef56b9acf67a7dba75ec01f403497049d7cff111628edfe7b57278554dc798"; address: "faef56b9acf67a7dba75ec01f403497049d7cff111628edfe7b57278554dc798"; date: "Jan 12, 2014"; time: "12:23 <font size='2'>AM</font>"; amount: "0.<font size='2'>000709159241</font>"; balance: "19301.<font size='2'>870709159241</font>"; description: ""; out: false }
|
ListElement { paymentId: "faef56b9acf67a7dba75ec01f403497049d7cff111628edfe7b57278554dc798"; address: "faef56b9acf67a7dba75ec01f403497049d7cff111628edfe7b57278554dc798"; date: "Jan 12, 2014"; time: "12:23 <font size='2'>AM</font>"; amount: "0.<font size='2'>000709159241</font>"; balance: "19301.<font size='2'>870709159241</font>"; description: ""; out: false }
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
Scroll {
|
Scroll {
|
||||||
id: flickableScroll
|
id: flickableScroll
|
||||||
|
|
|
@ -7,54 +7,53 @@
|
||||||
|
|
||||||
TransactionInfo *TransactionHistory::transaction(int index)
|
TransactionInfo *TransactionHistory::transaction(int index)
|
||||||
{
|
{
|
||||||
// box up Bitmonero::TransactionInfo
|
|
||||||
Bitmonero::TransactionInfo * impl = m_pimpl->transaction(index);
|
if (index < 0 || index >= m_tinfo.size()) {
|
||||||
if (!impl) {
|
|
||||||
qCritical("%s: no transaction info for index %d", __FUNCTION__, index);
|
qCritical("%s: no transaction info for index %d", __FUNCTION__, index);
|
||||||
qCritical("%s: there's %d transactions in backend", __FUNCTION__, m_pimpl->count());
|
qCritical("%s: there's %d transactions in backend", __FUNCTION__, m_pimpl->count());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
TransactionInfo * result = new TransactionInfo(impl, this);
|
return m_tinfo.at(index);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionInfo *TransactionHistory::transaction(const QString &id)
|
//// XXX: not sure if this method really needed;
|
||||||
{
|
//TransactionInfo *TransactionHistory::transaction(const QString &id)
|
||||||
// box up Bitmonero::TransactionInfo
|
//{
|
||||||
Bitmonero::TransactionInfo * impl = m_pimpl->transaction(id.toStdString());
|
// return nullptr;
|
||||||
TransactionInfo * result = new TransactionInfo(impl, this);
|
//}
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<TransactionInfo *> TransactionHistory::getAll() const
|
QList<TransactionInfo *> TransactionHistory::getAll() const
|
||||||
{
|
{
|
||||||
|
// XXX this invalidates previously saved history that might be used by model
|
||||||
|
emit refreshStarted();
|
||||||
qDeleteAll(m_tinfo);
|
qDeleteAll(m_tinfo);
|
||||||
m_tinfo.clear();
|
m_tinfo.clear();
|
||||||
TransactionHistory * parent = const_cast<TransactionHistory*>(this);
|
TransactionHistory * parent = const_cast<TransactionHistory*>(this);
|
||||||
for (const auto i : m_pimpl->getAll()) {
|
for (const auto i : m_pimpl->getAll()) {
|
||||||
TransactionInfo * ti = new TransactionInfo(i, parent);
|
TransactionInfo * ti = new TransactionInfo(i, parent);
|
||||||
|
qDebug() << ti->hash();
|
||||||
m_tinfo.append(ti);
|
m_tinfo.append(ti);
|
||||||
}
|
}
|
||||||
|
emit refreshFinished();
|
||||||
return m_tinfo;
|
return m_tinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransactionHistory::refresh()
|
void TransactionHistory::refresh()
|
||||||
{
|
{
|
||||||
// XXX this invalidates previously saved history that might be used by clients
|
// rebuilding transaction list in wallet_api;
|
||||||
|
|
||||||
emit refreshStarted();
|
|
||||||
m_pimpl->refresh();
|
m_pimpl->refresh();
|
||||||
emit refreshFinished();
|
// copying list here and keep track on every item to avoid memleaks
|
||||||
|
getAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 TransactionHistory::count() const
|
quint64 TransactionHistory::count() const
|
||||||
{
|
{
|
||||||
return m_pimpl->count();
|
return m_tinfo.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TransactionHistory::TransactionHistory(Bitmonero::TransactionHistory *pimpl, QObject *parent)
|
TransactionHistory::TransactionHistory(Bitmonero::TransactionHistory *pimpl, QObject *parent)
|
||||||
: QObject(parent), m_pimpl(pimpl)
|
: QObject(parent), m_pimpl(pimpl)
|
||||||
{
|
{
|
||||||
|
// this->refresh();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,14 @@ class TransactionHistory : public QObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Q_INVOKABLE TransactionInfo *transaction(int index);
|
Q_INVOKABLE TransactionInfo *transaction(int index);
|
||||||
Q_INVOKABLE TransactionInfo * transaction(const QString &id);
|
// Q_INVOKABLE TransactionInfo * transaction(const QString &id);
|
||||||
Q_INVOKABLE QList<TransactionInfo*> getAll() const;
|
Q_INVOKABLE QList<TransactionInfo*> getAll() const;
|
||||||
Q_INVOKABLE void refresh();
|
Q_INVOKABLE void refresh();
|
||||||
quint64 count() const;
|
quint64 count() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void refreshStarted();
|
void refreshStarted() const;
|
||||||
void refreshFinished();
|
void refreshFinished() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ public:
|
||||||
|
|
||||||
virtual void moneyReceived(const std::string &txId, uint64_t amount)
|
virtual void moneyReceived(const std::string &txId, uint64_t amount)
|
||||||
{
|
{
|
||||||
|
|
||||||
qDebug() << __FUNCTION__;
|
qDebug() << __FUNCTION__;
|
||||||
emit m_wallet->moneyReceived(QString::fromStdString(txId), amount);
|
emit m_wallet->moneyReceived(QString::fromStdString(txId), amount);
|
||||||
}
|
}
|
||||||
|
@ -40,14 +39,12 @@ public:
|
||||||
virtual void newBlock(uint64_t height)
|
virtual void newBlock(uint64_t height)
|
||||||
{
|
{
|
||||||
// qDebug() << __FUNCTION__;
|
// qDebug() << __FUNCTION__;
|
||||||
m_wallet->m_history->refresh();
|
|
||||||
emit m_wallet->newBlock(height);
|
emit m_wallet->newBlock(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void updated()
|
virtual void updated()
|
||||||
{
|
{
|
||||||
qDebug() << __FUNCTION__;
|
qDebug() << __FUNCTION__;
|
||||||
m_wallet->m_history->refresh();
|
|
||||||
emit m_wallet->updated();
|
emit m_wallet->updated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +52,6 @@ public:
|
||||||
virtual void refreshed()
|
virtual void refreshed()
|
||||||
{
|
{
|
||||||
qDebug() << __FUNCTION__;
|
qDebug() << __FUNCTION__;
|
||||||
|
|
||||||
emit m_wallet->refreshed();
|
emit m_wallet->refreshed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +89,11 @@ bool Wallet::connected() const
|
||||||
return m_walletImpl->connected();
|
return m_walletImpl->connected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Wallet::synchronized() const
|
||||||
|
{
|
||||||
|
return m_walletImpl->synchronized();
|
||||||
|
}
|
||||||
|
|
||||||
QString Wallet::errorString() const
|
QString Wallet::errorString() const
|
||||||
{
|
{
|
||||||
return QString::fromStdString(m_walletImpl->errorString());
|
return QString::fromStdString(m_walletImpl->errorString());
|
||||||
|
@ -207,19 +208,16 @@ void Wallet::disposeTransaction(PendingTransaction *t)
|
||||||
delete t;
|
delete t;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionHistory *Wallet::history()
|
TransactionHistory *Wallet::history() const
|
||||||
{
|
{
|
||||||
// if (m_history->count() == 0) {
|
|
||||||
// m_history->refresh();
|
|
||||||
// }
|
|
||||||
|
|
||||||
return m_history;
|
return m_history;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionHistoryModel *Wallet::historyModel()
|
TransactionHistoryModel *Wallet::historyModel() const
|
||||||
{
|
{
|
||||||
if (!m_historyModel) {
|
if (!m_historyModel) {
|
||||||
m_historyModel = new TransactionHistoryModel(this);
|
Wallet * w = const_cast<Wallet*>(this);
|
||||||
|
m_historyModel = new TransactionHistoryModel(w);
|
||||||
m_historyModel->setTransactionHistory(this->history());
|
m_historyModel->setTransactionHistory(this->history());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ class Wallet : public QObject
|
||||||
Q_PROPERTY(QString seedLanguage READ getSeedLanguage)
|
Q_PROPERTY(QString seedLanguage READ getSeedLanguage)
|
||||||
Q_PROPERTY(Status status READ status)
|
Q_PROPERTY(Status status READ status)
|
||||||
Q_PROPERTY(bool connected READ connected)
|
Q_PROPERTY(bool connected READ connected)
|
||||||
|
Q_PROPERTY(bool synchronized READ synchronized)
|
||||||
Q_PROPERTY(QString errorString READ errorString)
|
Q_PROPERTY(QString errorString READ errorString)
|
||||||
Q_PROPERTY(QString address READ address)
|
Q_PROPERTY(QString address READ address)
|
||||||
Q_PROPERTY(quint64 balance READ balance)
|
Q_PROPERTY(quint64 balance READ balance)
|
||||||
|
@ -52,9 +53,13 @@ public:
|
||||||
//! returns last operation's status
|
//! returns last operation's status
|
||||||
Status status() const;
|
Status status() const;
|
||||||
|
|
||||||
//! returns of wallet connected
|
//! returns true if wallet connected
|
||||||
bool connected() const;
|
bool connected() const;
|
||||||
|
|
||||||
|
//! returns true if wallet was ever synchronized
|
||||||
|
bool synchronized() const;
|
||||||
|
|
||||||
|
|
||||||
//! returns last operation's error message
|
//! returns last operation's error message
|
||||||
QString errorString() const;
|
QString errorString() const;
|
||||||
|
|
||||||
|
@ -98,7 +103,6 @@ public:
|
||||||
//! refreshes the wallet
|
//! refreshes the wallet
|
||||||
Q_INVOKABLE bool refresh();
|
Q_INVOKABLE bool refresh();
|
||||||
|
|
||||||
|
|
||||||
//! refreshes the wallet asynchronously
|
//! refreshes the wallet asynchronously
|
||||||
Q_INVOKABLE void refreshAsync();
|
Q_INVOKABLE void refreshAsync();
|
||||||
|
|
||||||
|
@ -116,10 +120,10 @@ public:
|
||||||
Q_INVOKABLE void disposeTransaction(PendingTransaction * t);
|
Q_INVOKABLE void disposeTransaction(PendingTransaction * t);
|
||||||
|
|
||||||
//! returns transaction history
|
//! returns transaction history
|
||||||
TransactionHistory * history();
|
TransactionHistory * history() const;
|
||||||
|
|
||||||
//! returns transaction history model
|
//! returns transaction history model
|
||||||
TransactionHistoryModel * historyModel();
|
TransactionHistoryModel * historyModel() const;
|
||||||
|
|
||||||
//! generate payment id
|
//! generate payment id
|
||||||
Q_INVOKABLE QString generatePaymentId() const;
|
Q_INVOKABLE QString generatePaymentId() const;
|
||||||
|
@ -160,7 +164,7 @@ private:
|
||||||
// history lifetime managed by wallet;
|
// history lifetime managed by wallet;
|
||||||
TransactionHistory * m_history;
|
TransactionHistory * m_history;
|
||||||
// Used for UI history view
|
// Used for UI history view
|
||||||
TransactionHistoryModel * m_historyModel;
|
mutable TransactionHistoryModel * m_historyModel;
|
||||||
QString m_paymentId;
|
QString m_paymentId;
|
||||||
mutable QTime m_daemonBlockChainHeightTime;
|
mutable QTime m_daemonBlockChainHeightTime;
|
||||||
mutable quint64 m_daemonBlockChainHeight;
|
mutable quint64 m_daemonBlockChainHeight;
|
||||||
|
|
Loading…
Reference in a new issue