A Qt Widget to display a money entry. More...
#include <MoneyEntryWidget.h>
Public Slots | |
void | setCurrentIndex (const int index) |
Sets the current index of the currency code. | |
Signals | |
void | currentIndexChanged (int index) |
Triggered when the current index of the currency selection changes. | |
void | editingFinished () |
Triggered when the user finishes editing the displayed money amount. | |
void | moneyChanged (const pecunia::Money &m) |
Triggered when the value of the money changes. | |
Public Member Functions | |
MoneyEntryWidget (const foundation::QtPtr< QWidget > &parent) | |
Fully initialises the widget. | |
pecunia::Money | amount () const |
An accessor to the displayed amount of money. | |
std::optional<::QString > | amountErrorMessage () const noexcept |
Determines if the money as entered in the widget is valid, i.e. no errors. | |
void | clear () |
Clears the money entry fields within the widget. | |
pecunia::Currency | code () const |
Retrieves the current code from the code GUI element. | |
std::set< pecunia::Currency > | currencies () const noexcept |
An accessor to the possible currencies that are selectable. | |
void | disableCurrencySelection () |
Disables the currency selection GUI element. | |
void | enableCurrencySelection () |
Enables the currency selection GUI element in the money entry widget. | |
void | hideCodes () |
Hides the currency code selection GUI element. | |
bool | isReadOnly () const |
An accessor that, when true, shows if the widget is read-only. | |
void | setAmount (const pecunia::Money &money) |
Changes the displayed amount of money. | |
void | setLabel (const QString &text) |
Changes the label text for the money entry widget. | |
void | setReadOnly (const bool isReadOnly) |
Sets the widget to a read-only or editable state. | |
void | setUsableCurrencies (const std::set< pecunia::Currency > &codes, const navigation::CurrencyDisplayOptions &displayAs) |
Changes the set of usable currencies for the widget. | |
void | setUsableCurrency (const pecunia::Currency &code, const navigation::CurrencyDisplayOptions &displayAs) |
Changes the possible currencies that a user can select. | |
void | showCodes () |
Shows the currency code selection GUI element. | |
void | showLabel (const bool shouldShow) |
Controls the visibility of the amount label. | |
QString | textAmount () const |
Retrieves the textual contents of the monetary amount GUI element. | |
std::optional< pecunia::Money > | tryAmount () const |
An accessor to the displayed amount of money. | |
A Qt Widget to display a money entry.
|
explicit |
Fully initialises the widget.
parent | The parent responsible for the memory of the widget. |
|
nodiscard |
An accessor to the displayed amount of money.
|
nodiscardnoexcept |
Determines if the money as entered in the widget is valid, i.e. no errors.
void drn::desktop_ui::MoneyEntryWidget::clear | ( | ) |
Clears the money entry fields within the widget.
|
nodiscard |
Retrieves the current code from the code GUI element.
|
nodiscardnoexcept |
An accessor to the possible currencies that are selectable.
|
signal |
Triggered when the current index of the currency selection changes.
index | The new selected index in the currency GUI element. |
void drn::desktop_ui::MoneyEntryWidget::disableCurrencySelection | ( | ) |
Disables the currency selection GUI element.
|
signal |
Triggered when the user finishes editing the displayed money amount.
void drn::desktop_ui::MoneyEntryWidget::enableCurrencySelection | ( | ) |
Enables the currency selection GUI element in the money entry widget.
void drn::desktop_ui::MoneyEntryWidget::hideCodes | ( | ) |
Hides the currency code selection GUI element.
|
nodiscard |
An accessor that, when true, shows if the widget is read-only.
|
signal |
Triggered when the value of the money changes.
m | The new value for the money when valid, default constructed value when it's invalid. |
void drn::desktop_ui::MoneyEntryWidget::setAmount | ( | const pecunia::Money & | money | ) |
Changes the displayed amount of money.
money | The new money value to be displayed. |
|
slot |
Sets the current index of the currency code.
Error | if the index exceeds the number of available codes in the GUI element. |
index | The index to set as current. |
void drn::desktop_ui::MoneyEntryWidget::setLabel | ( | const QString & | text | ) |
Changes the label text for the money entry widget.
text | The new text to be set as the label. |
void drn::desktop_ui::MoneyEntryWidget::setReadOnly | ( | const bool | isReadOnly | ) |
Sets the widget to a read-only or editable state.
isReadOnly | A boolean flag indicating whether the widget should be read-only (true) or editable (false). |
void drn::desktop_ui::MoneyEntryWidget::setUsableCurrencies | ( | const std::set< pecunia::Currency > & | codes, |
const navigation::CurrencyDisplayOptions & | displayAs ) |
Changes the set of usable currencies for the widget.
codes | A set of Currency codes that are allowed to be used. |
displayAs | Options for how the currencies should be displayed. |
void drn::desktop_ui::MoneyEntryWidget::setUsableCurrency | ( | const pecunia::Currency & | code, |
const navigation::CurrencyDisplayOptions & | displayAs ) |
Changes the possible currencies that a user can select.
code | The code the user can select from. |
displayAs | Options for how the currencies should be displayed. |
void drn::desktop_ui::MoneyEntryWidget::showCodes | ( | ) |
Shows the currency code selection GUI element.
void drn::desktop_ui::MoneyEntryWidget::showLabel | ( | const bool | shouldShow | ) |
Controls the visibility of the amount label.
shouldShow | A boolean flag indicating whether the label should be shown or hidden. |
|
nodiscard |
Retrieves the textual contents of the monetary amount GUI element.
|
nodiscard |
An accessor to the displayed amount of money.