X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fqt%2Fmintingtablemodel.cpp;fp=src%2Fqt%2Fmintingtablemodel.cpp;h=7eece74c01e6570d6990f7ac1dbb84b408817412;hb=d2a0c21492bba6b0a78cc6114da7120eb2f46dba;hp=1007c95747dd9436234bd2e085eca47b0b17ca93;hpb=94804ecb3305f240537041fd3f396f867de53b3f;p=novacoin.git diff --git a/src/qt/mintingtablemodel.cpp b/src/qt/mintingtablemodel.cpp index 1007c95..7eece74 100644 --- a/src/qt/mintingtablemodel.cpp +++ b/src/qt/mintingtablemodel.cpp @@ -1,4 +1,5 @@ #include "mintingtablemodel.h" +#include "mintingfilterproxy.h" #include "transactiontablemodel.h" #include "guiutil.h" #include "kernelrecord.h" @@ -157,7 +158,27 @@ public: } else if(inWallet && inModel) { - // Updated -- nothing to do, status update will take care of this + // Updated -- remove spent coins from table + std::vector toCheck = KernelRecord::decomposeOutput(wallet, mi->second); + BOOST_FOREACH(const KernelRecord &rec, toCheck) + { + if(rec.spent) + { + for(int i = 0; i < cachedWallet.size(); i++) + { + KernelRecord cachedRec = cachedWallet.at(i); + if((rec.hash == cachedRec.hash) + && (rec.nTime == cachedRec.nTime) + && (rec.nValue == cachedRec.nValue)) + { + parent->beginRemoveRows(QModelIndex(), i, i); + cachedWallet.removeAt(i); + parent->endRemoveRows(); + break; + } + } + } + } } } } @@ -229,6 +250,16 @@ void MintingTableModel::update() BOOST_FOREACH(uint256 hash, wallet->vMintingWalletUpdated) { updated.append(hash); + + // Also check the inputs to remove spent outputs from the table if necessary + CWalletTx wtx; + if(wallet->GetTransaction(hash, wtx)) + { + BOOST_FOREACH(const CTxIn& txin, wtx.vin) + { + updated.append(txin.prevout.hash); + } + } } wallet->vMintingWalletUpdated.clear(); } @@ -237,9 +268,15 @@ void MintingTableModel::update() if(!updated.empty()) { priv->updateWallet(updated); + mintingProxyModel->invalidate(); // Force deletion of empty rows } } +void MintingTableModel::setMintingProxyModel(MintingFilterProxy *mintingProxy) +{ + mintingProxyModel = mintingProxy; +} + int MintingTableModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent);