mirror of
https://github.com/feather-wallet/feather.git
synced 2025-04-24 05:08:12 +00:00
Receive: don't refresh model on new block
This commit is contained in:
parent
2c5f766a7b
commit
c5aef15bb0
5 changed files with 28 additions and 2 deletions
src
|
@ -69,6 +69,18 @@ bool Subaddress::refresh(quint32 accountIndex)
|
|||
return !potentialWalletFileCorruption;
|
||||
}
|
||||
|
||||
void Subaddress::updateUsed(quint32 accountIndex)
|
||||
{
|
||||
for (quint32 i = 0; i < m_rows.count(); i++) {
|
||||
SubaddressRow& row = m_rows[i];
|
||||
|
||||
if (m_wallet2->get_subaddress_used({accountIndex, i}) != row.used) {
|
||||
row.used = !row.used;
|
||||
emit rowUpdated(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qsizetype Subaddress::count() const
|
||||
{
|
||||
return m_rows.length();
|
||||
|
|
|
@ -20,6 +20,7 @@ class Subaddress : public QObject
|
|||
|
||||
public:
|
||||
bool refresh(quint32 accountIndex);
|
||||
void updateUsed(quint32 accountIndex);
|
||||
[[nodiscard]] qsizetype count() const;
|
||||
|
||||
const SubaddressRow& row(int index) const;
|
||||
|
@ -38,6 +39,7 @@ public:
|
|||
signals:
|
||||
void refreshStarted() const;
|
||||
void refreshFinished() const;
|
||||
void rowUpdated(qsizetype index) const;
|
||||
void corrupted() const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -545,14 +545,18 @@ void Wallet::onNewBlock(uint64_t walletHeight) {
|
|||
this->syncStatusUpdated(walletHeight, daemonHeight);
|
||||
|
||||
if (this->isSynchronized()) {
|
||||
this->refreshModels();
|
||||
m_history->refresh();
|
||||
m_coins->refresh();
|
||||
this->subaddress()->updateUsed(this->currentSubaddressAccount());
|
||||
}
|
||||
}
|
||||
|
||||
void Wallet::onUpdated() {
|
||||
this->updateBalance();
|
||||
if (this->isSynchronized()) {
|
||||
this->refreshModels();
|
||||
m_history->refresh();
|
||||
m_coins->refresh();
|
||||
this->subaddress()->updateUsed(this->currentSubaddressAccount());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ SubaddressModel::SubaddressModel(QObject *parent, Subaddress *subaddress)
|
|||
{
|
||||
connect(m_subaddress, &Subaddress::refreshStarted, this, &SubaddressModel::beginResetModel);
|
||||
connect(m_subaddress, &Subaddress::refreshFinished, this, &SubaddressModel::endResetModel);
|
||||
connect(m_subaddress, &Subaddress::rowUpdated, this, &SubaddressModel::rowUpdated);
|
||||
}
|
||||
|
||||
int SubaddressModel::rowCount(const QModelIndex &parent) const
|
||||
|
@ -193,3 +194,8 @@ const SubaddressRow& SubaddressModel::entryFromIndex(const QModelIndex &index) c
|
|||
Q_ASSERT(index.isValid() && index.row() < m_subaddress->count());
|
||||
return m_subaddress->row(index.row());
|
||||
}
|
||||
|
||||
void SubaddressModel::rowUpdated(qsizetype index)
|
||||
{
|
||||
emit dataChanged(this->index(index, 0), this->index(index, SubaddressModel::COUNT - 1), {Qt::DisplayRole, Qt::EditRole});
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ public:
|
|||
|
||||
void setCurrentSubaddressAccount(quint32 accountIndex);
|
||||
|
||||
void rowUpdated(qsizetype index);
|
||||
|
||||
private:
|
||||
Subaddress *m_subaddress;
|
||||
QVariant parseSubaddressRow(const SubaddressRow &subaddress, const QModelIndex &index, int role) const;
|
||||
|
|
Loading…
Reference in a new issue