25
25
#include " types/typesconv.h"
26
26
27
27
#include " masterscore.h"
28
+ #include " measure.h"
28
29
#include " score.h"
29
30
#include " segment.h"
30
31
#include " staff.h"
@@ -152,7 +153,7 @@ bool KeySig::isChange() const
152
153
if (!segment () || segment ()->segmentType () != SegmentType::KeySig) {
153
154
return false ;
154
155
}
155
- Fraction keyTick = tick ();
156
+ const Fraction keyTick = tick ();
156
157
return staff ()->currentKeyTick (keyTick) == keyTick;
157
158
}
158
159
@@ -197,12 +198,39 @@ PointF KeySig::staffOffset() const
197
198
return PointF (0.0 , 0.0 );
198
199
}
199
200
201
+ EngravingItem* KeySig::propertyDelegate (Pid propertyId)
202
+ {
203
+ switch (propertyId) {
204
+ case Pid::KEY:
205
+ case Pid::KEY_CONCERT:
206
+ case Pid::SHOW_COURTESY:
207
+ case Pid::KEYSIG_MODE:
208
+ case Pid::IS_COURTESY: {
209
+ if (staff () && segment ()) {
210
+ const Fraction changeTick = staff ()->currentKeyTick (tick ());
211
+ if (Segment* s = score ()->tick2segment (changeTick, true , SegmentType::KeySig)) {
212
+ return toKeySig (s->element (staff2track (staffIdx ())));
213
+ }
214
+ }
215
+ break ;
216
+ }
217
+ default :
218
+ break ;
219
+ }
220
+
221
+ return nullptr ;
222
+ }
223
+
200
224
// ---------------------------------------------------------
201
225
// getProperty
202
226
// ---------------------------------------------------------
203
227
204
228
PropertyValue KeySig::getProperty (Pid propertyId) const
205
229
{
230
+ EngravingItem* e = const_cast <KeySig*>(this )->propertyDelegate (propertyId);
231
+ if (e && !isChange ()) {
232
+ return e->getProperty (propertyId);
233
+ }
206
234
switch (propertyId) {
207
235
case Pid::KEY:
208
236
return int (key ());
@@ -225,29 +253,21 @@ PropertyValue KeySig::getProperty(Pid propertyId) const
225
253
226
254
bool KeySig::setProperty (Pid propertyId, const PropertyValue& v)
227
255
{
256
+ EngravingItem* e = const_cast <KeySig*>(this )->propertyDelegate (propertyId);
257
+ if (e && !isChange ()) {
258
+ return e->setProperty (propertyId, v);
259
+ }
228
260
switch (propertyId) {
229
261
case Pid::KEY:
230
- if (generated ()) {
231
- return false ;
232
- }
233
262
setKey (m_sig.concertKey (), Key (v.toInt ()));
234
263
break ;
235
264
case Pid::KEY_CONCERT:
236
- if (generated ()) {
237
- return false ;
238
- }
239
265
setKey (Key (v.toInt ()));
240
266
break ;
241
267
case Pid::SHOW_COURTESY:
242
- if (generated ()) {
243
- return false ;
244
- }
245
268
setShowCourtesy (v.toBool ());
246
269
break ;
247
270
case Pid::KEYSIG_MODE:
248
- if (generated ()) {
249
- return false ;
250
- }
251
271
setMode (KeyMode (v.toInt ()));
252
272
staff ()->setKey (tick (), keySigEvent ());
253
273
break ;
0 commit comments