Browse Source

Add loading indicator to table.

import_zecw
Aditya Kulkarni 6 years ago
parent
commit
35be99170d
  1. 19
      src/balancestablemodel.cpp
  2. 2
      src/balancestablemodel.h
  3. 7
      src/rpc.cpp

19
src/balancestablemodel.cpp

@ -3,13 +3,14 @@
#include "utils.h" #include "utils.h"
BalancesTableModel::BalancesTableModel(QObject *parent) BalancesTableModel::BalancesTableModel(QObject *parent)
: QAbstractTableModel(parent) : QAbstractTableModel(parent) {
{
} }
void BalancesTableModel::setNewData(const QMap<QString, double>* balances, void BalancesTableModel::setNewData(const QMap<QString, double>* balances,
const QList<UnspentOutput>* outputs) const QList<UnspentOutput>* outputs)
{ {
loading = false;
int currentRows = rowCount(QModelIndex()); int currentRows = rowCount(QModelIndex());
// Copy over the utxos for our use // Copy over the utxos for our use
delete utxos; delete utxos;
@ -39,7 +40,12 @@ BalancesTableModel::~BalancesTableModel() {
int BalancesTableModel::rowCount(const QModelIndex&) const int BalancesTableModel::rowCount(const QModelIndex&) const
{ {
if (modeldata == nullptr) return 0; if (modeldata == nullptr) {
if (loading)
return 1;
else
return 0;
}
return modeldata->size(); return modeldata->size();
} }
@ -50,6 +56,13 @@ int BalancesTableModel::columnCount(const QModelIndex&) const
QVariant BalancesTableModel::data(const QModelIndex &index, int role) const QVariant BalancesTableModel::data(const QModelIndex &index, int role) const
{ {
if (loading) {
if (role == Qt::DisplayRole)
return "Loading...";
else
return QVariant();
}
if (role == Qt::TextAlignmentRole && index.column() == 1) return QVariant(Qt::AlignRight | Qt::AlignVCenter); if (role == Qt::TextAlignmentRole && index.column() == 1) return QVariant(Qt::AlignRight | Qt::AlignVCenter);
if (role == Qt::ForegroundRole) { if (role == Qt::ForegroundRole) {

2
src/balancestablemodel.h

@ -21,6 +21,8 @@ public:
private: private:
QList<std::tuple<QString, QString>>* modeldata = nullptr; QList<std::tuple<QString, QString>>* modeldata = nullptr;
QList<UnspentOutput>* utxos = nullptr; QList<UnspentOutput>* utxos = nullptr;
bool loading = true;
}; };
#endif // BALANCESTABLEMODEL_H #endif // BALANCESTABLEMODEL_H

7
src/rpc.cpp

@ -648,9 +648,12 @@ void RPC::refreshSentZTrans() {
// with the confirmed block number, so we don't have to keep calling gettransaction for the // with the confirmed block number, so we don't have to keep calling gettransaction for the
// sent items. // sent items.
for (TransactionItem& sentTx: newSentZTxs) { for (TransactionItem& sentTx: newSentZTxs) {
auto error = txidList->value(sentTx.txid)["confirmations"].is_null(); auto j = txidList->value(sentTx.txid);
if (j.is_null())
continue;
auto error = j["confirmations"].is_null();
if (!error) if (!error)
sentTx.confirmations = txidList->value(sentTx.txid)["confirmations"].get<json::number_unsigned_t>(); sentTx.confirmations = j["confirmations"].get<json::number_unsigned_t>();
} }
transactionsTableModel->addZSentData(newSentZTxs); transactionsTableModel->addZSentData(newSentZTxs);

Loading…
Cancel
Save