DuxReiNummariae 1.0.0-alpha.23
Simple and powerful budgeting application
 
Loading...
Searching...
No Matches
drn::desktop_ui::MoneyEntryWidget Class Referencefinal

A Qt Widget to display a money entry. More...

#include <MoneyEntryWidget.h>

Inheritance diagram for drn::desktop_ui::MoneyEntryWidget:
Collaboration diagram for drn::desktop_ui::MoneyEntryWidget:

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.
 

Detailed Description

A Qt Widget to display a money entry.

Constructor & Destructor Documentation

◆ MoneyEntryWidget()

drn::desktop_ui::MoneyEntryWidget::MoneyEntryWidget ( const foundation::QtPtr< QWidget > & parent)
explicit

Fully initialises the widget.

Parameters
parentThe parent responsible for the memory of the widget.

Member Function Documentation

◆ amount()

pecunia::Money drn::desktop_ui::MoneyEntryWidget::amount ( ) const
nodiscard

An accessor to the displayed amount of money.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ amountErrorMessage()

std::optional<::QString > drn::desktop_ui::MoneyEntryWidget::amountErrorMessage ( ) const
nodiscardnoexcept

Determines if the money as entered in the widget is valid, i.e. no errors.

Returns
A null optional when the money is valid, else the error text of why the money is not valid.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void drn::desktop_ui::MoneyEntryWidget::clear ( )

Clears the money entry fields within the widget.

Postcondition
The monetary amount and currency GUI elements are changed to an empty state.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ code()

pecunia::Currency drn::desktop_ui::MoneyEntryWidget::code ( ) const
nodiscard

Retrieves the current code from the code GUI element.

Returns
The currently selected currency code.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ currencies()

std::set< pecunia::Currency > drn::desktop_ui::MoneyEntryWidget::currencies ( ) const
nodiscardnoexcept

An accessor to the possible currencies that are selectable.

◆ currentIndexChanged

void drn::desktop_ui::MoneyEntryWidget::currentIndexChanged ( int index)
signal

Triggered when the current index of the currency selection changes.

Parameters
indexThe new selected index in the currency GUI element.

◆ disableCurrencySelection()

void drn::desktop_ui::MoneyEntryWidget::disableCurrencySelection ( )

Disables the currency selection GUI element.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ editingFinished

void drn::desktop_ui::MoneyEntryWidget::editingFinished ( )
signal

Triggered when the user finishes editing the displayed money amount.

◆ enableCurrencySelection()

void drn::desktop_ui::MoneyEntryWidget::enableCurrencySelection ( )

Enables the currency selection GUI element in the money entry widget.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hideCodes()

void drn::desktop_ui::MoneyEntryWidget::hideCodes ( )

Hides the currency code selection GUI element.

Postcondition
This the visibility of the currency code GUI element is hidden from the user interface.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isReadOnly()

bool drn::desktop_ui::MoneyEntryWidget::isReadOnly ( ) const
nodiscard

An accessor that, when true, shows if the widget is read-only.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ moneyChanged

void drn::desktop_ui::MoneyEntryWidget::moneyChanged ( const pecunia::Money & m)
signal

Triggered when the value of the money changes.

Parameters
mThe new value for the money when valid, default constructed value when it's invalid.

◆ setAmount()

void drn::desktop_ui::MoneyEntryWidget::setAmount ( const pecunia::Money & money)

Changes the displayed amount of money.

Parameters
moneyThe new money value to be displayed.
Postcondition
The GUI elements displaying the monetary amount are updated to the supplied values.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setCurrentIndex

void drn::desktop_ui::MoneyEntryWidget::setCurrentIndex ( const int index)
slot

Sets the current index of the currency code.

Exceptions
Errorif the index exceeds the number of available codes in the GUI element.
Parameters
indexThe index to set as current.
Postcondition
The currency code GUI element displays the currency code at the supplied index.

◆ setLabel()

void drn::desktop_ui::MoneyEntryWidget::setLabel ( const QString & text)

Changes the label text for the money entry widget.

Parameters
textThe new text to be set as the label.
Postcondition
The GUI element displaying the label information about the money widget to the supplied values.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setReadOnly()

void drn::desktop_ui::MoneyEntryWidget::setReadOnly ( const bool isReadOnly)

Sets the widget to a read-only or editable state.

Parameters
isReadOnlyA boolean flag indicating whether the widget should be read-only (true) or editable (false).
Postcondition
If set to read-only, the amount input is disabled, and the currency code selection is disabled. Otherwise, both are enabled.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUsableCurrencies()

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.

Parameters
codesA set of Currency codes that are allowed to be used.
displayAsOptions for how the currencies should be displayed.
Postcondition
The GUI element for currency selection is populated with the supplied currencies. The first entry is empty (Currency::XXX), to allow selecting no currency.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUsableCurrency()

void drn::desktop_ui::MoneyEntryWidget::setUsableCurrency ( const pecunia::Currency & code,
const navigation::CurrencyDisplayOptions & displayAs )

Changes the possible currencies that a user can select.

Parameters
codeThe code the user can select from.
displayAsOptions for how the currencies should be displayed.
Postcondition
The GUI element for currency selection is populated with the supplied currencies. The first entry is empty (Currency::XXX), to allow selecting no currency.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ showCodes()

void drn::desktop_ui::MoneyEntryWidget::showCodes ( )

Shows the currency code selection GUI element.

Postcondition
This the visibility of the currency code GUI element is shown on the user interface.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ showLabel()

void drn::desktop_ui::MoneyEntryWidget::showLabel ( const bool shouldShow)

Controls the visibility of the amount label.

Parameters
shouldShowA boolean flag indicating whether the label should be shown or hidden.
Postcondition
When the flag is true, the labeling is shown, else it's hidden.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ textAmount()

QString drn::desktop_ui::MoneyEntryWidget::textAmount ( ) const
nodiscard

Retrieves the textual contents of the monetary amount GUI element.

Returns
Textual representation of the amount, with no validation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryAmount()

std::optional< pecunia::Money > drn::desktop_ui::MoneyEntryWidget::tryAmount ( ) const
nodiscard

An accessor to the displayed amount of money.

Here is the call graph for this function:
Here is the caller graph for this function: