wowlet/src/vr/qml/wallet/HistoryTable.qml

188 lines
7.2 KiB
QML
Raw Normal View History

2021-04-05 12:37:41 +01:00
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.2
import wowlet.Wallet 1.0
import wowlet.WalletManager 1.0
import wowlet.TransactionHistory 1.0
import wowlet.TransactionInfo 1.0
import wowlet.TransactionHistoryModel 1.0
import wowlet.TransactionHistoryProxyModel 1.0
import "../common"
Item {
id: root
2021-04-06 01:20:42 +01:00
property var txModel
property int txCount: 0
2021-04-05 12:37:41 +01:00
property var txModelData: []
property int sideMargin: 20
ListModel { id: txListViewModel }
ColumnLayout {
anchors.fill: parent
spacing: 0
2021-04-06 01:20:42 +01:00
MyText {
visible: txCount == 0
text: "No transactions to display."
2021-04-08 02:40:44 +01:00
fontColor: Style.fontColorBright
2021-04-06 01:20:42 +01:00
}
2021-04-05 12:37:41 +01:00
ListView {
id: listView
visible: true
Layout.fillWidth: true
Layout.fillHeight: true
spacing: 10
2021-04-06 01:20:42 +01:00
model: txModel
2021-04-05 12:37:41 +01:00
interactive: false
delegate: Rectangle {
2021-04-06 01:20:42 +01:00
id: delegate
2021-04-05 12:37:41 +01:00
anchors.left: parent ? parent.left : undefined
anchors.right: parent ? parent.right : undefined
height: 54
2021-04-08 02:40:44 +01:00
color: Style.historyBackgroundColor
2021-04-05 12:37:41 +01:00
property bool isout: false;
property string amount: "0";
property string description: "";
property string date: "2021-13-37";
property bool confirmed: false
property bool failed: false
property bool pending: false
property int confirmations: 0
property int confirmationsRequired: 0
Component.onCompleted: {
isout = getTxData(index, TransactionHistoryModel.TransactionIsOutRole);
amount = getTxData(index, TransactionHistoryModel.Amount);
description = getTxData(index, TransactionHistoryModel.Description);
date = getTxData(index, TransactionHistoryModel.Date);
failed = getTxData(index, TransactionHistoryModel.TransactionFailedRole);
pending = getTxData(index, TransactionHistoryModel.TransactionPendingRole);
confirmations = getTxData(index, TransactionHistoryModel.TransactionConfirmationsRole);
confirmationsRequired = getTxData(index, TransactionHistoryModel.TransactionConfirmationsRequiredRole);
confirmed = confirmations >= confirmationsRequired;
2021-04-06 01:20:42 +01:00
root.txCount = index;
2021-04-05 12:37:41 +01:00
}
RowLayout {
spacing: 0
clip: true
height: parent.height
anchors.left: parent.left
anchors.right: parent.right
Rectangle {
2021-04-06 01:20:42 +01:00
Layout.preferredWidth: 56
Layout.fillHeight: true
2021-04-08 02:40:44 +01:00
color: Style.historyBackgroundColorBright
2021-04-06 01:20:42 +01:00
Image {
width: 32
height: 32
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
source: {
2021-04-05 12:37:41 +01:00
if(failed) return "qrc:/assets/images/warning.png"
else if(pending) return "qrc:/assets/images/unconfirmed.png"
else if(!confirmed) return "qrc:/assets/images/clock1.png"
else return "qrc:/assets/images/confirmed.png"
//confirmed ? "qrc:/checkmark_icon" : "qrc:/expired_icon"
}
2021-04-06 01:20:42 +01:00
}
2021-04-05 12:37:41 +01:00
}
Rectangle {
2021-04-06 01:20:42 +01:00
Layout.preferredWidth: 300
Layout.leftMargin: 10
Layout.rightMargin: 10
Layout.fillHeight: true
color: "transparent"
2021-04-05 12:37:41 +01:00
2021-04-06 01:20:42 +01:00
MyText {
2021-04-05 12:37:41 +01:00
// date
2021-04-06 01:20:42 +01:00
anchors.verticalCenter: parent.verticalCenter
fontSize: 22
2021-04-08 02:40:44 +01:00
fontColor: Style.fontColorBright
2021-04-06 01:20:42 +01:00
text: date
2021-04-05 12:37:41 +01:00
2021-04-06 01:20:42 +01:00
Component.onCompleted: {
parent.Layout.preferredWidth = width;
}
}
2021-04-05 12:37:41 +01:00
}
Rectangle {
2021-04-06 01:20:42 +01:00
Layout.fillHeight: true
Layout.leftMargin: 10
color: "transparent"
MyText {
anchors.verticalCenter: parent.verticalCenter
fontSize: 22
2021-04-06 01:20:42 +01:00
text: description !== "" ? description : "..."
2021-04-08 02:40:44 +01:00
fontColor: description !== "" ? Style.fontColorBright : Style.fontColorDimmed
2021-04-06 01:20:42 +01:00
Component.onCompleted: {
parent.Layout.preferredWidth = width;
}
}
2021-04-05 12:37:41 +01:00
}
Item {
2021-04-06 01:20:42 +01:00
Layout.fillWidth: true
2021-04-05 12:37:41 +01:00
}
Rectangle {
2021-04-06 01:20:42 +01:00
Layout.preferredWidth: 420
Layout.fillHeight: true
2021-04-08 02:40:44 +01:00
color: Style.historyBackgroundColorBright
2021-04-06 01:20:42 +01:00
MyText {
anchors.right: parent.right
anchors.rightMargin: 10
anchors.verticalCenter: parent.verticalCenter
fontSize: 24
2021-04-06 01:20:42 +01:00
fontBold: true
text: amount
2021-04-08 02:40:44 +01:00
fontColor: !isout ? Style.historyFontColorPlusAmount : Style.historyFontColorMinAmount
2021-04-06 01:20:42 +01:00
}
2021-04-05 12:37:41 +01:00
}
2021-04-06 01:20:42 +01:00
}
}
}
2021-04-05 12:37:41 +01:00
2021-04-06 01:20:42 +01:00
Item {
Layout.fillHeight: true
}
2021-04-05 12:37:41 +01:00
}
2021-04-06 01:20:42 +01:00
Rectangle {
z: parent.z - 1
color: "transparent"
anchors.fill: parent
}
2021-04-05 12:37:41 +01:00
2021-04-06 01:20:42 +01:00
function getTxData(x, y) {
var idx = txModel.index(x, y);
return txModel.data(idx, 0);
2021-04-05 12:37:41 +01:00
}
function onPageCompleted() {
if(currentWallet == null || typeof currentWallet.history === "undefined" ) return;
2021-04-06 01:20:42 +01:00
root.txCount = 0;
root.txModel = appWindow.currentWallet.historyModel;
2021-04-05 12:37:41 +01:00
//root.model.sortRole = TransactionHistoryModel.TransactionBlockHeightRole;
//root.model.sort(0, Qt.DescendingOrder);
}
}