From 7f29cf91dfcba697afbc1af85f0e3c9d38b091b7 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 4 Sep 2025 19:50:51 +0200 Subject: [PATCH] Removing GSI methods which are no longer required as they are included in the base class now, added + fixed GSI unit tests for LayoutView --- .../laybasic/gsiDeclLayLayoutViewBase.cc | 62 ------------------- .../laybasic/layEditorOptionsPages.cc | 6 +- testdata/ruby/layLayoutView.rb | 31 ++++++++-- 3 files changed, 29 insertions(+), 70 deletions(-) diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc index 3306852bc..1f5b9b50f 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc @@ -1942,68 +1942,6 @@ LAYBASIC_PUBLIC Class decl_LayoutViewBase (decl_Dispatcher, "\n" "This method has been added in version 0.26." ) + - // HINT: the cast is important to direct GSI to the LayoutView method rather than the - // Plugin method (in which case we get a segmentation violation ..) - // TODO: this method belongs to the Plugin interface and should be located there. - // Change this once there is a mixin concept available and the Plugin interface can - // be mixed into LayoutView. - gsi::method ("clear_config", (void (lay::LayoutViewBase::*)()) &lay::LayoutViewBase::clear_config, - "@brief Clears the local configuration parameters\n" - "\n" - "See \\set_config for a description of the local configuration parameters." - ) + - // TODO: this method belongs to the Plugin interface and should be located there. - // Change this once there is a mixin concept available and the Plugin interface can - // be mixed into LayoutView. - gsi::method_ext ("get_config_names", &get_config_names, - "@brief Gets the configuration parameter names\n" - "\n" - "@return A list of configuration parameter names\n" - "\n" - "This method returns the names of all known configuration parameters. These names can be used to " - "get and set configuration parameter values.\n" - "\n" - "This method was introduced in version 0.25.\n" - ) + - // TODO: this method belongs to the Plugin interface and should be located there. - // Change this once there is a mixin concept available and the Plugin interface can - // be mixed into LayoutView. - gsi::method ("get_config", (std::string (lay::LayoutViewBase::*)(const std::string &name) const) &lay::LayoutViewBase::config_get, gsi::arg ("name"), - "@brief Gets the value of a local configuration parameter\n" - "\n" - "@param name The name of the configuration parameter whose value shall be obtained (a string)\n" - "\n" - "@return The value of the parameter\n" - "\n" - "See \\set_config for a description of the local configuration parameters." - ) + - // TODO: this method belongs to the Plugin interface and should be located there. - // Change this once there is a mixin concept available and the Plugin interface can - // be mixed into LayoutView. - gsi::method ("set_config", (void (lay::LayoutViewBase::*)(const std::string &name, const std::string &value)) &lay::LayoutViewBase::config_set, gsi::arg ("name"), gsi::arg ("value"), - "@brief Sets a local configuration parameter with the given name to the given value\n" - "\n" - "@param name The name of the configuration parameter to set\n" - "@param value The value to which to set the configuration parameter\n" - "\n" - "This method sets a local configuration parameter with the given name to the given value. " - "Values can only be strings. Numerical values have to be converted into strings first. " - "Local configuration parameters override global configurations for this specific view. " - "This allows for example to override global settings of background colors. " - "Any local settings are not written to the configuration file. " - ) + - // TODO: this method belongs to the Plugin interface and should be located there. - // Change this once there is a mixin concept available and the Plugin interface can - // be mixed into LayoutView. - gsi::method ("commit_config", (void (lay::LayoutViewBase::*)()) &lay::LayoutViewBase::config_end, - "@brief Commits the configuration settings\n" - "\n" - "Some configuration options are queued for performance reasons and become active only after 'commit_config' has been called. " - "After a sequence of \\set_config calls, this method should be called to activate the " - "settings made by these calls.\n" - "\n" - "This method has been introduced in version 0.25.\n" - ) + gsi::method_ext ("transaction", &gsi::transaction, gsi::arg ("description"), "@brief Begins a transaction\n" "\n" diff --git a/src/laybasic/laybasic/layEditorOptionsPages.cc b/src/laybasic/laybasic/layEditorOptionsPages.cc index 855515d2d..6d9b97f92 100644 --- a/src/laybasic/laybasic/layEditorOptionsPages.cc +++ b/src/laybasic/laybasic/layEditorOptionsPages.cc @@ -292,7 +292,7 @@ EditorOptionsModalPages::EditorOptionsModalPages (EditorOptionsPages *parent) QVBoxLayout *ly = new QVBoxLayout (this); ly->setContentsMargins (0, 0, 0, 0); - QVBoxLayout *ly4 = new QVBoxLayout (this); + QVBoxLayout *ly4 = new QVBoxLayout (0); ly4->setContentsMargins (6, 6, 6, 0); ly->addLayout (ly4); mp_pages = new QTabWidget (this); @@ -306,9 +306,9 @@ EditorOptionsModalPages::EditorOptionsModalPages (EditorOptionsPages *parent) ly->addWidget (mp_single_page_frame, 1); mp_single_page_frame->hide (); - QVBoxLayout *ly3 = new QVBoxLayout (this); - ly->addLayout (ly3); + QVBoxLayout *ly3 = new QVBoxLayout (0); ly3->setContentsMargins (6, 6, 6, 6); + ly->addLayout (ly3); mp_button_box = new QDialogButtonBox (this); ly3->addWidget (mp_button_box); mp_button_box->setOrientation (Qt::Horizontal); diff --git a/testdata/ruby/layLayoutView.rb b/testdata/ruby/layLayoutView.rb index 2d55f84e1..e56c64a05 100644 --- a/testdata/ruby/layLayoutView.rb +++ b/testdata/ruby/layLayoutView.rb @@ -506,9 +506,8 @@ class LAYLayoutView_TestClass < TestBase end class DummyPlugin < RBA::Plugin - def initialize(manager, view) - self.manager = manager - self.view = view + def initialize + super end end @@ -516,8 +515,8 @@ class LAYLayoutView_TestClass < TestBase def initialize() register(1000, "dummy_plugin", "Dummy Plugin") end - def create_plugin(manager, unused, view) - DummyPlugin::new(manager, view) + def create_plugin(manager, dispatcher, view) + DummyPlugin::new end end @@ -601,6 +600,28 @@ class LAYLayoutView_TestClass < TestBase end + # private config + def test_10 + + lv = RBA::LayoutView::new(true) + + assert_equal(lv.get_config_names.member?("edit-grid"), true) + lv.set_config("edit-grid", "0.01") + # smoke test + lv.commit_config + assert_equal(lv.get_config("edit-grid"), "0.01") + lv.clear_config + assert_equal(lv.get_config("edit-grid"), "") + + # unknown config names can be used, but are not initialized + lv.set_config("does-not-exist", "aaa") + assert_equal(lv.get_config_names.member?("does-not-exist"), true) + assert_equal(lv.get_config("does-not-exist"), "aaa") + lv.clear_config + assert_equal(lv.get_config_names.member?("does-not-exist"), false) + + end + end load("test_epilogue.rb")