Mercurial > hg > svcore
diff base/PropertyContainer.cpp @ 277:3b8008d09541
* Add a colour database, and Add New Colour function to the colour combo
in property box. The colour property is only correctly handled in the
waveform layer so far.
* Add en_GB translation, to translate those annoying Color texts in the
Qt colour picker dialog.
author | Chris Cannam |
---|---|
date | Wed, 11 Jul 2007 17:21:37 +0000 |
parents | 21b9b25bff48 |
children | 516819f2b97b |
line wrap: on
line diff
--- a/base/PropertyContainer.cpp Thu Jul 05 11:07:01 2007 +0000 +++ b/base/PropertyContainer.cpp Wed Jul 11 17:21:37 2007 +0000 @@ -17,6 +17,7 @@ #include "CommandHistory.h" #include "RangeMapper.h" #include "UnitDatabase.h" +#include "ColourDatabase.h" #include <QColor> @@ -57,8 +58,15 @@ } QString -PropertyContainer::getPropertyValueLabel(const PropertyName &, int) const +PropertyContainer::getPropertyValueLabel(const PropertyName &name, int value) const { + if (getPropertyType(name) == ColourProperty) { + ColourDatabase *db = ColourDatabase::getInstance(); + if (value >= 0 && size_t(value) < db->getColourCount()) { + return db->getColourName(value); + } + } + return QString(); } @@ -190,14 +198,10 @@ } case ColourProperty: - { - QColor c(valueString); - if (c.isValid()) { - value = c.rgb(); - success = true; - } + value = ColourDatabase::getInstance()->getColourIndex(valueString); + if (value >= 0) success = true; + else value = 0; break; - } case UnitsProperty: value = UnitDatabase::getInstance()->getUnitId(valueString, false);