Skip to content
Snippets Groups Projects
Commit fe612512 authored by jonymt's avatar jonymt
Browse files

[+] added network handler for service

[+] added network handler for service
parent f1023b78
No related branches found
No related tags found
1 merge request!16Features 2510
Pipeline #824 failed with stage
Showing
with 280 additions and 13 deletions
...@@ -44,6 +44,7 @@ SOURCES += \ ...@@ -44,6 +44,7 @@ SOURCES += \
DapChainNodeNetworkModel.cpp \ DapChainNodeNetworkModel.cpp \
DapScreenHistoryFilterModel.cpp \ DapScreenHistoryFilterModel.cpp \
DapScreenHistoryModel.cpp \ DapScreenHistoryModel.cpp \
DapSettingsNetworkModel.cpp \
DapUiQmlWidgetChainTransactions.cpp \ DapUiQmlWidgetChainTransactions.cpp \
main.cpp \ main.cpp \
DapUiQmlWidgetChainBallance.cpp \ DapUiQmlWidgetChainBallance.cpp \
...@@ -80,6 +81,7 @@ HEADERS += \ ...@@ -80,6 +81,7 @@ HEADERS += \
DapChainNodeNetworkModel.h \ DapChainNodeNetworkModel.h \
DapScreenHistoryFilterModel.h \ DapScreenHistoryFilterModel.h \
DapScreenHistoryModel.h \ DapScreenHistoryModel.h \
DapSettingsNetworkModel.h \
DapUiQmlWidgetChainBallance.h \ DapUiQmlWidgetChainBallance.h \
DapUiQmlWidgetChainBlockExplorer.h \ DapUiQmlWidgetChainBlockExplorer.h \
DapUiQmlWidgetChainNodeLogs.h \ DapUiQmlWidgetChainNodeLogs.h \
...@@ -115,4 +117,6 @@ unix: !mac : !android { ...@@ -115,4 +117,6 @@ unix: !mac : !android {
INSTALLS += gui_target INSTALLS += gui_target
} }
DISTFILES += #DISTFILES += \
# DapUiQmlScreenSettings.qml \
# DapUiQmlScreenSettingsForm.ui.qml
#include "DapSettingsNetworkModel.h"
DapSettingsNetworkModel::DapSettingsNetworkModel(QObject *parent) : QAbstractListModel(parent)
{
m_NetworkList = QStringList() << "First" << "Second" << "Third" << "Forth";
}
DapSettingsNetworkModel& DapSettingsNetworkModel::getInstance()
{
static DapSettingsNetworkModel instance;
return instance;
}
int DapSettingsNetworkModel::rowCount(const QModelIndex& parent) const
{
Q_UNUSED(parent)
return m_NetworkList.count();
}
QVariant DapSettingsNetworkModel::data(const QModelIndex& index, int role) const
{
if(!index.isValid()) return QVariant();
if(role == DisplayName)
return m_NetworkList.at(index.row());
return QVariant();
}
QHash<int, QByteArray> DapSettingsNetworkModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[DisplayName] = "network";
return roles;
}
QString DapSettingsNetworkModel::getCurrentNetwork() const
{
return m_CurrentNetwork;
}
void DapSettingsNetworkModel::setNetworkList(const QStringList& aNetworkList)
{
if(m_NetworkList == aNetworkList) return;
beginResetModel();
m_NetworkList = aNetworkList;
endResetModel();
}
void DapSettingsNetworkModel::setCurrentNetwork(QString CurrentNetwork)
{
if (m_CurrentNetwork == CurrentNetwork)
return;
m_CurrentNetwork = CurrentNetwork;
emit currentNetworkChanged(m_CurrentNetwork);
}
#ifndef DAPSETTINGSNETWORKMODEL_H
#define DAPSETTINGSNETWORKMODEL_H
#include <QAbstractListModel>
#include <QStringList>
#include <QDebug>
class DapSettingsNetworkModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(QString CurrentNetwork READ getCurrentNetwork WRITE setCurrentNetwork NOTIFY currentNetworkChanged)
public:
enum DisplayRole {
DisplayName = Qt::UserRole
};
private:
QStringList m_NetworkList;
QString m_CurrentNetwork;
public:
explicit DapSettingsNetworkModel(QObject *parent = nullptr);
static DapSettingsNetworkModel &getInstance();
int rowCount(const QModelIndex& parent) const;
QVariant data(const QModelIndex& index, int role) const;
QHash<int, QByteArray> roleNames() const;
QString getCurrentNetwork() const;
public slots:
void setNetworkList(const QStringList& aNetworkList);
void setCurrentNetwork(QString CurrentNetwork);
signals:
void currentNetworkChanged(QString currentNetwork);
};
#endif // DAPSETTINGSNETWORKMODEL_H
...@@ -49,7 +49,9 @@ Page { ...@@ -49,7 +49,9 @@ Page {
} }
ListElement { ListElement {
name: qsTr("Settings") name: qsTr("Settings")
page: "DapQmlScreenAbout.qml" // page: "DapQmlScreenAbout.qml"
page: "DapUiQmlScreenSettings.qml"
// page: "DapUiQmlWidgetSettingsNetwork.qml"
source: "qrc:/Resources/Icons/defaul_icon.png" source: "qrc:/Resources/Icons/defaul_icon.png"
} }
ListElement { ListElement {
......
import QtQuick 2.4
import QtQuick.Controls 2.12
DapUiQmlScreenSettingsForm {
anchors.fill: parent
ListModel {
id: dapListModelSettings
ListElement {
name: qsTr("Network")
element: "DapUiQmlWidgetSettingsNetwork.qml"
}
}
ListView {
id: dapListViewSettings
anchors.fill: parent
model: dapListModelSettings
delegate: Component {
Item {
width: parent.width
height: loaderSettings.height
Loader {
id: loaderSettings
source: element
}
}
}
section.property: "name"
section.criteria: ViewSection.FullString
section.delegate: Component {
Rectangle {
width: parent.width
height: 30 * pt
color: "#DFE1E6"
Text {
anchors.fill: parent
anchors.leftMargin: 18 * pt
verticalAlignment: Qt.AlignVCenter
text: section
font.family: "Roboto"
font.pixelSize: 12 * pt
color: "#5F5F63"
}
}
}
}
}
import QtQuick 2.4
Item {
anchors.fill: parent
}
...@@ -15,13 +15,14 @@ DapUiQmlWidgetConsoleForm { ...@@ -15,13 +15,14 @@ DapUiQmlWidgetConsoleForm {
execute.enabled = false; execute.enabled = false;
} }
Connections { Connections {
target: dapServiceController target: dapServiceController
onResultChanged: { onResultChanged: {
command.clear() command.clear()
result.text = dapServiceController.Result result.text = dapServiceController.Result
execute.enabled = true execute.enabled = true
} }
} }
} }
import QtQuick 2.4
import QtQuick.Controls 2.12
DapUiQmlWidgetSettingsNetworkForm {
width: parent.width
height: childrenRect.height
ComboBox {
width: 150
height: 50
anchors.left: parent.left
anchors.top: parent.top
anchors.leftMargin: 18 * pt
anchors.topMargin: 13 * pt
model: dapSettingsNetworkModel
textRole: "network"
}
}
import QtQuick 2.4
Item {
width: 400
height: 400
}
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "DapChainNodeNetworkModel.h" #include "DapChainNodeNetworkModel.h"
#include "DapChainNodeNetworkExplorer.h" #include "DapChainNodeNetworkExplorer.h"
#include "DapScreenHistoryFilterModel.h" #include "DapScreenHistoryFilterModel.h"
#include "DapSettingsNetworkModel.h"
#include <QRegExp> #include <QRegExp>
...@@ -73,9 +74,10 @@ int main(int argc, char *argv[]) ...@@ -73,9 +74,10 @@ int main(int argc, char *argv[])
engine.rootContext()->setContextProperty("dapChainWalletsModel", &DapChainWalletsModel::getInstance()); engine.rootContext()->setContextProperty("dapChainWalletsModel", &DapChainWalletsModel::getInstance());
engine.rootContext()->setContextProperty("dapNodeNetworkModel", &DapChainNodeNetworkModel::getInstance()); engine.rootContext()->setContextProperty("dapNodeNetworkModel", &DapChainNodeNetworkModel::getInstance());
engine.rootContext()->setContextProperty("dapHistoryModel", &DapScreenHistoryFilterModel::getInstance()); engine.rootContext()->setContextProperty("dapHistoryModel", &DapScreenHistoryFilterModel::getInstance());
engine.rootContext()->setContextProperty("dapSettingsNetworkModel", &DapSettingsNetworkModel::getInstance());
engine.rootContext()->setContextProperty("pt", 1.3); engine.rootContext()->setContextProperty("pt", 1.3);
engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty()) if (engine.rootObjects().isEmpty())
return -1; return -1;
......
...@@ -58,5 +58,9 @@ ...@@ -58,5 +58,9 @@
<file>DapUiQmlWidgetLastActions.qml</file> <file>DapUiQmlWidgetLastActions.qml</file>
<file>DapUiQmlWidgetLastActionsForm.ui.qml</file> <file>DapUiQmlWidgetLastActionsForm.ui.qml</file>
<file>DapUiQmlScreenHistoryForm.ui.qml</file> <file>DapUiQmlScreenHistoryForm.ui.qml</file>
<file>DapUiQmlWidgetSettingsNetwork.qml</file>
<file>DapUiQmlWidgetSettingsNetworkForm.ui.qml</file>
<file>DapUiQmlScreenSettings.qml</file>
<file>DapUiQmlScreenSettingsForm.ui.qml</file>
</qresource> </qresource>
</RCC> </RCC>
...@@ -20,7 +20,7 @@ ICON = icon.ico ...@@ -20,7 +20,7 @@ ICON = icon.ico
win32 { win32 {
VERSION = $${VER_MAJ}.$${VER_MIN}.$$VER_PAT VERSION = $${VER_MAJ}.$${VER_MIN}.$$VER_PAT
DEFINES += CLI_PATH=\\\"./cellframe-node-cli.exe\\\" DEFINES += CLI_PATH=\\\"./kelvin-node-cli.exe\\\"
DEFINES += LOG_FILE=\\\"./opt/cellframe-node/var/log/cellframe-node_logs.txt\\\" DEFINES += LOG_FILE=\\\"./opt/cellframe-node/var/log/cellframe-node_logs.txt\\\"
} }
else { else {
...@@ -48,7 +48,8 @@ SOURCES += \ ...@@ -48,7 +48,8 @@ SOURCES += \
$$PWD/DapChainNode.cpp \ $$PWD/DapChainNode.cpp \
$$PWD/DapChainNodeCache.cpp \ $$PWD/DapChainNodeCache.cpp \
$$PWD/DapChainWalletHandler.cpp \ $$PWD/DapChainWalletHandler.cpp \
$$PWD/DapChainLogHandler.cpp $$PWD/DapChainLogHandler.cpp \
DapChainNetworkHandler.cpp
HEADERS += \ HEADERS += \
$$PWD/DapChainDashboardService.h \ $$PWD/DapChainDashboardService.h \
...@@ -57,7 +58,8 @@ HEADERS += \ ...@@ -57,7 +58,8 @@ HEADERS += \
$$PWD/DapChainNodeCache.h \ $$PWD/DapChainNodeCache.h \
$$PWD/DapChainNodeNetworkHandler.h \ $$PWD/DapChainNodeNetworkHandler.h \
$$PWD/DapChainWalletHandler.h \ $$PWD/DapChainWalletHandler.h \
$$PWD/DapChainLogHandler.h $$PWD/DapChainLogHandler.h \
DapChainNetworkHandler.h
include (../libdap/libdap.pri) include (../libdap/libdap.pri)
include (../libdap-crypto/libdap-crypto.pri) include (../libdap-crypto/libdap-crypto.pri)
......
...@@ -13,9 +13,12 @@ DapChainDashboardService::DapChainDashboardService() : DapRpcService(nullptr) ...@@ -13,9 +13,12 @@ DapChainDashboardService::DapChainDashboardService() : DapRpcService(nullptr)
m_pDapChainNodeHandler = new DapChainNodeNetworkHandler(this); m_pDapChainNodeHandler = new DapChainNodeNetworkHandler(this);
m_pDapChainHistoryHandler = new DapChainHistoryHandler {this}; m_pDapChainHistoryHandler = new DapChainHistoryHandler(this);
QObject::connect(m_pDapChainHistoryHandler, &DapChainHistoryHandler::requsetWallets, this, &DapChainDashboardService::doRequestWallets); QObject::connect(m_pDapChainHistoryHandler, &DapChainHistoryHandler::requsetWallets, this, &DapChainDashboardService::doRequestWallets);
QObject::connect(m_pDapChainHistoryHandler, &DapChainHistoryHandler::changeHistory, this, &DapChainDashboardService::doSendNewHistory); QObject::connect(m_pDapChainHistoryHandler, &DapChainHistoryHandler::changeHistory, this, &DapChainDashboardService::doSendNewHistory);
m_pDapChainNetworkHandler = new DapChainNetworkHandler(this);
QObject::connect(m_pDapChainNetworkHandler, &DapChainNetworkHandler::changeCurrentNetwork, m_pDapChainHistoryHandler, &DapChainHistoryHandler::setCurrentNetwork);
} }
bool DapChainDashboardService::start() bool DapChainDashboardService::start()
...@@ -88,6 +91,16 @@ QVariant DapChainDashboardService::getHistory() const ...@@ -88,6 +91,16 @@ QVariant DapChainDashboardService::getHistory() const
return m_pDapChainHistoryHandler->getHistory(); return m_pDapChainHistoryHandler->getHistory();
} }
QStringList DapChainDashboardService::getNetworkList() const
{
return m_pDapChainNetworkHandler->getNetworkList();
}
void DapChainDashboardService::setCurrentNetwork(const QString& aNetwork)
{
m_pDapChainNetworkHandler->setCurrentNetwork(aNetwork);
}
void DapChainDashboardService::doRequestWallets() void DapChainDashboardService::doRequestWallets()
{ {
m_pDapChainHistoryHandler->onRequestNewHistory(m_pDapChainWalletHandler->getWallets()); m_pDapChainHistoryHandler->onRequestNewHistory(m_pDapChainWalletHandler->getWallets());
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "DapChainWalletHandler.h" #include "DapChainWalletHandler.h"
#include "DapChainNodeNetworkHandler.h" #include "DapChainNodeNetworkHandler.h"
#include "DapChainHistoryHandler.h" #include "DapChainHistoryHandler.h"
#include "DapChainNetworkHandler.h"
#include <QLocalServer> #include <QLocalServer>
typedef class DapRpcLocalServer DapUiService; typedef class DapRpcLocalServer DapUiService;
...@@ -49,6 +50,8 @@ class DapChainDashboardService : public DapRpcService ...@@ -49,6 +50,8 @@ class DapChainDashboardService : public DapRpcService
/// Recipient history of transactions /// Recipient history of transactions
DapChainHistoryHandler* m_pDapChainHistoryHandler {nullptr}; DapChainHistoryHandler* m_pDapChainHistoryHandler {nullptr};
DapChainNetworkHandler* m_pDapChainNetworkHandler {nullptr};
public: public:
/// Standard сonstructor. /// Standard сonstructor.
explicit DapChainDashboardService(); explicit DapChainDashboardService();
...@@ -103,6 +106,10 @@ public slots: ...@@ -103,6 +106,10 @@ public slots:
/// @return QList data history /// @return QList data history
QVariant getHistory() const; QVariant getHistory() const;
QStringList getNetworkList() const;
void setCurrentNetwork(const QString& aNetwork);
private slots: private slots:
void doRequestWallets(); void doRequestWallets();
void doSendNewHistory(const QVariant& aData); void doSendNewHistory(const QVariant& aData);
......
...@@ -48,3 +48,9 @@ void DapChainHistoryHandler::onRequestNewHistory(const QMap<QString, QVariant>& ...@@ -48,3 +48,9 @@ void DapChainHistoryHandler::onRequestNewHistory(const QMap<QString, QVariant>&
emit changeHistory(m_history); emit changeHistory(m_history);
} }
} }
void DapChainHistoryHandler::setCurrentNetwork(const QString& aNetwork)
{
if(aNetwork == m_CurrentNetwork) return;
m_CurrentNetwork = aNetwork;
}
...@@ -16,6 +16,7 @@ class DapChainHistoryHandler : public QObject ...@@ -16,6 +16,7 @@ class DapChainHistoryHandler : public QObject
Q_OBJECT Q_OBJECT
private: private:
QString m_CurrentNetwork;
QVariant m_history; QVariant m_history;
QTimer* m_timoutRequestHistory; QTimer* m_timoutRequestHistory;
...@@ -30,6 +31,7 @@ public slots: ...@@ -30,6 +31,7 @@ public slots:
/// Request new tx history /// Request new tx history
/// @param wallet list /// @param wallet list
void onRequestNewHistory(const QMap<QString, QVariant>& aWallets); void onRequestNewHistory(const QMap<QString, QVariant>& aWallets);
void setCurrentNetwork(const QString& aNetwork);
signals: signals:
/// Signal for request wallets list /// Signal for request wallets list
......
#include "DapChainNetworkHandler.h"
DapChainNetworkHandler::DapChainNetworkHandler(QObject *parent) : QObject(parent)
{
}
QStringList DapChainNetworkHandler::getNetworkList() const
{
return QStringList();
}
void DapChainNetworkHandler::setCurrentNetwork(const QString& aNetwork)
{
emit changeCurrentNetwork(aNetwork);
}
#ifndef DAPCHAINNETWORKHANDLER_H
#define DAPCHAINNETWORKHANDLER_H
#include <QObject>
#include <QString>
class DapChainNetworkHandler : public QObject
{
Q_OBJECT
private:
QStringList m_NetworkList;
public:
explicit DapChainNetworkHandler(QObject *parent = nullptr);
QStringList getNetworkList() const;
public slots:
void setCurrentNetwork(const QString& aNetwork);
signals:
void changeCurrentNetwork(QString network);
};
#endif // DAPCHAINNETWORKHANDLER_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment