diff --git a/libgnucash/app-utils/gnc-option-impl.cpp b/libgnucash/app-utils/gnc-option-impl.cpp index 210ef99676..b12ca23aa8 100644 --- a/libgnucash/app-utils/gnc-option-impl.cpp +++ b/libgnucash/app-utils/gnc-option-impl.cpp @@ -211,8 +211,8 @@ qof_instance_from_guid(GncGUID* guid, GncOptionUIType type) case GncOptionUIType::BUDGET: qof_type = "Budget"; break; - case GncOptionUIType::OWNER: - qof_type = "gncOwner"; + case GncOptionUIType::JOB: + qof_type = "gncJob"; break; case GncOptionUIType::CUSTOMER: qof_type = "gncCustomer"; diff --git a/libgnucash/app-utils/gnc-option-uitype.hpp b/libgnucash/app-utils/gnc-option-uitype.hpp index b1e784a455..22098bb72b 100644 --- a/libgnucash/app-utils/gnc-option-uitype.hpp +++ b/libgnucash/app-utils/gnc-option-uitype.hpp @@ -51,6 +51,7 @@ enum class GncOptionUIType : unsigned int VENDOR, EMPLOYEE, INVOICE, + JOB, TAX_TABLE, QUERY, REPORT_LIST, diff --git a/libgnucash/app-utils/gnc-optiondb-impl.hpp b/libgnucash/app-utils/gnc-optiondb-impl.hpp index 472b1ca24f..95f77a34bd 100644 --- a/libgnucash/app-utils/gnc-optiondb-impl.hpp +++ b/libgnucash/app-utils/gnc-optiondb-impl.hpp @@ -36,7 +36,10 @@ extern "C" #include #include #include -#include +#include +#include +#include +#include #include } diff --git a/libgnucash/app-utils/gnc-optiondb.cpp b/libgnucash/app-utils/gnc-optiondb.cpp index 82b52928ab..5588499e09 100644 --- a/libgnucash/app-utils/gnc-optiondb.cpp +++ b/libgnucash/app-utils/gnc-optiondb.cpp @@ -1070,38 +1070,6 @@ gnc_register_internal_option(GncOptionDB* db, const char* section, GncOptionUIType::INTERNAL}; db->register_option(section, std::move(option)); } - -static inline GncOptionUIType -owner_type_to_ui_type(GncOwnerType type) -{ - switch (type) - { - case GNC_OWNER_NONE: - case GNC_OWNER_UNDEFINED: - case GNC_OWNER_JOB: - return GncOptionUIType::INTERNAL; - case GNC_OWNER_CUSTOMER: - return GncOptionUIType::CUSTOMER; - case GNC_OWNER_VENDOR: - return GncOptionUIType::VENDOR; - case GNC_OWNER_EMPLOYEE: - return GncOptionUIType::EMPLOYEE; - } - return GncOptionUIType::INTERNAL; -} - -void -gnc_register_owner_option(GncOptionDB* db, const char* section, - const char* name, const char* key, - const char* doc_string, GncOwner* value, - GncOwnerType type) -{ - GncOption option{section, name, key, doc_string, - (const QofInstance*)value->owner.undefined, - owner_type_to_ui_type(type)}; - db->register_option(section, std::move(option)); -} - void gnc_register_invoice_option(GncOptionDB* db, const char* section, const char* name, const char* key, diff --git a/libgnucash/app-utils/gnc-optiondb.h b/libgnucash/app-utils/gnc-optiondb.h index 885715622b..007bfd1f4f 100644 --- a/libgnucash/app-utils/gnc-optiondb.h +++ b/libgnucash/app-utils/gnc-optiondb.h @@ -44,7 +44,6 @@ extern "C" #include #include #include -#include #include /** diff --git a/libgnucash/app-utils/gnc-optiondb.hpp b/libgnucash/app-utils/gnc-optiondb.hpp index 3e8a96ee53..a5b6c427b9 100644 --- a/libgnucash/app-utils/gnc-optiondb.hpp +++ b/libgnucash/app-utils/gnc-optiondb.hpp @@ -37,7 +37,6 @@ extern "C" #include #include #include -#include #include } #include "gnc-option.hpp" @@ -620,33 +619,6 @@ inline void gnc_register_invoice_option(const GncOptionDBPtr& db, doc_string, value); } -/** - * Create a new owner-type option and register it in the options database. - * - * @param db A GncOptionDB* for calling from C. Caller retains ownership. - * @param section The database section for the option. - * @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 value The initial and default value for the option. - * @param type The Owner-type (Customer, Employee, or Vendor) - */ -void gnc_register_owner_option(GncOptionDB* db, const char* section, - const char* name, const char* key, - const char* doc_string, GncOwner* value, - GncOwnerType type); - -/** - * As above but takes a const GncOptionDBPtr& (const std::unique_ptr&) for calling from C++. - */ -inline void gnc_register_owner_option(const GncOptionDBPtr& db, - const char* section, const char* name, - const char* key, const char* doc_string, - GncOwner* value, GncOwnerType type) -{ - gnc_register_owner_option(db.get(), section, name, key, - doc_string, value, type); -} - /** * Create a new taxtable option and register it in the options database. * diff --git a/libgnucash/app-utils/gnc-optiondb.i b/libgnucash/app-utils/gnc-optiondb.i index 130e50878b..0541644b32 100644 --- a/libgnucash/app-utils/gnc-optiondb.i +++ b/libgnucash/app-utils/gnc-optiondb.i @@ -64,25 +64,33 @@ SCM scm_init_sw_gnc_optiondb_module(void); */ %typemap (out) QofInstance_s* { + swig_type_info *type = $descriptor(QofInstance_s); if ($1 == nullptr) { - $result = SCM_BOOL_F; + $result = SWIG_NewPointerObj(nullptr, type, FALSE); } else { auto ptr{static_cast(const_cast($1))}; - swig_type_info *type = SWIGTYPE_p_QofInstance_s; if (GNC_IS_COMMODITY($1)) - type = SWIGTYPE_p_gnc_commodity; + type = $descriptor(gnc_commodity*); else if (GNC_IS_ACCOUNT($1)) - type = SWIGTYPE_p_Account; + type = $descriptor(Account*); else if (GNC_IS_BUDGET($1)) - type = SWIGTYPE_p_GncBudget; + type = $descriptor(GncBudget*); else if (GNC_IS_INVOICE($1)) - type = SWIGTYPE_p_GncInvoice; + type = $descriptor(GncInvoice*); else if (GNC_IS_TAXTABLE($1)) - type = SWIGTYPE_p_GncTaxTable; + type = $descriptor(GncTaxTable*); + else if (GNC_IS_CUSTOMER($1)) + type = $descriptor(_gncCustomer*); + else if (GNC_IS_EMPLOYEE($1)) + type = $descriptor(_gncEmployee*); + else if (GNC_IS_JOB($1)) + type = $descriptor(_gncJob*); + else if (GNC_IS_VENDOR($1)) + type = $descriptor(_gncVendor*); $result = SWIG_NewPointerObj(ptr, type, FALSE); } } @@ -90,10 +98,12 @@ SCM scm_init_sw_gnc_optiondb_module(void); %typemap (in) QofInstance_s* { if (scm_is_true($input)) { - static const std::array types { - SWIGTYPE_p_QofInstance_s, SWIGTYPE_p_gnc_commodity, - SWIGTYPE_p_GncBudget, SWIGTYPE_p_GncInvoice, - SWIGTYPE_p_GncTaxTable, SWIGTYPE_p_Account + static const std::array types { + $descriptor(QofInstance_s*), $descriptor(gnc_commodity*), + $descriptor(GncBudget*), $descriptor(GncInvoice*), + $descriptor(GncTaxTable*), $descriptor(Account*), + $descriptor(_gncCustomer*), $descriptor(_gncEmployee*), + $descriptor(_gncJob*), $descriptor(_gncVendor*) }; void* ptr{}; auto pos = std::find_if(types.begin(), types.end(), @@ -168,10 +178,11 @@ scm_from_value(double value) template <> inline SCM scm_from_value(const QofInstance* value) { - if (!value) return SCM_BOOL_F; + swig_type_info *type = SWIGTYPE_p_QofInstance_s; + if (!value) + return SWIG_NewPointerObj(nullptr, type, FALSE); auto ptr{static_cast(const_cast(value))}; - swig_type_info *type = SWIGTYPE_p_QofInstance_s; if (GNC_IS_COMMODITY(value)) type = SWIGTYPE_p_gnc_commodity; else if (GNC_IS_ACCOUNT(value)) @@ -182,6 +193,14 @@ scm_from_value(const QofInstance* value) type = SWIGTYPE_p_GncInvoice; else if (GNC_IS_TAXTABLE(value)) type = SWIGTYPE_p_GncTaxTable; + else if (GNC_IS_CUSTOMER(value)) + type = SWIGTYPE_p__gncCustomer; + else if (GNC_IS_EMPLOYEE(value)) + type = SWIGTYPE_p__gncEmployee; + else if (GNC_IS_JOB(value)) + type = SWIGTYPE_p__gncJob; + else if (GNC_IS_VENDOR(value)) + type = SWIGTYPE_p__gncVendor; /* There is no type macro for QofQuery, it's not a GObject. else if (GNC_IS_QOFQUERY(value)) type = SWIGTYPE_p_Query; @@ -236,10 +255,12 @@ scm_to_value(SCM new_value) if (new_value == SCM_BOOL_F) return nullptr; - static const std::array types{ + static const std::array types{ SWIGTYPE_p_QofInstance_s, SWIGTYPE_p_gnc_commodity, SWIGTYPE_p_GncBudget, SWIGTYPE_p_GncInvoice, - SWIGTYPE_p_GncTaxTable, SWIGTYPE_p_Account + SWIGTYPE_p_GncTaxTable, SWIGTYPE_p_Account, + SWIGTYPE_p__gncCustomer, SWIGTYPE_p__gncEmployee, + SWIGTYPE_p__gncJob, SWIGTYPE_p__gncVendor }; void* ptr{}; auto pos = std::find_if(types.begin(), types.end(), @@ -502,7 +523,6 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB); %ignore gnc_register_internal_option(GncOptionDB*, const char*, const char*, const char*, const char*, std::string); %ignore gnc_register_currency_option(GncOptionDB*, const char*, const char*, const char*, const char*, gnc_commodity*); %ignore gnc_register_invoice_option(GncOptionDB*, const char*, const char*, const char*, const char*, GncInvoice*); -%ignore gnc_register_owner_option(GncOptionDB*, const char*, const char*, const char*, const char*, GncOwner*, GncOwnerType); %ignore gnc_register_taxtable_option(GncOptionDB*, const char*, const char*, const char*, const char*, GncTaxTable*); %ignore gnc_register_counter_option(GncOptionDB*, const char*, const char*, const char*, const char*, double); %ignore gnc_register_counter_format_option(GncOptionDB*, const char*, const char*, const char*, const char*, std::string);