mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-25 04:59:27 +00:00
added TransactionHistoryModel; renamings
This commit is contained in:
parent
bd8646dd19
commit
0ff3fd3212
22 changed files with 256 additions and 46 deletions
|
@ -252,17 +252,17 @@ Rectangle {
|
||||||
panel.receiveClicked()
|
panel.receiveClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.leftMargin: 16
|
anchors.leftMargin: 16
|
||||||
color: transferButton.checked || historyButton.checked ? "#1C1C1C" : "#505050"
|
color: transferButton.checked || historyButton.checked ? "#1C1C1C" : "#505050"
|
||||||
height: 1
|
height: 1
|
||||||
}*/
|
}
|
||||||
|
|
||||||
// ------------- History tab ---------------
|
// ------------- History tab ---------------
|
||||||
/*
|
|
||||||
MenuButton {
|
MenuButton {
|
||||||
id: historyButton
|
id: historyButton
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
@ -276,7 +276,7 @@ Rectangle {
|
||||||
panel.historyClicked()
|
panel.historyClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import QtQuick 2.2
|
import QtQuick 2.2
|
||||||
|
import QtQml 2.0
|
||||||
|
import QtQuick.Controls 2.0
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
@ -73,6 +75,18 @@ Rectangle {
|
||||||
Rectangle { height: 4; width: parent.width / 5; color: "#FF4F41" }
|
Rectangle { height: 4; width: parent.width / 5; color: "#FF4F41" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: replace loader with StackView
|
||||||
|
|
||||||
|
// StackView {
|
||||||
|
// id: stackView
|
||||||
|
// anchors.left: parent.left
|
||||||
|
// anchors.right: parent.right
|
||||||
|
// anchors.top: styledRow.bottom
|
||||||
|
// anchors.bottom: parent.bottom
|
||||||
|
// }
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: loader
|
id: loader
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import moneroComponents 1.0
|
import moneroComponents.Clipboard 1.0
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: listView
|
id: listView
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import moneroComponents 1.0
|
import moneroComponents.Clipboard 1.0
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: listView
|
id: listView
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import moneroComponents 1.0
|
import moneroComponents.Clipboard 1.0
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: listView
|
id: listView
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
MONERO_URL=https://github.com/monero-project/monero.git
|
# MONERO_URL=https://github.com/monero-project/monero.git
|
||||||
MONERO_BRANCH=master
|
# MONERO_BRANCH=master
|
||||||
# MONERO_URL=https://github.com/mbg033/monero.git
|
MONERO_URL=https://github.com/mbg033/monero.git
|
||||||
# MONERO_BRANCH=develop
|
MONERO_BRANCH=develop
|
||||||
# thanks to SO: http://stackoverflow.com/a/20283965/4118915
|
# thanks to SO: http://stackoverflow.com/a/20283965/4118915
|
||||||
CPU_CORE_COUNT=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu)
|
CPU_CORE_COUNT=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu)
|
||||||
pushd $(pwd)
|
pushd $(pwd)
|
||||||
|
|
13
main.cpp
13
main.cpp
|
@ -39,7 +39,7 @@
|
||||||
#include "Wallet.h"
|
#include "Wallet.h"
|
||||||
#include "PendingTransaction.h"
|
#include "PendingTransaction.h"
|
||||||
#include "TranslationManager.h"
|
#include "TranslationManager.h"
|
||||||
|
#include "model/TransactionHistoryModel.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,14 +56,15 @@ int main(int argc, char *argv[])
|
||||||
filter *eventFilter = new filter;
|
filter *eventFilter = new filter;
|
||||||
app.installEventFilter(eventFilter);
|
app.installEventFilter(eventFilter);
|
||||||
|
|
||||||
qmlRegisterType<clipboardAdapter>("moneroComponents", 1, 0, "Clipboard");
|
qmlRegisterType<clipboardAdapter>("moneroComponents.Clipboard", 1, 0, "Clipboard");
|
||||||
|
|
||||||
qmlRegisterUncreatableType<Wallet>("Bitmonero.Wallet", 1, 0, "Wallet", "Wallet can't be instantiated directly");
|
qmlRegisterUncreatableType<Wallet>("moneroComponents.Wallet", 1, 0, "Wallet", "Wallet can't be instantiated directly");
|
||||||
|
|
||||||
qmlRegisterUncreatableType<PendingTransaction>("Bitmonero.PendingTransaction", 1, 0, "PendingTransaction",
|
|
||||||
|
qmlRegisterUncreatableType<PendingTransaction>("moneroComponents.PendingTransaction", 1, 0, "PendingTransaction",
|
||||||
"PendingTransaction can't be instantiated directly");
|
"PendingTransaction can't be instantiated directly");
|
||||||
|
|
||||||
qmlRegisterUncreatableType<WalletManager>("Bitmonero.WalletManager", 1, 0, "WalletManager",
|
qmlRegisterUncreatableType<WalletManager>("moneroComponents.WalletManager", 1, 0, "WalletManager",
|
||||||
"WalletManager can't be instantiated directly");
|
"WalletManager can't be instantiated directly");
|
||||||
|
|
||||||
qmlRegisterUncreatableType<TranslationManager>("moneroComponents", 1, 0, "TranslationManager",
|
qmlRegisterUncreatableType<TranslationManager>("moneroComponents", 1, 0, "TranslationManager",
|
||||||
|
@ -72,6 +73,8 @@ int main(int argc, char *argv[])
|
||||||
qRegisterMetaType<PendingTransaction::Priority>();
|
qRegisterMetaType<PendingTransaction::Priority>();
|
||||||
|
|
||||||
|
|
||||||
|
qmlRegisterUncreatableType<TransactionHistoryModel>("moneroComponents", 1, 0, "TransactionHistoryModel",
|
||||||
|
"TranslationManager can't be instantiated directly");
|
||||||
|
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
|
|
7
main.qml
7
main.qml
|
@ -32,8 +32,9 @@ import QtQuick.Controls 1.1
|
||||||
import QtQuick.Controls.Styles 1.1
|
import QtQuick.Controls.Styles 1.1
|
||||||
import QtQuick.Dialogs 1.2
|
import QtQuick.Dialogs 1.2
|
||||||
import Qt.labs.settings 1.0
|
import Qt.labs.settings 1.0
|
||||||
import Bitmonero.Wallet 1.0
|
|
||||||
import Bitmonero.PendingTransaction 1.0
|
import moneroComponents.Wallet 1.0
|
||||||
|
import moneroComponents.PendingTransaction 1.0
|
||||||
|
|
||||||
|
|
||||||
import "components"
|
import "components"
|
||||||
|
@ -146,7 +147,7 @@ ApplicationWindow {
|
||||||
} else {
|
} else {
|
||||||
var wallet_path = walletPath();
|
var wallet_path = walletPath();
|
||||||
// console.log("opening wallet at: ", wallet_path, "with password: ", appWindow.password);
|
// console.log("opening wallet at: ", wallet_path, "with password: ", appWindow.password);
|
||||||
console.log("opening wallet at: ", wallet_path);
|
console.log("opening wallet at: ", wallet_path, ", testnet: ", persistentSettings.testnet);
|
||||||
walletManager.openWalletAsync(wallet_path, appWindow.password,
|
walletManager.openWalletAsync(wallet_path, appWindow.password,
|
||||||
persistentSettings.testnet);
|
persistentSettings.testnet);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,8 @@ CONFIG += c++11
|
||||||
QMAKE_DISTCLEAN += -r $$WALLET_ROOT
|
QMAKE_DISTCLEAN += -r $$WALLET_ROOT
|
||||||
|
|
||||||
INCLUDEPATH += $$WALLET_ROOT/include \
|
INCLUDEPATH += $$WALLET_ROOT/include \
|
||||||
$$PWD/src/libwalletqt
|
$$PWD/src/libwalletqt \
|
||||||
|
$$PWD/src
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
filter.h \
|
filter.h \
|
||||||
|
@ -22,7 +23,8 @@ HEADERS += \
|
||||||
src/libwalletqt/TransactionHistory.h \
|
src/libwalletqt/TransactionHistory.h \
|
||||||
src/libwalletqt/TransactionInfo.h \
|
src/libwalletqt/TransactionInfo.h \
|
||||||
oshelper.h \
|
oshelper.h \
|
||||||
TranslationManager.h
|
TranslationManager.h \
|
||||||
|
src/model/TransactionHistoryModel.h
|
||||||
|
|
||||||
|
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
|
@ -35,7 +37,8 @@ SOURCES += main.cpp \
|
||||||
src/libwalletqt/TransactionHistory.cpp \
|
src/libwalletqt/TransactionHistory.cpp \
|
||||||
src/libwalletqt/TransactionInfo.cpp \
|
src/libwalletqt/TransactionInfo.cpp \
|
||||||
oshelper.cpp \
|
oshelper.cpp \
|
||||||
TranslationManager.cpp
|
TranslationManager.cpp \
|
||||||
|
src/model/TransactionHistoryModel.cpp
|
||||||
|
|
||||||
lupdate_only {
|
lupdate_only {
|
||||||
SOURCES = *.qml \
|
SOURCES = *.qml \
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import "../components"
|
import "../components"
|
||||||
|
import moneroComponents.Wallet 1.0
|
||||||
|
import moneroComponents.WalletManager 1.0
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
color: "#F0EEEE"
|
color: "#F0EEEE"
|
||||||
|
|
|
@ -32,7 +32,7 @@ import QtQuick.Controls.Styles 1.4
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
|
|
||||||
import "../components"
|
import "../components"
|
||||||
import moneroComponents 1.0
|
import moneroComponents.Clipboard 1.0
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import Bitmonero.PendingTransaction 1.0
|
import moneroComponents.PendingTransaction 1.0
|
||||||
import "../components"
|
import "../components"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,6 @@
|
||||||
#include <wallet/wallet2_api.h>
|
#include <wallet/wallet2_api.h>
|
||||||
|
|
||||||
|
|
||||||
int TransactionHistory::count() const
|
|
||||||
{
|
|
||||||
return m_pimpl->count();
|
|
||||||
}
|
|
||||||
|
|
||||||
TransactionInfo *TransactionHistory::transaction(int index)
|
TransactionInfo *TransactionHistory::transaction(int index)
|
||||||
{
|
{
|
||||||
// box up Bitmonero::TransactionInfo
|
// box up Bitmonero::TransactionInfo
|
||||||
|
@ -39,10 +34,17 @@ QList<TransactionInfo *> TransactionHistory::getAll() const
|
||||||
void TransactionHistory::refresh()
|
void TransactionHistory::refresh()
|
||||||
{
|
{
|
||||||
// XXX this invalidates previously saved history that might be used by clients
|
// XXX this invalidates previously saved history that might be used by clients
|
||||||
|
emit refreshStarted();
|
||||||
m_pimpl->refresh();
|
m_pimpl->refresh();
|
||||||
emit invalidated();
|
emit refreshFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quint64 TransactionHistory::count() const
|
||||||
|
{
|
||||||
|
return m_pimpl->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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,14 +16,15 @@ class TransactionHistory : public QObject
|
||||||
Q_PROPERTY(int count READ count)
|
Q_PROPERTY(int count READ count)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int count() const;
|
|
||||||
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;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void invalidated();
|
void refreshStarted();
|
||||||
|
void refreshFinished();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "TransactionInfo.h"
|
#include "TransactionInfo.h"
|
||||||
|
#include "WalletManager.h"
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
TransactionInfo::Direction TransactionInfo::direction() const
|
TransactionInfo::Direction TransactionInfo::direction() const
|
||||||
|
@ -16,15 +18,15 @@ bool TransactionInfo::isFailed() const
|
||||||
return m_pimpl->isFailed();
|
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
|
quint64 TransactionInfo::blockHeight() const
|
||||||
|
|
|
@ -10,8 +10,8 @@ class TransactionInfo : public QObject
|
||||||
Q_PROPERTY(Direction direction READ direction)
|
Q_PROPERTY(Direction direction READ direction)
|
||||||
Q_PROPERTY(bool isPending READ isPending)
|
Q_PROPERTY(bool isPending READ isPending)
|
||||||
Q_PROPERTY(bool isFailed READ isFailed)
|
Q_PROPERTY(bool isFailed READ isFailed)
|
||||||
Q_PROPERTY(quint64 amount READ amount)
|
Q_PROPERTY(QString amount READ amount)
|
||||||
Q_PROPERTY(quint64 fee READ fee)
|
Q_PROPERTY(QString fee READ fee)
|
||||||
Q_PROPERTY(quint64 blockHeight READ blockHeight)
|
Q_PROPERTY(quint64 blockHeight READ blockHeight)
|
||||||
Q_PROPERTY(QString hash READ hash)
|
Q_PROPERTY(QString hash READ hash)
|
||||||
Q_PROPERTY(QString timestamp READ timestamp)
|
Q_PROPERTY(QString timestamp READ timestamp)
|
||||||
|
@ -23,6 +23,8 @@ public:
|
||||||
Direction_Out = Bitmonero::TransactionInfo::Direction_Out
|
Direction_Out = Bitmonero::TransactionInfo::Direction_Out
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_ENUM(Direction)
|
||||||
|
|
||||||
// TODO: implement as separate class;
|
// TODO: implement as separate class;
|
||||||
|
|
||||||
// struct Transfer {
|
// struct Transfer {
|
||||||
|
@ -30,11 +32,12 @@ public:
|
||||||
// const uint64_t amount;
|
// const uint64_t amount;
|
||||||
// const std::string address;
|
// const std::string address;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
Direction direction() const;
|
Direction direction() const;
|
||||||
bool isPending() const;
|
bool isPending() const;
|
||||||
bool isFailed() const;
|
bool isFailed() const;
|
||||||
quint64 amount() const;
|
QString amount() const;
|
||||||
quint64 fee() const;
|
QString fee() const;
|
||||||
quint64 blockHeight() const;
|
quint64 blockHeight() const;
|
||||||
//! transaction_id
|
//! transaction_id
|
||||||
QString hash() const;
|
QString hash() const;
|
||||||
|
@ -51,4 +54,7 @@ private:
|
||||||
Bitmonero::TransactionInfo * m_pimpl;
|
Bitmonero::TransactionInfo * m_pimpl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// in order to wrap it to QVariant
|
||||||
|
Q_DECLARE_METATYPE(TransactionInfo*)
|
||||||
|
|
||||||
#endif // TRANSACTIONINFO_H
|
#endif // TRANSACTIONINFO_H
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "Wallet.h"
|
#include "Wallet.h"
|
||||||
#include "PendingTransaction.h"
|
#include "PendingTransaction.h"
|
||||||
#include "TransactionHistory.h"
|
#include "TransactionHistory.h"
|
||||||
|
#include "model/TransactionHistoryModel.h"
|
||||||
#include "wallet/wallet2_api.h"
|
#include "wallet/wallet2_api.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
@ -59,7 +60,10 @@ private:
|
||||||
Wallet * m_wallet;
|
Wallet * m_wallet;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Wallet::Wallet(QObject * parent)
|
||||||
|
: Wallet(nullptr, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
QString Wallet::getSeed() const
|
QString Wallet::getSeed() const
|
||||||
{
|
{
|
||||||
|
@ -202,6 +206,16 @@ TransactionHistory *Wallet::history()
|
||||||
return m_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
|
QString Wallet::generatePaymentId() const
|
||||||
{
|
{
|
||||||
|
@ -228,6 +242,7 @@ Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_walletImpl(w)
|
, m_walletImpl(w)
|
||||||
, m_history(nullptr)
|
, m_history(nullptr)
|
||||||
|
, m_historyModel(nullptr)
|
||||||
, m_daemonBlockChainHeight(0)
|
, m_daemonBlockChainHeight(0)
|
||||||
, m_daemonBlockChainHeightTtl(DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS)
|
, m_daemonBlockChainHeightTtl(DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS)
|
||||||
{
|
{
|
||||||
|
@ -236,5 +251,6 @@ Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent)
|
||||||
|
|
||||||
Wallet::~Wallet()
|
Wallet::~Wallet()
|
||||||
{
|
{
|
||||||
|
|
||||||
Bitmonero::WalletManagerFactory::getWalletManager()->closeWallet(m_walletImpl);
|
Bitmonero::WalletManagerFactory::getWalletManager()->closeWallet(m_walletImpl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace Bitmonero {
|
||||||
|
|
||||||
|
|
||||||
class TransactionHistory;
|
class TransactionHistory;
|
||||||
|
class TransactionHistoryModel;
|
||||||
|
|
||||||
class Wallet : public QObject
|
class Wallet : public QObject
|
||||||
{
|
{
|
||||||
|
@ -27,8 +28,11 @@ class Wallet : public QObject
|
||||||
Q_PROPERTY(quint64 unlockedBalance READ unlockedBalance)
|
Q_PROPERTY(quint64 unlockedBalance READ unlockedBalance)
|
||||||
Q_PROPERTY(TransactionHistory * history READ history)
|
Q_PROPERTY(TransactionHistory * history READ history)
|
||||||
Q_PROPERTY(QString paymentId READ paymentId WRITE setPaymentId)
|
Q_PROPERTY(QString paymentId READ paymentId WRITE setPaymentId)
|
||||||
|
Q_PROPERTY(TransactionHistoryModel * historyModel READ historyModel)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
enum Status {
|
enum Status {
|
||||||
Status_Ok = Bitmonero::Wallet::Status_Ok,
|
Status_Ok = Bitmonero::Wallet::Status_Ok,
|
||||||
Status_Error = Bitmonero::Wallet::Status_Error
|
Status_Error = Bitmonero::Wallet::Status_Error
|
||||||
|
@ -111,6 +115,9 @@ public:
|
||||||
//! returns transaction history
|
//! returns transaction history
|
||||||
TransactionHistory * history();
|
TransactionHistory * history();
|
||||||
|
|
||||||
|
//! returns transaction history model
|
||||||
|
TransactionHistoryModel * historyModel();
|
||||||
|
|
||||||
//! generate payment id
|
//! generate payment id
|
||||||
Q_INVOKABLE QString generatePaymentId() const;
|
Q_INVOKABLE QString generatePaymentId() const;
|
||||||
|
|
||||||
|
@ -139,9 +146,9 @@ signals:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Wallet(QObject * parent = nullptr);
|
||||||
Wallet(Bitmonero::Wallet *w, QObject * parent = 0);
|
Wallet(Bitmonero::Wallet *w, QObject * parent = 0);
|
||||||
~Wallet();
|
~Wallet();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class WalletManager;
|
friend class WalletManager;
|
||||||
friend class WalletListenerImpl;
|
friend class WalletListenerImpl;
|
||||||
|
@ -149,6 +156,8 @@ private:
|
||||||
Bitmonero::Wallet * m_walletImpl;
|
Bitmonero::Wallet * m_walletImpl;
|
||||||
// history lifetime managed by wallet;
|
// history lifetime managed by wallet;
|
||||||
TransactionHistory * m_history;
|
TransactionHistory * m_history;
|
||||||
|
// Used for UI history view
|
||||||
|
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;
|
||||||
|
@ -156,4 +165,6 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // WALLET_H
|
#endif // WALLET_H
|
||||||
|
|
102
src/model/TransactionHistoryModel.cpp
Normal file
102
src/model/TransactionHistoryModel.cpp
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
#include "TransactionHistoryModel.h"
|
||||||
|
#include "TransactionHistory.h"
|
||||||
|
#include "TransactionInfo.h"
|
||||||
|
|
||||||
|
|
||||||
|
TransactionHistoryModel::TransactionHistoryModel(QObject *parent)
|
||||||
|
: QAbstractListModel(parent), m_transactionHistory(nullptr)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransactionHistoryModel::setTransactionHistory(TransactionHistory *th)
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
m_transactionHistory = th;
|
||||||
|
endResetModel();
|
||||||
|
emit transactionHistoryChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
TransactionHistory *TransactionHistoryModel::transactionHistory() const
|
||||||
|
{
|
||||||
|
return m_transactionHistory;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant TransactionHistoryModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if (!m_transactionHistory) {
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index.row() < 0 || (unsigned)index.row() >= m_transactionHistory->count()) {
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
TransactionInfo * tInfo = m_transactionHistory->transaction(index.row());
|
||||||
|
|
||||||
|
|
||||||
|
Q_ASSERT(tInfo);
|
||||||
|
if (!tInfo) {
|
||||||
|
qCritical("%s: internal error: no transaction info for index %d", __FUNCTION__, index.row());
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
QVariant result;
|
||||||
|
switch (role) {
|
||||||
|
case TransactionRole:
|
||||||
|
result = QVariant::fromValue(tInfo);
|
||||||
|
break;
|
||||||
|
case TransactionDirectionRole:
|
||||||
|
result = QVariant::fromValue(tInfo->direction());
|
||||||
|
break;
|
||||||
|
case TransactionPendingRole:
|
||||||
|
result = tInfo->isPending();
|
||||||
|
break;
|
||||||
|
case TransactionFailedRole:
|
||||||
|
result = tInfo->isFailed();
|
||||||
|
break;
|
||||||
|
case TransactionAmountRole:
|
||||||
|
result = tInfo->amount();
|
||||||
|
break;
|
||||||
|
case TransactionFeeRole:
|
||||||
|
result = tInfo->fee();
|
||||||
|
break;
|
||||||
|
case TransactionBlockHeightRole:
|
||||||
|
result = tInfo->blockHeight();
|
||||||
|
break;
|
||||||
|
case TransactionHashRole:
|
||||||
|
result = tInfo->hash();
|
||||||
|
break;
|
||||||
|
case TransactionTimeStampRole:
|
||||||
|
result = tInfo->timestamp();
|
||||||
|
break;
|
||||||
|
case TransactionPaymentIdRole:
|
||||||
|
result = tInfo->paymentId();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TransactionHistoryModel::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent)
|
||||||
|
return m_transactionHistory ? m_transactionHistory->count() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
QHash<int, QByteArray> TransactionHistoryModel::roleNames() const
|
||||||
|
{
|
||||||
|
QHash<int, QByteArray> roleNames = QAbstractListModel::roleNames();
|
||||||
|
roleNames.insert(TransactionRole, "transaction");
|
||||||
|
roleNames.insert(TransactionDirectionRole, "direction");
|
||||||
|
roleNames.insert(TransactionPendingRole, "isPending");
|
||||||
|
roleNames.insert(TransactionFailedRole, "isFailed");
|
||||||
|
roleNames.insert(TransactionAmountRole, "amount");
|
||||||
|
roleNames.insert(TransactionFeeRole, "fee");
|
||||||
|
roleNames.insert(TransactionBlockHeightRole, "blockHeight");
|
||||||
|
roleNames.insert(TransactionHashRole, "hash");
|
||||||
|
roleNames.insert(TransactionTimeStampRole, "timeStamp");
|
||||||
|
roleNames.insert(TransactionPaymentIdRole, "paymentId");
|
||||||
|
return roleNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
48
src/model/TransactionHistoryModel.h
Normal file
48
src/model/TransactionHistoryModel.h
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#ifndef TRANSACTIONHISTORYMODEL_H
|
||||||
|
#define TRANSACTIONHISTORYMODEL_H
|
||||||
|
|
||||||
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
|
class TransactionHistory;
|
||||||
|
class TransactionInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The TransactionHistoryModel class - read-only list model for Transaction History
|
||||||
|
*/
|
||||||
|
class TransactionHistoryModel : public QAbstractListModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(TransactionHistory * transactionHistory READ transactionHistory WRITE setTransactionHistory NOTIFY transactionHistoryChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum TransactionInfoRole {
|
||||||
|
TransactionRole = Qt::UserRole + 1, // for the TransactionInfo object;
|
||||||
|
TransactionDirectionRole,
|
||||||
|
TransactionPendingRole,
|
||||||
|
TransactionFailedRole,
|
||||||
|
TransactionAmountRole,
|
||||||
|
TransactionFeeRole,
|
||||||
|
TransactionBlockHeightRole,
|
||||||
|
TransactionHashRole,
|
||||||
|
TransactionTimeStampRole,
|
||||||
|
TransactionPaymentIdRole
|
||||||
|
};
|
||||||
|
|
||||||
|
TransactionHistoryModel(QObject * parent = 0);
|
||||||
|
void setTransactionHistory(TransactionHistory * th);
|
||||||
|
TransactionHistory * transactionHistory() const;
|
||||||
|
|
||||||
|
/// QAbstractListModel
|
||||||
|
virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
|
||||||
|
virtual int rowCount(const QModelIndex & parent = QModelIndex()) const override;
|
||||||
|
virtual QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void transactionHistoryChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
TransactionHistory * m_transactionHistory;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRANSACTIONHISTORYMODEL_H
|
|
@ -1,5 +1,5 @@
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import moneroComponents 1.0
|
import moneroComponents.Clipboard 1.0
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,8 @@
|
||||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import QtQuick 2.2
|
import QtQuick 2.2
|
||||||
import moneroComponents 1.0
|
|
||||||
import QtQuick.Dialogs 1.2
|
import QtQuick.Dialogs 1.2
|
||||||
import Bitmonero.Wallet 1.0
|
import moneroComponents.Wallet 1.0
|
||||||
import 'utils.js' as Utils
|
import 'utils.js' as Utils
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
Loading…
Reference in a new issue