25 #define YUILogComponent "ui"
28 #include "YItemSelector.h"
30 #define DEFAULT_VISIBLE_ITEMS 3
38 : visibleItems( DEFAULT_VISIBLE_ITEMS )
42 YItemCustomStatusVector customStates;
47 bool enforceSingleSelection )
50 enforceSingleSelection )
53 YUI_CHECK_NEW( priv );
60 const YItemCustomStatusVector & customStates )
66 YUI_CHECK_NEW( priv );
68 priv->customStates = customStates;
80 void YItemSelector::init()
93 return "YCustomStatusItemSelector";
102 return priv->visibleItems;
111 priv->visibleItems = newVal;
138 return ! priv->customStates.empty();
144 return priv->customStates.size();
157 return priv->customStates.at( (YItemCustomStatusVector::size_type) index );
167 void YItemSelector::checkCustomStates()
169 if ( priv->customStates.size() < 2 )
170 YUI_THROW(
YUIException(
"Need at least 2 different custom status value definitions" ) );
172 int maxStatus = priv->customStates.size() - 1;
174 for (
int i=0; i <= maxStatus; ++i )
176 YItemCustomStatus & status = priv->customStates.at( (YItemCustomStatusVector::size_type) i );
180 yuiError() <<
"Invalid nextStatus " << status.
nextStatus()
181 <<
" for status #" << i
190 yuiDebug() <<
"Status #" << i <<
": next status: #" << status.
nextStatus() << endl;
200 yuiDebug() <<
"Invalid old status: " << oldStatus << endl;
204 return priv->customStates.at( oldStatus ).nextStatus();
224 propSet.
add(
YProperty( YUIProperty_Value, YOtherProperty ) );
225 propSet.
add(
YProperty( YUIProperty_CurrentItem, YOtherProperty ) );
226 propSet.
add(
YProperty( YUIProperty_SelectedItems, YOtherProperty ) );
227 propSet.
add(
YProperty( YUIProperty_Items, YOtherProperty ) );
228 propSet.
add(
YProperty( YUIProperty_ItemStatus, YOtherProperty ) );
229 propSet.
add(
YProperty( YUIProperty_VisibleItems, YIntegerProperty ) );
230 propSet.
add(
YProperty( YUIProperty_IconPath, YStringProperty ) );
243 if ( propertyName == YUIProperty_Value )
return false;
244 else if ( propertyName == YUIProperty_CurrentItem )
return false;
245 else if ( propertyName == YUIProperty_SelectedItems )
return false;
246 else if ( propertyName == YUIProperty_Items )
return false;
247 else if ( propertyName == YUIProperty_ItemStatus )
return false;
248 else if ( propertyName == YUIProperty_VisibleItems )
setVisibleItems( val.integerVal() );
264 if ( propertyName == YUIProperty_Value )
return YPropertyValue( YOtherProperty );
265 else if ( propertyName == YUIProperty_CurrentItem )
return YPropertyValue( YOtherProperty );
266 else if ( propertyName == YUIProperty_SelectedItems )
return YPropertyValue( YOtherProperty );
267 else if ( propertyName == YUIProperty_Items )
return YPropertyValue( YOtherProperty );
268 else if ( propertyName == YUIProperty_ItemStatus )
return YPropertyValue( YOtherProperty );
void add(const YProperty &prop)
Add a property to this property set.
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
bool validCustomStatusIndex(int index) const
Return 'true' if a custom status index is within the valid range, i.e.
Class describing a non-binary status for an item.
virtual void setItemStatus(YItem *item, int status)
Set the status of an item.
A set of properties to check names and types against.
bool isEmpty() const
Returns 'true' if this property set does not contain anything.
virtual void setVisibleItems(int newVal)
Set the number of visible items.
std::string stringVal() const
Methods to get the value of this property.
virtual void updateCustomStatusIndicator(YItem *item)
Update the status indicator (status icon or text indicator) if this widget is using custom status val...
YPropertyType type() const
Returns the type of this property value.
const YItemCustomStatus & customStatus(int index)
Return the custom status with the specified index (counting from 0).
int nextStatus() const
This returns the next status to cycle through if the user clicks on the status or cycles through stat...
Class for widget properties.
virtual const YPropertySet & propertySet()
Return this class's property set.
int visibleItems() const
Return the number of visible items (i.e.
virtual ~YItemSelector()
Destructor.
bool usingCustomStatus() const
Return 'true' if this widget uses custom status values, 'false' if not (i.e.
void check(const std::string &propertyName) const
Check if a property 'propertyName' exists in this property set.
void setNextStatus(int value)
Set the next status.
YItemSelector(YWidget *parent, bool enforceSingleSelection=true)
Standard constructor.
virtual const char * widgetClass() const
Return a descriptive name of this widget class for logging, debugging etc.
int cycleCustomStatus(int oldStatus)
Cycle through the custom status values according to the custom status table, i.e.
Transport class for the value of simple properties.
void setStatus(int newStatus)
Set the status of this item.
int customStatusCount() const
Return the number of custom status values or 0 if no custom status values are used.
Base class for UI Exceptions.
Simple item class for SelectionBox, ComboBox, MultiSelectionBox etc.