libyui
 
Loading...
Searching...
No Matches
YSelectionWidget Class Reference

#include <YSelectionWidget.h>

Inheritance diagram for YSelectionWidget:
Collaboration diagram for YSelectionWidget:

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
 
YItemitemAt (int index) const
 
YItemfirstItem () const
 
virtual YItemselectedItem ()
 
virtual YItemCollection selectedItems ()
 
bool hasSelectedItem ()
 
virtual void selectItem (YItem *item, bool selected=true)
 
virtual void setItemStatus (YItem *item, int status)
 
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
 
void dumpItems () const
 
bool enforceSingleSelection () const
 
virtual void shortcutChanged ()
 
virtual std::string shortcutString () const
 
virtual void setShortcutString (const std::string &str)
 
- Public Member Functions inherited from YWidget
virtual ~YWidget ()
 
virtual std::string debugLabel () const
 
std::string helpText () const
 
void setHelpText (const std::string &helpText)
 
virtual const YPropertySetpropertySet ()
 
virtual bool setProperty (const std::string &propertyName, const YPropertyValue &val)
 
virtual YPropertyValue getProperty (const std::string &propertyName)
 
bool hasChildren () const
 
YWidgetfirstChild () const
 
YWidgetlastChild () const
 
YWidgetListIterator childrenBegin () const
 
YWidgetListIterator childrenEnd () const
 
YWidgetListConstIterator childrenConstBegin () const
 
YWidgetListConstIterator childrenConstEnd () const
 
YWidgetListIterator begin ()
 
YWidgetListIterator end ()
 
int childrenCount () const
 
bool contains (YWidget *child) const
 
virtual void addChild (YWidget *child)
 
virtual void removeChild (YWidget *child)
 
void deleteChildren ()
 
YWidgetparent () const
 
bool hasParent () const
 
void setParent (YWidget *newParent)
 
YDialogfindDialog ()
 
YWidgetfindWidget (YWidgetID *id, bool doThrow=true) const
 
virtual int preferredWidth ()=0
 
virtual int preferredHeight ()=0
 
virtual int preferredSize (YUIDimension dim)
 
virtual void setSize (int newWidth, int newHeight)=0
 
bool isValid () const
 
bool beingDestroyed () const
 
void * widgetRep () const
 
void setWidgetRep (void *toolkitWidgetRep)
 
bool hasId () const
 
YWidgetIDid () const
 
void setId (YWidgetID *newId_disown)
 
virtual void setEnabled (bool enabled=true)
 
void setDisabled ()
 
virtual bool isEnabled () const
 
virtual bool stretchable (YUIDimension dim) const
 
void setStretchable (YUIDimension dim, bool newStretch)
 
void setDefaultStretchable (YUIDimension dim, bool newStretch)
 
virtual int weight (YUIDimension dim)
 
bool hasWeight (YUIDimension dim)
 
void setWeight (YUIDimension dim, int weight)
 
void setNotify (bool notify=true)
 
bool notify () const
 
void setNotifyContextMenu (bool notifyContextMenu=true)
 
bool notifyContextMenu () const
 
bool sendKeyEvents () const
 
void setSendKeyEvents (bool doSend)
 
bool autoShortcut () const
 
void setAutoShortcut (bool _newAutoShortcut)
 
int functionKey () const
 
bool hasFunctionKey () const
 
virtual void setFunctionKey (int fkey_no)
 
virtual bool setKeyboardFocus ()
 
virtual const char * userInputProperty ()
 
void dumpWidgetTree (int indentationLevel=0)
 
void dumpDialogWidgetTree ()
 
void setChildrenEnabled (bool enabled)
 
virtual void saveUserInput (YMacroRecorder *macroRecorder)
 
void * operator new (size_t size)
 
void operator delete (void *ptr) noexcept
 
virtual void startMultipleChanges ()
 
virtual void doneMultipleChanges ()
 

Protected Member Functions

 YSelectionWidget (YWidget *parent, const std::string &label, bool enforceSingleSelection, bool recursiveSelection=false)
 
void setEnforceSingleSelection (bool on)
 
void setEnforceInitialSelection (bool on)
 
bool enforceInitialSelection () 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
 
- Protected Member Functions inherited from YWidget
 YWidget (YWidget *parent)
 
YWidgetChildrenManagerchildrenManager () const
 
void setChildrenManager (YWidgetChildrenManager *manager)
 
void setBeingDestroyed ()
 
void dumpWidget (YWidget *w, int indentationLevel)
 

Detailed Description

Constructor & Destructor Documentation

