MCPcopy Create free account
hub / github.com/ElementsProject/elements / unitChanged

Method unitChanged

src/qt/bitcoinamountfield.cpp:469–492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

467}
468
469void BitcoinAmountField::unitChanged(int idx)
470{
471 const CAsset previous_asset = amount->value().first;
472
473 // Use description tooltip for current unit for the combobox
474 const QVariant& userdata = unit->itemData(idx, Qt::UserRole);
475 if (userdata.type() == QVariant::UserType) {
476 const CAsset asset = userdata.value<CAsset>();
477 unit->setToolTip(tr("Custom asset (%1)").arg(QString::fromStdString(asset.GetHex())));
478
479 amount->setDisplayUnit(asset);
480 } else {
481 // Determine new unit ID
482 int newUnit = userdata.toInt();
483
484 unit->setToolTip(BitcoinUnits::description(newUnit));
485
486 amount->setDisplayUnit(newUnit);
487 }
488
489 if (!(m_allowed_assets.count(previous_asset) || amount->value().first == previous_asset)) {
490 removeAssetChoice(previous_asset);
491 }
492}
493
494void BitcoinAmountField::setDisplayUnit(const CAsset& asset)
495{

Callers

nothing calls this directly

Calls 5

typeMethod · 0.80
countMethod · 0.80
valueMethod · 0.45
GetHexMethod · 0.45
setDisplayUnitMethod · 0.45

Tested by

no test coverage detected