[GUI] Early work on visualizing a transaction

Super ugly right now, just showing that the data is actually there
This commit is contained in:
Nathan Hourt 2015-07-27 16:59:55 -04:00
parent 5d7ae4e6a8
commit 2c77085bdf
3 changed files with 44 additions and 0 deletions

View file

@ -4,6 +4,13 @@
#include <QVariant>
QString Asset::formatAmount(qint64 amount) const
{
graphene::chain::asset_object ao;
ao.precision = m_precision;
return QString::fromStdString(ao.amount_to_string(amount));
}
void Asset::update(const graphene::chain::asset_object& asset)
{
if (asset.id.instance() != id())

View file

@ -30,6 +30,8 @@ public:
power *= 10;
return power;
}
/// Given an amount like 123401, return "1234.01"
Q_INVOKABLE QString formatAmount(qint64 amount) const;
void update(const graphene::chain::asset_object& asset);

View file

@ -29,4 +29,39 @@ FormBase {
trx.appendOperation(arg[op])
console.log(JSON.stringify(trx))
}
Component {
id: transactionDelegate
Rectangle {
width: Scaling.cm(10)
height: childrenRect.height + Scaling.cm(1)
radius: Scaling.mm(3)
color: "#EEEEEE"
border.width: Scaling.mm(.25)
border.color: "black"
Column {
y: Scaling.cm(.5)
x: y
width: parent.width - Scaling.cm(1)
Repeater {
model: trx.operations
Label {
property Asset transferAsset: app.model.getAsset(modelData.amountType)
property Asset feeAsset: app.model.getAsset(modelData.feeType)
text: qsTr("Transfer %1 %2 from %3 to %4\nFee: %5 %6").arg(transferAsset.formatAmount(modelData.amount))
.arg(transferAsset.symbol)
.arg(app.model.getAccount(modelData.sender).name)
.arg(app.model.getAccount(modelData.receiver).name)
.arg(feeAsset.formatAmount(modelData.fee))
.arg(feeAsset.symbol)
}
}
}
}
}
Loader {
sourceComponent: trx && Array.prototype.slice.call(trx.operations).length > 0? transactionDelegate : undefined
}
}