diff --git a/src/qt/mintingtablemodel.cpp b/src/qt/mintingtablemodel.cpp index 18fd6591..5da17b27 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" @@ -153,7 +154,27 @@ class MintingTablePriv } 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; + } + } + } + } } } } @@ -225,6 +246,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(); } @@ -233,9 +264,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); @@ -445,4 +482,3 @@ QModelIndex MintingTableModel::index(int row, int column, const QModelIndex &par return QModelIndex(); } } - diff --git a/src/qt/mintingtablemodel.h b/src/qt/mintingtablemodel.h index c265ce52..db521635 100644 --- a/src/qt/mintingtablemodel.h +++ b/src/qt/mintingtablemodel.h @@ -7,6 +7,7 @@ class CWallet; class MintingTablePriv; +class MintingFilterProxy; class KernelRecord; class WalletModel; @@ -27,6 +28,7 @@ class MintingTableModel : public QAbstractTableModel }; + void setMintingProxyModel(MintingFilterProxy *mintingProxy); int rowCount(const QModelIndex &parent) const; int columnCount(const QModelIndex &parent) const; QVariant data(const QModelIndex &index, int role) const; @@ -41,6 +43,7 @@ class MintingTableModel : public QAbstractTableModel QStringList columns; int mintingInterval; MintingTablePriv *priv; + MintingFilterProxy *mintingProxyModel; QString lookupAddress(const std::string &address, bool tooltip) const; diff --git a/src/qt/mintingview.cpp b/src/qt/mintingview.cpp index 07505757..7b4eb922 100644 --- a/src/qt/mintingview.cpp +++ b/src/qt/mintingview.cpp @@ -108,6 +108,7 @@ void MintingView::setModel(WalletModel *model) mintingProxyModel->setSourceModel(model->getMintingTableModel()); mintingProxyModel->setDynamicSortFilter(true); mintingProxyModel->setSortRole(Qt::EditRole); + model->getMintingTableModel()->setMintingProxyModel(mintingProxyModel); mintingView->setModel(mintingProxyModel); mintingView->setAlternatingRowColors(true);