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 );
bool validCustomStatusIndex(int index) const
Return 'true' if a custom status index is within the valid range, i.e.
int cycleCustomStatus(int oldStatus)
Cycle through the custom status values according to the custom status table, i.e. ...
virtual const YPropertySet & propertySet()
Return this class's property set.
bool isEmpty() const
Returns 'true' if this property set does not contain anything.
int visibleItems() const
Return the number of visible items (i.e.
Transport class for the value of simple properties.
void add(const YProperty &prop)
Add a property to this property set.
A set of properties to check names and types against.
virtual const char * widgetClass() const
Return a descriptive name of this widget class for logging, debugging etc.
virtual void setItemStatus(YItem *item, int status)
Set the status of an item.
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Class describing a non-binary status for an item.
virtual ~YItemSelector()
Destructor.
std::string stringVal() const
Methods to get the value of this property.
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.
Simple item class for SelectionBox, ComboBox, MultiSelectionBox etc.
YItemSelector(YWidget *parent, bool enforceSingleSelection=true)
Standard constructor.
virtual void setVisibleItems(int newVal)
Set the number of visible items.
virtual void updateCustomStatusIndicator(YItem *item)
Update the status indicator (status icon or text indicator) if this widget is using custom status val...
void setStatus(int newStatus)
Set the status of this item.
void setNextStatus(int value)
Set the next status.
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
void check(const std::string &propertyName) const
Check if a property 'propertyName' exists in this property set.
int customStatusCount() const
Return the number of custom status values or 0 if no custom status values are used.
Base class for UI Exceptions.
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).
bool usingCustomStatus() const
Return 'true' if this widget uses custom status values, 'false' if not (i.e.