comparison base/PropertyContainer.h @ 0:da6937383da8

initial import
author Chris Cannam
date Tue, 10 Jan 2006 16:33:16 +0000
parents
children d86891498eef
comparison
equal deleted inserted replaced
-1:000000000000 0:da6937383da8
1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 A waveform viewer and audio annotation editor.
5 Chris Cannam, Queen Mary University of London, 2005
6
7 This is experimental software. Not for distribution.
8 */
9
10 #ifndef _PROPERTY_CONTAINER_H_
11 #define _PROPERTY_CONTAINER_H_
12
13 #include <QString>
14 #include <QObject>
15 #include <vector>
16
17 class Playable;
18
19 class PropertyContainer
20 {
21 public:
22 typedef QString PropertyName;
23 typedef std::vector<PropertyName> PropertyList;
24
25 enum PropertyType {
26 ToggleProperty, // on or off
27 RangeProperty, // range of integers
28 ValueProperty, // range of integers given string labels
29 ColourProperty, // colours, get/set as qRgb
30 InvalidProperty, // property not found!
31 };
32
33 /**
34 * Get a list of the names of all the supported properties on this
35 * container. Note that these should already have been
36 * internationalized with a call to tr() or equivalent. If the
37 * container needs to test for equality with string literals
38 * subsequently, it must be sure to call tr() again on the strings
39 * in order to ensure they match.
40 */
41 virtual PropertyList getProperties() const;
42
43 /**
44 * Return the type of the given property, or InvalidProperty if
45 * the property is not supported on this container.
46 */
47 virtual PropertyType getPropertyType(const PropertyName &) const;
48
49 /**
50 * If this property has something in common with other properties
51 * on this container, return a name that can be used to group them
52 * (in order to save screen space, for example). e.g. "Window
53 * Type" and "Window Size" might both have a group name of "Window".
54 * If this property is not groupable, return the empty string.
55 */
56 virtual QString getPropertyGroupName(const PropertyName &) const;
57
58 /**
59 * Return the minimum and maximum values for the given property
60 * and its current value in this container. Min and/or max may be
61 * passed as NULL if their values are not required.
62 */
63 virtual int getPropertyRangeAndValue(const PropertyName &,
64 int *min, int *max) const;
65
66 /**
67 * If the given property is a ValueProperty, return the display
68 * label to be used for the given value for that property.
69 */
70 virtual QString getPropertyValueLabel(const PropertyName &,
71 int value) const;
72
73 /**
74 * Set a property. This is used for all property types. For
75 * boolean properties, zero is false and non-zero true; for
76 * colours, the integer value should be treated as a qRgb.
77 */
78 virtual void setProperty(const PropertyName &, int value);
79
80 virtual QString getPropertyContainerName() const = 0;
81 virtual QString getPropertyContainerIconName() const = 0;
82
83 Playable *getPlayable() const { return 0; }
84 };
85
86 #endif