From 047799cb12773bad1015dd54ef59d459e2ac720a Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sun, 6 Jan 2019 05:53:13 +0000 Subject: [PATCH] CAsset: GetIdentifier to get label or hex id --- src/assetsdir.cpp | 7 +++++++ src/assetsdir.h | 3 +++ src/qt/guiutil.cpp | 6 +----- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/assetsdir.cpp b/src/assetsdir.cpp index 0b897828a3..8ac47edd47 100644 --- a/src/assetsdir.cpp +++ b/src/assetsdir.cpp @@ -72,6 +72,13 @@ std::string CAssetsDir::GetLabel(const CAsset& asset) const return GetMetadata(asset).GetLabel(); } +std::string CAssetsDir::GetIdentifier(const CAsset& asset) const +{ + const std::string label = GetMetadata(asset).GetLabel(); + if (!label.empty()) return label; + return asset.GetHex(); +} + std::vector CAssetsDir::GetKnownAssets() const { std::vector knownAssets; diff --git a/src/assetsdir.h b/src/assetsdir.h index 0c6e6814ca..798e5395f5 100644 --- a/src/assetsdir.h +++ b/src/assetsdir.h @@ -40,6 +40,9 @@ class CAssetsDir /** @return the label associated to the asset id */ std::string GetLabel(const CAsset& asset) const; + /** @return the label associated to the asset id, or some other identifier */ + std::string GetIdentifier(const CAsset& asset) const; + std::vector GetKnownAssets() const; }; diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index f00d12bbec..c76d301615 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -790,12 +790,8 @@ QString formatAssetAmount(const CAsset& asset, const CAmount& amount, const int if (fraction) { str += QString(".%1").arg(fraction, 8, 10, QLatin1Char('0')); } - std::string asset_label = gAssetsDir.GetLabel(asset); - if (asset_label.empty()) { - asset_label = asset.GetHex(); - } if (include_asset_name) { - str += QString(" ") + QString::fromStdString(asset_label); + str += QString(" ") + QString::fromStdString(gAssetsDir.GetIdentifier(asset)); } return str; }