Skip to content

Commit

Permalink
Move the GncOptionUIType and dirty members to GncOptionUIUtem.
Browse files Browse the repository at this point in the history
Even though it makes the class not pure virtual any more it is necessary
behavior common to all possible subclasses.
  • Loading branch information
jralls committed Aug 1, 2021
1 parent 3200bd4 commit ac0e706
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions libgnucash/app-utils/gnc-option-ui.hpp
Expand Up @@ -44,14 +44,17 @@ using GncOptionUIItemPtr = std::unique_ptr<GncOptionUIItem>;
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__
2 changes: 1 addition & 1 deletion libgnucash/app-utils/test/gtest-gnc-option.cpp
Expand Up @@ -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(); }
Expand Down

0 comments on commit ac0e706

Please sign in to comment.