1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
24 #include <qlistview.h>
29 class YQWidgetCaption;
33 class YQTree : public QFrame, public YTree
42 YQTree( YWidget * parent, const string & label );
50 * Change the label text.
52 * Reimplemented from YSelectionWidget.
54 virtual void setLabel( const string & label );
57 * Rebuild the displayed tree from the internally stored YTreeItems.
59 * The application should call this (once) after all items have been added
60 * with addItem(). YTree::addItems() calls this automatically.
62 * Implemented from YTree.
64 virtual void rebuildTree();
67 * Select or deselect an item.
69 * Reimplemented from YSelectionWidget.
71 virtual void selectItem( YItem * item, bool selected = true );
76 * Reimplemented from YSelectionWidget.
78 virtual void deselectAllItems();
83 * Reimplemented from YSelectionWidget.
85 virtual void deleteAllItems();
88 * Set enabled/disbled state.
90 * Reimplemented from YWidget.
92 virtual void setEnabled( bool enabled );
95 * Preferred width of the widget.
97 * Reimplemented from YWidget.
99 virtual int preferredWidth();
102 * Preferred height of the widget.
104 * Reimplemented from YWidget.
106 virtual int preferredHeight();
109 * Set the new size of the widget.
111 * Reimplemented from YWidget.
113 virtual void setSize( int newWidth, int newHeight );
116 * Accept the keyboard focus.
118 virtual bool setKeyboardFocus();
124 * Propagate a tree item selection.
126 * This will trigger a 'SelectionChanged' event if 'notify' is set.
128 void slotSelected( Q3ListViewItem * item );
131 * Propagate a double click or pressing the space key on a tree item.
133 * This will trigger an 'Activated' event if 'notify' is set.
135 void slotActivated( Q3ListViewItem * item);
141 * Select an item via the corresponding YQTreItem.
143 void selectItem( YQTreeItem * item );
146 * Open the branch of 'item' recursively to its toplevel item.
148 void openBranch( Q3ListViewItem * item );
151 * Build a tree of items that will be displayed (YQTreeItems) from the
152 * original items between iterators 'begin' and 'end' as child items of
153 * 'parentItem' (or as toplevel items if 'parentItem' is 0).
155 void buildDisplayTree( YQTreeItem * parentItem,
163 YQWidgetCaption * _caption;
164 Q3ListView * _qt_listView;
169 class YQTreeItem: public Q3ListViewItem
174 * Constructor for a top level item.
176 YQTreeItem( YQTree * tree,
178 YTreeItem * origItem,
182 * Constructor for a non-top level item.
184 YQTreeItem( YQTree * tree,
186 YTreeItem * origItem,
190 * Returns the original YTreeItem of which this item is a clone.
192 YTreeItem * origItem() { return _origItem; }
197 * Reimplemented from Q3ListViewItem.
199 virtual void setOpen( bool open );
205 * Init function. All constructors end up here.
207 void init( YQTree * tree,
208 YTreeItem * yTreeItem,
215 * Sort key of this item.
217 * Reimplemented from Q3ListViewItem.
219 QString key( int column, bool ascending ) const;
227 YTreeItem * _origItem;
233 #endif // ifndef YQTree_h