Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoinamountfield.cpp
Show First 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | private: | ||||
mutable QSize cachedMinimumSizeHint; | mutable QSize cachedMinimumSizeHint; | ||||
/** | /** | ||||
* Parse a string into a number of base monetary units and | * Parse a string into a number of base monetary units and | ||||
* return validity. | * return validity. | ||||
* @note Must return 0 if !valid. | * @note Must return 0 if !valid. | ||||
*/ | */ | ||||
Amount parse(const QString &text, bool *valid_out = 0) const { | Amount parse(const QString &text, bool *valid_out = 0) const { | ||||
Amount val = 0; | Amount val(0); | ||||
bool valid = BitcoinUnits::parse(currentUnit, text, &val); | bool valid = BitcoinUnits::parse(currentUnit, text, &val); | ||||
if (valid) { | if (valid) { | ||||
if (val < Amount(0) || val > BitcoinUnits::maxMoney()) { | if (val < Amount(0) || val > BitcoinUnits::maxMoney()) { | ||||
valid = false; | valid = false; | ||||
} | } | ||||
} | } | ||||
if (valid_out) { | if (valid_out) { | ||||
*valid_out = valid; | *valid_out = valid; | ||||
Show All 26 Lines | StepEnabled stepEnabled() const override { | ||||
// Allow step-up with empty field. | // Allow step-up with empty field. | ||||
return StepUpEnabled; | return StepUpEnabled; | ||||
} | } | ||||
StepEnabled rv = 0; | StepEnabled rv = 0; | ||||
bool valid = false; | bool valid = false; | ||||
Amount val = value(&valid); | Amount val = value(&valid); | ||||
if (valid) { | if (valid) { | ||||
if (val > 0) { | if (val > Amount(0)) { | ||||
rv |= StepDownEnabled; | rv |= StepDownEnabled; | ||||
} | } | ||||
if (val < BitcoinUnits::maxMoney()) { | if (val < BitcoinUnits::maxMoney()) { | ||||
rv |= StepUpEnabled; | rv |= StepUpEnabled; | ||||
} | } | ||||
} | } | ||||
return rv; | return rv; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |