[GUI] Add debugging UI for fetching accounts

This commit is contained in:
Nathan Hourt 2015-07-13 16:21:01 -04:00
parent 2f429e07f1
commit b8bd8a1905
3 changed files with 53 additions and 20 deletions

View file

@ -46,6 +46,7 @@ Account* ChainDataModel::getAccount(qint64 id)
} }
catch ( const fc::exception& e ) catch ( const fc::exception& e )
{ {
edump((e.to_detail_string()));
Q_EMIT exceptionThrown( QString::fromStdString(e.to_string()) ); Q_EMIT exceptionThrown( QString::fromStdString(e.to_string()) );
} }
}); });
@ -61,7 +62,6 @@ Account* ChainDataModel::getAccount(QString name)
return *itr; return *itr;
} }
auto acct = new Account(this); auto acct = new Account(this);
acct->setProperty("id", --m_account_query_num ); acct->setProperty("id", --m_account_query_num );
acct->setProperty("name", name); acct->setProperty("name", name);
@ -93,11 +93,12 @@ Account* ChainDataModel::getAccount(QString name)
} }
catch ( const fc::exception& e ) catch ( const fc::exception& e )
{ {
edump((e.to_detail_string()));
Q_EMIT exceptionThrown( QString::fromStdString(e.to_string()) ); Q_EMIT exceptionThrown( QString::fromStdString(e.to_string()) );
} }
}); });
return nullptr; return acct;
} }
QQmlListProperty<Balance> Account::balances() QQmlListProperty<Balance> Account::balances()

View file

@ -47,8 +47,8 @@ class Balance : public QObject {
class Account : public QObject { class Account : public QObject {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString name MEMBER name) Q_PROPERTY(QString name MEMBER name NOTIFY nameChanged)
Q_PROPERTY(qint64 id MEMBER id) Q_PROPERTY(qint64 id MEMBER id NOTIFY idChanged)
Q_PROPERTY(QQmlListProperty<Balance> balances READ balances) Q_PROPERTY(QQmlListProperty<Balance> balances READ balances)
QString name; QString name;
@ -63,6 +63,10 @@ public:
qint64 getId()const { return id; } qint64 getId()const { return id; }
QQmlListProperty<Balance> balances(); QQmlListProperty<Balance> balances();
signals:
void nameChanged();
void idChanged();
}; };
struct by_id; struct by_id;

View file

@ -38,14 +38,42 @@ ApplicationWindow {
id: appSettings id: appSettings
category: "appSettings" category: "appSettings"
} }
Connections {
target: app
onExceptionThrown: console.log("Exception from app: " + message)
}
Column {
anchors.centerIn: parent
Button { Button {
text: "Transfer" text: "Transfer"
anchors.centerIn: parent
onClicked: formBox.showForm(Qt.createComponent("TransferForm.qml"), function() { onClicked: formBox.showForm(Qt.createComponent("TransferForm.qml"), function() {
console.log("Closed form") 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 { FormBox {
id: formBox id: formBox