From 869f54b6a2ee2bb3931d5e7f23d43fdf5b942f40 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 1 Mar 2014 13:36:36 +0000 Subject: [PATCH] QML txCount. --- walleth/MainWin.cpp | 8 ++++---- walleth/MainWin.h | 8 +++++--- walleth/Simple.qml | 8 ++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/walleth/MainWin.cpp b/walleth/MainWin.cpp index 84f432413..c3ee9f0fc 100644 --- a/walleth/MainWin.cpp +++ b/walleth/MainWin.cpp @@ -112,7 +112,7 @@ u256 QAccount::balance() const return 0; } -uint64_t QAccount::txCount() const +double QAccount::txCount() const { if (m_eth) return m_eth->txCountAt(m_address); @@ -162,9 +162,9 @@ void QEthereum::setListening(bool _l) client()->stopNetwork(); } -uint64_t QEthereum::txCountAt(Address _a) const +double QEthereum::txCountAt(Address _a) const { - return (uint64_t)client()->postState().transactionsFrom(_a); + return (double)client()->postState().transactionsFrom(_a); } unsigned QEthereum::peerCount() const @@ -263,7 +263,7 @@ void Main::timerEvent(QTimerEvent *) void Main::on_about_triggered() { - QMessageBox::about(this, "About Walleth PoC-" + QString(ETH_QUOTED(ETH_VERSION)).section('.', 1, 1), "Walleth/v" ETH_QUOTED(ETH_VERSION) "/" ETH_QUOTED(ETH_BUILD_TYPE) "/" ETH_QUOTED(ETH_BUILD_PLATFORM) "\nBy Gav Wood, 2014.\nBased on a design by Vitalik Buterin.\n\nTeam Ethereum++ includes: Tim Hughes, Eric Lombrozo, Marko Simovic, Alex Leverington and several others."); + QMessageBox::about(this, "About Walleth PoC-" + QString(ETH_QUOTED(ETH_VERSION)).section('.', 1, 1), "Walleth/v" ETH_QUOTED(ETH_VERSION) "/" ETH_QUOTED(ETH_BUILD_TYPE) "/" ETH_QUOTED(ETH_BUILD_PLATFORM) " - " ETH_QUOTED(ETH_COMMIT_HASH) "\nBy Gav Wood, 2014.\nBased on a design by Vitalik Buterin.\n\nTeam Ethereum++ includes: Tim Hughes, Eric Lombrozo, Marko Simovic, Alex Leverington and several others."); } void Main::writeSettings() diff --git a/walleth/MainWin.h b/walleth/MainWin.h index 4df12e3a2..5da39b7d1 100644 --- a/walleth/MainWin.h +++ b/walleth/MainWin.h @@ -56,6 +56,8 @@ public: Q_INVOKABLE double toFinney(eth::u256 _t) const { return toWei(_t) / (double)eth::finney; } Q_INVOKABLE double toEther(eth::u256 _t) const { return toWei(_t) / (double)eth::ether; } + Q_INVOKABLE double value(eth::u256 _t) const { return (double)_t; } + Q_INVOKABLE QString stringOf(eth::u256 _t) const { return QString::fromStdString(eth::formatBalance(_t)); } }; @@ -88,7 +90,7 @@ public: Q_INVOKABLE QEthereum* ethereum() const { return m_eth; } Q_INVOKABLE eth::u256 balance() const; - Q_INVOKABLE uint64_t txCount() const; + Q_INVOKABLE double txCount() const; Q_INVOKABLE bool isContract() const; // TODO: past transactions models. @@ -105,7 +107,7 @@ private: eth::Address m_address; Q_PROPERTY(eth::u256 balance READ balance NOTIFY changed STORED false) - Q_PROPERTY(uint64_t txCount READ txCount NOTIFY changed STORED false) + Q_PROPERTY(double txCount READ txCount NOTIFY changed STORED false) Q_PROPERTY(bool isContract READ isContract NOTIFY changed STORED false) Q_PROPERTY(eth::Address address MEMBER m_address NOTIFY changed) Q_PROPERTY(QEthereum* ethereum READ ethereum WRITE setEthereum NOTIFY ethChanged) @@ -130,7 +132,7 @@ public: Q_INVOKABLE bool isMining() const; Q_INVOKABLE eth::u256 balanceAt(eth::Address _a) const; - Q_INVOKABLE uint64_t txCountAt(eth::Address _a) const; + Q_INVOKABLE double txCountAt(eth::Address _a) const; Q_INVOKABLE bool isContractAt(eth::Address _a) const; Q_INVOKABLE unsigned peerCount() const; diff --git a/walleth/Simple.qml b/walleth/Simple.qml index c56a7e870..53cb7def4 100644 --- a/walleth/Simple.qml +++ b/walleth/Simple.qml @@ -10,9 +10,9 @@ Item { anchors.fill: parent anchors.margins: 9 - Qt.application.name: "Walleth" - Qt.application.organization: "Ethereum" - Qt.application.domain: "org.ethereum" +// Qt.application.name: "Walleth" +// Qt.application.organization: "Ethereum" +// Qt.application.domain: "org.ethereum" Ethereum { id: eth @@ -30,7 +30,7 @@ Item { // KeyPair provides makeTransaction(recvAddress, value, data (array)) Text { - text: "Balance: " + Balance.stringOf(myAccount.balance) + "[" + myAccount.txCount + "]" + "\nAccount: " + Key.stringOf(myAccount.address) + text: "Balance: " + Balance.stringOf(myAccount.balance) + " [" + myAccount.txCount + "]" + "\nAccount: " + Key.stringOf(myAccount.address) Layout.minimumHeight: 30 Layout.fillHeight: true Layout.fillWidth: true