00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _PROPERTY_CONTAINER_H_
00017 #define _PROPERTY_CONTAINER_H_
00018
00019 #include "Command.h"
00020
00021 #include <QString>
00022 #include <QObject>
00023 #include <vector>
00024
00025 class PlayParameters;
00026 class RangeMapper;
00027
00028 class PropertyContainer : public QObject
00029 {
00030 Q_OBJECT
00031
00032 public:
00033 virtual ~PropertyContainer() { }
00034
00035 typedef QString PropertyName;
00036 typedef std::vector<PropertyName> PropertyList;
00037
00038 enum PropertyType {
00039 ToggleProperty,
00040 RangeProperty,
00041 ValueProperty,
00042 ColourProperty,
00043 UnitsProperty,
00044 InvalidProperty,
00045 };
00046
00051 virtual PropertyList getProperties() const;
00052
00056 virtual QString getPropertyLabel(const PropertyName &) const = 0;
00057
00062 virtual PropertyType getPropertyType(const PropertyName &) const;
00063
00067 virtual QString getPropertyIconName(const PropertyName &) const;
00068
00076 virtual QString getPropertyGroupName(const PropertyName &) const;
00077
00083 virtual int getPropertyRangeAndValue(const PropertyName &,
00084 int *min, int *max, int *deflt) const;
00085
00090 virtual QString getPropertyValueLabel(const PropertyName &,
00091 int value) const;
00092
00101 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
00102
00103 virtual QString getPropertyContainerName() const = 0;
00104 virtual QString getPropertyContainerIconName() const = 0;
00105
00106 virtual PlayParameters *getPlayParameters() { return 0; }
00107
00108 signals:
00109 void propertyChanged(PropertyContainer::PropertyName);
00110
00111 public slots:
00118 virtual void setProperty(const PropertyName &, int value);
00119
00124 virtual void setPropertyWithCommand(const PropertyName &, int value);
00125
00141 virtual void setProperty(QString nameString, QString valueString);
00142
00146 virtual void setPropertyWithCommand(QString nameString, QString valueString);
00147
00148 protected:
00149
00150 class SetPropertyCommand : public Command
00151 {
00152 public:
00153 SetPropertyCommand(PropertyContainer *pc, const PropertyName &pn, int);
00154 virtual ~SetPropertyCommand() { }
00155
00156 virtual void execute();
00157 virtual void unexecute();
00158 virtual QString getName() const;
00159
00160 protected:
00161 PropertyContainer *m_pc;
00162 PropertyName m_pn;
00163 int m_value;
00164 int m_oldValue;
00165 };
00166
00167 virtual bool convertPropertyStrings(QString nameString, QString valueString,
00168 PropertyName &name, int &value);
00169 };
00170
00171 #endif