LCOV - code coverage report
Current view: top level - libgnucash/engine - gnc-option-ui.hpp (source / functions) Coverage Total Hit
Test: gnucash.info Lines: 20.0 % 5 1
Test Date: 2026-11-02 18:19:43 Functions: 20.0 % 5 1
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /********************************************************************\
       2              :  * gnc-option-ui.hpp -- UI association for GncOption                *
       3              :  * Copyright (C) 2019 John Ralls <jralls@ceridwen.us>               *
       4              :  *                                                                  *
       5              :  * This program is free software; you can redistribute it and/or    *
       6              :  * modify it under the terms of the GNU General Public License as   *
       7              :  * published by the Free Software Foundation; either version 2 of   *
       8              :  * the License, or (at your option) any later version.              *
       9              :  *                                                                  *
      10              :  * This program is distributed in the hope that it will be useful,  *
      11              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
      12              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
      13              :  * GNU General Public License for more details.                     *
      14              :  *                                                                  *
      15              :  * You should have received a copy of the GNU General Public License*
      16              :  * along with this program; if not, contact:                        *
      17              :  *                                                                  *
      18              :  * Free Software Foundation           Voice:  +1-617-542-5942       *
      19              :  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
      20              :  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
      21              :  *                                                                  *
      22              : \********************************************************************/
      23              : 
      24              : #ifndef GNC_OPTION_UI_HPP_
      25              : #define GNC_OPTION_UI_HPP_
      26              : 
      27              : #include <memory>
      28              : #include "gnc-option-uitype.hpp"
      29              : 
      30              : class GncOption;
      31              : class GncOptionUIItem;
      32              : using GncOptionUIItemPtr = std::unique_ptr<GncOptionUIItem>;
      33              : 
      34              : /**
      35              :  * Holds a pointer to the UI item which will control the option and an enum
      36              :  * representing the type of the option for dispatch purposes; all of that
      37              :  * happens in gnucash/gnome-utils/dialog-options and
      38              :  * gnucash/gnome/business-option-gnome.
      39              :  *
      40              :  * This class takes no ownership responsibility, so calling code is responsible
      41              :  * for ensuring that the UI_Item is alive. For convenience the public
      42              :  * clear_ui_item function can be used as a weak_ptr's destruction callback to
      43              :  * ensure that the ptr will be nulled if the ui_item is destroyed elsewhere.
      44              :  */
      45              : 
      46              : class GncOptionUIItem
      47              : {
      48              : public:
      49            0 :     GncOptionUIItem(GncOptionUIType type) : m_type{type} {}
      50            0 :     virtual ~GncOptionUIItem() = default;
      51            3 :     GncOptionUIType get_ui_type() const noexcept { return m_type; }
      52            0 :     virtual void set_dirty(bool status) noexcept { m_dirty = status; }
      53            0 :     virtual bool get_dirty() const noexcept { return m_dirty; }
      54              :     virtual void set_selectable(bool selectable) const noexcept = 0;
      55              :     virtual void clear_ui_item() = 0;
      56              :     virtual void set_ui_item_from_option(GncOption& option) noexcept = 0;
      57              :     virtual void set_option_from_ui_item(GncOption& option) noexcept = 0;
      58              : private:
      59              :     GncOptionUIType m_type;
      60              :     bool m_dirty = false;
      61              : };
      62              : 
      63              : #endif //GNC_OPTION_UI_HPP__
        

Generated by: LCOV version 2.0-1