libyui  3.0.10
YSelectionWidget Class Reference

#include <YSelectionWidget.h>

Inheritance diagram for YSelectionWidget:
Collaboration diagram for YSelectionWidget:

List of all members.

Public Member Functions

virtual ~YSelectionWidget ()
virtual const char * widgetClass () const
std::string label () const
virtual void setLabel (const std::string &newLabel)
virtual void addItem (YItem *item_disown)
void addItem (const std::string &itemLabel, bool selected=false)
void addItem (const std::string &itemLabel, const std::string &iconName, bool selected=false)
virtual void addItems (const YItemCollection &itemCollection)
virtual void deleteAllItems ()
void setItems (const YItemCollection &itemCollection)
YItemIterator itemsBegin ()
YItemConstIterator itemsBegin () const
YItemIterator itemsEnd ()
YItemConstIterator itemsEnd () const
bool hasItems () const
int itemsCount () const
YItemfirstItem () const
virtual YItemselectedItem ()
virtual YItemCollection selectedItems ()
bool hasSelectedItem ()
virtual void selectItem (YItem *item, bool selected=true)
virtual void deselectAllItems ()
void setIconBasePath (const std::string &basePath)
std::string iconBasePath () const
std::string iconFullPath (const std::string &iconName) const
std::string iconFullPath (YItem *item) const
bool itemsContain (YItem *item) const
YItemfindItem (const std::string &itemLabel) const
virtual std::string shortcutString () const
virtual void setShortcutString (const std::string &str)

Protected Member Functions

 YSelectionWidget (YWidget *parent, const std::string &label, bool enforceSingleSelection, bool recurisveSelection=false)
void setEnforceSingleSelection (bool on)
bool enforceSingleSelection () const
bool recursiveSelection () const
YItemfindSelectedItem (YItemConstIterator begin, YItemConstIterator end)
void findSelectedItems (YItemCollection &selectedItems, YItemConstIterator begin, YItemConstIterator end)
void deselectAllItems (YItemIterator begin, YItemIterator end)
YItemfindItem (const std::string &wantedItemLabel, YItemConstIterator begin, YItemConstIterator end) const
bool itemsContain (YItem *wantedItem, YItemConstIterator begin, YItemConstIterator end) const
YItemitemAt (int index) const

Detailed Description

Base class for selection widgets:

Definition at line 42 of file YSelectionWidget.h.


Constructor & Destructor Documentation

YSelectionWidget::YSelectionWidget ( YWidget parent,
const std::string &  label,
bool  enforceSingleSelection,
bool  recurisveSelection = false 
) [protected]

Constructor.

'singleSelectionMode' indicates if this base class should enforce single selection when items are added or when items are selected from the application. Note that single selection can also mean that no item is selected.

Definition at line 55 of file YSelectionWidget.cc.

Destructor.

Definition at line 70 of file YSelectionWidget.cc.

Here is the call graph for this function:


Member Function Documentation

void YSelectionWidget::addItem ( YItem item_disown) [virtual]

Add one item. This widget assumes ownership of the item object and will delete it in its destructor.

NOTE: For tree items, call this only for the toplevel items; all non-toplevel items are already owned by their respective parent items. Adding them to the parent widget will clash with this ownership.

Derived classes can overwrite this function, but they should call this base class function in the new implementation.

Reimplemented in YContextMenu, YMenuButton, and YDumbTab.

Definition at line 168 of file YSelectionWidget.cc.

Here is the call graph for this function:

void YSelectionWidget::addItem ( const std::string &  itemLabel,
bool  selected = false 
)

Overloaded for convenience: Add an item by string.

Definition at line 235 of file YSelectionWidget.cc.

Here is the call graph for this function:

void YSelectionWidget::addItem ( const std::string &  itemLabel,
const std::string &  iconName,
bool  selected = false 
)

Overloaded for convenience: Add an item with a text and an icon. Note that not all UIs can display icons.

Definition at line 225 of file YSelectionWidget.cc.

Here is the call graph for this function:

void YSelectionWidget::addItems ( const YItemCollection &  itemCollection) [virtual]

Add multiple items. For some UIs, this can be more efficient than calling addItem() multiple times.

Reimplemented in YTree, YContextMenu, and YMenuButton.

