diff --git a/CellFrameDashboardGUI/DapScreenHistoryModel.cpp b/CellFrameDashboardGUI/DapScreenHistoryModel.cpp index ac5b71693c474e239c347945181a39be5a4402ea..f88c594fefca282206c914d4dee937ef6b4111e5 100644 --- a/CellFrameDashboardGUI/DapScreenHistoryModel.cpp +++ b/CellFrameDashboardGUI/DapScreenHistoryModel.cpp @@ -26,22 +26,6 @@ QHash<int, QByteArray> DapScreenHistoryModel::roleNames() const return names; } -QString DapScreenHistoryModel::toConvertCurrency(const QString& aMoney) const -{ - QString money; - - QStringList major = aMoney.split("."); - if(!major.isEmpty()) money = major.at(0); - else money = aMoney; - - for (int i = money.size() - 3; i >= 1; i -= 3) - money.insert(i, ' '); - - if(major.count() > 1) money.append("." + major.at(1)); - - return money; -} - void DapScreenHistoryModel::receiveNewData(const QVariant& aData) { if(!aData.isValid()) @@ -88,7 +72,7 @@ void DapScreenHistoryModel::receiveNewData(const QVariant& aData) default: break; } - item.Cryptocurrency = toConvertCurrency(item.Cryptocurrency); + item.Cryptocurrency = DapChainConvertor::getInstance().toConvertCurrency(item.Cryptocurrency); item.Cryptocurrency += " " + item.TokenName; item.Currency.append(" USD"); diff --git a/CellFrameDashboardGUI/DapScreenHistoryModel.h b/CellFrameDashboardGUI/DapScreenHistoryModel.h index 0993e31181fa0844d71998d95b24ca952dbf4b89..5df298d2c73bdc75b83623842599fa406b74371c 100644 --- a/CellFrameDashboardGUI/DapScreenHistoryModel.h +++ b/CellFrameDashboardGUI/DapScreenHistoryModel.h @@ -8,6 +8,7 @@ #include <QDateTime> #include <QTimer> #include "DapHistoryType.h" +#include "DapChainConvertor.h" #define MASK_FOR_MODEL QString("MMMM, dd") @@ -43,8 +44,6 @@ public: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QHash<int, QByteArray> roleNames() const override; - Q_INVOKABLE QString toConvertCurrency(const QString& aMoney) const; - public slots: /// Receive new tx history /// @param QList<QStringList> data diff --git a/CellFrameDashboardGUI/DapUiQmlWidgetLastActionsSectionForm.qml b/CellFrameDashboardGUI/DapUiQmlWidgetLastActionsSectionForm.qml index a015babb205d8a140f241e1a11c204e522a42f9e..3acb5e81676f923a1b15fa28e6a56dbe898aff9f 100644 --- a/CellFrameDashboardGUI/DapUiQmlWidgetLastActionsSectionForm.qml +++ b/CellFrameDashboardGUI/DapUiQmlWidgetLastActionsSectionForm.qml @@ -4,8 +4,6 @@ import QtQuick.Controls 2.2 import QtQuick.Layouts 1.12 Rectangle { -// width: dapListView.width -// height: 30 * pt color: "#C2CAD1" Text { diff --git a/CellFrameDashboardGUI/DapUiQmlWidgetStatusBar.qml b/CellFrameDashboardGUI/DapUiQmlWidgetStatusBar.qml index 07448f9a15085d1969143a4e897b3712ccb99353..57f3f619e3b8f2be6ce2e3ed3471717b3014eec9 100644 --- a/CellFrameDashboardGUI/DapUiQmlWidgetStatusBar.qml +++ b/CellFrameDashboardGUI/DapUiQmlWidgetStatusBar.qml @@ -1,6 +1,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.5 import QtQuick.Controls.Styles 1.4 +import DapTransactionHistory 1.0 Rectangle { @@ -63,7 +64,10 @@ Rectangle { if(currentIndex === -1) fieldWalletBalance.text = 0; else - fieldWalletBalance.text = dapChainWalletsModel.get(comboboxWallet.currentIndex).tokens[currentIndex * 2]; + { + var money = dapChainWalletsModel.get(comboboxWallet.currentIndex).tokens[currentIndex * 2]; + fieldWalletBalance.text = dapChainConvertor.toConvertCurrency(money); + } } } diff --git a/CellFrameDashboardGUI/DapUiQmlWidgetStatusBarComboBox.qml b/CellFrameDashboardGUI/DapUiQmlWidgetStatusBarComboBox.qml index a35556d7ddbcbf7fbdfdf6aa073f61299843b18f..19244ec4339b41522675c75920c9926e73396443 100644 --- a/CellFrameDashboardGUI/DapUiQmlWidgetStatusBarComboBox.qml +++ b/CellFrameDashboardGUI/DapUiQmlWidgetStatusBarComboBox.qml @@ -4,24 +4,6 @@ import QtQuick.Controls.Styles 1.4 ComboBox { width: 100 * pt - -// id: comboboxWallet -// anchors.left: parent.left -// anchors.top: parent.top -// anchors.bottom: parent.bottom -// anchors.leftMargin: 30 * pt -// anchors.topMargin: 10 * pt -// anchors.bottomMargin: 10 * pt -// width: 100 * pt -// model: dapChainWalletsModel -// textRole: "name" - - -// delegate: ItemDelegate { -// width: parent.width -// highlighted: parent.highlightedIndex === index -// } - indicator: Image { source: parent.popup.visible ? "qrc:/Resources/Icons/ic_arrow_drop_up.png" : "qrc:/Resources/Icons/ic_arrow_drop_down.png" width: 24 * pt diff --git a/CellFrameDashboardGUI/main.cpp b/CellFrameDashboardGUI/main.cpp index ff2ee42c7a064ba77e8b90d68cd85082918b15c0..4f66a2258a39d7bf887e978577e082cd1343a10f 100755 --- a/CellFrameDashboardGUI/main.cpp +++ b/CellFrameDashboardGUI/main.cpp @@ -24,6 +24,7 @@ #include "DapChainNodeNetworkExplorer.h" #include "DapScreenHistoryFilterModel.h" #include "DapConsoleModel.h" +#include "DapChainConvertor.h" #include <QRegExp> @@ -75,6 +76,7 @@ int main(int argc, char *argv[]) engine.rootContext()->setContextProperty("dapNodeNetworkModel", &DapChainNodeNetworkModel::getInstance()); engine.rootContext()->setContextProperty("dapConsoleModel", &DapConsoleModel::getInstance()); engine.rootContext()->setContextProperty("dapHistoryModel", &DapScreenHistoryFilterModel::getInstance()); + engine.rootContext()->setContextProperty("dapChainConvertor", &DapChainConvertor::getInstance()); engine.rootContext()->setContextProperty("pt", 1.3); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); diff --git a/libCellFrameDashboardCommon/DapChainConvertor.cpp b/libCellFrameDashboardCommon/DapChainConvertor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..34d7d318247b2cc7635370e5b2b52acc1112930e --- /dev/null +++ b/libCellFrameDashboardCommon/DapChainConvertor.cpp @@ -0,0 +1,28 @@ +#include "DapChainConvertor.h" + +DapChainConvertor::DapChainConvertor(QObject *parent) : QObject(parent) +{ + +} + +DapChainConvertor& DapChainConvertor::getInstance() +{ + static DapChainConvertor instance; + return instance; +} + +QString DapChainConvertor::toConvertCurrency(const QString& aMoney) +{ + QString money; + + QStringList major = aMoney.split("."); + if(!major.isEmpty()) money = major.at(0); + else money = aMoney; + + for (int i = money.size() - 3; i >= 1; i -= 3) + money.insert(i, ' '); + + if(major.count() > 1) money.append("." + major.at(1)); + + return money; +} diff --git a/libCellFrameDashboardCommon/DapChainConvertor.h b/libCellFrameDashboardCommon/DapChainConvertor.h new file mode 100644 index 0000000000000000000000000000000000000000..25dcd861f5ab7b7acb1cc0d8fbe28c47245229f9 --- /dev/null +++ b/libCellFrameDashboardCommon/DapChainConvertor.h @@ -0,0 +1,20 @@ +#ifndef DAPCHAINCONVERTOR_H +#define DAPCHAINCONVERTOR_H + +#include <QObject> + +class DapChainConvertor : public QObject +{ + Q_OBJECT + +public: + explicit DapChainConvertor(QObject *parent = nullptr); + /// Get instance of this class + /// @param instance of this class + static DapChainConvertor &getInstance(); + +public slots: + Q_INVOKABLE QString toConvertCurrency(const QString& aMoney); +}; + +#endif // DAPCHAINCONVERTOR_H diff --git a/libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri b/libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri index 6e8beb83da91f703e58e56382528782fa57733e6..44882919b7139474ea4d7cf9f99b2a82352155f5 100755 --- a/libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri +++ b/libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri @@ -13,6 +13,7 @@ QT += quick quickwidgets CONFIG += c++11 SOURCES +=\ + $$PWD/DapChainConvertor.cpp \ $$PWD/DapHalper.cpp \ $$PWD/DapHistoryType.cpp \ $$PWD/DapSettings.cpp \ @@ -22,6 +23,7 @@ SOURCES +=\ $$PWD/DapChainWallet.cpp HEADERS +=\ + $$PWD/DapChainConvertor.h \ $$PWD/DapHalper.h \ $$PWD/DapHistoryType.h \ $$PWD/DapSettings.h \