Commit Graph

24611 Commits

Author SHA1 Message Date
John Ralls
3b78b6e894 Change the GncOptionMultichoiceValue permissible value return types to const char*.
From std::string. The consumer is a GtkWidget so we might as well do the conversion
inside the class and this will simplify adding these functions to GncOptionDateValue
in the next commit.
2021-07-10 17:29:16 -07:00
John Ralls
d5f6a2539b Replace GncOption::_get_option() with a friend function swig_get_option.
Implemented in gnc-optiondb.i it more clearly indicates the intended
use and restricts the access. Unfortunately further limiting the
friend declaration with #ifdef SWIG prevented the declaration from
working, raising the error "m_option is a private member of GncOption".
2021-07-10 17:29:15 -07:00
John Ralls
93a3716c00 Enable retrieval of a GncOptionDateValue's relative period.
So that it can be displayed by dialog-option.
2021-07-10 17:29:15 -07:00
John Ralls
dc876d4041 Provide an accessor to GncOptionAccountValue::m_allowed
To enable its use by gnc_account_sel_filter
2021-07-10 17:29:15 -07:00
John Ralls
102f36c3be Provide more than one Date UI type to match options available in dialog-option.c
Also differentiates begin-period and end-period controls.
2021-07-10 17:29:15 -07:00
John Ralls
6c7f976a65 Make second arg to gnc_glist_to_scm_list const char*
So that C++ won't complain when passed a static string.
2021-07-10 17:29:15 -07:00
John Ralls
99c2c5e439 GncOptionUIItem from the GncOptionVariant classes to GncOption.
Separating the UI from the data model. Note that the GncOptionVariant
classes still have a GncOptionUIType member to ensure that a
GncOptionUIItem of the right type is attached.
2021-07-10 17:29:15 -07:00
John Ralls
1bea809cec Remove the UI interface from GncOptionDB.
UI operations occur only in dialog-option so there's no need to expose
them from GncOptionDB.
2021-07-10 17:29:15 -07:00
John Ralls
cbf7d70ecd Integrate gnc-option into app-utils.
Includes converting swig-app-utils-guile to c++.
2021-07-10 17:29:15 -07:00
John Ralls
81c5ac6689 Remove the incomplete book-currency code.
Not everything from the 6 Book-Currency commits is removed: Switching
the Num and split-action fields and restricting edits of transactions
older than n days were included and those changes are left in place.

Some other partly-implemented features were also part of these commits
and were removed: Options for setting a default capital gains account
and currency, completion of the LIFO cap-gains policy, and creation of
a list of cap-gains policies.

