#include <PropertyContainer.h>

Inheritance diagram for PropertyContainer:
Inheritance graph
Collaboration diagram for PropertyContainer:
Collaboration graph

Classes

class  SetPropertyCommand
 

Public Types

enum  PropertyType {
  ToggleProperty, RangeProperty, ValueProperty, ColourProperty,
  ColourMapProperty, UnitsProperty, InvalidProperty
}
 
typedef QString PropertyName
 
typedef std::vector< PropertyNamePropertyList
 

Public Slots

virtual void setProperty (const PropertyName &, int value)
 Set a property. More...
 
virtual CommandgetSetPropertyCommand (const PropertyName &, int value)
 Obtain a command that sets the given property, which can be added to the command history for undo/redo. More...
 
virtual void setPropertyFuzzy (QString nameString, QString valueString)
 Set a property using a fuzzy match. More...
 
virtual CommandgetSetPropertyCommand (QString nameString, QString valueString)
 As above, but returning a command. More...
 

Signals

void propertyChanged (PropertyContainer::PropertyName)
 

Public Member Functions

virtual ~PropertyContainer ()
 
virtual PropertyList getProperties () const
 Get a list of the names of all the supported properties on this container. More...
 
virtual QString getPropertyLabel (const PropertyName &) const =0
 Return the human-readable (and i18n'ised) name of a property. More...
 
virtual PropertyType getPropertyType (const PropertyName &) const
 Return the type of the given property, or InvalidProperty if the property is not supported on this container. More...
 
virtual QString getPropertyIconName (const PropertyName &) const
 Return an icon for the property, if any. More...
 
virtual QString getPropertyGroupName (const PropertyName &) const
 If this property has something in common with other properties on this container, return a name that can be used to group them (in order to save screen space, for example). More...
 
virtual int getPropertyRangeAndValue (const PropertyName &, int *min, int *max, int *deflt) const
 Return the minimum and maximum values for the given property and its current value in this container. More...
 
virtual QString getPropertyValueLabel (const PropertyName &, int value) const
 If the given property is a ValueProperty, return the display label to be used for the given value for that property. More...
 
virtual QString getPropertyValueIconName (const PropertyName &, int value) const
 If the given property is a ValueProperty, return the icon to be used for the given value for that property, if any. More...
 
virtual RangeMappergetNewPropertyRangeMapper (const PropertyName &) const
 If the given property is a RangeProperty, return a new RangeMapper object mapping its integer range onto an underlying floating point value range for human-intelligible display, if appropriate. More...
 
virtual QString getPropertyContainerName () const =0
 
virtual QString getPropertyContainerIconName () const =0
 
virtual std::shared_ptr< PlayParametersgetPlayParameters ()
 Return the play parameters for this layer, if any. More...
 

Protected Member Functions

virtual bool convertPropertyStrings (QString nameString, QString valueString, PropertyName &name, int &value)
 

Detailed Description

Definition at line 29 of file PropertyContainer.h.

Member Typedef Documentation

Definition at line 36 of file PropertyContainer.h.

Definition at line 37 of file PropertyContainer.h.

Member Enumeration Documentation

Enumerator
ToggleProperty 
RangeProperty 
ValueProperty 
ColourProperty 
ColourMapProperty 
UnitsProperty 
InvalidProperty 

Definition at line 39 of file PropertyContainer.h.

Constructor & Destructor Documentation

virtual PropertyContainer::~PropertyContainer ( )
inlinevirtual

Definition at line 34 of file PropertyContainer.h.

Member Function Documentation

PropertyContainer::PropertyList PropertyContainer::getProperties ( ) const
virtual

Get a list of the names of all the supported properties on this container.

These should be fixed (i.e. not internationalized).

Reimplemented in Preferences.

Definition at line 23 of file PropertyContainer.cpp.

Referenced by convertPropertyStrings().

virtual QString PropertyContainer::getPropertyLabel ( const PropertyName ) const
pure virtual

Return the human-readable (and i18n'ised) name of a property.

Implemented in Preferences.

Referenced by convertPropertyStrings().

PropertyContainer::PropertyType PropertyContainer::getPropertyType ( const PropertyName ) const
virtual

Return the type of the given property, or InvalidProperty if the property is not supported on this container.

Reimplemented in Preferences.

Definition at line 29 of file PropertyContainer.cpp.

References InvalidProperty.

Referenced by convertPropertyStrings().

QString PropertyContainer::getPropertyIconName ( const PropertyName ) const
virtual

Return an icon for the property, if any.

Definition at line 35 of file PropertyContainer.cpp.

QString PropertyContainer::getPropertyGroupName ( const PropertyName ) const
virtual

If this property has something in common with other properties on this container, return a name that can be used to group them (in order to save screen space, for example).

e.g. "Window Type" and "Window Size" might both have a group name of "Window". If this property is not groupable, return the empty string.

Definition at line 41 of file PropertyContainer.cpp.

int PropertyContainer::getPropertyRangeAndValue ( const PropertyName ,
int *  min,
int *  max,
int *  deflt 
) const
virtual

Return the minimum and maximum values for the given property and its current value in this container.

Min and/or max may be passed as NULL if their values are not required.

Reimplemented in Preferences.

Definition at line 47 of file PropertyContainer.cpp.

Referenced by convertPropertyStrings(), PropertyContainer::SetPropertyCommand::execute(), and getSetPropertyCommand().

QString PropertyContainer::getPropertyValueLabel ( const PropertyName ,
int  value 
) const
virtual

If the given property is a ValueProperty, return the display label to be used for the given value for that property.

Reimplemented in Preferences.

Definition at line 57 of file PropertyContainer.cpp.

Referenced by convertPropertyStrings().

QString PropertyContainer::getPropertyValueIconName ( const PropertyName ,
int  value 
) const
virtual

If the given property is a ValueProperty, return the icon to be used for the given value for that property, if any.

Definition at line 63 of file PropertyContainer.cpp.

RangeMapper * PropertyContainer::getNewPropertyRangeMapper ( const PropertyName ) const
virtual

If the given property is a RangeProperty, return a new RangeMapper object mapping its integer range onto an underlying floating point value range for human-intelligible display, if appropriate.

The RangeMapper should be allocated with new, and the caller takes responsibility for deleting it. Return NULL (as in the default implementation) if there is no such mapping.

Definition at line 69 of file PropertyContainer.cpp.

Referenced by convertPropertyStrings().

virtual QString PropertyContainer::getPropertyContainerName ( ) const
pure virtual

Implemented in Preferences.

Referenced by setProperty().

virtual QString PropertyContainer::getPropertyContainerIconName ( ) const
pure virtual

Implemented in Preferences.

virtual std::shared_ptr<PlayParameters> PropertyContainer::getPlayParameters ( )
inlinevirtual

Return the play parameters for this layer, if any.

The return value is a shared_ptr that, if not null, can be passed to e.g. PlayParameterRepository::EditCommand to change the parameters.

Definition at line 121 of file PropertyContainer.h.

References getSetPropertyCommand(), propertyChanged(), setProperty(), and setPropertyFuzzy().

void PropertyContainer::setProperty ( const PropertyName name,
int  value 
)
virtualslot

Set a property.

This is used for all property types. For boolean properties, zero is false and non-zero true; for colours, the integer value is an index into the colours in the global ColourDatabase.

Definition at line 75 of file PropertyContainer.cpp.

References getPropertyContainerName().

Referenced by PropertyContainer::SetPropertyCommand::execute(), getPlayParameters(), setPropertyFuzzy(), and PropertyContainer::SetPropertyCommand::unexecute().

Command * PropertyContainer::getSetPropertyCommand ( const PropertyName name,
int  value 
)
virtualslot

Obtain a command that sets the given property, which can be added to the command history for undo/redo.

Returns NULL if the property is already set to the given value.

Definition at line 81 of file PropertyContainer.cpp.

References getPropertyRangeAndValue().

Referenced by getPlayParameters(), and getSetPropertyCommand().

void PropertyContainer::setPropertyFuzzy ( QString  nameString,
QString  valueString 
)
virtualslot

Set a property using a fuzzy match.

Compare nameString with the property labels and underlying names, and if it matches one (with preference given to labels), try to convert valueString appropriately and set it. The valueString should contain a value label for value properties, a mapped value for range properties, "on" or "off" for toggle properties, a colour or unit name, or the underlying integer value for the property.

Note that as property and value labels may be translatable, the results of this function may vary by locale. It is intended for handling user-originated strings, not persistent storage.

The default implementation should work for most subclasses.

Definition at line 89 of file PropertyContainer.cpp.

References convertPropertyStrings(), and setProperty().

Referenced by getPlayParameters().

Command * PropertyContainer::getSetPropertyCommand ( QString  nameString,
QString  valueString 
)
virtualslot

As above, but returning a command.

Definition at line 104 of file PropertyContainer.cpp.

References convertPropertyStrings(), and getSetPropertyCommand().


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