1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQMultiSelectionBox.h
15 Author: Stefan Hundhammer <sh@suse.de>
20 #ifndef YQMultiSelectionBox_h
21 #define YQMultiSelectionBox_h
24 #include <QColorGroup>
25 #include <QTreeWidget>
27 #include "YMultiSelectionBox.h"
29 class YQWidgetCaption;
30 class YQMultiSelectionBoxItem;
33 class YQMultiSelectionBox : public QFrame, public YMultiSelectionBox
42 YQMultiSelectionBox( YWidget * parent, const string & label );
47 ~YQMultiSelectionBox();
50 * Change the label text.
52 * Reimplemented from YSelectionWidget.
54 virtual void setLabel( const string & label );
59 * Reimplemented from YSelectionWidget.
61 virtual void addItem( YItem * item );
64 * Select or deselect an item.
66 * Reimplemented from YSelectionWidget.
68 virtual void selectItem( YItem * item, bool selected = true );
73 * Reimplemented from YSelectionWidget.
75 virtual void deselectAllItems();
80 * Reimplemented from YSelectionWidget.
82 virtual void deleteAllItems();
85 * Return the the item that currently has the keyboard focus
86 * or 0 if no item currently has the keyboard focus.
88 * Reimplemented from YMultiSelectionBox.
90 virtual YItem * currentItem();
93 * Set the keyboard focus to the specified item.
94 * 0 means clear the keyboard focus.
96 * Reimplemented from YMultiSelectionBox.
98 virtual void setCurrentItem( YItem * item );
101 * Set enabled/disabled state.
103 * Reimplemented from YWidget.
105 virtual void setEnabled( bool enabled );
108 * Preferred width of the widget.
110 * Reimplemented from YWidget.
112 virtual int preferredWidth();
115 * Preferred height of the widget.
117 * Reimplemented from YWidget.
119 virtual int preferredHeight();
122 * Set the new size of the widget.
124 * Reimplemented from YWidget.
126 virtual void setSize( int newWidth, int newHeight );
129 * Accept the keyboard focus.
131 virtual bool setKeyboardFocus();
134 * Sends a ValueChanged signal.
136 void sendValueChanged();
141 * Emitted upon when an item changes its state.
148 * Send SelectionChanged event if `opt(`notify) is set.
153 * Send ValueChanged event if `opt(`notify) is set.
155 void slotValueChanged();
160 * Find the counterpart of 'item'. Return 0 if there is none.
162 YQMultiSelectionBoxItem * findItem( YItem * item );
165 YQWidgetCaption * _caption;
166 QTreeWidget * _qt_listView;
171 class YQMultiSelectionBoxItem: public QTreeWidgetItem
177 YQMultiSelectionBoxItem( YQMultiSelectionBox * parent,
178 QTreeWidget * listView,
184 virtual ~YQMultiSelectionBoxItem() {}
187 * Return the corresponding YItem.
189 YItem * yItem() const { return _yItem; }
195 * Called when the on/off state changes.
196 * Triggers a 'valueChanged' event in the associated YQMultiSelectionBox.
198 * Reimplemented from QChecklistItem.
200 void stateChange( bool newState );
203 * Returns the sort key for any column.
204 * In this case, maintain item creation order.
206 * Reimplemented from Q3ListViewItem.
208 virtual QString key ( int column,
209 bool ascending ) const;
217 YQMultiSelectionBox * _multiSelectionBox;
221 * The next serial number to use
223 static int _item_count;