Chris@49
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 A waveform viewer and audio annotation editor.
|
Chris@2
|
5 Chris Cannam, Queen Mary University of London, 2005-2006
|
Chris@0
|
6
|
Chris@0
|
7 This is experimental software. Not for distribution.
|
Chris@0
|
8 */
|
Chris@0
|
9
|
Chris@0
|
10 #ifndef _PROPERTY_CONTAINER_H_
|
Chris@0
|
11 #define _PROPERTY_CONTAINER_H_
|
Chris@0
|
12
|
Chris@46
|
13 #include "Command.h"
|
Chris@46
|
14
|
Chris@0
|
15 #include <QString>
|
Chris@0
|
16 #include <QObject>
|
Chris@0
|
17 #include <vector>
|
Chris@0
|
18
|
Chris@28
|
19 class PlayParameters;
|
Chris@0
|
20
|
Chris@29
|
21 class PropertyContainer : public QObject
|
Chris@0
|
22 {
|
Chris@29
|
23 Q_OBJECT
|
Chris@29
|
24
|
Chris@0
|
25 public:
|
Chris@27
|
26 virtual ~PropertyContainer() { }
|
Chris@27
|
27
|
Chris@0
|
28 typedef QString PropertyName;
|
Chris@0
|
29 typedef std::vector<PropertyName> PropertyList;
|
Chris@0
|
30
|
Chris@0
|
31 enum PropertyType {
|
Chris@0
|
32 ToggleProperty, // on or off
|
Chris@0
|
33 RangeProperty, // range of integers
|
Chris@0
|
34 ValueProperty, // range of integers given string labels
|
Chris@0
|
35 ColourProperty, // colours, get/set as qRgb
|
Chris@0
|
36 InvalidProperty, // property not found!
|
Chris@0
|
37 };
|
Chris@0
|
38
|
Chris@0
|
39 /**
|
Chris@0
|
40 * Get a list of the names of all the supported properties on this
|
Chris@0
|
41 * container. Note that these should already have been
|
Chris@0
|
42 * internationalized with a call to tr() or equivalent. If the
|
Chris@0
|
43 * container needs to test for equality with string literals
|
Chris@0
|
44 * subsequently, it must be sure to call tr() again on the strings
|
Chris@0
|
45 * in order to ensure they match.
|
Chris@0
|
46 */
|
Chris@0
|
47 virtual PropertyList getProperties() const;
|
Chris@0
|
48
|
Chris@0
|
49 /**
|
Chris@0
|
50 * Return the type of the given property, or InvalidProperty if
|
Chris@0
|
51 * the property is not supported on this container.
|
Chris@0
|
52 */
|
Chris@0
|
53 virtual PropertyType getPropertyType(const PropertyName &) const;
|
Chris@0
|
54
|
Chris@0
|
55 /**
|
Chris@0
|
56 * If this property has something in common with other properties
|
Chris@0
|
57 * on this container, return a name that can be used to group them
|
Chris@0
|
58 * (in order to save screen space, for example). e.g. "Window
|
Chris@0
|
59 * Type" and "Window Size" might both have a group name of "Window".
|
Chris@0
|
60 * If this property is not groupable, return the empty string.
|
Chris@0
|
61 */
|
Chris@0
|
62 virtual QString getPropertyGroupName(const PropertyName &) const;
|
Chris@0
|
63
|
Chris@0
|
64 /**
|
Chris@0
|
65 * Return the minimum and maximum values for the given property
|
Chris@0
|
66 * and its current value in this container. Min and/or max may be
|
Chris@0
|
67 * passed as NULL if their values are not required.
|
Chris@0
|
68 */
|
Chris@0
|
69 virtual int getPropertyRangeAndValue(const PropertyName &,
|
Chris@0
|
70 int *min, int *max) const;
|
Chris@0
|
71
|
Chris@0
|
72 /**
|
Chris@0
|
73 * If the given property is a ValueProperty, return the display
|
Chris@0
|
74 * label to be used for the given value for that property.
|
Chris@0
|
75 */
|
Chris@0
|
76 virtual QString getPropertyValueLabel(const PropertyName &,
|
Chris@0
|
77 int value) const;
|
Chris@0
|
78
|
Chris@29
|
79 virtual QString getPropertyContainerName() const = 0;
|
Chris@29
|
80 virtual QString getPropertyContainerIconName() const = 0;
|
Chris@29
|
81
|
Chris@29
|
82 virtual PlayParameters *getPlayParameters() { return 0; }
|
Chris@29
|
83
|
Chris@29
|
84 signals:
|
Chris@29
|
85 void propertyChanged(PropertyName);
|
Chris@29
|
86
|
Chris@29
|
87 public slots:
|
Chris@0
|
88 /**
|
Chris@0
|
89 * Set a property. This is used for all property types. For
|
Chris@0
|
90 * boolean properties, zero is false and non-zero true; for
|
Chris@0
|
91 * colours, the integer value should be treated as a qRgb.
|
Chris@0
|
92 */
|
Chris@0
|
93 virtual void setProperty(const PropertyName &, int value);
|
Chris@46
|
94
|
Chris@46
|
95 /**
|
Chris@46
|
96 * Set a property using a command, supporting undo and redo.
|
Chris@46
|
97 */
|
Chris@46
|
98 virtual void setPropertyWithCommand(const PropertyName &, int value);
|
Chris@46
|
99
|
Chris@46
|
100 protected:
|
Chris@46
|
101
|
Chris@46
|
102 class SetPropertyCommand : public Command
|
Chris@46
|
103 {
|
Chris@46
|
104 public:
|
Chris@46
|
105 SetPropertyCommand(PropertyContainer *pc, const PropertyName &pn, int);
|
Chris@46
|
106 virtual ~SetPropertyCommand() { }
|
Chris@46
|
107
|
Chris@46
|
108 virtual void execute();
|
Chris@46
|
109 virtual void unexecute();
|
Chris@46
|
110 virtual QString getName() const;
|
Chris@46
|
111
|
Chris@46
|
112 protected:
|
Chris@46
|
113 PropertyContainer *m_pc;
|
Chris@46
|
114 PropertyName m_pn;
|
Chris@46
|
115 int m_value;
|
Chris@46
|
116 int m_oldValue;
|
Chris@46
|
117 };
|
Chris@0
|
118 };
|
Chris@0
|
119
|
Chris@0
|
120 #endif
|