From f50e71a763d24d93a7a9b475c16c2d39d0a3503d Mon Sep 17 00:00:00 2001 From: "evgenii.tagiltsev" <tagiltsev.evgenii@gmail.com> Date: Fri, 13 Dec 2019 15:32:17 +0100 Subject: [PATCH] [*] moved slots and signals from DapTransaction to DapServiceController --- .../CellFrameDashboardGUI.pro | 6 ++-- .../DapServiceController.cpp | 15 +++++--- CellFrameDashboardGUI/DapServiceController.h | 6 ++++ CellFrameDashboardGUI/DapTransaction.cpp | 28 --------------- CellFrameDashboardGUI/DapTransaction.h | 35 ------------------- CellFrameDashboardGUI/main.cpp | 1 - .../DapUiQmlScreenMainWindowForm.ui.qml | 1 - 7 files changed, 19 insertions(+), 73 deletions(-) delete mode 100644 CellFrameDashboardGUI/DapTransaction.cpp delete mode 100644 CellFrameDashboardGUI/DapTransaction.h diff --git a/CellFrameDashboardGUI/CellFrameDashboardGUI.pro b/CellFrameDashboardGUI/CellFrameDashboardGUI.pro index 370cf496b..be1d35cb2 100755 --- a/CellFrameDashboardGUI/CellFrameDashboardGUI.pro +++ b/CellFrameDashboardGUI/CellFrameDashboardGUI.pro @@ -80,8 +80,7 @@ SOURCES += \ $$PWD/DapServiceClientNativeLinux.cpp \ $$PWD/DapServiceClientNativeWin.cpp \ $$PWD/DapServiceClientNativeMacOS.cpp \ - $$PWD/DapChainWalletsModel.cpp \ - DapTransaction.cpp + $$PWD/DapChainWalletsModel.cpp RESOURCES += $$PWD/qml.qrc @@ -108,8 +107,7 @@ HEADERS += \ $$PWD/DapServiceClientNativeLinux.h \ $$PWD/DapServiceClientNativeWin.h \ $$PWD/DapChainWalletsModel.h \ - $$PWD/DapWalletFilterModel.h \ - DapTransaction.h + $$PWD/DapWalletFilterModel.h include (../libdap/libdap.pri) include (../libdap-crypto/libdap-crypto.pri) diff --git a/CellFrameDashboardGUI/DapServiceController.cpp b/CellFrameDashboardGUI/DapServiceController.cpp index 416dcc082..d5cfc6d76 100644 --- a/CellFrameDashboardGUI/DapServiceController.cpp +++ b/CellFrameDashboardGUI/DapServiceController.cpp @@ -73,10 +73,7 @@ void DapServiceController::init(DapServiceClient *apDapServiceClient) connect(m_pDapCommandController, &DapCommandController::sigWalletData, &DapChainWalletModel::instance(), &DapChainWalletModel::setWalletData); - connect(&DapTransaction::instance(), &DapTransaction::sendMempool, m_pDapCommandController, &DapCommandController::sendMempool); - connect(&DapTransaction::instance(), &DapTransaction::sendToken, m_pDapCommandController, &DapCommandController::takeFromMempool); - connect(m_pDapCommandController, &DapCommandController::sendResponseTransaction, &DapTransaction::instance(), &DapTransaction::receiveResult); - + connect(m_pDapCommandController, &DapCommandController::sendResponseTransaction, this, &DapServiceController::resultMempool); } QString DapServiceController::getBrand() const @@ -285,6 +282,16 @@ QObject *DapServiceController::singletonProvider(QQmlEngine *engine, QJSEngine * return &getInstance(); } +void DapServiceController::createTransaction(const QString& aFromWallet, const QString& aToAddress, const QString& aToken, const QString& aNetwork, const quint64 aValue) +{ + m_pDapCommandController->sendMempool(aFromWallet, aToAddress, aToken, aNetwork, aValue); +} + +void DapServiceController::sendToken(const QString& aNetwork) +{ + m_pDapCommandController->takeFromMempool(aNetwork); +} + void DapServiceController::requestWalletData() { m_pDapCommandController->requestWalletData(); diff --git a/CellFrameDashboardGUI/DapServiceController.h b/CellFrameDashboardGUI/DapServiceController.h index d2fe094cb..d2aa1edcf 100644 --- a/CellFrameDashboardGUI/DapServiceController.h +++ b/CellFrameDashboardGUI/DapServiceController.h @@ -175,9 +175,15 @@ public slots: /// @param scriptEngine The QJSEngine class provides an environment for evaluating JavaScript code. static QObject *singletonProvider(QQmlEngine *engine, QJSEngine *scriptEngine); + void createTransaction(const QString& aFromWallet, const QString& aToAddress, const QString& aToken, const QString& aNetwork, const quint64 aValue); + void sendToken(const QString& aNetwork); + public slots: /// Request wallet data void requestWalletData(); + +signals: + void resultMempool(bool result); }; #endif // DAPSERVICECONTROLLER_H diff --git a/CellFrameDashboardGUI/DapTransaction.cpp b/CellFrameDashboardGUI/DapTransaction.cpp deleted file mode 100644 index 01f91e1da..000000000 --- a/CellFrameDashboardGUI/DapTransaction.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "DapTransaction.h" - -DapTransaction::DapTransaction(QObject *parent) : QObject(parent) -{ - -} - -DapTransaction& DapTransaction::instance() -{ - static DapTransaction instance; - return instance; -} - -void DapTransaction::createRequestTransaction(const QString& aFromWallet, const QString& aToAddress, const QString& aToken, const QString& aNetwork, const quint64 aValue) -{ - emit sendMempool(aFromWallet, aToAddress, aToken, aNetwork, aValue); -} - -void DapTransaction::sendToken(const QString& aNetwork) -{ - emit sendTransaction(aNetwork); -} - -void DapTransaction::receiveResult(const bool aSuccessful) -{ - if(aSuccessful) emit sendToken("private"); - emit sendResult(aSuccessful); -} diff --git a/CellFrameDashboardGUI/DapTransaction.h b/CellFrameDashboardGUI/DapTransaction.h deleted file mode 100644 index 90e8d6998..000000000 --- a/CellFrameDashboardGUI/DapTransaction.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef DAPTRANSACTION_H -#define DAPTRANSACTION_H - -#include <QObject> - -class DapTransaction : public QObject -{ - Q_OBJECT - -public: - explicit DapTransaction(QObject *parent = nullptr); - static DapTransaction& instance(); - -public slots: - /// Request for creation new transaction - /// @param name of wallet - /// @param address of a receiver - /// @param name of token - /// @param name of network - /// @param sum for transaction - void createRequestTransaction(const QString& aFromWallet, const QString& aToAddress, const QString& aToken, const QString& aNetwork, const quint64 aValue); - /// Taking everything from mempool - /// @param network - void sendToken(const QString& aNetwork); - /// Recevie result of putting to mempool - /// @param successful or not - void receiveResult(const bool aSuccessful); - -signals: - void sendResult(bool result); - void sendMempool(const QString& fromWallet, const QString& toAddress, const QString& token, const QString& network, const quint64 value); - void sendTransaction(const QString& network); -}; - -#endif // DAPTRANSACTION_H diff --git a/CellFrameDashboardGUI/main.cpp b/CellFrameDashboardGUI/main.cpp index 19f74a605..14920b113 100644 --- a/CellFrameDashboardGUI/main.cpp +++ b/CellFrameDashboardGUI/main.cpp @@ -96,7 +96,6 @@ int main(int argc, char *argv[]) engine.rootContext()->setContextProperty("dapWalletFilterModel", &DapWalletFilterModel::instance()); engine.rootContext()->setContextProperty("dapWalletModel", &DapChainWalletModel::instance()); engine.rootContext()->setContextProperty("clipboard", &DapClipboard::instance()); - engine.rootContext()->setContextProperty("dapTransaction", &DapTransaction::instance()); engine.rootContext()->setContextProperty("pt", 1.3); engine.load(QUrl("qrc:/screen/main.qml")); diff --git a/CellFrameDashboardGUI/screen/DapUiQmlScreenMainWindowForm.ui.qml b/CellFrameDashboardGUI/screen/DapUiQmlScreenMainWindowForm.ui.qml index fefed8375..2e11ad423 100644 --- a/CellFrameDashboardGUI/screen/DapUiQmlScreenMainWindowForm.ui.qml +++ b/CellFrameDashboardGUI/screen/DapUiQmlScreenMainWindowForm.ui.qml @@ -125,7 +125,6 @@ Page { delegate: componentItemMainMenuTab clip: true interactive: false - currentIndex: 0 } focus: true } -- GitLab