comparison 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
comparison
equal deleted inserted replaced
276:657825878970 277:3b8008d09541
15 15
16 #include "PropertyContainer.h" 16 #include "PropertyContainer.h"
17 #include "CommandHistory.h" 17 #include "CommandHistory.h"
18 #include "RangeMapper.h" 18 #include "RangeMapper.h"
19 #include "UnitDatabase.h" 19 #include "UnitDatabase.h"
20 #include "ColourDatabase.h"
20 21
21 #include <QColor> 22 #include <QColor>
22 23
23 #include <iostream> 24 #include <iostream>
24 25
55 if (deflt) *deflt = 0; 56 if (deflt) *deflt = 0;
56 return 0; 57 return 0;
57 } 58 }
58 59
59 QString 60 QString
60 PropertyContainer::getPropertyValueLabel(const PropertyName &, int) const 61 PropertyContainer::getPropertyValueLabel(const PropertyName &name, int value) const
61 { 62 {
63 if (getPropertyType(name) == ColourProperty) {
64 ColourDatabase *db = ColourDatabase::getInstance();
65 if (value >= 0 && size_t(value) < db->getColourCount()) {
66 return db->getColourName(value);
67 }
68 }
69
62 return QString(); 70 return QString();
63 } 71 }
64 72
65 RangeMapper * 73 RangeMapper *
66 PropertyContainer::getNewPropertyRangeMapper(const PropertyName &) const 74 PropertyContainer::getNewPropertyRangeMapper(const PropertyName &) const
188 } 196 }
189 break; 197 break;
190 } 198 }
191 199
192 case ColourProperty: 200 case ColourProperty:
193 { 201 value = ColourDatabase::getInstance()->getColourIndex(valueString);
194 QColor c(valueString); 202 if (value >= 0) success = true;
195 if (c.isValid()) { 203 else value = 0;
196 value = c.rgb(); 204 break;
197 success = true;
198 }
199 break;
200 }
201 205
202 case UnitsProperty: 206 case UnitsProperty:
203 value = UnitDatabase::getInstance()->getUnitId(valueString, false); 207 value = UnitDatabase::getInstance()->getUnitId(valueString, false);
204 if (value >= 0) success = true; 208 if (value >= 0) success = true;
205 else value = 0; 209 else value = 0;