Definition at line 241 of file YSelectionWidget.cc.

Here is the call graph for this function:

Delete all items.

Derived classes can overwrite this function, but they should call this base class function in the new implementation.

Reimplemented in YContextMenu, and YMenuButton.

Definition at line 76 of file YSelectionWidget.cc.

Here is the call graph for this function:

Deselect all items.

Derived classes can overwrite this function, but they should call this base class function in the new implementation.

Definition at line 454 of file YSelectionWidget.cc.

Here is the call graph for this function:

void YSelectionWidget::deselectAllItems ( YItemIterator  begin,
YItemIterator  end 
) [protected]

Recursively deselect all items between iterators 'begin' and 'end'.

Definition at line 460 of file YSelectionWidget.cc.

Here is the call graph for this function:

bool YSelectionWidget::enforceSingleSelection ( ) const [protected]

Return 'true' if this base class should enforce single selection.

Definition at line 107 of file YSelectionWidget.cc.

YItem * YSelectionWidget::findItem ( const std::string &  itemLabel) const

Find the (first) item with the specified label. Return 0 if there is no item with that label.

Definition at line 476 of file YSelectionWidget.cc.

Here is the call graph for this function:

YItem * YSelectionWidget::findItem ( const std::string &  wantedItemLabel,
YItemConstIterator  begin,
YItemConstIterator  end 
) const [protected]

Recursively try to find an item with label 'wantedItemLabel' between iterators 'begin' and 'end'. Return that item or 0 if there is none.

Definition at line 483 of file YSelectionWidget.cc.

Here is the call graph for this function:

YItem * YSelectionWidget::findSelectedItem ( YItemConstIterator  begin,
YItemConstIterator  end 
) [protected]

Recursively try to find the first selected item between iterators 'begin' and 'end'. Return that item or 0 if there is none.

Definition at line 326 of file YSelectionWidget.cc.

Here is the call graph for this function:

void YSelectionWidget::findSelectedItems ( YItemCollection &  selectedItems,
YItemConstIterator  begin,
YItemConstIterator  end 
) [protected]

Recursively find all selected items between iterators 'begin' and 'end' and add each of them to the 'selectedItems' YItemCollection.

Definition at line 363 of file YSelectionWidget.cc.

Here is the call graph for this function:

Return the first item or 0 if there is none.

Definition at line 299 of file YSelectionWidget.cc.

Return 'true' if this widget has any items.

Definition at line 286 of file YSelectionWidget.cc.

Return 'true' if any item is selected.

Definition at line 384 of file YSelectionWidget.cc.

Here is the call graph for this function:

std::string YSelectionWidget::iconBasePath ( ) const

Return this widget's base path where to look up icons as set with setIconBasePath().

Definition at line 131 of file YSelectionWidget.cc.

std::string YSelectionWidget::iconFullPath ( const std::string &  iconName) const

Return the full path + file name for the specified icon name. If iconBasePath is non-empty, it is prepended to the icon name. Otherwise, YUI::yApp()->iconLoader() and its icon search paths is used find the icon in one of them

If 'iconName' is empty, this will return an empty string.

Definition at line 137 of file YSelectionWidget.cc.

std::string YSelectionWidget::iconFullPath ( YItem item) const

Return the full path + file name for the icon of the specified item. If iconBasePath is non-empty, it is prepended to the item's iconName. Otherwise, YUI::yApp()->iconLoader() and its icon search paths is used find the icon in one of them

If 'item' does not have an iconName specified, this will return an empty string.

Definition at line 159 of file YSelectionWidget.cc.

Here is the call graph for this function:

YItem * YSelectionWidget::itemAt ( int  index) const [protected]

Return the item at index 'index' (from 0) or 0 if there is no such item.

Definition at line 309 of file YSelectionWidget.cc.

YItemIterator YSelectionWidget::itemsBegin ( )

Return an iterator that points to the first item.

For YSelectionWidgets that can have tree structures, this iterator will iterate over the toplevel items.

Important: Don't use this iterator to iterate over all items and check their "selected" state; that information might not always be up to date. Use the dedicated functions for that.

Definition at line 260 of file YSelectionWidget.cc.

bool YSelectionWidget::itemsContain ( YItem item) const

Return 'true' if this widget's items contain the specified item.

