Add DataModel class

This commit is contained in:
Aditya Kulkarni
2019-10-07 11:01:37 -07:00
parent 06244faa29
commit 31cdab70d3
15 changed files with 211 additions and 123 deletions

View File

@@ -7,8 +7,8 @@ BalancesTableModel::BalancesTableModel(QObject *parent)
: QAbstractTableModel(parent) {
}
void BalancesTableModel::setNewData(const QMap<QString, double>* balances,
const QList<UnspentOutput>* outputs)
void BalancesTableModel::setNewData(const QMap<QString, double> balances,
const QList<UnspentOutput> outputs)
{
loading = false;
@@ -16,15 +16,16 @@ void BalancesTableModel::setNewData(const QMap<QString, double>* balances,
// Copy over the utxos for our use
delete utxos;
utxos = new QList<UnspentOutput>();
// This is a QList deep copy.
*utxos = *outputs;
*utxos = outputs;
// Process the address balances into a list
delete modeldata;
modeldata = new QList<std::tuple<QString, double>>();
std::for_each(balances->keyBegin(), balances->keyEnd(), [=] (auto keyIt) {
if (balances->value(keyIt) > 0)
modeldata->push_back(std::make_tuple(keyIt, balances->value(keyIt)));
std::for_each(balances.keyBegin(), balances.keyEnd(), [=] (auto keyIt) {
if (balances.value(keyIt) > 0)
modeldata->push_back(std::make_tuple(keyIt, balances.value(keyIt)));
});
// And then update the data