diff --git a/libmscore/chord.h b/libmscore/chord.h index 187b214c24948..2838c8e626946 100644 --- a/libmscore/chord.h +++ b/libmscore/chord.h @@ -198,7 +198,7 @@ class Chord : public ChordRest { void toGraceAfter(); virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true); - virtual void setTrack(int val); + virtual void setTrack(int val) override; void computeUp(); diff --git a/libmscore/chordrest.cpp b/libmscore/chordrest.cpp index f4b8cefcffe91..8f28ddb9b27fb 100644 --- a/libmscore/chordrest.cpp +++ b/libmscore/chordrest.cpp @@ -1116,29 +1116,6 @@ QString ChordRest::durationUserName() return QString("%1%2").arg(tupletType).arg(dotString); } -//--------------------------------------------------------- -// setTrack -//--------------------------------------------------------- - -void ChordRest::setTrack(int val) - { - foreach(Articulation* a, _articulations) - a->setTrack(val); - Element::setTrack(val); - if (type() == Element::Type::CHORD) { - foreach(Note* n, static_cast(this)->notes()) - n->setTrack(val); - } - if (_beam) - _beam->setTrack(val); - foreach(Lyrics* l, _lyricsList) { - if (l) - l->setTrack(val); - } - if (tuplet()) - tuplet()->setTrack(val); - } - //--------------------------------------------------------- // tick //--------------------------------------------------------- @@ -1378,6 +1355,45 @@ Segment* ChordRest::nextSegmentAfterCR(Segment::Type types) const return 0; } +//--------------------------------------------------------- +// setTrack +//--------------------------------------------------------- + +void ChordRest::setTrack(int val) + { + Element::setTrack(val); + processSiblings([val] (Element* e) { e->setTrack(val); } ); + } + +//--------------------------------------------------------- +// setScore +//--------------------------------------------------------- + +void ChordRest::setScore(Score* s) + { + Element::setScore(s); + processSiblings([s] (Element* e) { e->setScore(s); } ); + } + +//--------------------------------------------------------- +// processSiblings +//--------------------------------------------------------- + +void ChordRest::processSiblings(std::function func) + { + if (_beam) + func(_beam); + for (Articulation* a : _articulations) + func(a); + if (_tabDur) + func(_tabDur); + for (Lyrics* l : _lyricsList) + if (l) + func(l); + if (tuplet()) + func(tuplet()); + } + //--------------------------------------------------------- // nextElement //--------------------------------------------------------- diff --git a/libmscore/chordrest.h b/libmscore/chordrest.h index a658d61bf7361..56fd9f89647a1 100644 --- a/libmscore/chordrest.h +++ b/libmscore/chordrest.h @@ -55,6 +55,8 @@ class ChordRest : public DurationElement { TDuration _durationType; int _staffMove; // -1, 0, +1, used for crossbeaming + void processSiblings(std::function func); + protected: QList _articulations; Beam* _beam; @@ -140,7 +142,7 @@ class ChordRest : public DurationElement { : _durationType.ticks(); } QString durationUserName(); - virtual void setTrack(int val); + virtual void setTrack(int val) override; virtual int tick() const; virtual int rtick() const; virtual Space space() const { return _space; } @@ -169,6 +171,7 @@ class ChordRest : public DurationElement { void writeBeam(Xml& xml); Segment* nextSegmentAfterCR(Segment::Type types) const; + virtual void setScore(Score* s) override; virtual Element* nextElement() override; virtual Element* prevElement() override; virtual QString accessibleExtraInfo() override; diff --git a/libmscore/note.cpp b/libmscore/note.cpp index f5bb5d4f948b0..d074b9c0632c6 100644 --- a/libmscore/note.cpp +++ b/libmscore/note.cpp @@ -2533,6 +2533,10 @@ void Note::setScore(Score* s) Element::setScore(s); if (_tieFor) _tieFor->setScore(s); + if (_accidental) + _accidental->setScore(s); + for (Element* el : _el) + el->setScore(s); } //---------------------------------------------------------