mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-11-17 08:17:59 +00:00
Merge pull request #2775
fbfc531
History: display Address Book names for known destination addresses (xiphon)
This commit is contained in:
commit
7c38a836d3
4 changed files with 31 additions and 3 deletions
|
@ -633,7 +633,17 @@ Rectangle {
|
||||||
MoneroComponents.TextPlain {
|
MoneroComponents.TextPlain {
|
||||||
font.family: MoneroComponents.Style.fontRegular.name
|
font.family: MoneroComponents.Style.fontRegular.name
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
text: isout ? qsTr("Sent") : qsTr("Received") + translationManager.emptyString
|
text: {
|
||||||
|
if (!isout) {
|
||||||
|
return qsTr("Received") + translationManager.emptyString;
|
||||||
|
}
|
||||||
|
const addressBookName = currentWallet ? currentWallet.addressBook.getDescription(address) : null;
|
||||||
|
if (!addressBookName)
|
||||||
|
{
|
||||||
|
return qsTr("Sent") + translationManager.emptyString;
|
||||||
|
}
|
||||||
|
return addressBookName;
|
||||||
|
}
|
||||||
color: MoneroComponents.Style.historyHeaderTextColor
|
color: MoneroComponents.Style.historyHeaderTextColor
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
themeTransitionBlackColor: MoneroComponents.Style._b_historyHeaderTextColor
|
themeTransitionBlackColor: MoneroComponents.Style._b_historyHeaderTextColor
|
||||||
|
|
|
@ -55,8 +55,10 @@ void AddressBook::getAll()
|
||||||
{
|
{
|
||||||
QWriteLocker locker(&m_lock);
|
QWriteLocker locker(&m_lock);
|
||||||
|
|
||||||
|
m_addresses.clear();
|
||||||
m_rows.clear();
|
m_rows.clear();
|
||||||
for (auto &abr: m_addressBookImpl->getAll()) {
|
for (auto &abr: m_addressBookImpl->getAll()) {
|
||||||
|
m_addresses.insert(QString::fromStdString(abr->getAddress()), m_rows.size());
|
||||||
m_rows.append(abr);
|
m_rows.append(abr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,3 +130,15 @@ int AddressBook::lookupPaymentID(const QString &payment_id) const
|
||||||
|
|
||||||
return m_addressBookImpl->lookupPaymentID(payment_id.toStdString());
|
return m_addressBookImpl->lookupPaymentID(payment_id.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString AddressBook::getDescription(const QString &address) const
|
||||||
|
{
|
||||||
|
QReadLocker locker(&m_lock);
|
||||||
|
|
||||||
|
const QMap<QString, size_t>::const_iterator it = m_addresses.find(address);
|
||||||
|
if (it == m_addresses.end())
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return QString::fromStdString(m_rows.value(*it)->getDescription());
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#define ADDRESSBOOK_H
|
#define ADDRESSBOOK_H
|
||||||
|
|
||||||
#include <wallet/api/wallet2_api.h>
|
#include <wallet/api/wallet2_api.h>
|
||||||
|
#include <QMap>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QReadWriteLock>
|
#include <QReadWriteLock>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
@ -51,6 +52,7 @@ public:
|
||||||
Q_INVOKABLE QString errorString() const;
|
Q_INVOKABLE QString errorString() const;
|
||||||
Q_INVOKABLE int errorCode() const;
|
Q_INVOKABLE int errorCode() const;
|
||||||
Q_INVOKABLE int lookupPaymentID(const QString &payment_id) const;
|
Q_INVOKABLE int lookupPaymentID(const QString &payment_id) const;
|
||||||
|
Q_INVOKABLE QString getDescription(const QString &address) const;
|
||||||
|
|
||||||
enum ErrorCode {
|
enum ErrorCode {
|
||||||
Status_Ok,
|
Status_Ok,
|
||||||
|
@ -76,7 +78,8 @@ private:
|
||||||
friend class Wallet;
|
friend class Wallet;
|
||||||
Monero::AddressBook * m_addressBookImpl;
|
Monero::AddressBook * m_addressBookImpl;
|
||||||
mutable QReadWriteLock m_lock;
|
mutable QReadWriteLock m_lock;
|
||||||
mutable QList<Monero::AddressBookRow*> m_rows;
|
QList<Monero::AddressBookRow*> m_rows;
|
||||||
|
QMap<QString, size_t> m_addresses;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ADDRESSBOOK_H
|
#endif // ADDRESSBOOK_H
|
||||||
|
|
|
@ -74,7 +74,7 @@ class Wallet : public QObject
|
||||||
Q_PROPERTY(TransactionHistorySortFilterModel * historyModel READ historyModel NOTIFY historyModelChanged)
|
Q_PROPERTY(TransactionHistorySortFilterModel * historyModel READ historyModel NOTIFY historyModelChanged)
|
||||||
Q_PROPERTY(QString path READ path)
|
Q_PROPERTY(QString path READ path)
|
||||||
Q_PROPERTY(AddressBookModel * addressBookModel READ addressBookModel)
|
Q_PROPERTY(AddressBookModel * addressBookModel READ addressBookModel)
|
||||||
Q_PROPERTY(AddressBook * addressBook READ addressBook)
|
Q_PROPERTY(AddressBook * addressBook READ addressBook NOTIFY addressBookChanged)
|
||||||
Q_PROPERTY(SubaddressModel * subaddressModel READ subaddressModel)
|
Q_PROPERTY(SubaddressModel * subaddressModel READ subaddressModel)
|
||||||
Q_PROPERTY(Subaddress * subaddress READ subaddress)
|
Q_PROPERTY(Subaddress * subaddress READ subaddress)
|
||||||
Q_PROPERTY(SubaddressAccountModel * subaddressAccountModel READ subaddressAccountModel)
|
Q_PROPERTY(SubaddressAccountModel * subaddressAccountModel READ subaddressAccountModel)
|
||||||
|
@ -357,6 +357,7 @@ signals:
|
||||||
void moneyReceived(const QString &txId, quint64 amount);
|
void moneyReceived(const QString &txId, quint64 amount);
|
||||||
void unconfirmedMoneyReceived(const QString &txId, quint64 amount);
|
void unconfirmedMoneyReceived(const QString &txId, quint64 amount);
|
||||||
void newBlock(quint64 height, quint64 targetHeight);
|
void newBlock(quint64 height, quint64 targetHeight);
|
||||||
|
void addressBookChanged() const;
|
||||||
void historyModelChanged() const;
|
void historyModelChanged() const;
|
||||||
void walletCreationHeightChanged();
|
void walletCreationHeightChanged();
|
||||||
void deviceButtonRequest(quint64 buttonCode);
|
void deviceButtonRequest(quint64 buttonCode);
|
||||||
|
|
Loading…
Reference in a new issue