libyui-qt  2.43.5
 All Classes Functions Variables
YQMultiSelectionBox.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
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: YQMultiSelectionBox.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #ifndef YQMultiSelectionBox_h
27 #define YQMultiSelectionBox_h
28 
29 #include <QFrame>
30 #include <QColorGroup>
31 #include <QTreeWidget>
32 
33 #include <yui/YMultiSelectionBox.h>
34 
35 class YQWidgetCaption;
37 
38 
39 class YQMultiSelectionBox : public QFrame, public YMultiSelectionBox
40 {
41  Q_OBJECT
42 
43 public:
44 
45  /**
46  * Constructor.
47  **/
48  YQMultiSelectionBox( YWidget * parent, const std::string & label );
49 
50  /**
51  * Destructor.
52  **/
54 
55  /**
56  * Change the label text.
57  *
58  * Reimplemented from YSelectionWidget.
59  **/
60  virtual void setLabel( const std::string & label );
61 
62  /**
63  * Add an item.
64  *
65  * Reimplemented from YSelectionWidget.
66  **/
67  virtual void addItem( YItem * item );
68 
69  /**
70  * Select or deselect an item.
71  *
72  * Reimplemented from YSelectionWidget.
73  **/
74  virtual void selectItem( YItem * item, bool selected = true );
75 
76  /**
77  * Deselect all items.
78  *
79  * Reimplemented from YSelectionWidget.
80  **/
81  virtual void deselectAllItems();
82 
83  /**
84  * Delete all items.
85  *
86  * Reimplemented from YSelectionWidget.
87  **/
88  virtual void deleteAllItems();
89 
90  /**
91  * Return the the item that currently has the keyboard focus
92  * or 0 if no item currently has the keyboard focus.
93  *
94  * Reimplemented from YMultiSelectionBox.
95  **/
96  virtual YItem * currentItem();
97 
98  /**
99  * Set the keyboard focus to the specified item.
100  * 0 means clear the keyboard focus.
101  *
102  * Reimplemented from YMultiSelectionBox.
103  **/
104  virtual void setCurrentItem( YItem * item );
105 
106  /**
107  * Set enabled/disabled state.
108  *
109  * Reimplemented from YWidget.
110  **/
111  virtual void setEnabled( bool enabled );
112 
113  /**
114  * Preferred width of the widget.
115  *
116  * Reimplemented from YWidget.
117  **/
118  virtual int preferredWidth();
119 
120  /**
121  * Preferred height of the widget.
122  *
123  * Reimplemented from YWidget.
124  **/
125  virtual int preferredHeight();
126 
127  /**
128  * Set the new size of the widget.
129  *
130  * Reimplemented from YWidget.
131  **/
132  virtual void setSize( int newWidth, int newHeight );
133 
134  /**
135  * Accept the keyboard focus.
136  **/
137  virtual bool setKeyboardFocus();
138 
139 
140 signals:
141  /**
142  * Emitted upon when an item changes its state.
143  **/
144  void valueChanged();
145 
146 
147 protected slots:
148  /**
149  * Send SelectionChanged event if `opt(`notify) is set.
150  **/
151  void slotSelected();
152 
153  /**
154  * Send ValueChanged event if `opt(`notify) is set.
155  **/
156  void slotValueChanged();
157 
158  void slotItemChanged( QTreeWidgetItem*, int );
159 
160 protected:
161  /**
162  * Find the counterpart of 'item'. Return 0 if there is none.
163  **/
164  YQMultiSelectionBoxItem * findItem( YItem * item );
165 
166 
167  YQWidgetCaption * _caption;
168  QTreeWidget * _qt_listView;
169 };
170 
171 
172 
173 class YQMultiSelectionBoxItem: public QTreeWidgetItem
174 {
175 public:
176  /**
177  * Constructor.
178  **/
180  QTreeWidget * listView,
181  YItem * yItem );
182 
183  /**
184  * Destructor.
185  **/
187 
188  /**
189  * Return the corresponding YItem.
190  **/
191  YItem * yItem() const { return _yItem; }
192 
193 
194 protected:
195 
196  //
197  // Data members
198  //
199 
200  YItem * _yItem;
201  int _serial;
202  YQMultiSelectionBox * _multiSelectionBox;
203 
204 
205  /**
206  * The next serial number to use
207  **/
208  static int _item_count;
209 };
210 
211 #endif // YQLabel_h
YQMultiSelectionBox(YWidget *parent, const std::string &label)
virtual void deleteAllItems()
YQMultiSelectionBoxItem(YQMultiSelectionBox *parent, QTreeWidget *listView, YItem *yItem)
virtual YItem * currentItem()
virtual void setSize(int newWidth, int newHeight)
virtual void setLabel(const std::string &label)
virtual void deselectAllItems()
virtual void setEnabled(bool enabled)
YQMultiSelectionBoxItem * findItem(YItem *item)
virtual void setCurrentItem(YItem *item)
virtual bool setKeyboardFocus()
virtual void selectItem(YItem *item, bool selected=true)
virtual void addItem(YItem *item)