Definition at line 420 of file YSelectionWidget.cc.

Here is the call graph for this function:

bool YSelectionWidget::itemsContain ( YItem wantedItem,
YItemConstIterator  begin,
YItemConstIterator  end 
) const [protected]

Recursively check if 'wantedItem' is between iterators 'begin' and 'end'.

Definition at line 428 of file YSelectionWidget.cc.

Here is the call graph for this function:

Return the number of items.

For YSelectionWidgets that can have tree structures, this returns the number of toplevel items.

Definition at line 292 of file YSelectionWidget.cc.

YItemIterator YSelectionWidget::itemsEnd ( )

Return an iterator that points behind the last item.

Definition at line 273 of file YSelectionWidget.cc.

std::string YSelectionWidget::label ( ) const

Return this widget's label (the caption above the item list).

Definition at line 95 of file YSelectionWidget.cc.

bool YSelectionWidget::recursiveSelection ( ) const [protected]

Return 'true' if this base class should select children recursively.

Definition at line 112 of file YSelectionWidget.cc.

Return the (first) selected item or 0 if none is selected.

Reimplemented in YComboBox.

Definition at line 319 of file YSelectionWidget.cc.

Here is the call graph for this function:

YItemCollection YSelectionWidget::selectedItems ( ) [virtual]

Return all selected items. This is mostly useful for derived classes that allow selecting multiple items.

This function does not transfer ownership of those items to the caller, so don't try to delete them!

Reimplemented in YComboBox.

Definition at line 353 of file YSelectionWidget.cc.

Here is the call graph for this function:

void YSelectionWidget::selectItem ( YItem item,
bool  selected = true 
) [virtual]

Select or deselect an item.

Notice that this is different from YItem::setSelected() because unlike the latter function, this function informs the parent widget of the selection change.

If only one item can be selected at any time (single selection), the derived class will make sure to deselect any previous selection, if applicable.

Derived classes should overwrite this function, but they should call this base class function at the new function's start (this will also check if the item really belongs to this widget and throw an exception if not).

Reimplemented in YComboBox.

Definition at line 390 of file YSelectionWidget.cc.

Here is the call graph for this function:

void YSelectionWidget::setEnforceSingleSelection ( bool  on) [protected]

Set single selection mode on or off. In single selection mode, only one item can be selected at any time.

If set, this base class enforces this when items are added or when items are selected from the application. Note that single selection can also mean that no item is selected.

Definition at line 119 of file YSelectionWidget.cc.

Here is the call graph for this function:

void YSelectionWidget::setIconBasePath ( const std::string &  basePath)

Set this widget's base path where to look up icons. If this is a relative path, YUI::qApp()->iconBasePath() is prepended.

Definition at line 125 of file YSelectionWidget.cc.

void YSelectionWidget::setItems ( const YItemCollection &  itemCollection) [inline]

Delete all items and add new items.

Definition at line 127 of file YSelectionWidget.h.

Here is the call graph for this function:

void YSelectionWidget::setLabel ( const std::string &  newLabel) [virtual]

Change this widget's label (the caption above the item list).

Derived classes should overwrite this function, but they should call this base class function in the new implementation.

Definition at line 101 of file YSelectionWidget.cc.

virtual void YSelectionWidget::setShortcutString ( const std::string &  str) [inline, virtual]

Set the string of this widget that holds the keyboard shortcut.

Reimplemented from YWidget.

Reimplemented from YWidget.

Reimplemented in YDumbTab.

Definition at line 268 of file YSelectionWidget.h.

Here is the call graph for this function:

virtual std::string YSelectionWidget::shortcutString ( ) const [inline, virtual]

Get the string of this widget that holds the keyboard shortcut.

Reimplemented from YWidget.

Reimplemented from YWidget.

Reimplemented in YDumbTab.

Definition at line 261 of file YSelectionWidget.h.

Here is the call graph for this function:

virtual const char* YSelectionWidget::widgetClass ( ) const [inline, virtual]

Returns a descriptive name of this widget class for logging, debugging etc.

Reimplemented from YWidget.

Reimplemented in YTable, YSelectionBox, YComboBox, YTree, YContextMenu, YMenuButton, YDumbTab, and YMultiSelectionBox.

Definition at line 69 of file YSelectionWidget.h.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations Friends