diff --git a/KelvinDashboardGUI/DapChainWalletsModel.cpp b/KelvinDashboardGUI/DapChainWalletsModel.cpp index 1abadc1e093f711da67041f961bc0ce7accd8793..8c348c790a8cb0e3a731791c2de864ab89cc421e 100755 --- a/KelvinDashboardGUI/DapChainWalletsModel.cpp +++ b/KelvinDashboardGUI/DapChainWalletsModel.cpp @@ -26,6 +26,7 @@ QVariant DapChainWalletsModel::data(const QModelIndex &index, int role) const case AddressWalletRole: return m_dapChainWallets.at(index.row())->getAddress(); case BalanceWalletRole: return m_dapChainWallets.at(index.row())->getBalance(); case TokensWalletRole: return m_dapChainWallets.at(index.row())->getTokens(); + case CountWalletRole: return m_dapChainWallets.at(index.row())->getCount(); default: return QVariant(); } @@ -39,7 +40,8 @@ QHash<int, QByteArray> DapChainWalletsModel::roleNames() const { NameWalletRole, "name" }, { AddressWalletRole, "address" }, { BalanceWalletRole, "balance" }, - { TokensWalletRole, "tokens" } + { TokensWalletRole, "tokens" }, + { CountWalletRole, "count" } }; return roles; @@ -48,10 +50,10 @@ QHash<int, QByteArray> DapChainWalletsModel::roleNames() const QVariantMap DapChainWalletsModel::get(int row) const { if (m_dapChainWallets.count() == 0) { - return { {"iconPath", ""}, {"name", ""}, {"address", ""}, {"balance", ""}, {"tokens", QStringList()} }; + return { {"iconPath", ""}, {"name", ""}, {"address", ""}, {"balance", ""}, {"tokens", QStringList()}, {"count", 0} }; } const DapChainWallet *wallet = m_dapChainWallets.value(row); - return { {"iconPath", wallet->getIconPath()}, {"name", wallet->getName()}, {"address", wallet->getAddress()}, {"balance", wallet->getBalance()}, {"tokens", wallet->getTokens()} }; + return { {"iconPath", wallet->getIconPath()}, {"name", wallet->getName()}, {"address", wallet->getAddress()}, {"balance", wallet->getBalance()}, {"tokens", wallet->getTokens()}, {"count", wallet->getCount()} }; } void DapChainWalletsModel::append(const DapChainWallet &arWallet) @@ -80,7 +82,7 @@ void DapChainWalletsModel::set(int row, const QString& asIconPath, const QString wallet->setAddress(asAddresss); wallet->setBalance(aBalance); wallet->setTokens(aTokens); - dataChanged(index(row, 0), index(row, 0), { IconWalletRole, NameWalletRole, AddressWalletRole, BalanceWalletRole }); + dataChanged(index(row, 0), index(row, 0), { IconWalletRole, NameWalletRole, AddressWalletRole, BalanceWalletRole, CountWalletRole }); } void DapChainWalletsModel::remove(int row) diff --git a/KelvinDashboardGUI/DapChainWalletsModel.h b/KelvinDashboardGUI/DapChainWalletsModel.h index fe59c4adac99aab061f815949863c5dee46e25d5..afcb2c57d144d63fd91782d133132cbd74145de7 100755 --- a/KelvinDashboardGUI/DapChainWalletsModel.h +++ b/KelvinDashboardGUI/DapChainWalletsModel.h @@ -17,7 +17,8 @@ enum DapChainWalletRole { NameWalletRole = Qt::UserRole, AddressWalletRole, BalanceWalletRole, - TokensWalletRole + TokensWalletRole, + CountWalletRole }; class DapChainWalletsModel : public QAbstractListModel diff --git a/KelvinDashboardGUI/DapUiQmlScreenDialogSendToken.qml b/KelvinDashboardGUI/DapUiQmlScreenDialogSendToken.qml index 960c3f397e1163346be83596556845157880b2db..1e410fb61426f6833817da817b9d91b4e830eb7d 100755 --- a/KelvinDashboardGUI/DapUiQmlScreenDialogSendToken.qml +++ b/KelvinDashboardGUI/DapUiQmlScreenDialogSendToken.qml @@ -57,7 +57,7 @@ Dialog { delegate: ItemDelegate { width: comboBoxToken.width contentItem: Text { - text: modelData + text: token font: comboBoxToken.font elide: Text.ElideRight verticalAlignment: Text.AlignVCenter diff --git a/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.qml b/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.qml index 343588c277e36778d9c744ff995e8d24735ca5e0..fc8a26317c0cc8812a6f61f5e71b9902f8c856a0 100755 --- a/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.qml +++ b/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.qml @@ -27,33 +27,16 @@ DapUiQmlWidgetChainWalletForm { } } } - - - - - - listViewTokens.onCurrentItemChanged: - { - updateBalanceText(); - console.log(textBalance.text); - } - - buttonSaveWallet.onClicked: { - dialogAddWallet.show() - } - - buttonDeleteWallet.onClicked: { - dialogRemoveWallet.show() - } - - buttonSendToken.onClicked: { - dialogSendToken.show() - } listViewWallet.onCurrentItemChanged: { -// listViewTokens.model = listViewWallet.model.get(listViewWallet.currentIndex).tokens - + listViewTokens.model.clear() + for(var i = 0; i < listViewWallet.model.get(listViewWallet.currentIndex).count; i++) + { + var value = listViewWallet.model.get(listViewWallet.currentIndex).balance[i] + listViewTokens.model.append({token: listViewWallet.model.get(listViewWallet.currentIndex).tokens[i], balance: value.replace(/[^\d.-]/g, '')}); + } + if(listViewWallet.currentIndex >= 0) { indexWallet = listViewWallet.currentIndex @@ -65,7 +48,18 @@ DapUiQmlWidgetChainWalletForm { listViewWallet.currentIndex = 0 } -// updateBalanceText(); -// addressWallet.text = listViewWallet.model.get(listViewWallet.currentIndex).address + addressWallet.text = listViewWallet.model.get(listViewWallet.currentIndex).address + } + + buttonSaveWallet.onClicked: { + dialogAddWallet.show() + } + + buttonDeleteWallet.onClicked: { + dialogRemoveWallet.show() + } + + buttonSendToken.onClicked: { + dialogSendToken.show() } } diff --git a/KelvinDashboardGUI/DapUiQmlWidgetChainWalletForm.ui.qml b/KelvinDashboardGUI/DapUiQmlWidgetChainWalletForm.ui.qml index cb4d8936aa283162c47b3000f1eb8c2c2c0d1399..e2c666e5302539b9202199c634a9f72676f9f175 100755 --- a/KelvinDashboardGUI/DapUiQmlWidgetChainWalletForm.ui.qml +++ b/KelvinDashboardGUI/DapUiQmlWidgetChainWalletForm.ui.qml @@ -14,7 +14,6 @@ Page { property alias dialogAddWallet: dialogAddWallet property alias dialogSendToken: dialogSendToken property alias addressWallet: addressWallet - property alias textBalance: textBalance property alias listViewTokens: listViewTokens property alias buttonSendToken: buttonSendToken property alias buttonDeleteWallet: buttonDeleteWallet @@ -71,35 +70,101 @@ Page { anchors.top: parent.top anchors.bottom: parent.bottom - TextEdit { - id: addressWallet - font.pixelSize: 11 - wrapMode: Text.Wrap - selectByMouse: true - color: "black" - selectionColor: "#008080" - clip: true + Row + { + id: rowAddress anchors.top: parent.top - anchors.horizontalCenter: parent.horizontalCenter anchors.left: parent.left - readOnly: true + anchors.right: parent.right + height: 100 + width: parent.width + Rectangle + { + id: rectangleLableAddress + color: "green" + width: 150 + height: parent.height + Text + { + id: labelAddress + anchors.centerIn: parent + text: "Address" + font.pixelSize: 22 + color: "white" + } + } + Column + { + id: columnAddress + width: rowAddress.width - rectangleLableAddress.width + height: parent.height + clip: true + TextEdit { + id: addressWallet + font.pixelSize: 16 + wrapMode: TextEdit.WrapAnywhere + + selectByMouse: true + color: "#353841" + selectionColor: "#353841" + clip: true + readOnly: true + height: parent.height - rectangleBottomBorder.height + width: parent.width + verticalAlignment: TextEdit.AlignVCenter + horizontalAlignment: TextEdit.AlignHCenter + } + Rectangle + { + id: rectangleBottomBorder + color: "green" + height: 1 + width: columnAddress.width + } + } } ListView { id: listViewTokens - orientation: ListView.Vertical - anchors.top: addressWallet.bottom + height: 100 + orientation: ListView.Horizontal + anchors.top: rowAddress.bottom anchors.left: parent.left - anchors.bottom: parent.bottom - width: parent.width * 2 / 3 + anchors.right: parent.right flickableDirection: Flickable.VerticalFlick - delegate: Item { - width: 200 - height: 50 - Text { - id: nameField - text: modelData - color: listViewTokens.currentIndex === index ? 'green' : 'black' + preferredHighlightBegin: parent.width/2-width/3/2; + preferredHighlightEnd: parent.width/2+width/3/2 + highlightRangeMode: ListView.StrictlyEnforceRange + snapMode: ListView.SnapOneItem; + model: ListModel { + id: modelTokens + } + + delegate: Item { + id: delegateListViewTokens + width: listViewTokens.width/3; height: listViewTokens.height + Column + { + id: itemRectangleIfoWallet + anchors.centerIn: delegateListViewTokens + Text { + id: itemNameWallet; + anchors.horizontalCenter: parent.horizontalCenter + text: token; + color: listViewTokens.currentIndex === index ? 'green' : "#BBBEBF"; + font.pixelSize: listViewTokens.currentIndex === index ? 40 : 30; + font.family: "Roboto" + font.weight: Font.Thin + } + Text { + id: itemBalanceWallet; + anchors.horizontalCenter: parent.horizontalCenter + text: balance + color: listViewTokens.currentIndex === index ? 'green' : "#BBBEBF"; + font.pixelSize: listViewTokens.currentIndex === index ? 40 : 30; + font.family: "Roboto" + font.weight: Font.Thin + } } MouseArea { anchors.fill: parent @@ -108,20 +173,26 @@ Page { } focus: true + clip: true } - Text { - id: textBalance - wrapMode: Text.NoWrap - textFormat: Text.PlainText - clip: false - anchors.top: addressWallet.bottom - anchors.left: listViewTokens.right - anchors.bottom: parent.bottom + Rectangle + { + id: rectangleHistory + anchors.top: listViewTokens.bottom + anchors.left: parent.left anchors.right: parent.right - - font.pixelSize: 30 - font.bold: true + color: "green" + width: parent.width + height: 30 + Text + { + id: labelHistory + anchors.centerIn: parent + text: "History" + font.pixelSize: 22 + color: "white" + } } } diff --git a/libKelvinDashboardCommon/DapChainWallet.cpp b/libKelvinDashboardCommon/DapChainWallet.cpp index 1ef76c80b4b531e11736d85201cd5c9438970e20..d2b43c6f24176647b3a86d05768de9e60d605c8b 100755 --- a/libKelvinDashboardCommon/DapChainWallet.cpp +++ b/libKelvinDashboardCommon/DapChainWallet.cpp @@ -71,3 +71,8 @@ void DapChainWallet::setTokens(const QStringList &aTokens) emit tokensChanged(m_tokens); } + +int DapChainWallet::getCount() const +{ + return m_tokens.count(); +} diff --git a/libKelvinDashboardCommon/DapChainWallet.h b/libKelvinDashboardCommon/DapChainWallet.h index 1537b883d8c6dd5cbffcc236379f799c354bf22d..062b86047e3a5c9b584b828593ca443b039afcbd 100755 --- a/libKelvinDashboardCommon/DapChainWallet.h +++ b/libKelvinDashboardCommon/DapChainWallet.h @@ -13,6 +13,7 @@ class DapChainWallet : public QObject QString m_sAddress; QStringList m_balance; QStringList m_tokens; + int m_iCount; public: DapChainWallet(QObject *parent = nullptr) { Q_UNUSED(parent)} @@ -25,6 +26,7 @@ public: Q_PROPERTY(QString address MEMBER m_sAddress READ getAddress WRITE setAddress NOTIFY addressChanged) Q_PROPERTY(QStringList balance MEMBER m_balance READ getBalance WRITE setBalance NOTIFY balanceChanged) Q_PROPERTY(QStringList tokens MEMBER m_tokens READ getTokens WRITE setTokens NOTIFY tokensChanged) + Q_PROPERTY(int count MEMBER m_iCount READ getCount) QString getName() const; void setName(const QString &asName); @@ -40,6 +42,8 @@ public: QStringList getTokens() const; void setTokens(const QStringList& aTokens); + int getCount() const; + signals: void iconPathChanged(const QString& asIconPath); void nameChanged(const QString& asName);