From 26d8a32b7395d7bf1d1da7c32b9f2cdf5770510a Mon Sep 17 00:00:00 2001 From: Patrick Storz Date: Tue, 6 Aug 2019 00:11:54 +0200 Subject: Optimize parameter string generation Also rename overloaded string() functions, so it's clear what they actually do, as it's not the same thing at all... --- src/extension/prefdialog/parameter-notebook.cpp | 33 ++++++++++--------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'src/extension/prefdialog/parameter-notebook.cpp') diff --git a/src/extension/prefdialog/parameter-notebook.cpp b/src/extension/prefdialog/parameter-notebook.cpp index e84150aa2..50c21b3eb 100644 --- a/src/extension/prefdialog/parameter-notebook.cpp +++ b/src/extension/prefdialog/parameter-notebook.cpp @@ -24,13 +24,6 @@ #include "xml/node.h" - -/** - * The root directory in the preferences database for extension - * related parameters. - */ -#define PREF_DIR "extensions" - namespace Inkscape { namespace Extension { @@ -70,10 +63,10 @@ ParamNotebook::ParamNotebookPage::~ParamNotebookPage () } } -void ParamNotebook::ParamNotebookPage::string(std::list &list) const +void ParamNotebook::ParamNotebookPage::build_param_string_list(std::list &list) const { for (auto parameter : parameters) { - parameter->string(list); + parameter->build_param_string_list(list); } } @@ -209,23 +202,23 @@ const Glib::ustring& ParamNotebook::set(const int in, SPDocument * /*doc*/, Inks return _value; } -void ParamNotebook::string(std::list &list) const +void ParamNotebook::build_param_string_list(std::list &list) const { - std::string param_string; - param_string += "--"; - param_string += _name; - param_string += "="; - - param_string += "\""; - param_string += _value; // the name of the current page - param_string += "\""; - list.insert(list.end(), param_string); + // call base-class method to add the parameter string for the notebook itself + InxParameter::build_param_string_list(list); + // iterate over notebook pages for (auto page : pages) { - page->string(list); + page->build_param_string_list(list); } } +std::string ParamNotebook::value_to_string() const +{ + return _value; +} + + /** A special category of Gtk::Notebook to handle notebook parameters. */ class NotebookWidget : public Gtk::Notebook { private: -- cgit v1.2.3