libyui  3.10.0
YDescribedItem.h
1 /*
2  Copyright (c) [2019] SUSE LLC
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YDescribedItem.h
20 
21  Author: Stefan Hundhammer <shundhammer@suse.de>
22 
23 /-*/
24 
25 #ifndef YDescribedItem_h
26 #define YDescribedItem_h
27 
28 #include "YItem.h"
29 
30 
31 /**
32  * Item class that has a (possibly multi-line) description text in addition to
33  * the normal label.
34  **/
35 class YDescribedItem: public YItem
36 {
37 public:
38 
39  /**
40  * Constructor with the label, the description and optionally the selected
41  * state.
42  **/
43  YDescribedItem( const std::string & label,
44  const std::string & description = "",
45  bool selected = false )
46  : YItem( label, selected )
47  , _description( description )
48  , _enabled( true )
49  {}
50 
51  /**
52  * Constructor with the label, the description, the icon name and
53  * optionally the selected state.
54  **/
55  YDescribedItem( const std::string & label,
56  const std::string & description,
57  const std::string & iconName,
58  bool selected = false )
60  , _description( description )
61  , _enabled( true )
62  {}
63 
64  /**
65  * Destructor.
66  **/
67  virtual ~YDescribedItem() {}
68 
69  /**
70  * Return this item's description text. This is the (typically longer)
71  * subtext that the user sees in a dialog, so this will usually be a
72  * translated text.
73  **/
74  std::string description() const { return _description; }
75 
76  /**
77  * Set this item's description text.
78  **/
79  void setDescription( const std::string & desc ) { _description = desc; }
80 
81  /**
82  * Return 'true' if this item is enabled (which is the default). Items are
83  * only ever disabled if the application explicitly sets them to disabled.
84  **/
85  bool enabled() const { return _enabled; }
86 
87  /**
88  * Set this item to enabled or disabled.
89  *
90  * Notice that this only stores that status internally. To have any effect
91  * on an associated widget, use the widget's method to enable or disable an
92  * item (which will usually call this method internally at some point).
93  **/
94  void setEnabled( bool value ) { _enabled = value; }
95 
96 private:
97 
98  std::string _description;
99  bool _enabled;
100 
101 }; // class YDescribedItem
102 
103 #endif // YDescribedItem_h
Item class that has a (possibly multi-line) description text in addition to the normal label.
bool enabled() const
Return 'true' if this item is enabled (which is the default).
void setEnabled(bool value)
Set this item to enabled or disabled.
YDescribedItem(const std::string &label, const std::string &description="", bool selected=false)
Constructor with the label, the description and optionally the selected state.
std::string description() const
Return this item's description text.
YDescribedItem(const std::string &label, const std::string &description, const std::string &iconName, bool selected=false)
Constructor with the label, the description, the icon name and optionally the selected state.
void setDescription(const std::string &desc)
Set this item's description text.
virtual ~YDescribedItem()
Destructor.
Simple item class for SelectionBox, ComboBox, MultiSelectionBox etc.
Definition: YItem.h:50
std::string label() const
Return this item's label.
Definition: YItem.h:82
bool selected() const
Return 'true' if this item is currently selected.
Definition: YItem.h:107
std::string iconName() const
Return this item's icon name.
Definition: YItem.h:92