Add the ability to delete a path from options

There is a requirement to delete the "Fancy Date Format" book KVP data
when set to unset. This was not possible as is as it would delete all
the 'Business' options. This is still possible by passing a null list.
This commit is contained in:
Robert Fewell 2016-11-28 19:39:10 +00:00 committed by Geert Janssens
parent 7d927cb830
commit 03a11451bd
3 changed files with 13 additions and 4 deletions

View File

@ -247,7 +247,7 @@ Account * gnc_book_get_template_root(QofBook *book);
%typemap(out) KvpValue * " $result = gnc_kvp_value_ptr_to_scm($1); "
%typemap(in) GSList *key_path " $1 = gnc_scm_to_gslist_string($input);"
void qof_book_options_delete (QofBook *book);
void qof_book_options_delete (QofBook *book, GSList *key_path);
void qof_book_set_option (QofBook *book, KvpValue *new_value, GSList *key_path);
KvpValue* qof_book_get_option (QofBook *book, GSList *key_path);

View File

@ -1202,9 +1202,17 @@ qof_book_get_option (QofBook *book, GSList *path)
}
void
qof_book_options_delete (QofBook *book)
qof_book_options_delete (QofBook *book, GSList *path)
{
KvpFrame *root = qof_instance_get_slots(QOF_INSTANCE (book));
if (path != nullptr)
{
Path path_v {KVP_OPTION_PATH};
for (auto item = path; item != nullptr; item = g_slist_next(item))
path_v.push_back(static_cast<const char*>(item->data));
delete root->set_path(path_v, nullptr);
}
else
delete root->set_path(KVP_OPTION_PATH, nullptr);
}

View File

@ -409,8 +409,9 @@ KvpValue* qof_book_get_option (QofBook *book, GSList *path);
* Primarily used from Scheme to clear out the options before saving a new set.
* @param book: The book.
* @param list: A GList of keys which from a path under KVP_OPTION_PATH.
* If GList is Null, the whole option is deleted.
*/
void qof_book_options_delete (QofBook *book);
void qof_book_options_delete (QofBook *book, GSList *path);
/** @} End of Doxygen Include */
/** deprecated */
#define qof_book_get_guid(X) qof_entity_get_guid (QOF_INSTANCE(X))