diff --git a/CellFrameDashboardGUI/DapServiceController.cpp b/CellFrameDashboardGUI/DapServiceController.cpp index 5502b5a01717b571477e9f5db7d7c259225db5e9..baeed08f01062ffa0369f83da373db4eacb2f41f 100644 --- a/CellFrameDashboardGUI/DapServiceController.cpp +++ b/CellFrameDashboardGUI/DapServiceController.cpp @@ -57,6 +57,11 @@ void DapServiceController::setIndexCurrentNetwork(int iIndexCurrentNetwork) emit indexCurrentNetworkChanged(m_iIndexCurrentNetwork); } +QString DapServiceController::getCurrentChain() const +{ + return (m_sCurrentNetwork == "private") ? "gdb" : "plasma"; +} + /// Get an instance of a class. /// @return Instance of a class. DapServiceController &DapServiceController::getInstance() @@ -122,6 +127,8 @@ void DapServiceController::registerCommand() // Transaction confirmation m_transceivers.append(qMakePair(dynamic_cast<DapAbstractCommand*>(m_DAPRpcSocket->addService(new DapMempoolProcessCommand("DapMempoolProcessCommand",m_DAPRpcSocket))), QString("mempoolProcessed"))); + m_transceivers.append(qMakePair(dynamic_cast<DapAbstractCommand*>(m_DAPRpcSocket->addService(new DapGetWalletHistoryCommand("DapGetWalletHistoryCommand",m_DAPRpcSocket))), QString("historyReceived"))); + connect(this, &DapServiceController::walletsListReceived, [=] (const QVariant& walletList) { QByteArray array = QByteArray::fromHex(walletList.toByteArray()); @@ -143,6 +150,27 @@ void DapServiceController::registerCommand() emit walletsReceived(wallets); }); + connect(this, &DapServiceController::historyReceived, [=] (const QVariant& wallethistory) + { + QByteArray array = QByteArray::fromHex(wallethistory.toByteArray()); + QList<DapWalletHistoryEvent> tempWalletHistory; + + QDataStream in(&array, QIODevice::ReadOnly); + in >> tempWalletHistory; + + QList<QObject*> walletHistory; + auto begin = tempWalletHistory.begin(); + auto end = tempWalletHistory.end(); + DapWalletHistoryEvent * wallethistoryEvent = nullptr; + for(;begin != end; ++begin) + { + wallethistoryEvent = new DapWalletHistoryEvent(*begin); + walletHistory.append(wallethistoryEvent); + } + + emit walletHistoryReceived(walletHistory); + }); + registerEmmitedSignal(); } diff --git a/CellFrameDashboardGUI/DapServiceController.h b/CellFrameDashboardGUI/DapServiceController.h index 93c7c971d2a21c2b70007373e43b3998a705a50a..73103963daae14c9dc99db3d7b695f4d89d24fd5 100644 --- a/CellFrameDashboardGUI/DapServiceController.h +++ b/CellFrameDashboardGUI/DapServiceController.h @@ -24,6 +24,7 @@ #include "Models/DapWalletModel.h" #include "Handlers/DapCreateTransactionCommand.h" #include "Handlers/DapMempoolProcessCommand.h" +#include "Handlers/DapGetWalletHistoryCommand.h" class DapServiceController : public QObject { @@ -80,6 +81,8 @@ public: Q_PROPERTY(QString CurrentNetwork MEMBER m_sVersion READ getCurrentNetwork WRITE setCurrentNetwork NOTIFY currentNetworkChanged) Q_PROPERTY(int IndexCurrentNetwork MEMBER m_iIndexCurrentNetwork READ getIndexCurrentNetwork WRITE setIndexCurrentNetwork NOTIFY indexCurrentNetworkChanged) + + Q_PROPERTY(QString CurrentChain READ getCurrentChain) /// Client controller initialization. /// @param apDapServiceClient Network connection controller. @@ -99,6 +102,8 @@ public: Q_INVOKABLE void setIndexCurrentNetwork(int iIndexCurrentNetwork); + Q_INVOKABLE QString getCurrentChain() const; + signals: /// The signal is emitted when the Brand company property changes. /// @param asBrand Brand @@ -136,6 +141,10 @@ signals: void walletTokensReceived(const QVariant& walletTokens); void indexCurrentNetworkChanged(int iIndexCurrentNetwork); + + void historyReceived(const QVariant& walletHistory); + + void walletHistoryReceived(const QList<QObject*>& walletHistory); private slots: /// Register command. diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardScreenForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardScreenForm.ui.qml index e96b43ce7eee36fc5deda2faf60dd667628ff02c..4317260aeffb9d3e902018dd021d18365a72e1e7 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardScreenForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardScreenForm.ui.qml @@ -22,6 +22,8 @@ DapAbstractScreen property alias dapListViewWallet: listViewWallet + property alias dapNameWalletTitle: titleText + Rectangle { id: titleBlock diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTab.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTab.qml index e39539879b4e4c71aae8350ae0d0f3ed5352e33b..0a900234e7edc1cec98bc2d2d55f2ff3982b47ab 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTab.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTab.qml @@ -27,6 +27,8 @@ DapDashboardTabForm dapDashboardTopPanel.dapComboboxWallet.onCurrentIndexChanged: { dapDashboardScreen.dapListViewWallet.model = dapModelWallets.get(dapDashboardTopPanel.dapComboboxWallet.currentIndex).networks + dapDashboardScreen.dapNameWalletTitle.text = dapWallets[dapDashboardTopPanel.dapComboboxWallet.currentIndex].Name + dapServiceController.requestToService("DapGetWalletHistoryCommand", dapServiceController.CurrentNetwork, dapServiceController.CurrentChain, dapWallets[dapDashboardTopPanel.dapComboboxWallet.currentIndex].findAddress(dapServiceController.CurrentNetwork)); } // Signal-slot connection realizing panel switching depending on predefined rules @@ -36,10 +38,18 @@ DapDashboardTabForm onNextActivated: { currentRightPanel = dapDashboardRightPanel.push(currentRightPanel.dapNextRightPanel); + if(parametrsRightPanel === lastActionsWallet) + { + dapServiceController.requestToService("DapGetWalletHistoryCommand", dapServiceController.CurrentNetwork, dapServiceController.CurrentChain, dapWallets[dapDashboardTopPanel.dapComboboxWallet.currentIndex].findAddress(dapServiceController.CurrentNetwork)); + } } onPreviousActivated: { currentRightPanel = dapDashboardRightPanel.push(currentRightPanel.dapPreviousRightPanel); + if(parametrsRightPanel === lastActionsWallet) + { + dapServiceController.requestToService("DapGetWalletHistoryCommand", dapServiceController.CurrentNetwork, dapServiceController.CurrentChain, dapWallets[dapDashboardTopPanel.dapComboboxWallet.currentIndex].findAddress(dapServiceController.CurrentNetwork)); + } } } @@ -48,7 +58,6 @@ DapDashboardTabForm target: dapMainWindow onModelWalletsUpdated: { - console.log(dapIndexCurrentWallet) dapDashboardTopPanel.dapComboboxWallet.currentIndex = dapIndexCurrentWallet } } diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapLastActionsRightPanel.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapLastActionsRightPanel.qml index 0bb86b51b957a46450a2aac7c9cb13409b3e84df..ec81db590f323c786b517072dc5a86e3cbf637ea 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapLastActionsRightPanel.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapLastActionsRightPanel.qml @@ -9,313 +9,11 @@ DapLastActionsRightPanelForm property date today: new Date() property date yesterday: new Date(new Date().setDate(new Date().getDate()-1)) + property alias dapModelLastActions: modelLastActions + ListModel { - id: modelActions - ListElement - { - name: "Token 2" - status: "Received" - amount: 892.145 - currency: "TKN2" - date: "2020-01-15" - } - ListElement - { - name: "Kelvin" - status: "Received" - amount: 753.987 - currency: "KLVN" - date: "2020-01-14" - } - ListElement - { - name: "NewGold" - status: "Sent" - amount: 300.986 - currency: "NGD" - date: "2020-01-13" - } - ListElement - { - name: "Token 2" - status: "Sent" - amount: 500.986 - currency: "TKN2" - date: "2020-01-13" - } - ListElement - { - name: "Kelvin" - status: "Received" - amount: 753.987 - currency: "KLVN" - date: "2019-12-30" - } - ListElement - { - name: "NewGold" - status: "Sent" - amount: 300.986 - currency: "NGD" - date: "2019-12-30" - } - ListElement - { - name: "Token 2" - status: "Sent" - amount: 500.986 - currency: "TKN2" - date: "2019-12-28" - } - ListElement - { - name: "Kelvin" - status: "Received" - amount: 753.987 - currency: "KLVN" - date: "2019-12-15" - } - ListElement - { - name: "NewGold" - status: "Sent" - amount: 300.986 - currency: "NGD" - date: "2019-11-12" - } - ListElement - { - name: "Token 2" - status: "Sent" - amount: 500.986 - currency: "TKN2" - date: "2019-11-12" - } - ListElement - { - name: "Kelvin" - status: "Received" - amount: 753.987 - currency: "KLVN" - date: "2019-10-05" - } - ListElement - { - name: "NewGold" - status: "Sent" - amount: 300.986 - currency: "NGD" - date: "2019-10-04" - } - ListElement - { - name: "Token 2" - status: "Sent" - amount: 500.986 - currency: "TKN2" - date: "2019-10-04" - } - ListElement - { - name: "Kelvin" - status: "Received" - amount: 753.987 - currency: "KLVN" - date: "2019-10-02" - } - ListElement - { - name: "NewGold" - status: "Sent" - amount: 300.986 - currency: "NGD" - date: "2019-10-01" - } - ListElement - { - name: "Token 2" - status: "Sent" - amount: 500.986 - currency: "TKN2" - date: "2019-08-20" - } - ListElement - { - name: "Kelvin" - status: "Received" - amount: 753.987 - currency: "KLVN" - date: "2019-08-20" - } - ListElement - { - name: "NewGold" - status: "Sent" - amount: 300.986 - currency: "NGD" - date: "2019-08-16" - } - ListElement - { - name: "Token 2" - status: "Sent" - amount: 500.986 - currency: "TKN2" - date: "2019-07-25" - } - ListElement - { - name: "Token 2" - status: "Received" - amount: 892.145 - currency: "TKN2" - date: "2020-01-15" - } - ListElement - { - name: "Kelvin" - status: "Received" - amount: 753.987 - currency: "KLVN" - date: "2020-01-14" - } - ListElement - { - name: "NewGold" - status: "Sent" - amount: 300.986 - currency: "NGD" - date: "2020-01-13" - } - ListElement - { - name: "Token 2" - status: "Sent" - amount: 500.986 - currency: "TKN2" - date: "2020-01-13" - } - ListElement - { - name: "Kelvin" - status: "Received" - amount: 753.987 - currency: "KLVN" - date: "2019-12-30" - } - ListElement - { - name: "NewGold" - status: "Sent" - amount: 300.986 - currency: "NGD" - date: "2019-12-30" - } - ListElement - { - name: "Token 2" - status: "Sent" - amount: 500.986 - currency: "TKN2" - date: "2019-12-28" - } - ListElement - { - name: "Kelvin" - status: "Received" - amount: 753.987 - currency: "KLVN" - date: "2019-12-15" - } - ListElement - { - name: "NewGold" - status: "Sent" - amount: 300.986 - currency: "NGD" - date: "2019-11-12" - } - ListElement - { - name: "Token 2" - status: "Sent" - amount: 500.986 - currency: "TKN2" - date: "2019-11-12" - } - ListElement - { - name: "Kelvin" - status: "Received" - amount: 753.987 - currency: "KLVN" - date: "2019-10-05" - } - ListElement - { - name: "NewGold" - status: "Sent" - amount: 300.986 - currency: "NGD" - date: "2019-10-04" - } - ListElement - { - name: "Token 2" - status: "Sent" - amount: 500.986 - currency: "TKN2" - date: "2019-10-04" - } - ListElement - { - name: "Kelvin" - status: "Received" - amount: 753.987 - currency: "KLVN" - date: "2019-10-02" - } - ListElement - { - name: "NewGold" - status: "Sent" - amount: 300.986 - currency: "NGD" - date: "2019-10-01" - } - ListElement - { - name: "Token 2" - status: "Sent" - amount: 500.986 - currency: "TKN2" - date: "2019-08-20" - } - ListElement - { - name: "Kelvin" - status: "Received" - amount: 753.987 - currency: "KLVN" - date: "2019-08-20" - } - ListElement - { - name: "NewGold" - status: "Sent" - amount: 300.986 - currency: "NGD" - date: "2019-08-16" - } - ListElement - { - name: "Token 2" - status: "Sent" - amount: 500.986 - currency: "TKN2" - date: "2019-07-25" - } + id: modelLastActions } Component @@ -345,6 +43,22 @@ DapLastActionsRightPanelForm } } + Connections + { + target: dapServiceController + onWalletHistoryReceived: + { + modelLastActions.clear() + for (var i = 0; i < walletHistory.length; ++i) + { + modelLastActions.append({ "name" : walletHistory[i].Name, + "amount" : walletHistory[i].Amount, + "status" : walletHistory[i].Status, + "date" : walletHistory[i].Date}) + } + } + } + ////@ Functions for "Today" or "Yesterday" or "Month, Day" or "Month, Day, Year" output function getDateString(date) { diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapLastActionsRightPanelForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapLastActionsRightPanelForm.ui.qml index 001ea7c5d045a1344151cba25a62441ba75f5cdf..696b34d1c898dfd42882171c077a409d70f8f364 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapLastActionsRightPanelForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapLastActionsRightPanelForm.ui.qml @@ -42,7 +42,7 @@ DapAbstractRightPanel id: lastActionsView anchors.fill: parent clip: true - model: modelActions + model: modelLastActions delegate: Rectangle { @@ -66,7 +66,7 @@ DapAbstractRightPanel Text { Layout.fillWidth: true - text: model.name + text: name color: "#3E3853" font.family: "Roboto" font.styleName: "Normal" @@ -78,7 +78,7 @@ DapAbstractRightPanel Text { Layout.fillWidth: true - text: model.status + text: status color: "#757184" font.family: "Roboto" font.styleName: "Normal" @@ -89,13 +89,13 @@ DapAbstractRightPanel Text { - property string sign: (model.status === "Sent") ? "- " : "+ " + property string sign: (status === "Sent") ? "- " : "+ " Layout.fillHeight: true Layout.fillWidth: true horizontalAlignment: Qt.AlignRight verticalAlignment: Qt.AlignVCenter color: "#3E3853" - text: sign + model.amount + " " + model.currency + text: sign + amount + " " + name font.family: "Roboto" font.styleName: "Normal" font.weight: Font.Normal diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentDoneRightPanel.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentDoneRightPanel.qml index c1d95241c0def92a8cc984b2be123b3b9552139e..8141632a14b1b633c63d4028e3c7b55e20a2cb8f 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentDoneRightPanel.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentDoneRightPanel.qml @@ -4,8 +4,7 @@ DapNewPaymentDoneRightPanelForm { dapButtonSend.onClicked: { - var chain = dapServiceController.CurrentNetwork === "private" ? "gdb": "plasma" - dapServiceController.requestToService("DapMempoolProcessCommand", dapServiceController.CurrentNetwork, chain) + dapServiceController.requestToService("DapMempoolProcessCommand", dapServiceController.CurrentNetwork, dapServiceController.CurrentChain) nextActivated("transaction done") } diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanel.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanel.qml index 4ee51ff7c5ccaf5b0e9eeb6bdbc19dd4c741a6d6..01fae4651186df1500cba095d1aac3a77f5c29ce 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanel.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanel.qml @@ -13,8 +13,7 @@ DapNewPaymentMainRightPanelForm dapButtonSend.onClicked: { - var chain = dapServiceController.CurrentNetwork === "private" ? "gdb": "plasma" - dapServiceController.requestToService("DapCreateTransactionCommand", dapServiceController.CurrentNetwork, chain, dapCurrentWallet, dapTextInputRecipientWalletAddress.text, dapCmboBoxToken.currentText, dapTextInputAmountPayment.text) + dapServiceController.requestToService("DapCreateTransactionCommand", dapServiceController.CurrentNetwork, dapServiceController.CurrentChain, dapCurrentWallet, dapTextInputRecipientWalletAddress.text, dapCmboBoxToken.currentText, dapTextInputAmountPayment.text) nextActivated("transaction created") } diff --git a/CellFrameDashboardService/DapServiceController.cpp b/CellFrameDashboardService/DapServiceController.cpp index 90901c36ff0ae9c8eeb5af14eb1540d88a25420b..07f38726c2afa19e0dfe193ed3b6fb4a69ab0e88 100755 --- a/CellFrameDashboardService/DapServiceController.cpp +++ b/CellFrameDashboardService/DapServiceController.cpp @@ -66,6 +66,8 @@ void DapServiceController::registerCommand() m_pServer->addService(new DapCreateTransactionCommand("DapCreateTransactionCommand", m_pServer, CLI_PATH)); // Transaction confirmation m_pServer->addService(new DapMempoolProcessCommand("DapMempoolProcessCommand", m_pServer, CLI_PATH)); + + m_pServer->addService(new DapGetWalletHistoryCommand("DapGetWalletHistoryCommand", m_pServer, CLI_PATH)); } /// Initialize system tray. diff --git a/CellFrameDashboardService/DapServiceController.h b/CellFrameDashboardService/DapServiceController.h index f48be4eac4e2865deeac2dcf144e3e1962613b1a..941b567590fb33339350673e7f8b4f5d1aad2e5d 100755 --- a/CellFrameDashboardService/DapServiceController.h +++ b/CellFrameDashboardService/DapServiceController.h @@ -35,6 +35,7 @@ typedef class DapRpcLocalServer DapUiService; #include "Handlers/DapGetWalletTokenInfoCommand.h" #include "Handlers/DapCreateTransactionCommand.h" #include "Handlers/DapMempoolProcessCommand.h" +#include "Handlers/DapGetWalletHistoryCommand.h" #include "DapSystemTrayIcon.h" #include "DapToolTipWidget.h" diff --git a/libCellFrameDashboardCommon/DapWalletHistoryEvent.cpp b/libCellFrameDashboardCommon/DapWalletHistoryEvent.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0d6a1a5325550a70b762790dd11e412099b59052 --- /dev/null +++ b/libCellFrameDashboardCommon/DapWalletHistoryEvent.cpp @@ -0,0 +1,97 @@ +#include "DapWalletHistoryEvent.h" + +DapWalletHistoryEvent::DapWalletHistoryEvent(QObject *parent) : QObject(parent) +{ + +} + +DapWalletHistoryEvent::DapWalletHistoryEvent(const DapWalletHistoryEvent &aHistoryEvent) + : m_sName(aHistoryEvent.m_sName), m_sStatus(aHistoryEvent.m_sStatus), + m_dAmount(aHistoryEvent.m_dAmount), m_sDate(aHistoryEvent.m_sDate) +{ + +} + +DapWalletHistoryEvent &DapWalletHistoryEvent::operator=(const DapWalletHistoryEvent &aHistoryEvent) +{ + m_sName = aHistoryEvent.m_sName; + m_sStatus = aHistoryEvent.m_sStatus; + m_dAmount = aHistoryEvent.m_dAmount; + m_sDate = aHistoryEvent.m_sDate; + return (*this); +} + +bool DapWalletHistoryEvent::operator==(const DapWalletHistoryEvent &aHistoryEvent) const +{ + return (m_sName == aHistoryEvent.m_sName) + && (m_sStatus == aHistoryEvent.m_sStatus) + && (m_dAmount == aHistoryEvent.m_dAmount) + && (m_sDate == aHistoryEvent.m_sDate); +} + +QString DapWalletHistoryEvent::getName() const +{ + return m_sName; +} + +void DapWalletHistoryEvent::setName(const QString &sName) +{ + m_sName = sName; + + emit nameChanged(m_sName); +} + +double DapWalletHistoryEvent::getAmount() const +{ + return m_dAmount; +} + +void DapWalletHistoryEvent::setAmount(double dAmount) +{ + m_dAmount = dAmount; + + emit amountChanged(m_dAmount); +} + +QString DapWalletHistoryEvent::getStatus() const +{ + return m_sStatus; +} + +void DapWalletHistoryEvent::setStatus(const QString &sStatus) +{ + m_sStatus = sStatus; + + emit statusChanged(m_sStatus); +} + +QString DapWalletHistoryEvent::getDate() const +{ + return m_sDate; +} + +void DapWalletHistoryEvent::setDate(const QString &sDate) +{ + m_sDate = sDate; + + emit dateChanged(m_sDate); +} + +QDataStream& operator << (QDataStream& aOut, const DapWalletHistoryEvent& aHistoryEvent) +{ + aOut << aHistoryEvent.m_sName + << aHistoryEvent.m_dAmount + << aHistoryEvent.m_sStatus + << aHistoryEvent.m_sDate; + return aOut; +} + +QDataStream& operator >> (QDataStream& aOut, DapWalletHistoryEvent& aHistoryEvent) +{ + aOut >> aHistoryEvent.m_sName; + aOut.setFloatingPointPrecision(QDataStream::DoublePrecision); + aOut >> aHistoryEvent.m_dAmount; + aOut >> aHistoryEvent.m_sStatus + >> aHistoryEvent.m_sDate; + return aOut; +} diff --git a/libCellFrameDashboardCommon/DapWalletHistoryEvent.h b/libCellFrameDashboardCommon/DapWalletHistoryEvent.h new file mode 100644 index 0000000000000000000000000000000000000000..6bbb933863f8db39d03c6ee71785b5ad2cc03954 --- /dev/null +++ b/libCellFrameDashboardCommon/DapWalletHistoryEvent.h @@ -0,0 +1,52 @@ +#ifndef DAPWALLETHISTORYEVENT_H +#define DAPWALLETHISTORYEVENT_H + +#include <QObject> +#include <QString> +#include <QDataStream> + +class DapWalletHistoryEvent : public QObject +{ + Q_OBJECT + + /// Token name. + QString m_sName; + /// Token balance. + QString m_sStatus; + + double m_dAmount {0.0}; + + QString m_sDate; + +public: + explicit DapWalletHistoryEvent(QObject *parent = nullptr); + DapWalletHistoryEvent(const DapWalletHistoryEvent& aHistoryEvent); + DapWalletHistoryEvent& operator=(const DapWalletHistoryEvent& aHistoryEvent); + bool operator==(const DapWalletHistoryEvent& aHistoryEvent) const; + + Q_PROPERTY(QString Name MEMBER m_sName READ getName WRITE setName NOTIFY nameChanged) + Q_PROPERTY(double Amount MEMBER m_dAmount READ getAmount WRITE setAmount NOTIFY amountChanged) + Q_PROPERTY(QString Status MEMBER m_sName READ getStatus WRITE setStatus NOTIFY statusChanged) + Q_PROPERTY(QString Date MEMBER m_dAmount READ getDate WRITE setDate NOTIFY dateChanged) + + friend QDataStream& operator << (QDataStream& aOut, const DapWalletHistoryEvent& aHistoryEvent); + friend QDataStream& operator >> (QDataStream& aOut, DapWalletHistoryEvent& aHistoryEvent); + +signals: + void nameChanged(const QString& asName); + void amountChanged(const double& adAmount); + void statusChanged(const QString& asStatus); + void dateChanged(const QString& asDate); + +public slots: + QString getName() const; + void setName(const QString &sName); + double getAmount() const; + void setAmount(double dAmount); + QString getStatus() const; + void setStatus(const QString &sStatus); + QString getDate() const; + void setDate(const QString &sDate); +}; + +#endif // DAPWALLETHISTORYEVENT_H diff --git a/libCellFrameDashboardCommon/DapWalletToken.cpp b/libCellFrameDashboardCommon/DapWalletToken.cpp index 49832e6856abbfd7368e1fc467c5134d227970c3..beb3c270554869389a8c8e46cc06b91da152741e 100644 --- a/libCellFrameDashboardCommon/DapWalletToken.cpp +++ b/libCellFrameDashboardCommon/DapWalletToken.cpp @@ -92,8 +92,6 @@ void DapWalletToken::setIcon(const QString &sIcon) QDataStream& operator << (QDataStream& aOut, const DapWalletToken& aToken) { - QString emission; - emission.setNum(aToken.m_iEmission); aOut << aToken.m_sName << aToken.m_dBalance << aToken.m_iEmission diff --git a/libCellFrameDashboardCommon/Handlers/DapGetWalletHistoryCommand.cpp b/libCellFrameDashboardCommon/Handlers/DapGetWalletHistoryCommand.cpp index ae61be3cb49fb745e1ada98bbae695894d1913c7..aada237cacfd26f60a6baa3e2d70c32de5992af3 100644 --- a/libCellFrameDashboardCommon/Handlers/DapGetWalletHistoryCommand.cpp +++ b/libCellFrameDashboardCommon/Handlers/DapGetWalletHistoryCommand.cpp @@ -13,7 +13,10 @@ DapGetWalletHistoryCommand::DapGetWalletHistoryCommand(const QString &asServicen /// Send a response to the client. /// @details Performed on the service side. -/// @param arg1...arg10 Parameters. +/// @param arg1 Network. +/// @param arg2 Chain. +/// @param arg3 Wallet address. +/// @param arg4...arg10 Parameters. /// @return Reply to client. QVariant DapGetWalletHistoryCommand::respondToClient(const QVariant &arg1, const QVariant &arg2, const QVariant &arg3, const QVariant &arg4, const QVariant &arg5, const QVariant &arg6, const QVariant &arg7, const QVariant &arg8, const QVariant &arg9, const QVariant &arg10) { @@ -28,28 +31,32 @@ QVariant DapGetWalletHistoryCommand::respondToClient(const QVariant &arg1, const Q_UNUSED(arg9) Q_UNUSED(arg10) - QList<QVariant> data; + QList<DapWalletHistoryEvent> events; QProcess process; - process.start(QString("%1 tx_history -net %2 -chain gdb -addr %3").arg(m_sCliPath).arg(arg1.toString()).arg(arg2.toString())); + process.start(QString("%1 tx_history -net %2 -chain %3 -addr %4").arg(m_sCliPath).arg(arg1.toString()).arg(arg2.toString()).arg(arg3.toString())); process.waitForFinished(-1); QByteArray result = process.readAll(); if(!result.isEmpty()) { QRegularExpression regular("((\\w{3}\\s+){2}\\d{1,2}\\s+(\\d{1,2}:*){3}\\s+\\d{4})\\s+(\\w+)\\s+(\\d+)\\s(\\w+)\\s+\\w+\\s+([\\w\\d]+)", QRegularExpression::MultilineOption); QRegularExpressionMatchIterator matchItr = regular.globalMatch(result); + while (matchItr.hasNext()) { - if(data.count() >= 100) break; + DapWalletHistoryEvent event; QRegularExpressionMatch match = matchItr.next(); - QStringList dataItem = QStringList() - << match.captured(1) - << match.captured(4) - << match.captured(5) - << match.captured(6) - << match.captured(7); - data << dataItem; + QLocale setLocale = QLocale(QLocale::English, QLocale::UnitedStates); + event.setDate(setLocale.toDateTime(match.captured(1), "ddd MMM d hh:mm:ss yyyy").toString("yyyy-MM-dd")); + event.setStatus(match.captured(4) == "send" ? "Sent" : "Received"); + event.setAmount(match.captured(5).toDouble()); + event.setName(match.captured(6)); + events.append(event); } } - return data; + QByteArray datas; + QDataStream out(&datas, QIODevice::WriteOnly); + out << events; + + return QJsonValue::fromVariant(datas.toHex());; } diff --git a/libCellFrameDashboardCommon/Handlers/DapGetWalletHistoryCommand.h b/libCellFrameDashboardCommon/Handlers/DapGetWalletHistoryCommand.h index d192e96bb1711eaeb279479a616c91e41ce76a31..ba6c4d2461c74f1a2ea60baeaf561d2d9edb9ebc 100644 --- a/libCellFrameDashboardCommon/Handlers/DapGetWalletHistoryCommand.h +++ b/libCellFrameDashboardCommon/Handlers/DapGetWalletHistoryCommand.h @@ -4,8 +4,10 @@ #include <QProcess> #include <QRegExp> #include <QRegularExpression> +#include <QDate> #include "DapWallet.h" +#include "DapWalletHistoryEvent.h" #include "DapAbstractCommand.h" class DapGetWalletHistoryCommand : public DapAbstractCommand @@ -24,7 +26,10 @@ public: public slots: /// Send a response to the client. /// @details Performed on the service side. - /// @param arg1...arg10 Parameters. + /// @param arg1 Network. + /// @param arg2 Chain. + /// @param arg3 Wallet address. + /// @param arg4...arg10 Parameters. /// @return Reply to client. QVariant respondToClient(const QVariant &arg1 = QVariant(), const QVariant &arg2 = QVariant(), const QVariant &arg3 = QVariant(), const QVariant &arg4 = QVariant(), diff --git a/libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri b/libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri index e4d854e52c902fc6315944a5f6caf1804f60f196..027bdfa29f6d72ec62de7ae8a5d93d97d66b9b58 100755 --- a/libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri +++ b/libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri @@ -21,6 +21,7 @@ SOURCES +=\ $$PWD/DapSystemTrayIcon.cpp \ $$PWD/DapWallet.cpp \ $$PWD/DapWalletToken.cpp \ + $$PWD/DapWalletHistoryEvent.cpp \ $$PWD/Handlers/DapAbstractCommand.cpp \ $$PWD/Handlers/DapActivateClientCommand.cpp \ $$PWD/Handlers/DapGetListNetworksCommand.cpp \ @@ -46,6 +47,7 @@ HEADERS +=\ $$PWD/DapSystemTrayIcon.h \ $$PWD/DapWallet.h \ $$PWD/DapWalletToken.h \ + $$PWD/DapWalletHistoryEvent.h\ $$PWD/Handlers/DapAbstractCommand.h \ $$PWD/Handlers/DapActivateClientCommand.h \ $$PWD/Handlers/DapGetListNetworksCommand.h \