comparison layer/NoteLayer.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 c2ed5014d4ff
children b4809e942e7d
comparison
equal deleted inserted replaced
215:d2334a77db73 216:34bbbcb3c01f
101 return QString(); 101 return QString();
102 } 102 }
103 103
104 int 104 int
105 NoteLayer::getPropertyRangeAndValue(const PropertyName &name, 105 NoteLayer::getPropertyRangeAndValue(const PropertyName &name,
106 int *min, int *max) const 106 int *min, int *max, int *deflt) const
107 { 107 {
108 //!!! factor this colour handling stuff out into a colour manager class 108 //!!! factor this colour handling stuff out into a colour manager class
109 109
110 int deft = 0; 110 int val = 0;
111 111
112 if (name == "Colour") { 112 if (name == "Colour") {
113 113
114 if (min) *min = 0; 114 if (min) *min = 0;
115 if (max) *max = 5; 115 if (max) *max = 5;
116 116 if (deflt) *deflt = 0;
117 if (m_colour == Qt::black) deft = 0; 117
118 else if (m_colour == Qt::darkRed) deft = 1; 118 if (m_colour == Qt::black) val = 0;
119 else if (m_colour == Qt::darkBlue) deft = 2; 119 else if (m_colour == Qt::darkRed) val = 1;
120 else if (m_colour == Qt::darkGreen) deft = 3; 120 else if (m_colour == Qt::darkBlue) val = 2;
121 else if (m_colour == QColor(200, 50, 255)) deft = 4; 121 else if (m_colour == Qt::darkGreen) val = 3;
122 else if (m_colour == QColor(255, 150, 50)) deft = 5; 122 else if (m_colour == QColor(200, 50, 255)) val = 4;
123 else if (m_colour == QColor(255, 150, 50)) val = 5;
123 124
124 } else if (name == "Vertical Scale") { 125 } else if (name == "Vertical Scale") {
125 126
126 if (min) *min = 0; 127 if (min) *min = 0;
127 if (max) *max = 3; 128 if (max) *max = 3;
129 if (deflt) *deflt = int(AutoAlignScale);
128 130
129 deft = int(m_verticalScale); 131 val = int(m_verticalScale);
130 132
131 } else if (name == "Scale Units") { 133 } else if (name == "Scale Units") {
132 134
135 if (deflt) *deflt = 0;
133 if (m_model) { 136 if (m_model) {
134 deft = UnitDatabase::getInstance()->getUnitId 137 val = UnitDatabase::getInstance()->getUnitId
135 (m_model->getScaleUnits()); 138 (m_model->getScaleUnits());
136 } 139 }
137 140
138 } else { 141 } else {
139 142
140 deft = Layer::getPropertyRangeAndValue(name, min, max); 143 val = Layer::getPropertyRangeAndValue(name, min, max, deflt);
141 } 144 }
142 145
143 return deft; 146 return val;
144 } 147 }
145 148
146 QString 149 QString
147 NoteLayer::getPropertyValueLabel(const PropertyName &name, 150 NoteLayer::getPropertyValueLabel(const PropertyName &name,
148 int value) const 151 int value) const