comparison layer/TextLayer.cpp @ 216:34bbbcb3c01f sv1-1.0pre1

* Make getPropertyRangeAndValue return the default separately from the current value. Previously some contexts were incorrectly treating the current value as a default.
author Chris Cannam
date Fri, 02 Mar 2007 14:00:12 +0000
parents 6969f21da18a
children 28c8e8e3c537
comparison
equal deleted inserted replaced
215:d2334a77db73 216:34bbbcb3c01f
80 return ValueProperty; 80 return ValueProperty;
81 } 81 }
82 82
83 int 83 int
84 TextLayer::getPropertyRangeAndValue(const PropertyName &name, 84 TextLayer::getPropertyRangeAndValue(const PropertyName &name,
85 int *min, int *max) const 85 int *min, int *max, int *deflt) const
86 { 86 {
87 //!!! factor this colour handling stuff out into a colour manager class 87 //!!! factor this colour handling stuff out into a colour manager class
88 88
89 int deft = 0; 89 int val = 0;
90 90
91 if (name == "Colour") { 91 if (name == "Colour") {
92 92
93 if (min) *min = 0; 93 if (min) *min = 0;
94 if (max) *max = 5; 94 if (max) *max = 5;
95 95 if (deflt) *deflt = 0;
96 if (m_colour == Qt::black) deft = 0; 96
97 else if (m_colour == Qt::darkRed) deft = 1; 97 if (m_colour == Qt::black) val = 0;
98 else if (m_colour == Qt::darkBlue) deft = 2; 98 else if (m_colour == Qt::darkRed) val = 1;
99 else if (m_colour == Qt::darkGreen) deft = 3; 99 else if (m_colour == Qt::darkBlue) val = 2;
100 else if (m_colour == QColor(200, 50, 255)) deft = 4; 100 else if (m_colour == Qt::darkGreen) val = 3;
101 else if (m_colour == QColor(255, 150, 50)) deft = 5; 101 else if (m_colour == QColor(200, 50, 255)) val = 4;
102 else if (m_colour == QColor(255, 150, 50)) val = 5;
102 103
103 } else { 104 } else {
104 105
105 deft = Layer::getPropertyRangeAndValue(name, min, max); 106 val = Layer::getPropertyRangeAndValue(name, min, max, deflt);
106 } 107 }
107 108
108 return deft; 109 return val;
109 } 110 }
110 111
111 QString 112 QString
112 TextLayer::getPropertyValueLabel(const PropertyName &name, 113 TextLayer::getPropertyValueLabel(const PropertyName &name,
113 int value) const 114 int value) const