Chris@0: /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */ Chris@0: Chris@0: /* Chris@0: A waveform viewer and audio annotation editor. Chris@2: Chris Cannam, Queen Mary University of London, 2005-2006 Chris@0: Chris@0: This is experimental software. Not for distribution. Chris@0: */ Chris@0: Chris@0: #ifndef _PROPERTY_CONTAINER_H_ Chris@0: #define _PROPERTY_CONTAINER_H_ Chris@0: Chris@0: #include Chris@0: #include Chris@0: #include Chris@0: Chris@28: class PlayParameters; Chris@0: Chris@29: class PropertyContainer : public QObject Chris@0: { Chris@29: Q_OBJECT Chris@29: Chris@0: public: Chris@27: virtual ~PropertyContainer() { } Chris@27: Chris@0: typedef QString PropertyName; Chris@0: typedef std::vector PropertyList; Chris@0: Chris@0: enum PropertyType { Chris@0: ToggleProperty, // on or off Chris@0: RangeProperty, // range of integers Chris@0: ValueProperty, // range of integers given string labels Chris@0: ColourProperty, // colours, get/set as qRgb Chris@0: InvalidProperty, // property not found! Chris@0: }; Chris@0: Chris@0: /** Chris@0: * Get a list of the names of all the supported properties on this Chris@0: * container. Note that these should already have been Chris@0: * internationalized with a call to tr() or equivalent. If the Chris@0: * container needs to test for equality with string literals Chris@0: * subsequently, it must be sure to call tr() again on the strings Chris@0: * in order to ensure they match. Chris@0: */ Chris@0: virtual PropertyList getProperties() const; Chris@0: Chris@0: /** Chris@0: * Return the type of the given property, or InvalidProperty if Chris@0: * the property is not supported on this container. Chris@0: */ Chris@0: virtual PropertyType getPropertyType(const PropertyName &) const; Chris@0: Chris@0: /** Chris@0: * If this property has something in common with other properties Chris@0: * on this container, return a name that can be used to group them Chris@0: * (in order to save screen space, for example). e.g. "Window Chris@0: * Type" and "Window Size" might both have a group name of "Window". Chris@0: * If this property is not groupable, return the empty string. Chris@0: */ Chris@0: virtual QString getPropertyGroupName(const PropertyName &) const; Chris@0: Chris@0: /** Chris@0: * Return the minimum and maximum values for the given property Chris@0: * and its current value in this container. Min and/or max may be Chris@0: * passed as NULL if their values are not required. Chris@0: */ Chris@0: virtual int getPropertyRangeAndValue(const PropertyName &, Chris@0: int *min, int *max) const; Chris@0: Chris@0: /** Chris@0: * If the given property is a ValueProperty, return the display Chris@0: * label to be used for the given value for that property. Chris@0: */ Chris@0: virtual QString getPropertyValueLabel(const PropertyName &, Chris@0: int value) const; Chris@0: Chris@29: virtual QString getPropertyContainerName() const = 0; Chris@29: virtual QString getPropertyContainerIconName() const = 0; Chris@29: Chris@29: virtual PlayParameters *getPlayParameters() { return 0; } Chris@29: Chris@29: signals: Chris@29: void propertyChanged(PropertyName); Chris@29: Chris@29: public slots: Chris@0: /** Chris@0: * Set a property. This is used for all property types. For Chris@0: * boolean properties, zero is false and non-zero true; for Chris@0: * colours, the integer value should be treated as a qRgb. Chris@0: */ Chris@0: virtual void setProperty(const PropertyName &, int value); Chris@0: }; Chris@0: Chris@0: #endif