libyui
Public Member Functions | Protected Member Functions

YSelectionWidget Class Reference

#include <YSelectionWidget.h>

Inheritance diagram for YSelectionWidget:
YWidget YComboBox YContextMenu YDumbTab YMenuButton YMultiSelectionBox YSelectionBox YTable YTree

List of all members.

Public Member Functions

virtual ~YSelectionWidget ()
virtual const char * widgetClass () const
string label () const
virtual void setLabel (const string &newLabel)
virtual void addItem (YItem *item_disown)
void addItem (const string &itemLabel, bool selected=false)
void addItem (const string &itemLabel, const 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 string &basePath)
string iconBasePath () const
string iconFullPath (const string &iconName) const
string iconFullPath (YItem *item) const
bool itemsContain (YItem *item) const
YItemfindItem (const string &itemLabel) const
virtual string shortcutString () const
virtual void setShortcutString (const string &str)

Protected Member Functions

 YSelectionWidget (YWidget *parent, const 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 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:


Constructor & Destructor Documentation

YSelectionWidget::YSelectionWidget ( YWidget parent,
const 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.

YSelectionWidget::~YSelectionWidget ( ) [virtual]

Destructor.


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, YDumbTab, and YMenuButton.

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

Overloaded for convenience: Add an item by string.

void YSelectionWidget::addItem ( const string &  itemLabel,
const 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.

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 YContextMenu, YMenuButton, and YTree.

void YSelectionWidget::deleteAllItems ( ) [virtual]

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.

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

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

void YSelectionWidget::deselectAllItems ( ) [virtual]

Deselect all items.

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

bool YSelectionWidget::enforceSingleSelection ( ) const [protected]

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

YItem * YSelectionWidget::findItem ( const 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.

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

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

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.

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.

YItem * YSelectionWidget::firstItem ( ) const

Return the first item or 0 if there is none.

bool YSelectionWidget::hasItems ( ) const

Return 'true' if this widget has any items.

bool YSelectionWidget::hasSelectedItem ( )

Return 'true' if any item is selected.

string YSelectionWidget::iconBasePath ( ) const

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

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.

string YSelectionWidget::iconFullPath ( const 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.

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

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

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.

bool YSelectionWidget::itemsContain ( YItem item) const

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

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

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

int YSelectionWidget::itemsCount ( ) const

Return the number of items.

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

YItemIterator YSelectionWidget::itemsEnd ( )

Return an iterator that points behind the last item.

string YSelectionWidget::label ( ) const

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

bool YSelectionWidget::recursiveSelection ( ) const [protected]

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

YItem * YSelectionWidget::selectedItem ( ) [virtual]

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

Reimplemented in YComboBox.

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.

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.

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.

void YSelectionWidget::setIconBasePath ( const string &  basePath)

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

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

Delete all items and add new items.

void YSelectionWidget::setLabel ( const 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.

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

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

Reimplemented from YWidget.

Reimplemented from YWidget.

Reimplemented in YDumbTab.

virtual 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.

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 YComboBox, YContextMenu, YDumbTab, YMenuButton, YMultiSelectionBox, YSelectionBox, YTable, and YTree.


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