Add loading indicator to table.
This commit is contained in:
parent
1adb4cf820
commit
35be99170d
|
@ -3,13 +3,14 @@
|
|||
#include "utils.h"
|
||||
|
||||
BalancesTableModel::BalancesTableModel(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
: QAbstractTableModel(parent) {
|
||||
}
|
||||
|
||||
void BalancesTableModel::setNewData(const QMap<QString, double>* balances,
|
||||
const QList<UnspentOutput>* outputs)
|
||||
{
|
||||
loading = false;
|
||||
|
||||
int currentRows = rowCount(QModelIndex());
|
||||
// Copy over the utxos for our use
|
||||
delete utxos;
|
||||
|
@ -39,7 +40,12 @@ BalancesTableModel::~BalancesTableModel() {
|
|||
|
||||
int BalancesTableModel::rowCount(const QModelIndex&) const
|
||||
{
|
||||
if (modeldata == nullptr) return 0;
|
||||
if (modeldata == nullptr) {
|
||||
if (loading)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
return modeldata->size();
|
||||
}
|
||||
|
||||
|
@ -50,6 +56,13 @@ int BalancesTableModel::columnCount(const QModelIndex&) 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::ForegroundRole) {
|
||||
|
|
|
@ -21,6 +21,8 @@ public:
|
|||
private:
|
||||
QList<std::tuple<QString, QString>>* modeldata = nullptr;
|
||||
QList<UnspentOutput>* utxos = nullptr;
|
||||
|
||||
bool loading = true;
|
||||
};
|
||||
|
||||
#endif // BALANCESTABLEMODEL_H
|
|
@ -648,9 +648,12 @@ void RPC::refreshSentZTrans() {
|
|||
// with the confirmed block number, so we don't have to keep calling gettransaction for the
|
||||
// sent items.
|
||||
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)
|
||||
sentTx.confirmations = txidList->value(sentTx.txid)["confirmations"].get<json::number_unsigned_t>();
|
||||
sentTx.confirmations = j["confirmations"].get<json::number_unsigned_t>();
|
||||
}
|
||||
|
||||
transactionsTableModel->addZSentData(newSentZTxs);
|
||||
|
|
Loading…
Reference in New Issue