mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-12-01 13:09:41 -06:00
Provide an accessor to GncOptionAccountValue::m_allowed
To enable its use by gnc_account_sel_filter
This commit is contained in:
parent
102f36c3be
commit
dc876d4041
@ -92,6 +92,7 @@ set(app_utils_ALL_LIBRARIES
|
||||
gnc-engine
|
||||
gnc-locale-tax
|
||||
gnucash-guile
|
||||
${GLIB_LDFLAGS}
|
||||
${GIO_LDFLAGS}
|
||||
${LIBXML2_LDFLAGS}
|
||||
${LIBXSLT_LDFLAGS}
|
||||
|
@ -48,6 +48,24 @@ GncOptionAccountValue::validate(const GncOptionAccountList& values) const
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a GList of account types to pass to gnc_account_sel_set_acct_filters.
|
||||
* gnc_account_sel_set_acct_filters copies the list so the intermediary caller
|
||||
* is responsible for freeing the list.
|
||||
*
|
||||
* @return an allocated GList* or nullptr if the list is empty.
|
||||
*/
|
||||
GList*
|
||||
GncOptionAccountValue::account_type_list() const noexcept
|
||||
{
|
||||
if (m_allowed.empty())
|
||||
return nullptr;
|
||||
GList* retval;
|
||||
for (auto type : m_allowed)
|
||||
retval = g_list_prepend(retval, GINT_TO_POINTER(type));
|
||||
return g_list_reverse(retval);
|
||||
}
|
||||
|
||||
static constexpr int days_in_month[12]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
|
||||
static void
|
||||
|
@ -584,6 +584,7 @@ public:
|
||||
//throw!
|
||||
m_value = values;
|
||||
}
|
||||
GList* account_type_list() const noexcept;
|
||||
bool is_changed() const noexcept { return m_value != m_default_value; }
|
||||
GncOptionUIType get_ui_type() const noexcept { return m_ui_type; }
|
||||
void make_internal() { m_ui_type = GncOptionUIType::INTERNAL; }
|
||||
|
@ -256,6 +256,18 @@ GncOption::permissible_value_description(std::size_t index) const
|
||||
}, *m_option);
|
||||
}
|
||||
|
||||
GList*
|
||||
GncOption::account_type_list() const noexcept
|
||||
{
|
||||
return std::visit([] (const auto& option) -> GList* {
|
||||
if constexpr (std::is_same_v<std::decay_t<decltype(option)>,
|
||||
GncOptionAccountValue>)
|
||||
return option.account_type_list();
|
||||
else
|
||||
return nullptr;
|
||||
}, *m_option);
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
GncOption::out_stream(std::ostream& oss) const
|
||||
{
|
||||
|
@ -24,6 +24,11 @@
|
||||
#ifndef GNC_OPTION_HPP_
|
||||
#define GNC_OPTION_HPP_
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <glib.h>
|
||||
}
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <variant>
|
||||
@ -86,6 +91,7 @@ public:
|
||||
const std::string& permissible_value(std::size_t index) const;
|
||||
const std::string& permissible_value_name(std::size_t index) const;
|
||||
const std::string& permissible_value_description(std::size_t index) const;
|
||||
GList* account_type_list() const noexcept;
|
||||
std::ostream& out_stream(std::ostream& oss) const;
|
||||
std::istream& in_stream(std::istream& iss);
|
||||
std::ostream& to_scheme(std::ostream& oss) const;
|
||||
|
Loading…
Reference in New Issue
Block a user