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 <Q3CheckListItem>
26 #include <qlistview.h>
28 #include "YMultiSelectionBox.h"
30 class YQWidgetCaption;
31 class YQMultiSelectionBoxItem;
34 class YQMultiSelectionBox : public QFrame, public YMultiSelectionBox
43 YQMultiSelectionBox( YWidget * parent, const string & label );
48 ~YQMultiSelectionBox();
51 * Change the label text.
53 * Reimplemented from YSelectionWidget.
55 virtual void setLabel( const string & label );
60 * Reimplemented from YSelectionWidget.
62 virtual void addItem( YItem * item );
65 * Select or deselect an item.
67 * Reimplemented from YSelectionWidget.
69 virtual void selectItem( YItem * item, bool selected = true );
74 * Reimplemented from YSelectionWidget.
76 virtual void deselectAllItems();
81 * Reimplemented from YSelectionWidget.
83 virtual void deleteAllItems();
86 * Return the the item that currently has the keyboard focus
87 * or 0 if no item currently has the keyboard focus.
89 * Reimplemented from YMultiSelectionBox.
91 virtual YItem * currentItem();
94 * Set the keyboard focus to the specified item.
95 * 0 means clear the keyboard focus.
97 * Reimplemented from YMultiSelectionBox.
99 virtual void setCurrentItem( YItem * item );
102 * Set enabled/disabled state.
104 * Reimplemented from YWidget.
106 virtual void setEnabled( bool enabled );
109 * Preferred width of the widget.
111 * Reimplemented from YWidget.
113 virtual int preferredWidth();
116 * Preferred height of the widget.
118 * Reimplemented from YWidget.
120 virtual int preferredHeight();
123 * Set the new size of the widget.
125 * Reimplemented from YWidget.
127 virtual void setSize( int newWidth, int newHeight );
130 * Accept the keyboard focus.
132 virtual bool setKeyboardFocus();
135 * Sends a ValueChanged signal.
137 void sendValueChanged();
142 * Emitted upon when an item changes its state.
149 * Send SelectionChanged event if `opt(`notify) is set.
154 * Send ValueChanged event if `opt(`notify) is set.
156 void slotValueChanged();
161 * Find the counterpart of 'item'. Return 0 if there is none.
163 YQMultiSelectionBoxItem * findItem( YItem * item );
166 YQWidgetCaption * _caption;
167 Q3ListView * _qt_listView;
172 class YQMultiSelectionBoxItem: public Q3CheckListItem
178 YQMultiSelectionBoxItem( YQMultiSelectionBox * parent,
179 Q3ListView * listView,
185 virtual ~YQMultiSelectionBoxItem() {}
188 * Return the corresponding YItem.
190 YItem * yItem() const { return _yItem; }
196 * Called when the on/off state changes.
197 * Triggers a 'valueChanged' event in the associated YQMultiSelectionBox.
199 * Reimplemented from QChecklistItem.
201 void stateChange( bool newState );
204 * Returns the sort key for any column.
205 * In this case, maintain item creation order.
207 * Reimplemented from Q3ListViewItem.
209 virtual QString key ( int column,
210 bool ascending ) const;
218 YQMultiSelectionBox * _multiSelectionBox;
222 * The next serial number to use
224 static int _item_count;