If any of these are to be revived they should each be done in a separate
feature branch and submitted via Github pull request for a code review
before merging; a design discussion on gnucash-devel before restarting
work is also advisable.
2021-07-10 17:29:11 -07:00
John Ralls
aa246d3096 Make implementation classes and template code visible only in app-utils.
So only GncOption and the GncOptionDB free-function interface are public.
We don't want to expose template headers widely, it would blow up compilation
times and might lead to one definition rule violations.
2021-07-10 17:24:58 -07:00
John Ralls
20b3ef8a89 Handle some minor differences between libc++ (clang) and libstdc++ (gcc). 2021-07-10 17:24:58 -07:00
John Ralls
cd6ccbe331 Fix account-tree double-free in scheme test when built with gcc.
Oddly when built with clang it doesn't exhibit the crash.
2021-07-10 17:24:58 -07:00
John Ralls
691cb0992e Follow change in loading method for engine's guile bindings. 2021-07-10 17:24:58 -07:00
John Ralls
cbd0607e80 Implement load and store options from/to book options. 2021-07-10 17:24:58 -07:00
John Ralls
5a82aac639 Hide constexpr constants from SWIG.
Swig bindings don't need them and SWIG can't digest constexpr.
2021-07-10 17:24:58 -07:00
John Ralls
ffc6866406 Changes to accommodate moving guile engine bindings to bindings/guile.
Plus for changing targets gncmod-engine and gncmod-app-utils to
gnc-engine and gnc-app-utils.
2021-07-10 17:24:58 -07:00
John Ralls
d2535fe21b KvpValue: Use boost::typeindex::type_id instead of buildtin typeid.
Under some build conditions boost::typeindex will use an internal type
identifier that's different from the C++ builtin. In that case type equality
tests to C++ typeid in boost::variant will fail, breaking it. Using
boost::typeindex::type_id ensures that the comparisons always work.
2021-07-10 17:24:58 -07:00
John Ralls
009219c63d Much less ugly and fragile.
Finding the right form now relies on the form name instead of its
position in the parse tree.
2021-07-10 17:24:58 -07:00
John Ralls
276641ef15 Change parse of option input to generate a parse tree.
This is I hope less brittle than the previous character-counting, though
it's still brittle because it relies instead on counting form-depth.
2021-07-10 17:24:57 -07:00
John Ralls
51a1430c24 Remove stray diagnostic. 2021-07-10 17:24:57 -07:00
John Ralls
76172af239 Implement saving and loading OptionDB items to/from scheme and
key-value string representations.
2021-07-10 17:24:57 -07:00
John Ralls
6ab5618b76 Set a 50-character limit on the saved size of option section and name.
Allows use of istream::getline() to retrieve the values, simplifying
delimiter detection.
2021-07-10 17:24:57 -07:00
John Ralls
d7a2a0ffff Make a constant for std::numeric_limits<std::size_t>max().
Improves readability.
2021-07-10 17:24:57 -07:00
John Ralls
826d75af16 Use istream::getline instead of std::getline for date option type parsing. 2021-07-10 17:24:57 -07:00
John Ralls
c5294ed6b3 Fix missing-declaration errors in swig-gnc-optiondb-guile.cpp. 2021-07-10 17:24:57 -07:00
John Ralls
7ccba53739 Add stream functions to_scheme and from_scheme to GncOption.
These add or parse the textual noise needed to replicate the Scheme options'
serialization technique of saving scheme forms for saving report options
and then evaluating those forms to restore the option values. Required for
backward saved-reports compatibility.
2021-07-10 17:24:57 -07:00
John Ralls
1ea3822665 More operator <</>> Fixups. 2021-07-10 17:24:57 -07:00
John Ralls
98ca190700 Fix commodity in/out to use namespace & mnemonic instead of GUID. 2021-07-10 17:24:57 -07:00
John Ralls
4b997cd025 Fixups for GncOptionDateValue better design. 2021-07-10 17:24:57 -07:00
John Ralls
b2fb57d39e Fix GncOption::set_value() to work with GncOptionDateValue::set_value(RelativeDatePeriod).
Adjusting tests as necessary.
2021-07-10 17:24:57 -07:00
John Ralls
4dcf4a0e6a Test GncOptionRangeValue as a GncOption.
Better representation of how it will be used.
2021-07-10 17:24:57 -07:00
John Ralls
4cabd6c052 Change the GncOptionMultichoiceValue test to use a GncOption.
Requires exposing the permissible values functions to GncOption.
2021-07-10 17:24:57 -07:00
John Ralls
e2a36a8be3 Expose function validate to GncOption and test it on GncOptionValidatedValue. 2021-07-10 17:24:57 -07:00
John Ralls
6df516dfcd Clean up the commodity/currency tests with a better fixture class. 2021-07-10 17:24:57 -07:00
John Ralls
52d0ec5290 Change GncOptionDateValue design to better match usage.
Added advantage that it handles (not correctly, but in the same way as
the old code) the ambiguity between a period starting or ending with
the stored value "relative . today".
2021-07-10 17:24:57 -07:00
John Ralls
883127a59d Implement operators >> and << on GncOption. 2021-07-10 17:24:57 -07:00
John Ralls
e583c84f4e Clean up comments for GncOptionDateValue. 2021-07-10 17:24:57 -07:00
John Ralls
aaf6b14c67 Remove commented-out code. 2021-07-10 17:24:57 -07:00
John Ralls
1b00399b14 Remove GncOptionValue<std::Vector<GncGUID>>.
This going to be the Account List option implementation, but a more
customized approach is better.
2021-07-10 17:24:57 -07:00
John Ralls
5a9c4ccaf8 Clean out copies of the option.scm comments used as a development guide. 2021-07-10 17:24:57 -07:00
John Ralls
b95ea2c4aa Add Account-list options. 2021-07-10 17:24:57 -07:00
John Ralls
7183e7c43a Fix begin/end of quarter calculations.
Set the period to the calendar year if it's not set in prefs.
Handle correctly the FY start month being after the current month.
2021-07-10 17:24:57 -07:00
John Ralls
399573a89d Fix multichoice test construction. 2021-07-10 17:24:57 -07:00
John Ralls
12c5b94430 New scheme function gnc_option_default_value. 2021-07-10 17:24:57 -07:00
John Ralls
3f576671aa Adapt GncOptionMultiChoiceValue to support list options.
Main change adds a value field to the constructor to set the value and
default value.
2021-07-10 17:24:57 -07:00
John Ralls
2f2ac99944 Replace the direct wrapping of GncOptionDB-set-option-string-foo.
With a simple type-free function gnc_option_set. This mirrors the current
(gnc:option-set(gnc:lookup-option... and takes care of SCM type conversion.
2021-07-10 17:24:57 -07:00
John Ralls
252ba9b477 Change GncOptionDB::lookup_option to gnc_option_value().
The old gnc:lookup-option returned the option object so that it could be
manipulated rather than getting its value; gnc_option_value replicates
the behavior of (gnc:option-value (gnc:lookup-option)).
2021-07-10 17:24:57 -07:00
John Ralls
ff7b263a5f Fix up and test the int specialization of GncOptionRangeValue.
Not sure yet that a double one is really needed.
2021-07-10 17:24:57 -07:00
John Ralls
39b7c9c74d Convert scm_from_value() to templates for stricter overload resolution. 2021-07-10 17:24:57 -07:00