svcore
1.9
|
#include <PropertyContainer.h>
Classes | |
class | SetPropertyCommand |
Public Types | |
enum | PropertyType { ToggleProperty, RangeProperty, ValueProperty, ColourProperty, UnitsProperty, InvalidProperty } |
typedef QString | PropertyName |
typedef std::vector< PropertyName > | PropertyList |
Public Slots | |
virtual void | setProperty (const PropertyName &, int value) |
Set a property. | |
virtual Command * | getSetPropertyCommand (const PropertyName &, int value) |
Obtain a command that sets the given property, which can be added to the command history for undo/redo. | |
virtual void | setPropertyFuzzy (QString nameString, QString valueString) |
Set a property using a fuzzy match. | |
virtual Command * | getSetPropertyCommand (QString nameString, QString valueString) |
As above, but returning a command. | |
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. | |
virtual QString | getPropertyLabel (const PropertyName &) const =0 |
Return the human-readable (and i18n'ised) name of a property. | |
virtual PropertyType | getPropertyType (const PropertyName &) const |
Return the type of the given property, or InvalidProperty if the property is not supported on this container. | |
virtual QString | getPropertyIconName (const PropertyName &) const |
Return an icon for the property, if any. | |
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). | |
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. | |
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. | |
virtual RangeMapper * | getNewPropertyRangeMapper (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. | |
virtual QString | getPropertyContainerName () const =0 |
virtual QString | getPropertyContainerIconName () const =0 |
virtual PlayParameters * | getPlayParameters () |
Protected Member Functions | |
virtual bool | convertPropertyStrings (QString nameString, QString valueString, PropertyName &name, int &value) |
Definition at line 28 of file PropertyContainer.h.
typedef QString PropertyContainer::PropertyName |
Definition at line 35 of file PropertyContainer.h.
typedef std::vector<PropertyName> PropertyContainer::PropertyList |
Definition at line 36 of file PropertyContainer.h.
Definition at line 38 of file PropertyContainer.h.
virtual PropertyContainer::~PropertyContainer | ( | ) | [inline, virtual] |
Definition at line 33 of file PropertyContainer.h.
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(), 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().
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 63 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 PlayParameters* PropertyContainer::getPlayParameters | ( | ) | [inline, virtual] |
Definition at line 106 of file PropertyContainer.h.
void PropertyContainer::propertyChanged | ( | PropertyContainer::PropertyName | ) | [signal] |
Referenced by Preferences::setBackgroundMode(), Preferences::setFixedSampleRate(), Preferences::setNormaliseAudio(), Preferences::setOctaveOfMiddleC(), Preferences::setOmitTempsFromRecentFiles(), Preferences::setPropertyBoxLayout(), Preferences::setResampleOnLoad(), Preferences::setResampleQuality(), Preferences::setShowSplash(), Preferences::setSpectrogramSmoothing(), Preferences::setSpectrogramXSmoothing(), Preferences::setTemporaryDirectoryRoot(), Preferences::setTimeToTextMode(), Preferences::setTuningFrequency(), Preferences::setViewFontSize(), and Preferences::setWindowType().
void PropertyContainer::setProperty | ( | const PropertyName & | name, |
int | value | ||
) | [virtual, slot] |
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.
Reimplemented in Preferences.
Definition at line 69 of file PropertyContainer.cpp.
References getPropertyContainerName().
Referenced by setPropertyFuzzy().
Command * PropertyContainer::getSetPropertyCommand | ( | const PropertyName & | name, |
int | value | ||
) | [virtual, slot] |
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 75 of file PropertyContainer.cpp.
References getPropertyRangeAndValue().
Referenced by getSetPropertyCommand().
void PropertyContainer::setPropertyFuzzy | ( | QString | nameString, |
QString | valueString | ||
) | [virtual, slot] |
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 83 of file PropertyContainer.cpp.
References convertPropertyStrings(), and setProperty().
Command * PropertyContainer::getSetPropertyCommand | ( | QString | nameString, |
QString | valueString | ||
) | [virtual, slot] |
As above, but returning a command.
Definition at line 98 of file PropertyContainer.cpp.
References convertPropertyStrings(), and getSetPropertyCommand().
bool PropertyContainer::convertPropertyStrings | ( | QString | nameString, |
QString | valueString, | ||
PropertyName & | name, | ||
int & | value | ||
) | [protected, virtual] |
Definition at line 113 of file PropertyContainer.cpp.
References ColourProperty, UnitDatabase::getInstance(), getNewPropertyRangeMapper(), RangeMapper::getPositionForValue(), getProperties(), getPropertyLabel(), getPropertyRangeAndValue(), getPropertyType(), getPropertyValueLabel(), UnitDatabase::getUnitId(), InvalidProperty, RangeProperty, SVDEBUG, ToggleProperty, UnitsProperty, and ValueProperty.
Referenced by getSetPropertyCommand(), and setPropertyFuzzy().