48 int *min,
int *max,
int *deflt)
const 52 if (deflt) *deflt = 0;
71 cerr <<
"WARNING: PropertyContainer[" <<
getPropertyContainerName() <<
"]::setProperty(" << name <<
"): no implementation in subclass!" << endl;
78 if (value == currentValue)
return 0;
88 cerr <<
"WARNING: PropertyContainer::setProperty(\"" 89 << nameString <<
"\", \"" 91 <<
"\"): Name and value conversion failed" << endl;
103 cerr <<
"WARNING: PropertyContainer::getSetPropertyCommand(\"" 104 << nameString <<
"\", \"" 106 <<
"\"): Name and value conversion failed" << endl;
118 QString adjusted = nameString.trimmed();
119 adjusted.replace(
'_',
' ');
120 adjusted.replace(
'-',
' ');
124 for (PropertyList::iterator pli = pl.begin(); pli != pl.end(); ++pli) {
128 if (label !=
"" && (nameString == label || adjusted == label)) {
131 }
else if (nameString == *pli) {
138 cerr <<
"PropertyContainer::convertPropertyStrings: Unable to match name string \"" << nameString <<
"\"" << endl;
143 bool success =
false;
145 bool isDouble =
false;
146 double dval = valueString.toDouble(&isDouble);
151 if (valueString == tr(
"yes") ||
152 valueString == tr(
"on") ||
153 valueString == tr(
"true")) {
154 value = 1; success =
true;
155 }
else if (valueString == tr(
"no") ||
156 valueString == tr(
"off") ||
157 valueString == tr(
"false")) {
158 value = 0; success =
true;
178 for (
int i = min; i <= max; ++i) {
190 if (value >= 0) success =
true;
195 SVDEBUG <<
"PropertyContainer::convertPropertyStrings: Invalid property name \"" << name <<
"\"" << endl;
199 if (success)
return true;
205 int i = valueString.toInt(&ok);
207 cerr <<
"PropertyContainer::convertPropertyStrings: Unable to parse value string \"" << valueString <<
"\"" << endl;
209 }
else if (i < min || i > max) {
210 SVDEBUG <<
"PropertyContainer::convertPropertyStrings: Property value \"" << i <<
"\" outside valid range " << min <<
" to " << max << endl;
231 m_oldValue = m_pc->getPropertyRangeAndValue(m_pn, 0, 0, 0);
232 m_pc->setProperty(m_pn, m_value);
238 m_pc->setProperty(m_pn, m_oldValue);
244 return tr(
"Set %1 Property").arg(m_pn);
int getUnitId(QString unit, bool registerNew=true)
Return the reference id for a given unit name.
virtual PropertyType getPropertyType(const PropertyName &) const
Return the type of the given property, or InvalidProperty if the property is not supported on this co...
virtual QString getName() const
virtual bool convertPropertyStrings(QString nameString, QString valueString, PropertyName &name, int &value)
virtual RangeMapper * getNewPropertyRangeMapper(const PropertyName &) const
If the given property is a RangeProperty, return a new RangeMapper object mapping its integer range o...
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...
virtual QString getPropertyContainerName() const =0
virtual PropertyList getProperties() const
Get a list of the names of all the supported properties on this container.
virtual void setPropertyFuzzy(QString nameString, QString valueString)
Set a property using a fuzzy match.
static UnitDatabase * getInstance()
virtual QString getPropertyLabel(const PropertyName &) const =0
Return the human-readable (and i18n'ised) name of a property.
virtual QString getPropertyGroupName(const PropertyName &) const
If this property has something in common with other properties on this container, return a name that ...
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/red...
virtual QString getPropertyIconName(const PropertyName &) const
Return an icon for the property, if any.
SetPropertyCommand(PropertyContainer *pc, const PropertyName &pn, int)
virtual int getPositionForValue(float value) const =0
Return the position that maps to the given value, rounding to the nearest position and clamping to th...
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 void setProperty(const PropertyName &, int value)
Set a property.
std::vector< PropertyName > PropertyList