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

[+] added filling combobox

parent fe612512
No related branches found
No related tags found
1 merge request!16Features 2510
Pipeline #831 passed with stage
in 3 minutes and 1 second
Showing
with 80 additions and 9 deletions
......@@ -63,6 +63,11 @@ void DapCommandController::setNewHistory(const QVariant& aData)
emit sendHistory(aData);
}
void DapCommandController::changeCurrentNetwork(const QString& aNetwork)
{
m_DAPRpcSocket->invokeRemoteMethod("RPCServer.changeCurrentNetwork", aNetwork);
}
void DapCommandController::processChangedLog()
{
// QStringList tempLogModel;
......@@ -186,12 +191,18 @@ void DapCommandController::processExecuteCommand()
void DapCommandController::processGetHistory()
{
qDebug() << "processGetHistory()";
DapRpcServiceReply *reply = static_cast<DapRpcServiceReply *>(sender());
QVariant result = reply->response().result().toArray().toVariantList();
emit sendHistory(result);
}
void DapCommandController::processGetNetworkList()
{
DapRpcServiceReply *reply = static_cast<DapRpcServiceReply *>(sender());
QStringList result = reply->response().result().toVariant().toStringList();
emit sendNetworkList(result);
}
/// Show or hide GUI client by clicking on the tray icon.
/// @param aIsActivated Accepts true - when requesting to
/// display a client, falso - when requesting to hide a client.
......@@ -245,6 +256,12 @@ void DapCommandController::getNodeNetwork()
connect(reply, SIGNAL(finished()), this, SLOT(processGetNodeNetwork()));
}
void DapCommandController::getNetworkList()
{
DapRpcServiceReply *reply = m_DAPRpcSocket->invokeRemoteMethod("RPCServer.getNetworkList");
connect(reply, SIGNAL(finished()), this, SLOT(processGetNetworkList()));
}
void DapCommandController::setNodeStatus(const bool aIsOnline)
{
/*DapRpcServiceReply *reply =*/ m_DAPRpcSocket->invokeRemoteMethod("RPCServer.setNodeStatus", aIsOnline);
......
......@@ -49,6 +49,8 @@ signals:
/// Signal for sending new transaction history
void sendHistory(const QVariant& aData);
void sendNetworkList(const QStringList& aList);
public:
/// Overloaded constructor.
/// @param apIODevice Data transfer device.
......@@ -78,6 +80,8 @@ private slots:
void processGetHistory();
void processGetNetworkList();
public slots:
/// Show or hide GUI client by clicking on the tray icon.
/// @param aIsActivated Accepts true - when requesting to
......@@ -98,6 +102,8 @@ public slots:
void getNodeNetwork();
void getNetworkList();
void setNodeStatus(const bool aIsOnline);
void executeCommand(const QString& command);
......@@ -110,6 +116,8 @@ public slots:
void getHistory();
/// Send to model new history
void setNewHistory(const QVariant& aData);
void changeCurrentNetwork(const QString& aNetwork);
};
#endif // COMMANDCONTROLLER_H
......@@ -59,6 +59,9 @@ void DapServiceController::init(DapServiceClient *apDapServiceClient)
connect(m_pDapCommandController, SIGNAL(sendHistory(QVariant)), this, SLOT(processGetHistory(QVariant)));
connect(m_pDapCommandController, &DapCommandController::sendHistory, &DapScreenHistoryModel::getInstance(), &DapScreenHistoryModel::receiveNewData);
connect(m_pDapCommandController, &DapCommandController::sendNetworkList, &DapSettingsNetworkModel::getInstance(), &DapSettingsNetworkModel::setNetworkList);
connect(&DapSettingsNetworkModel::getInstance(), &DapSettingsNetworkModel::currentNetworkChanged, m_pDapCommandController, &DapCommandController::changeCurrentNetwork);
}
QString DapServiceController::getBrand() const
......@@ -235,6 +238,11 @@ void DapServiceController::processGetHistory(const QVariant& aData)
DapScreenHistoryModel::getInstance().receiveNewData(aData);
}
void DapServiceController::getNetworkList()
{
m_pDapCommandController->getNetworkList();
}
/// Get an instance of a class.
/// @return Instance of a class.
......
......@@ -15,6 +15,7 @@
#include "DapChainWalletsModel.h"
#include "DapChainNodeNetworkModel.h"
#include "DapScreenHistoryModel.h"
#include "DapSettingsNetworkModel.h"
class DapServiceController : public QObject
{
......@@ -80,7 +81,7 @@ public:
void getWalletInfo(const QString& asWalletName);
void getNetworkList();
signals:
/// The signal is emitted when the Brand company property changes.
......
......@@ -28,7 +28,7 @@ public:
QVariant data(const QModelIndex& index, int role) const;
QHash<int, QByteArray> roleNames() const;
QString getCurrentNetwork() const;
Q_INVOKABLE QString getCurrentNetwork() const;
public slots:
void setNetworkList(const QStringList& aNetworkList);
......
......@@ -14,5 +14,12 @@ DapUiQmlWidgetSettingsNetworkForm {
anchors.topMargin: 13 * pt
model: dapSettingsNetworkModel
textRole: "network"
currentIndex: find(dapSettingsNetworkModel.CurrentNetwork)
onCurrentTextChanged: {
console.debug(currentText);
if(dapSettingsNetworkModel.CurrentNetwork != currentText)
dapSettingsNetworkModel.CurrentNetwork = currentText;
}
}
}
......@@ -54,6 +54,7 @@ int main(int argc, char *argv[])
dapServiceClient.init();
controller.getWallets();
controller.getHistory();
controller.getNetworkList();
DapScreenHistoryFilterModel::getInstance()
.setSourceModel(&DapScreenHistoryModel::getInstance());
......
......@@ -101,6 +101,12 @@ void DapChainDashboardService::setCurrentNetwork(const QString& aNetwork)
m_pDapChainNetworkHandler->setCurrentNetwork(aNetwork);
}
void DapChainDashboardService::changeCurrentNetwork(const QString& aNetwork)
{
m_pDapChainNetworkHandler->setCurrentNetwork(aNetwork);
m_pDapChainHistoryHandler->setCurrentNetwork(aNetwork);
}
void DapChainDashboardService::doRequestWallets()
{
m_pDapChainHistoryHandler->onRequestNewHistory(m_pDapChainWalletHandler->getWallets());
......
......@@ -110,6 +110,8 @@ public slots:
void setCurrentNetwork(const QString& aNetwork);
void changeCurrentNetwork(const QString& aNetwork);
private slots:
void doRequestWallets();
void doSendNewHistory(const QVariant& aData);
......
......@@ -22,7 +22,7 @@ void DapChainHistoryHandler::onRequestNewHistory(const QMap<QString, QVariant>&
for(int i = 0; i < wallets.count(); i++)
{
QProcess process;
process.start(QString(CLI_PATH) + " tx_history -net private -chain gdb -addr " + wallets.at(i).toString());
process.start(QString(CLI_PATH) + " tx_history -net " + m_CurrentNetwork + " -chain gdb -addr " + wallets.at(i).toString());
process.waitForFinished(-1);
QByteArray result = process.readAll();
......
#include "DapChainNetworkHandler.h"
DapChainNetworkHandler::DapChainNetworkHandler(QObject *parent) : QObject(parent)
DapChainNetworkHandler::DapChainNetworkHandler(QObject *parent) : QObject(parent),
m_CurrentNetwork(-1)
{
}
QStringList DapChainNetworkHandler::getNetworkList() const
QStringList DapChainNetworkHandler::getNetworkList()
{
return QStringList();
QStringList network;
/// TODO: It's test. We should change it later
QFile file("network.txt");
if(file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QString data = QString::fromStdString(file.readAll().toStdString());
network = data.split(": ").at(1).split(", ");
}
if(!network.isEmpty())
{
if(m_CurrentNetwork.isEmpty() || !m_NetworkList.contains(m_CurrentNetwork))
m_CurrentNetwork = network.at(0);
emit changeCurrentNetwork(m_CurrentNetwork);
}
return network;
}
void DapChainNetworkHandler::setCurrentNetwork(const QString& aNetwork)
{
emit changeCurrentNetwork(aNetwork);
if(m_NetworkList.contains(aNetwork))
emit changeCurrentNetwork(aNetwork);
}
......@@ -4,17 +4,20 @@
#include <QObject>
#include <QString>
#include <QFile>
class DapChainNetworkHandler : public QObject
{
Q_OBJECT
private:
QString m_CurrentNetwork;
QStringList m_NetworkList;
public:
explicit DapChainNetworkHandler(QObject *parent = nullptr);
QStringList getNetworkList() const;
QStringList getNetworkList();
public slots:
void setCurrentNetwork(const QString& aNetwork);
......
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