From ffcae85d8c0dd787f8317ff5e7a960660632a4eb Mon Sep 17 00:00:00 2001 From: jonymt <johanmt@yandex.ru> Date: Fri, 13 Sep 2019 10:45:30 +0200 Subject: [PATCH] [*] added test converter for currency --- KelvinDashboardGUI/DapScreenHistoryModel.cpp | 19 ++++---- KelvinDashboardGUI/DapScreenHistoryModel.h | 1 - KelvinDashboardGUI/DapServiceController.cpp | 2 - KelvinDashboardGUI/DapServiceController.h | 2 +- ...UiQmlWidgetExchangeOrderContentForm.ui.qml | 2 +- .../DapUiQmlWidgetExchangeOrderForm.ui.qml | 14 ++---- KelvinDashboardGUI/main.cpp | 1 + .../DapChainHistoryHandler.cpp | 1 - KelvinDashboardService/DapChainLogHandler.cpp | 48 ++++++++++--------- .../KelvinDashboardService.pro | 3 +- 10 files changed, 45 insertions(+), 48 deletions(-) diff --git a/KelvinDashboardGUI/DapScreenHistoryModel.cpp b/KelvinDashboardGUI/DapScreenHistoryModel.cpp index e5ed78fc4..91754fae2 100644 --- a/KelvinDashboardGUI/DapScreenHistoryModel.cpp +++ b/KelvinDashboardGUI/DapScreenHistoryModel.cpp @@ -3,9 +3,7 @@ DapScreenHistoryModel::DapScreenHistoryModel(QObject *parent) : QAbstractListModel(parent) { - m_timeout = new QTimer(this); - QObject::connect(m_timeout, &QTimer::timeout, this, &DapScreenHistoryModel::sendRequestHistory); - m_timeout->start(1000); + } DapScreenHistoryModel& DapScreenHistoryModel::getInstance() @@ -52,8 +50,6 @@ void DapScreenHistoryModel::receiveNewData(const QVariant& aData) return; } - if(m_timeout->isActive()) m_timeout->stop(); - beginResetModel(); QList<QVariant> dataList = aData.toList(); m_elementList.clear(); @@ -77,16 +73,23 @@ void DapScreenHistoryModel::receiveNewData(const QVariant& aData) item.TokenName = dataItem.at(3); item.WalletNumber = dataItem.at(5); // TODO: Later we should convert currency - item.Currency = "$ 0 USD"; + item.Currency = QString::number(dataItem.at(2).toDouble() * 0.98); switch (item.Status) { - case DapTransactionStatus::stSent: item.Cryptocurrency.prepend("- "); break; - case DapTransactionStatus::stReceived: item.Cryptocurrency.prepend("+ "); break; + case DapTransactionStatus::stSent: + item.Cryptocurrency.prepend("- "); + item.Currency.prepend("- $ "); + break; + case DapTransactionStatus::stReceived: + item.Cryptocurrency.prepend("+ "); + item.Currency.prepend("+ $ "); + break; default: break; } item.Cryptocurrency = toConvertCurrency(item.Cryptocurrency); item.Cryptocurrency += " " + item.TokenName; + item.Currency.append(" USD"); m_elementList.append(item); } diff --git a/KelvinDashboardGUI/DapScreenHistoryModel.h b/KelvinDashboardGUI/DapScreenHistoryModel.h index 181b2ea55..0993e3118 100644 --- a/KelvinDashboardGUI/DapScreenHistoryModel.h +++ b/KelvinDashboardGUI/DapScreenHistoryModel.h @@ -31,7 +31,6 @@ public: private: QList<DapTransactionItem> m_elementList; - QTimer* m_timeout; public: explicit DapScreenHistoryModel(QObject *parent = nullptr); diff --git a/KelvinDashboardGUI/DapServiceController.cpp b/KelvinDashboardGUI/DapServiceController.cpp index 25f3b6efb..3b8f210af 100755 --- a/KelvinDashboardGUI/DapServiceController.cpp +++ b/KelvinDashboardGUI/DapServiceController.cpp @@ -59,8 +59,6 @@ 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(&DapScreenHistoryModel::getInstance(), &DapScreenHistoryModel::sendRequestHistory, this, &DapServiceController::getHistory); } QString DapServiceController::getBrand() const diff --git a/KelvinDashboardGUI/DapServiceController.h b/KelvinDashboardGUI/DapServiceController.h index 3dcc8a31d..36f5ba190 100755 --- a/KelvinDashboardGUI/DapServiceController.h +++ b/KelvinDashboardGUI/DapServiceController.h @@ -124,7 +124,7 @@ public slots: /// Change status of node /// @param it is true if a node is online void setNodeStatus(const bool aIsOnline); - + /// void get(); /// Get node logs. diff --git a/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderContentForm.ui.qml b/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderContentForm.ui.qml index 3fc8fb2bb..be2e895fc 100644 --- a/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderContentForm.ui.qml +++ b/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderContentForm.ui.qml @@ -61,7 +61,7 @@ Item { verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignRight color: currencyTextInput.readOnly ? "#ACACAF" : "#737880" - font.family: fontExchange.name + font.family: contentFont font.pixelSize: 12 * pt text: index === 0 ? currencyName : qsTr("USD") } diff --git a/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderForm.ui.qml b/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderForm.ui.qml index 52ef1c085..0f2363717 100644 --- a/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderForm.ui.qml +++ b/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderForm.ui.qml @@ -11,22 +11,18 @@ Item { width: childrenRect.width height: childrenRect.height - FontLoader { - id: fontExchange - source: "qrc:/Resources/Fonts/roboto_regular.ttf" - } - ColumnLayout { DapUiQmlWidgetExchangeOrderTitleForm { id: orderTitle - orderFont: fontExchange.name + orderFont: "Roboto" + } Text { text: qsTr("Balance: ") + balance + " " + currencyName color: "#ACACAF" - font.family: fontExchange.name + font.family: "Roboto" font.pixelSize: 12 * pt } @@ -37,7 +33,7 @@ Item { } DapUiQmlWidgetExchangeOrderContentForm { - contentFont: fontExchange.name + contentFont: "Roboto" } Rectangle { @@ -46,7 +42,7 @@ Item { } DapUiQmlWidgetExchangeOrderButtonForm { - buttonFont: fontExchange.name + buttonFont: "Roboto" buttonText: titleOrder } } diff --git a/KelvinDashboardGUI/main.cpp b/KelvinDashboardGUI/main.cpp index 94b89492d..94d984564 100755 --- a/KelvinDashboardGUI/main.cpp +++ b/KelvinDashboardGUI/main.cpp @@ -52,6 +52,7 @@ int main(int argc, char *argv[]) controller.init(&dapServiceClient); dapServiceClient.init(); controller.getWallets(); + controller.getHistory(); DapScreenHistoryFilterModel::getInstance() .setSourceModel(&DapScreenHistoryModel::getInstance()); diff --git a/KelvinDashboardService/DapChainHistoryHandler.cpp b/KelvinDashboardService/DapChainHistoryHandler.cpp index 7a06ea47f..2bb2dd5fa 100644 --- a/KelvinDashboardService/DapChainHistoryHandler.cpp +++ b/KelvinDashboardService/DapChainHistoryHandler.cpp @@ -35,7 +35,6 @@ void DapChainHistoryHandler::onRequestNewHistory(const QMap<QString, QVariant>& while ((pos = rx.indexIn(result, pos)) != -1) { QStringList dataItem = QStringList() << rx.cap(1) << QString::number(DapTransactionStatusConvertor::getStatusByShort(rx.cap(4))) << rx.cap(5) << rx.cap(6) << rx.cap(7) << wallets.at(i).toString(); - qDebug() << "NEW MATCH" << pos << dataItem; data << dataItem; pos += rx.matchedLength(); } diff --git a/KelvinDashboardService/DapChainLogHandler.cpp b/KelvinDashboardService/DapChainLogHandler.cpp index 73c633b7e..809610d45 100755 --- a/KelvinDashboardService/DapChainLogHandler.cpp +++ b/KelvinDashboardService/DapChainLogHandler.cpp @@ -13,29 +13,31 @@ DapChainLogHandler::DapChainLogHandler(QObject *parent) : QObject(parent) QStringList DapChainLogHandler::request() { - QStringList m_listLogs; - QFile file(LOG_FILE); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - { - emit onUpdateModel(); - } - else - { - QTextStream in(&file); -// QRegExp rx("(\\[|\\]|\\s)([\\w*]{1,1}[\\w\\s\\W]+)([\\n]|\\])" ); !!! DO NOT DELETE!!! - QRegExp rx("(\\[|\\]|\\s)([\\w*]{1,1}[\\w\\s\\W]+)(\\]|$)" ); - rx.setMinimal(true); + /// TODO: The application doesn't work because of it. It needs to be changed +// QStringList m_listLogs; +// QFile file(LOG_FILE); +// if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) +// { +// emit onUpdateModel(); +// } +// else +// { +// QTextStream in(&file); +//// QRegExp rx("(\\[|\\]|\\s)([\\w*]{1,1}[\\w\\s\\W]+)([\\n]|\\])" ); !!! DO NOT DELETE!!! +// QRegExp rx("(\\[|\\]|\\s)([\\w*]{1,1}[\\w\\s\\W]+)(\\]|$)" ); +// rx.setMinimal(true); - while (!in.atEnd()) { - QString line = in.readLine(); - int pos{0}; - while((pos = rx.indexIn(line, pos)) != -1) - { - m_listLogs.append(rx.cap(2)); - pos += rx.matchedLength(); - } - } - } - return m_listLogs; +// while (!in.atEnd()) { +// QString line = in.readLine(); +// int pos{0}; +// while((pos = rx.indexIn(line, pos)) != -1) +// { +// m_listLogs.append(rx.cap(2)); +// pos += rx.matchedLength(); +// } +// } +// } +// return m_listLogs; + return QStringList(); } diff --git a/KelvinDashboardService/KelvinDashboardService.pro b/KelvinDashboardService/KelvinDashboardService.pro index 306f6d075..1ada50d22 100755 --- a/KelvinDashboardService/KelvinDashboardService.pro +++ b/KelvinDashboardService/KelvinDashboardService.pro @@ -21,8 +21,7 @@ ICON = icon.ico win32 { VERSION = $${VER_MAJ}.$${VER_MIN}.$$VER_PAT DEFINES += CLI_PATH=\\\"./kelvin-node-cli.exe\\\" -# DEFINES += LOG_FILE=\\\"./opt/kelvin-node/var/log/kelvin-node_logs.txt\\\" - DEFINES += LOG_FILE=\\\"./kelvin-node_logs.txt\\\" + DEFINES += LOG_FILE=\\\"./opt/kelvin-node/var/log/kelvin-node_logs.txt\\\" } else { VERSION = $$VER_MAJ\.$$VER_MIN\-$$VER_PAT -- GitLab