[GUI] Add debugging UI for fetching accounts
This commit is contained in:
parent
2f429e07f1
commit
b8bd8a1905
3 changed files with 53 additions and 20 deletions
|
|
@ -46,6 +46,7 @@ Account* ChainDataModel::getAccount(qint64 id)
|
|||
}
|
||||
catch ( const fc::exception& e )
|
||||
{
|
||||
edump((e.to_detail_string()));
|
||||
Q_EMIT exceptionThrown( QString::fromStdString(e.to_string()) );
|
||||
}
|
||||
});
|
||||
|
|
@ -61,7 +62,6 @@ Account* ChainDataModel::getAccount(QString name)
|
|||
return *itr;
|
||||
}
|
||||
|
||||
|
||||
auto acct = new Account(this);
|
||||
acct->setProperty("id", --m_account_query_num );
|
||||
acct->setProperty("name", name);
|
||||
|
|
@ -93,11 +93,12 @@ Account* ChainDataModel::getAccount(QString name)
|
|||
}
|
||||
catch ( const fc::exception& e )
|
||||
{
|
||||
edump((e.to_detail_string()));
|
||||
Q_EMIT exceptionThrown( QString::fromStdString(e.to_string()) );
|
||||
}
|
||||
});
|
||||
|
||||
return nullptr;
|
||||
return acct;
|
||||
}
|
||||
|
||||
QQmlListProperty<Balance> Account::balances()
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ class Balance : public QObject {
|
|||
class Account : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString name MEMBER name)
|
||||
Q_PROPERTY(qint64 id MEMBER id)
|
||||
Q_PROPERTY(QString name MEMBER name NOTIFY nameChanged)
|
||||
Q_PROPERTY(qint64 id MEMBER id NOTIFY idChanged)
|
||||
Q_PROPERTY(QQmlListProperty<Balance> balances READ balances)
|
||||
|
||||
QString name;
|
||||
|
|
@ -63,6 +63,10 @@ public:
|
|||
qint64 getId()const { return id; }
|
||||
|
||||
QQmlListProperty<Balance> balances();
|
||||
|
||||
signals:
|
||||
void nameChanged();
|
||||
void idChanged();
|
||||
};
|
||||
|
||||
struct by_id;
|
||||
|
|
|
|||
|
|
@ -38,14 +38,42 @@ ApplicationWindow {
|
|||
id: appSettings
|
||||
category: "appSettings"
|
||||
}
|
||||
Connections {
|
||||
target: app
|
||||
onExceptionThrown: console.log("Exception from app: " + message)
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
Button {
|
||||
text: "Transfer"
|
||||
anchors.centerIn: parent
|
||||
onClicked: formBox.showForm(Qt.createComponent("TransferForm.qml"), function() {
|
||||
console.log("Closed form")
|
||||
})
|
||||
}
|
||||
TextField {
|
||||
id: nameField
|
||||
onAccepted: lookupButton.clicked()
|
||||
focus: true
|
||||
}
|
||||
Button {
|
||||
id: lookupButton
|
||||
text: "Lookup"
|
||||
onClicked: {
|
||||
var acct = app.model.getAccount(nameField.text)
|
||||
// @disable-check M126
|
||||
if (acct == null)
|
||||
console.log("Got back null account")
|
||||
else if (acct.id >= 0)
|
||||
console.log(JSON.stringify(acct))
|
||||
else
|
||||
console.log("Waiting for result...")
|
||||
acct.idChanged.connect(function(loadedAcct) {
|
||||
console.log(JSON.stringify(loadedAcct))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FormBox {
|
||||
id: formBox
|
||||
|
|
|
|||
Loading…
Reference in a new issue