@@ -176,6 +176,19 @@ class TransactionTablePriv
176176 }
177177 }
178178
179+ void updateAddressBook (const QString& address, const QString& label, bool isMine, const QString& purpose, int status)
180+ {
181+ std::string address2 = address.toStdString ();
182+ int index = 0 ;
183+ for (auto & rec : cachedWallet) {
184+ if (rec.strAddress == address2) {
185+ rec.status .needsUpdate = true ;
186+ Q_EMIT parent->dataChanged (parent->index (index, TransactionTableModel::Status), parent->index (index, TransactionTableModel::Status));
187+ }
188+ index++;
189+ }
190+ }
191+
179192 int size ()
180193 {
181194 return cachedWallet.size ();
@@ -276,6 +289,12 @@ void TransactionTableModel::updateTransaction(const QString &hash, int status, b
276289 priv->updateWallet (updated, status, showTransaction);
277290}
278291
292+ void TransactionTableModel::updateAddressBook (const QString& address, const QString& label, bool isMine,
293+ const QString& purpose, int status)
294+ {
295+ priv->updateAddressBook (address, label, isMine, purpose, status);
296+ }
297+
279298void TransactionTableModel::updateConfirmations ()
280299{
281300 // Blocks came in since last poll.
@@ -669,7 +688,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
669688 case AddressRole:
670689 return QString::fromStdString (rec->strAddress );
671690 case LabelRole:
672- return walletModel-> getAddressTableModel ()-> labelForDestination ( rec->txDest ) ;
691+ return rec->status . label ;
673692 case AmountRole:
674693 return qint64 (rec->credit + rec->debit );
675694 case TxIDRole:
@@ -681,7 +700,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
681700 case TxPlainTextRole:
682701 {
683702 QString details;
684- QString txLabel = walletModel-> getAddressTableModel ()-> labelForDestination ( rec->txDest ) ;
703+ QString txLabel = rec->status . label ;
685704
686705 details.append (formatTxDate (rec));
687706 details.append (" " );
@@ -813,6 +832,16 @@ static void NotifyTransactionChanged(TransactionTableModel *ttm, CWallet *wallet
813832 notification.invoke (ttm);
814833}
815834
835+ static void NotifyAddressBookChanged (TransactionTableModel *ttm, CWallet *wallet, const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)
836+ {
837+ QMetaObject::invokeMethod (ttm, " updateAddressBook" , Qt::QueuedConnection,
838+ Q_ARG (QString, QString::fromStdString (CBitcoinAddress (address).ToString ())),
839+ Q_ARG (QString, QString::fromStdString (label)),
840+ Q_ARG (bool , isMine),
841+ Q_ARG (QString, QString::fromStdString (purpose)),
842+ Q_ARG (int , (int )status));
843+ }
844+
816845static void ShowProgress (TransactionTableModel *ttm, const std::string &title, int nProgress)
817846{
818847 if (nProgress == 0 )
@@ -838,12 +867,14 @@ void TransactionTableModel::subscribeToCoreSignals()
838867{
839868 // Connect signals to wallet
840869 wallet->NotifyTransactionChanged .connect (boost::bind (NotifyTransactionChanged, this , _1, _2, _3));
870+ wallet->NotifyAddressBookChanged .connect (boost::bind (NotifyAddressBookChanged, this , _1, _2, _3, _4, _5, _6));
841871 wallet->ShowProgress .connect (boost::bind (ShowProgress, this , _1, _2));
842872}
843873
844874void TransactionTableModel::unsubscribeFromCoreSignals ()
845875{
846876 // Disconnect signals from wallet
847877 wallet->NotifyTransactionChanged .disconnect (boost::bind (NotifyTransactionChanged, this , _1, _2, _3));
878+ wallet->NotifyAddressBookChanged .disconnect (boost::bind (NotifyAddressBookChanged, this , _1, _2, _3, _4, _5, _6));
848879 wallet->ShowProgress .disconnect (boost::bind (ShowProgress, this , _1, _2));
849880}
0 commit comments