diff --git a/KelvinDashboardGUI/DapScreenHistoryModel.cpp b/KelvinDashboardGUI/DapScreenHistoryModel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..779bc194f0b948c7b8afa7d3c9cc4cf92dabd1ec --- /dev/null +++ b/KelvinDashboardGUI/DapScreenHistoryModel.cpp @@ -0,0 +1,63 @@ +#include "DapScreenHistoryModel.h" + +DapScreenHistoryModel::DapScreenHistoryModel(QObject *parent) + : QAbstractListModel(parent) +{ + for(int i = 0; i < 5; i++) + { + DapTransactionItem element; + element.TokenName = QString("token %1").arg(i); + element.Date = "today"; + element.WalletNumber = "number wallet"; + element.Status = "sent"; + m_elementList.append(element); + } + + for(int i = 0; i < 5; i++) + { + DapTransactionItem element; + element.TokenName = QString("token %1").arg(i); + element.Date = "yesterday"; + element.WalletNumber = "number wallet"; + element.Status = "sent"; + m_elementList.append(element); + } +} + +DapScreenHistoryModel& DapScreenHistoryModel::getInstance() +{ + static DapScreenHistoryModel instance; + return instance; +} + +QHash<int, QByteArray> DapScreenHistoryModel::roleNames() const +{ + QHash<int, QByteArray> names; + names[DisplayDateRole] = "date"; + names[DisplayNameTokenRole] = "tokenName"; + names[DisplayNumberWalletRole] = "numberWallet"; + return names; +} + +int DapScreenHistoryModel::rowCount(const QModelIndex &parent) const +{ + // For list models only the root node (an invalid parent) should return the list's size. For all + // other (valid) parents, rowCount() should return 0 so that it does not become a tree model. + if (parent.isValid()) return 0; + + // FIXME: Implement me! + return m_elementList.count(); +} + +QVariant DapScreenHistoryModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) return QVariant(); + + switch (role) + { + case DisplayDateRole: return m_elementList.at(index.row()).Date; + case DisplayNameTokenRole: return m_elementList.at(index.row()).TokenName; + case DisplayNumberWalletRole: return m_elementList.at(index.row()).WalletNumber; + default: return QVariant(); + } +} diff --git a/KelvinDashboardGUI/DapScreenHistoryModel.h b/KelvinDashboardGUI/DapScreenHistoryModel.h new file mode 100644 index 0000000000000000000000000000000000000000..aa50bf6d11688e0ac5ca1a300c7e06860499dce8 --- /dev/null +++ b/KelvinDashboardGUI/DapScreenHistoryModel.h @@ -0,0 +1,47 @@ +#ifndef DAPSCREENHISTORYMODEL_H +#define DAPSCREENHISTORYMODEL_H + +#include <QDebug> +#include <QImage> +#include <QAbstractListModel> + +struct DapTransactionItem { + QString Date; + QImage TokenPic; + QString Status; + QString TokenName; + QString WalletNumber; + QString Cryptocurrency; + QString Currency; +}; + +class DapScreenHistoryModel : public QAbstractListModel +{ + Q_OBJECT + +private: + enum { + DisplayDateRole = Qt::UserRole, + DisplayNameTokenRole, + DisplayNumberWalletRole, + DisplayStatusRole, + DisplayCryptocurrency, + DisplayCurrency + }; + + QList<DapTransactionItem> m_elementList; + +public: + explicit DapScreenHistoryModel(QObject *parent = nullptr); + static DapScreenHistoryModel &getInstance(); + + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + QHash<int, QByteArray> roleNames() const override; + +public slots: + + +}; + +#endif // DAPSCREENHISTORYMODEL_H diff --git a/KelvinDashboardGUI/DapUiQmlScreenDashboard.qml b/KelvinDashboardGUI/DapUiQmlScreenDashboard.qml index ff2c19247c3b9829b98bd66ca72596e7aa8a05f6..af3bfd55dfad6c93fbe27ac3f1546c2f67687041 100755 --- a/KelvinDashboardGUI/DapUiQmlScreenDashboard.qml +++ b/KelvinDashboardGUI/DapUiQmlScreenDashboard.qml @@ -35,7 +35,8 @@ Page { } ListElement { name: qsTr("Logs") - page: "DapUiQmlWidgetChainNodeLogs.qml" +// page: "DapUiQmlWidgetChainNodeLogs.qml" + page: "DapUiQmlScreenHistory.qml" source: "qrc:/Resources/Icons/logs.png" } ListElement { diff --git a/KelvinDashboardGUI/DapUiQmlScreenHistory.qml b/KelvinDashboardGUI/DapUiQmlScreenHistory.qml new file mode 100644 index 0000000000000000000000000000000000000000..a0a21b19a3a41da9a8ca8e333d59ebf1c95621f1 --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlScreenHistory.qml @@ -0,0 +1,124 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.12 + +Page { +// ListModel { +// id: modeListView + +// ListElement { nameToken: "token1"; numberWallet: "123"; txStatus: "Error"; date: "today" } +// ListElement { nameToken: "token2"; numberWallet: "234"; txStatus: "Sent"; date: "tomorrow" } +// } + + ListView { + id: dapListView + anchors.fill: parent +// model: modeListView + model: dapHistoryModel + delegate: dapDelegate + section.property: "date" + section.criteria: ViewSection.FullString + section.delegate: dapDate + } + + Component { + id: dapDate + Rectangle { + width: dapListView.width + height: childrenRect.height + color: "#DFE1E6" + + Text { + color: "#5F5F63" + text: section + font.family: "Regular" + font.pointSize: 12 + leftPadding: 30 + } + } + } + + Component { + id: dapDelegate + + Rectangle { + id: dapDelegateContent + border.color: "#000000" + border.width: 1 + height: 60 + width: dapListView.width + anchors.leftMargin: 30 + anchors.rightMargin: 20 + + RowLayout { + anchors.fill: parent + spacing: 30 + + Rectangle { + id: dapToken + border.color: "#000000" + border.width: 1 + width: 60 + height: parent.height + + Image { + id: dapPicToken + width: 30 + height: 30 + anchors.topMargin: 15 + anchors.bottomMargin: 15 + anchors.left: parent.right + fillMode: Image.PreserveAspectFit + } + } + + Rectangle { + width: 246 + height: dapTokenName.contentHeight + anchors.topMargin: 24 + anchors.bottomMargin: 24 + + Text { + id: dapTokenName + text: tokenName + color: "#4F5357" + font.family: "Regular" + font.pointSize: 12 + } + + } + + Rectangle { + width: 330 + height: dapNumberWallet.contentHeight + anchors.topMargin: 24 + anchors.bottomMargin: 24 + + Text { + id: dapNumberWallet + text: numberWallet + color: "#4F5357" + font.family: "Regular" + font.pointSize: 12 + } + } + + + Rectangle { + width: 100 + height: dapStatus.contentHeight + anchors.topMargin: 24 + anchors.bottomMargin: 24 + + Text { + id: dapStatus + text: txStatus + color: "#4F5357" + font.family: "Regular" + font.pointSize: 12 + } + } + } + } + } +} diff --git a/KelvinDashboardGUI/KelvinDashboardGUI.pro b/KelvinDashboardGUI/KelvinDashboardGUI.pro index 46a8b6e30709ae62f6a2598d2a7efd113a4bf2d6..0fbdf8de95a5ee912642dc845c298822229726ee 100755 --- a/KelvinDashboardGUI/KelvinDashboardGUI.pro +++ b/KelvinDashboardGUI/KelvinDashboardGUI.pro @@ -42,6 +42,7 @@ ICON = icon.ico SOURCES += \ DapChainNodeNetworkExplorer.cpp \ DapChainNodeNetworkModel.cpp \ + DapScreenHistoryModel.cpp \ DapUiQmlWidgetChainTransactions.cpp \ main.cpp \ DapUiQmlWidgetChainBallance.cpp \ @@ -76,6 +77,7 @@ else: unix:!android: target.path = /opt/kelvin-dashboard/bin HEADERS += \ DapChainNodeNetworkExplorer.h \ DapChainNodeNetworkModel.h \ + DapScreenHistoryModel.h \ DapUiQmlWidgetChainBallance.h \ DapUiQmlWidgetChainBlockExplorer.h \ DapUiQmlWidgetChainNodeLogs.h \ diff --git a/KelvinDashboardGUI/main.cpp b/KelvinDashboardGUI/main.cpp index 8dface83a4ba01dfbcf4f55a5ae2a4974bbd2644..3aced68c19a01c83292431840c4b893f1882a527 100755 --- a/KelvinDashboardGUI/main.cpp +++ b/KelvinDashboardGUI/main.cpp @@ -22,6 +22,8 @@ #include "DapChainNodeNetworkModel.h" #include "DapChainNodeNetworkExplorer.h" +#include "DapScreenHistoryModel.h" + #include <QRegExp> int main(int argc, char *argv[]) @@ -51,11 +53,12 @@ int main(int argc, char *argv[]) controller.getNodeLogs(0, 100); controller.getWallets(); // controller.getNodeNetwork(); - + qmlRegisterType<DapScreenDialog>("KelvinDashboard", 1, 0, "DapScreenDialog"); qmlRegisterType<DapScreenDialogChangeWidget>("KelvinDashboard", 1, 0, "DapScreenDialogChangeWidget"); qmlRegisterType<DapLogMessage>("LogMessage", 1, 0, "DapLogMessage"); qmlRegisterType<DapChainNodeNetworkExplorer>("NodeNetworkExplorer", 1, 0, "DapUiQmlWidgetNodeNetwork"); +// qmlRegisterType<DapScreenHistoryModel>("") qmlRegisterSingletonType<DapUiQmlWidgetModel>("KelvinDashboard", 1, 0, "DapUiQmlWidgetModel", DapUiQmlWidgetModel::singletonProvider); QQmlApplicationEngine engine; @@ -64,6 +67,7 @@ int main(int argc, char *argv[]) engine.rootContext()->setContextProperty("dapLogModel", &DapLogModel::getInstance()); engine.rootContext()->setContextProperty("dapChainWalletsModel", &DapChainWalletsModel::getInstance()); engine.rootContext()->setContextProperty("dapNodeNetworkModel", &DapChainNodeNetworkModel::getInstance()); + engine.rootContext()->setContextProperty("dapHistoryModel", &DapScreenHistoryModel::getInstance()); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); // DapSettings &settings = DapSettings::getInstance("Settings.json"); diff --git a/KelvinDashboardGUI/qml.qrc b/KelvinDashboardGUI/qml.qrc index 1970cadf08a8b96312ee27840d1a2036237ea4c1..db35c92dc2fb94b36328191c653471117cfb9bc0 100755 --- a/KelvinDashboardGUI/qml.qrc +++ b/KelvinDashboardGUI/qml.qrc @@ -37,7 +37,8 @@ <file>DapUiQmlScreenDialogRemoveWallet.qml</file> <file>DapUiQmlWidgetConsoleForm.ui.qml</file> <file>DapUiQmlWidgetConsole.qml</file> - <file>Resources/Icons/logs.png</file> + <file>Resources/Icons/logs.png</file> <file>DapUiQmlWidgetNodeNetworkExplorer.qml</file> + <file>DapUiQmlScreenHistory.qml</file> </qresource> </RCC>