◆ YSelectionWidget()

YSelectionWidget::YSelectionWidget ( YWidget * parent,
const std::string & label,
bool enforceSingleSelection,
bool recursiveSelection = false )
protected

Constructor.

'enforceSingleSelection' 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::~YSelectionWidget ( )
virtual

Destructor.

Member Function Documentation

◆ addItem() [1/3]

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

Overloaded for convenience: Add an item by string.

◆ addItem() [2/3]

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.

◆ addItem() [3/3]

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

◆ addItems()

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

◆ deleteAllItems()

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

◆ deselectAllItems() [1/2]

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.

◆ deselectAllItems() [2/2]

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

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

◆ dumpItems()

void YSelectionWidget::dumpItems ( ) const

Dump all items and their selection state to the log.

◆ enforceInitialSelection()

bool YSelectionWidget::enforceInitialSelection ( ) const
protected

Return 'true' if this class enforces an initial selection.

◆ enforceSingleSelection()

bool YSelectionWidget::enforceSingleSelection ( ) const

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

◆ findItem() [1/2]

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.

◆ findItem() [2/2]

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.

◆ findSelectedItem()

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.

◆ findSelectedItems()

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.

◆ firstItem()

YItem * YSelectionWidget::firstItem ( ) const

Return the first item or 0 if there is none.

◆ hasItems()

bool YSelectionWidget::hasItems ( ) const

Return 'true' if this widget has any items.

◆ hasSelectedItem()

bool YSelectionWidget::hasSelectedItem ( )

Return 'true' if any item is selected.

◆ iconBasePath()

string YSelectionWidget::iconBasePath ( ) const

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

◆ iconFullPath() [1/2]

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.

◆ iconFullPath() [2/2]

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.

◆ itemAt()

YItem * YSelectionWidget::itemAt ( int index) const

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

◆ itemsBegin()

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.

◆ itemsContain() [1/2]

bool YSelectionWidget::itemsContain ( YItem * item) const

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

◆ itemsContain() [2/2]

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

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

◆ itemsCount()

int YSelectionWidget::itemsCount ( ) const

Return the number of items.

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

◆ itemsEnd()

YItemIterator YSelectionWidget::itemsEnd ( )

Return an iterator that points behind the last item.

◆ label()

string YSelectionWidget::label ( ) const

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

◆ recursiveSelection()

bool YSelectionWidget::recursiveSelection ( ) const
protected

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

◆ selectedItem()

YItem * YSelectionWidget::selectedItem ( )
virtual

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

Reimplemented in YComboBox.

◆ selectedItems()

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.

◆ selectItem()

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.

◆ setEnforceInitialSelection()

void YSelectionWidget::setEnforceInitialSelection ( bool on)
protected

In single selection mode, enforce selecting an initial item ('true' by default). This is ignored in multi selection mode.

◆ setEnforceSingleSelection()

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.

◆ setIconBasePath()

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.

◆ setItems()

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

Delete all items and add new items.

◆ setItemStatus()

void YSelectionWidget::setItemStatus ( YItem * item,
int status )
virtual

Set the status of an item.

This is similar to selectItem(), but with numeric values.

This default implementation just calls selectItem() with 'status' converted to boolean. Derived classes can choose to make more detailed use of the numeric value.

Reimplemented in YItemSelector.

◆ setLabel()

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.

◆ setShortcutString()

void YSelectionWidget::setShortcutString ( const std::string & str)
virtual

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

Also trigger a shortcutChanged() notification. This is useful for derived sub-classes to refresh the widget when any shortcut of any item was changed by the shortcut conflict manager.

Check YItemShortcut in YShortcut.{cc,h} for more details.

Reimplemented from YWidget.

Reimplemented from YWidget.

◆ shortcutChanged()

virtual void YSelectionWidget::shortcutChanged ( )
inlinevirtual

Notification that any shortcut of any item was changed by the shortcut conflict manager YShortcutManager.

Derived classes should reimplement this.

◆ shortcutString()

virtual std::string YSelectionWidget::shortcutString ( ) const
inlinevirtual

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

Notice that some sub-classes (e.g., YDumbTab, YItemSelection, YMenuBar) has one shortcut for each item. This value is not meaningful for such widget classes.

Check YItemShortcut in YShortcut.{cc,h} for more details.

Reimplemented from YWidget.

Reimplemented from YWidget.

◆ widgetClass()

virtual const char * YSelectionWidget::widgetClass ( ) const
inlinevirtual

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

Reimplemented from YWidget.

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


The documentation for this class was generated from the following files: