From ac0e7063c79bbc86ab01dbf57d955db131b74deb Mon Sep 17 00:00:00 2001 From: John Ralls Date: Tue, 10 Mar 2020 14:49:49 -0700 Subject: [PATCH] Move the GncOptionUIType and dirty members to GncOptionUIUtem. Even though it makes the class not pure virtual any more it is necessary behavior common to all possible subclasses. --- libgnucash/app-utils/gnc-option-ui.hpp | 11 +++++++---- libgnucash/app-utils/test/gtest-gnc-option.cpp | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libgnucash/app-utils/gnc-option-ui.hpp b/libgnucash/app-utils/gnc-option-ui.hpp index 847813b484..87ca289a8b 100644 --- a/libgnucash/app-utils/gnc-option-ui.hpp +++ b/libgnucash/app-utils/gnc-option-ui.hpp @@ -44,14 +44,17 @@ using GncOptionUIItemPtr = std::unique_ptr; class GncOptionUIItem { public: - GncOptionUIItem() = default; + GncOptionUIItem(GncOptionUIType type) : m_type{type} {} virtual ~GncOptionUIItem() = default; - virtual GncOptionUIType get_ui_type() const noexcept = 0; - virtual void set_dirty(bool status) noexcept = 0; - virtual bool get_dirty() const noexcept = 0; + GncOptionUIType get_ui_type() const noexcept { return m_type; } + virtual void set_dirty(bool status) noexcept { m_dirty = status; } + virtual bool get_dirty() const noexcept { return m_dirty; } virtual void clear_ui_item() = 0; virtual void set_ui_item_from_option(GncOption& option) noexcept = 0; virtual void set_option_from_ui_item(GncOption& option) noexcept = 0; +private: + GncOptionUIType m_type; + bool m_dirty = false; }; #endif //GNC_OPTION_UI_HPP__ diff --git a/libgnucash/app-utils/test/gtest-gnc-option.cpp b/libgnucash/app-utils/test/gtest-gnc-option.cpp index 6be3328ae8..a1144a4e0d 100644 --- a/libgnucash/app-utils/test/gtest-gnc-option.cpp +++ b/libgnucash/app-utils/test/gtest-gnc-option.cpp @@ -522,8 +522,8 @@ class OptionUIItem : public GncOptionUIItem GncUIType m_widget; bool m_dirty = false; public: + OptionUIItem() : GncOptionUIItem{GncOptionUIType::STRING} {} ~OptionUIItem() = default; - GncOptionUIType get_ui_type() const noexcept override { return GncOptionUIType::STRING; } void set_dirty(bool status) noexcept override { m_dirty = status; } bool get_dirty() const noexcept override { return m_dirty; } void clear_ui_item() override { m_widget.clear(); }