18 #include "validation.h" 22 #include <QStringList> 39 qDebug() <<
"AssetTablePriv::refreshWallet";
40 cachedBalances.clear();
42 if (currentActiveAssetCache) {
45 std::map<std::string, CAmount> balances;
46 std::map<std::string, std::vector<COutput> > outputs;
48 qWarning(
"AssetTablePriv::refreshWallet: Error retrieving asset balances");
51 std::set<std::string> setAssetsToSkip;
52 auto bal = balances.begin();
53 for (; bal != balances.end(); bal++) {
56 bool fIsAdministrator =
true;
58 if (setAssetsToSkip.count(bal->first))
64 if (!currentActiveAssetCache->GetAssetMetaDataIfExists(bal->first, assetData)) {
65 qWarning(
"AssetTablePriv::refreshWallet: Error retrieving asset data");
68 units = assetData.
units;
70 if (balances.count(bal->first +
OWNER_TAG)) {
71 setAssetsToSkip.insert(bal->first +
OWNER_TAG);
73 fIsAdministrator =
false;
77 std::string name = bal->first;
79 if (balances.count(name)) {
80 setAssetsToSkip.insert(bal->first);
84 cachedBalances.append(
AssetRecord(bal->first, bal->second, units, fIsAdministrator));
92 return cachedBalances.size();
96 if (idx >= 0 && idx < cachedBalances.size()) {
97 return &cachedBalances[idx];
105 QAbstractTableModel(parent),
109 columns << tr(
"Name") << tr(
"Quantity");
120 qDebug() <<
"AssetTableModel::CheckBalanceChanged";
122 Q_EMIT layoutAboutToBeChanged();
125 Q_EMIT layoutChanged();
150 return (
unsigned long long) rec->
quantity;
152 return QString::fromStdString(rec->
name);
159 case Qt::DecorationRole:
167 pixmap = QPixmap::fromImage(QImage(
":/icons/asset_administrator_dark"));
169 pixmap = QPixmap::fromImage(QImage(
":/icons/asset_administrator"));
173 case Qt::ToolTipRole:
182 if (role == Qt::DisplayRole)
186 }
else if (role == Qt::SizeHintRole) {
188 return QSize(300, 50);
189 else if (section == 1)
190 return QSize(200, 50);
191 }
else if (role == Qt::TextAlignmentRole) {
192 return Qt::AlignHCenter + Qt::AlignVCenter;
204 QModelIndex idx = createIndex(row, column,
priv->
index(row));
208 return QModelIndex();
219 return tr(
"Asset Name: ") + QString::fromStdString(wtx->
name);
224 return tr(
"Asset Quantity: ") + QString::fromStdString(wtx->
formattedQuantity());
AssetTableModel(WalletModel *parent=0)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
CCriticalSection cs_main
Global state.
QString formatAssetName(const AssetRecord *wtx) const
AssetTablePriv(AssetTableModel *_parent)
QVariant data(const QModelIndex &index, int role) const
QString formatTooltip(const AssetRecord *rec) const
QString formatAssetQuantity(const AssetRecord *wtx) const
AssetRecord * index(int idx)
void checkBalanceChanged()
QVariant headerData(int section, Qt::Orientation orientation, int role) const
UI model for unspent assets.
Models assets portion of wallet as table of owned assets.
CAssetsCache * GetCurrentAssetCache()
int columnCount(const QModelIndex &parent) const
int rowCount(const QModelIndex &parent) const
QList< AssetRecord > cachedBalances
Interface to Raven wallet from Qt view code.
bool GetAllMyAssetBalances(std::map< std::string, std::vector< COutput > > &outputs, std::map< std::string, CAmount > &amounts, const int confirmations, const std::string &prefix)
sets balances with the total quantity of each owned asset
Formatted amount, without brackets when unconfirmed.
Net amount of transaction.
std::string formattedQuantity() const
bool IsAssetNameAnOwner(const std::string &name)
Check if an asset is an owner.