]> Nutra Git (v2) - gamesguru/feather.git/commitdiff
Receive: don't refresh model on new block
authortobtoht <tob@featherwallet.org>
Wed, 12 Mar 2025 13:23:39 +0000 (14:23 +0100)
committertobtoht <tob@featherwallet.org>
Wed, 12 Mar 2025 13:23:39 +0000 (14:23 +0100)
src/libwalletqt/Subaddress.cpp
src/libwalletqt/Subaddress.h
src/libwalletqt/Wallet.cpp
src/model/SubaddressModel.cpp
src/model/SubaddressModel.h

index e9985203d4354c986b6ac314c43da4b97c48e4de..95be89f693cbafb3f64a46977ca9c094be0ba003 100644 (file)
@@ -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();
index b57d2370b86da9f591ae1e28eecd32d5ef74da51..2f5f6a111b634e9dd93238813751117a95804f3e 100644 (file)
@@ -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:
index 73a7dd1222cbbafa0589dcf48cc0bb278a6847e3..f9fa06afeed10a70afa8736cc846b2dc97a80c78 100644 (file)
@@ -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());
     }
 }
 
index 3161c80698a4af44cb5abc404155eb185d5bd3de..b67226cbf782dd65ec751ac193c4f0a8d9f6fc27 100644 (file)
@@ -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});
+}
index 4e45c2aad61c7f9bf3fd873ccc9f8a10b8bfc8a3..de6abed6bc3f0374fbb1410475342a92e03a04fd 100644 (file)
@@ -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;