mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[options] Fix implementation of gnc_register_owner_option
To take an owner-type parameter and to set the UIType accordingly.
This commit is contained in:
parent
aa0b0921f4
commit
1ff844c195
@ -678,6 +678,10 @@ gnc_register_account_list_limited_option(GncOptionDB* db,
|
|||||||
std::for_each(value.begin(), value.end(), [](auto& guid){
|
std::for_each(value.begin(), value.end(), [](auto& guid){
|
||||||
std::cout << gnc::GUID(guid).to_string() << " ";
|
std::cout << gnc::GUID(guid).to_string() << " ";
|
||||||
});
|
});
|
||||||
|
std::cout << "and types ";
|
||||||
|
std::for_each(allowed.begin(), allowed.end(), [](auto type) {
|
||||||
|
std::cout << xaccAccountTypeEnumAsString(type) << " ";
|
||||||
|
});
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
GncOption option{GncOptionAccountListValue{section, name, key, doc_string,
|
GncOption option{GncOptionAccountListValue{section, name, key, doc_string,
|
||||||
GncOptionUIType::ACCOUNT_LIST, value, std::move(allowed)}};
|
GncOptionUIType::ACCOUNT_LIST, value, std::move(allowed)}};
|
||||||
@ -812,10 +816,29 @@ gnc_register_query_option(GncOptionDB* db, const char* section,
|
|||||||
void
|
void
|
||||||
gnc_register_owner_option(GncOptionDB* db, const char* section,
|
gnc_register_owner_option(GncOptionDB* db, const char* section,
|
||||||
const char* name, const char* key,
|
const char* name, const char* key,
|
||||||
const char* doc_string, const GncOwner* value)
|
const char* doc_string, const GncOwner* value,
|
||||||
|
GncOwnerType type)
|
||||||
{
|
{
|
||||||
|
GncOptionUIType uitype;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case GNC_OWNER_CUSTOMER:
|
||||||
|
uitype = GncOptionUIType::CUSTOMER;
|
||||||
|
break;
|
||||||
|
case GNC_OWNER_EMPLOYEE:
|
||||||
|
uitype = GncOptionUIType::EMPLOYEE;
|
||||||
|
break;
|
||||||
|
case GNC_OWNER_JOB:
|
||||||
|
uitype = GncOptionUIType::JOB;
|
||||||
|
break;
|
||||||
|
case GNC_OWNER_VENDOR:
|
||||||
|
uitype = GncOptionUIType::VENDOR;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
uitype = GncOptionUIType::INTERNAL;
|
||||||
|
};
|
||||||
GncOption option{section, name, key, doc_string, value,
|
GncOption option{section, name, key, doc_string, value,
|
||||||
GncOptionUIType::INTERNAL};
|
uitype};
|
||||||
db->register_option(section, std::move(option));
|
db->register_option(section, std::move(option));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,10 +523,12 @@ inline void gnc_register_query_option(GncOptionDBPtr& db, const char* section,
|
|||||||
* @param name The option name.
|
* @param name The option name.
|
||||||
* @param doc_string A description of the option. This will be used in tooltips and should be marked for translation.
|
* @param doc_string A description of the option. This will be used in tooltips and should be marked for translation.
|
||||||
* @param value The initial and default value for the option.
|
* @param value The initial and default value for the option.
|
||||||
|
* @param type The type of owner, determines the UI type.
|
||||||
*/
|
*/
|
||||||
void gnc_register_owner_option(GncOptionDB* db, const char* section,
|
void gnc_register_owner_option(GncOptionDB* db, const char* section,
|
||||||
const char* name, const char* key,
|
const char* name, const char* key,
|
||||||
const char* doc_string, const GncOwner* value);
|
const char* doc_string, const GncOwner* value,
|
||||||
|
GncOwnerType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
|
* As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
|
||||||
@ -534,9 +536,10 @@ void gnc_register_owner_option(GncOptionDB* db, const char* section,
|
|||||||
inline void gnc_register_owner_option(GncOptionDBPtr& db, const char* section,
|
inline void gnc_register_owner_option(GncOptionDBPtr& db, const char* section,
|
||||||
const char* name, const char* key,
|
const char* name, const char* key,
|
||||||
const char* doc_string,
|
const char* doc_string,
|
||||||
const GncOwner* value)
|
const GncOwner* value,
|
||||||
|
GncOwnerType type)
|
||||||
{
|
{
|
||||||
gnc_register_owner_option(db.get(), section, name, key, doc_string, value);
|
gnc_register_owner_option(db.get(), section, name, key, doc_string, value, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user