diff --git a/importexport/capella/capella.cpp b/importexport/capella/capella.cpp index e3f2478460107..3c6c830e1845f 100644 --- a/importexport/capella/capella.cpp +++ b/importexport/capella/capella.cpp @@ -365,10 +365,10 @@ static void processBasicDrawObj(QList objects, Segment* s, int tr { TransposableObj* to = static_cast(oo); QString str = ""; - for (BasicDrawObj* bdo : to->variants) { + for (BasicDrawObj*& bdo : to->variants) { SimpleTextObj* st = static_cast(bdo); if (st->font().family() == "capella3") { - for (const QChar& ch : st->text()) { + for (QChar& ch : st->text()) { if (ch == 'Q') str += "b"; else if (ch == 'S') @@ -498,7 +498,7 @@ static bool findChordRests(BasicDrawObj const* const o, Score* score, const int if (cr) { if ((graceNumber1 > 0) && cr->isChord()) { // the spanner is starting from a grace note Chord* chord = toChord(cr); - for (Chord* cc : chord->graceNotes()) { + for (Chord*& cc : chord->graceNotes()) { --graceNumber1; if ((graceNumber1 == 0) && (!cr1)) cr1 = toChordRest(cc); // found first ChordRest @@ -515,7 +515,7 @@ static bool findChordRests(BasicDrawObj const* const o, Score* score, const int if (cr) { if ((graceNumber > 0) && cr->isChord()) { // the spanner is ending on a grace note Chord* chord = toChord(cr); - for (Chord* cc : chord->graceNotes()) { + for (Chord*& cc : chord->graceNotes()) { --graceNumber; if ((graceNumber == 0) && (!cr2)) cr2 = toChordRest(cc); // found 2nd ChordRest @@ -574,7 +574,7 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const ClefType pclef = score->staff(staffIdx)->defaultClefType()._concertClef; QList graceNotes; - for (NoteObj* no : cvoice->objects) { + for (NoteObj*& no : cvoice->objects) { switch (no->type()) { case CapellaNoteObjectType::REST: { @@ -766,7 +766,7 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const }; off += keyOffsets[int(key) + 7]; - for (const CNote& n : o->notes) { + for (const CNote& n : qAsConst(o->notes)) { Note* note = new Note(score); int pitch = 0; // .cap import: pitch contains the diatonic note number relative to clef and key @@ -802,7 +802,7 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const note->setTieFor(tie); } } - for (Verse v : o->verse) { + for (Verse& v : o->verse) { Lyrics* l = new Lyrics(score); l->setTrack(track); l->setPlainText(v.text); @@ -972,7 +972,7 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const // pass II // tick = startTick; - for (NoteObj* no : cvoice->objects) { + for (NoteObj*& no : cvoice->objects) { BasicDurationalObj* d = 0; if (no->type() == CapellaNoteObjectType::REST) d = static_cast(static_cast(no)); @@ -980,7 +980,7 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const d = static_cast(static_cast(no)); if (!d) continue; - for (BasicDrawObj* o : d->objects) { + for (BasicDrawObj*& o : d->objects) { switch (o->type) { case CapellaType::SIMPLE_TEXT: // qDebug("simple text at %d", tick); @@ -1175,9 +1175,9 @@ void convertCapella(Score* score, Capella* cap, bool capxMode) // score->style().set(Sid::hideEmptyStaves, true); #if 1 - for (CapSystem* csys : cap->systems) { + for (CapSystem*& csys : cap->systems) { qDebug("System:"); - for (CapStaff* cstaff : csys->staves) { + for (CapStaff*& cstaff : csys->staves) { CapStaffLayout* cl = cap->staffLayout(cstaff->iLayout); qDebug(" Staff layout <%s><%s><%s><%s><%s> %d barline %d-%d mode %d", qPrintable(cl->descr), qPrintable(cl->name), qPrintable(cl->abbrev), @@ -1191,7 +1191,7 @@ void convertCapella(Score* score, Capella* cap, bool capxMode) // find out the maximum number of staves // int staves = 0; - for (CapSystem* csys : cap->systems) { + for (CapSystem*& csys : cap->systems) { staves = qMax(staves, csys->staves.size()); } // @@ -1263,7 +1263,7 @@ void convertCapella(Score* score, Capella* cap, bool capxMode) if (bstaff) bstaff->setBarLineSpan(span != 0); - for (CapBracket cb : cap->brackets) { + for (CapBracket& cb : cap->brackets) { qDebug("Bracket %d-%d curly %d", cb.from, cb.to, cb.curly); Staff* staff = score->staves().value(cb.from); if (staff == 0) { @@ -1274,7 +1274,7 @@ void convertCapella(Score* score, Capella* cap, bool capxMode) staff->setBracketSpan(0, cb.to - cb.from + 1); } MeasureBase* measure = nullptr; - for (BasicDrawObj* o : cap->backgroundChord->objects) { + for (BasicDrawObj*& o : cap->backgroundChord->objects) { switch (o->type) { case CapellaType::SIMPLE_TEXT: { @@ -1325,7 +1325,7 @@ void convertCapella(Score* score, Capella* cap, bool capxMode) } Fraction systemTick = Fraction(0,1); - for (CapSystem* csys : cap->systems) { + for (CapSystem*& csys : cap->systems) { qDebug("readCapSystem"); /* if (csys->explLeftIndent > 0) { @@ -1336,7 +1336,7 @@ void convertCapella(Score* score, Capella* cap, bool capxMode) } */ Fraction mtick = Fraction(0,1); - for (CapStaff* cstaff : csys->staves) { + for (CapStaff*& cstaff : csys->staves) { // // assumption: layout index is mscore staffIdx // which means that there is a 1:1 relation between layout/staff @@ -1344,7 +1344,7 @@ void convertCapella(Score* score, Capella* cap, bool capxMode) qDebug(" ReadCapStaff %d/%d", cstaff->numerator, 1 << cstaff->log2Denom); int staffIdx = cstaff->iLayout; - for (CapVoice* cvoice : cstaff->voices) { + for (CapVoice*& cvoice : cstaff->voices) { Fraction tick = readCapVoice(score, cvoice, staffIdx, systemTick, capxMode); if (tick > mtick) mtick = tick; @@ -1354,7 +1354,7 @@ void convertCapella(Score* score, Capella* cap, bool capxMode) if (m && !m->lineBreak()) { LayoutBreak* lb = new LayoutBreak(score); lb->setLayoutBreakType(LayoutBreak::Type::LINE); - lb->setTrack(-1); // this are system elements + lb->setTrack(0); // these are system elements m->add(lb); } systemTick = mtick; diff --git a/libmscore/box.cpp b/libmscore/box.cpp index 2dd32f56fa2a1..d76a957ed85d9 100644 --- a/libmscore/box.cpp +++ b/libmscore/box.cpp @@ -576,7 +576,7 @@ Element* Box::drop(EditData& data) } break; } - lb->setTrack(-1); // these are system elements + lb->setTrack(0); // these are system elements lb->setParent(this); score()->undoAddElement(lb); return lb; diff --git a/libmscore/measure.cpp b/libmscore/measure.cpp index 6b2cced03f044..8b29e684089f5 100644 --- a/libmscore/measure.cpp +++ b/libmscore/measure.cpp @@ -364,7 +364,7 @@ AccidentalVal Measure::findAccidental(Note* note) const if (!e || !e->isChord()) continue; Chord* crd = toChord(e); - for (Chord* chord1 : crd->graceNotes()) { + for (Chord*& chord1 : crd->graceNotes()) { for (Note* note1 : chord1->notes()) { if (note1->tieBack() && note1->accidental() == 0) continue; @@ -425,7 +425,7 @@ AccidentalVal Measure::findAccidental(Segment* s, int staffIdx, int line, bool & if (!e || !e->isChord()) continue; Chord* chord = toChord(e); - for (Chord* chord1 : chord->graceNotes()) { + for (Chord*& chord1 : chord->graceNotes()) { for (Note* note : chord1->notes()) { if (note->tieBack() && note->accidental() == 0) continue; @@ -1503,8 +1503,8 @@ Element* Measure::drop(EditData& data) Bracket* b = toBracket(e); int level = 0; int firstStaff = 0; - for (Staff* s : score()->staves()) { - for (const BracketItem* bi : s->brackets()) { + for (Staff*& s : score()->staves()) { + for (BracketItem*& bi : s->brackets()) { int lastStaff = firstStaff + bi->bracketSpan() - 1; if (staffIdx >= firstStaff && staffIdx <= lastStaff) ++level; @@ -1536,7 +1536,7 @@ Element* Measure::drop(EditData& data) } else { // apply to all staves: - for (Staff* s : score()->staves()) + for (Staff*& s : score()->staves()) score()->undoChangeKeySig(s, tick(), k); } @@ -1587,7 +1587,7 @@ Element* Measure::drop(EditData& data) break; } if (b) { - b->setTrack(-1); // these are system elements + b->setTrack(0); // these are system elements b->setParent(measure); score()->undoAddElement(b); } @@ -1607,7 +1607,7 @@ Element* Measure::drop(EditData& data) const bool systemEnd = (nextVisStaffIdx == score()->nstaves()); if (systemEnd) { System* ns = 0; - for (System* ts : score()->systems()) { + for (System*& ts : score()->systems()) { if (ns) { ns = ts; break; @@ -1652,7 +1652,7 @@ Element* Measure::drop(EditData& data) } else if (bl->barLineType() == BarLineType::START_REPEAT) { Measure* m2 = isMMRest() ? mmRestFirst() : this; - for (Score* lscore : score()->scoreList()) { + for (Score*& lscore : score()->scoreList()) { Measure* lmeasure = lscore->tick2measure(m2->tick()); if (lmeasure) lmeasure->undoChangeProperty(Pid::REPEAT_START, true); @@ -1660,7 +1660,7 @@ Element* Measure::drop(EditData& data) } else if (bl->barLineType() == BarLineType::END_REPEAT) { Measure* m2 = isMMRest() ? mmRestLast() : this; - for (Score* lscore : score()->scoreList()) { + for (Score*& lscore : score()->scoreList()) { Measure* lmeasure = lscore->tick2measure(m2->tick()); if (lmeasure) lmeasure->undoChangeProperty(Pid::REPEAT_END, true); @@ -1668,7 +1668,7 @@ Element* Measure::drop(EditData& data) } else if (bl->barLineType() == BarLineType::END_START_REPEAT) { Measure* m2 = isMMRest() ? mmRestLast() : this; - for (Score* lscore : score()->scoreList()) { + for (Score*& lscore : score()->scoreList()) { Measure* lmeasure = lscore->tick2measure(m2->tick()); if (lmeasure) { lmeasure->undoChangeProperty(Pid::REPEAT_END, true); @@ -1808,7 +1808,7 @@ void Measure::adjustToLen(Fraction nf, bool appendRestsIfNecessary) score()->undoInsertTime(startTick, diff); score()->undo(new InsertTime(score(), startTick, diff)); - for (Score* s : score()->scoreList()) { + for (Score*& s : score()->scoreList()) { Measure* m = s->tick2measure(tick()); s->undo(new ChangeMeasureLen(m, nf)); if (nl > ol) { @@ -3950,7 +3950,7 @@ void Measure::setEndBarLineType(BarLineType val, int track, bool visible, QColor void Measure::barLinesSetSpan(Segment* seg) { int track = 0; - for (Staff* staff : score()->staves()) { + for (Staff*& staff : score()->staves()) { BarLine* bl = toBarLine(seg->element(track)); // get existing bar line for this staff, if any if (bl) { if (bl->generated()) { @@ -4236,7 +4236,7 @@ void Measure::addSystemHeader(bool isFirstSystem) Segment* kSegment = findFirstR(SegmentType::KeySig, Fraction(0,1)); Segment* cSegment = findFirstR(SegmentType::HeaderClef, Fraction(0,1)); - for (const Staff* staff : score()->staves()) { + for (Staff*& staff : score()->staves()) { const int track = staffIdx * VOICES; if (isFirstSystem || score()->styleB(Sid::genClef)) { diff --git a/libmscore/measurebase.cpp b/libmscore/measurebase.cpp index 94db6e1461355..9c89ad118218c 100644 --- a/libmscore/measurebase.cpp +++ b/libmscore/measurebase.cpp @@ -492,7 +492,7 @@ void MeasureBase::undoSetBreak(bool v, LayoutBreak::Type type) if (v) { LayoutBreak* lb = new LayoutBreak(score()); lb->setLayoutBreakType(type); - lb->setTrack(-1); // this are system elements + lb->setTrack(0); // these are system elements MeasureBase* mb = (isMeasure() && toMeasure(this)->isMMRest()) ? toMeasure(this)->mmRestLast() : this; lb->setParent(mb); score()->undoAddElement(lb); diff --git a/libmscore/scoreElement.cpp b/libmscore/scoreElement.cpp index 870cb15d38bc3..7ce2ac745327f 100644 --- a/libmscore/scoreElement.cpp +++ b/libmscore/scoreElement.cpp @@ -34,6 +34,7 @@ static const ElementName elementNames[] = { { ElementType::SCORE, "Score", QT_TRANSLATE_NOOP("elementName", "Score") }, { ElementType::SYMBOL, "Symbol", QT_TRANSLATE_NOOP("elementName", "Symbol") }, { ElementType::TEXT, "Text", QT_TRANSLATE_NOOP("elementName", "Text") }, + { ElementType::LAYOUT_BREAK, "LayoutBreak", QT_TRANSLATE_NOOP("elementName", "Layout Break") }, { ElementType::MEASURE_NUMBER, "MeasureNumber", QT_TRANSLATE_NOOP("elementName", "Measure Number") }, { ElementType::MMREST_RANGE, "MMRestRange", QT_TRANSLATE_NOOP("elementName", "Multimeasure Rest Range") }, { ElementType::INSTRUMENT_NAME, "InstrumentName", QT_TRANSLATE_NOOP("elementName", "Instrument Name") }, @@ -90,7 +91,6 @@ static const ElementName elementNames[] = { { ElementType::PEDAL_SEGMENT, "PedalSegment", QT_TRANSLATE_NOOP("elementName", "Pedal Segment") }, { ElementType::LYRICSLINE_SEGMENT, "LyricsLineSegment", QT_TRANSLATE_NOOP("elementName", "Melisma Line Segment") }, { ElementType::GLISSANDO_SEGMENT, "GlissandoSegment", QT_TRANSLATE_NOOP("elementName", "Glissando Segment") }, - { ElementType::LAYOUT_BREAK, "LayoutBreak", QT_TRANSLATE_NOOP("elementName", "Layout Break") }, { ElementType::SPACER, "Spacer", QT_TRANSLATE_NOOP("elementName", "Spacer") }, { ElementType::STAFF_STATE, "StaffState", QT_TRANSLATE_NOOP("elementName", "Staff State") }, { ElementType::NOTEHEAD, "NoteHead", QT_TRANSLATE_NOOP("elementName", "Notehead") }, diff --git a/libmscore/types.h b/libmscore/types.h index 1b967860b23dc..e5dc097a57509 100644 --- a/libmscore/types.h +++ b/libmscore/types.h @@ -40,6 +40,7 @@ enum class ElementType { SCORE, SYMBOL, TEXT, + LAYOUT_BREAK, MEASURE_NUMBER, MMREST_RANGE, INSTRUMENT_NAME, @@ -96,7 +97,6 @@ enum class ElementType { PEDAL_SEGMENT, LYRICSLINE_SEGMENT, GLISSANDO_SEGMENT, - LAYOUT_BREAK, SPACER, STAFF_STATE, NOTEHEAD, diff --git a/mtest/libmscore/barline/tst_barline.cpp b/mtest/libmscore/barline/tst_barline.cpp index 4297507925301..bc74e875be8de 100644 --- a/mtest/libmscore/barline/tst_barline.cpp +++ b/mtest/libmscore/barline/tst_barline.cpp @@ -276,7 +276,7 @@ void TestBarline::barline05() // create and add a LineBreak element LayoutBreak* lb = new LayoutBreak(score); lb->setLayoutBreakType(LayoutBreak::Type::LINE); - lb->setTrack(-1); // system-level element + lb->setTrack(0); // system-level element lb->setParent(msr); score->undoAddElement(lb); score->doLayout(); diff --git a/mtest/scripting/p1.log.ref b/mtest/scripting/p1.log.ref index a9a28aebc2baa..cf229d9a0b3b9 100644 --- a/mtest/scripting/p1.log.ref +++ b/mtest/scripting/p1.log.ref @@ -1,16 +1,16 @@ test script p1: read score elements -found:Clef (22) at 0 -found:KeySig (23) at 0 -found:TimeSig (25) at 0 +found:Clef (23) at 0 +found:KeySig (24) at 0 +found:TimeSig (26) at 0 found:Chord (92) at 0 beamMode:0 small:false stemDirection:AUTO duration:1/4 -found:Rest (26) at 480 +found:Rest (28) at 480 found:Chord (92) at 960 beamMode:0 small:false stemDirection:AUTO duration:1/2 -found:BarLine (12) at 1920 +found:BarLine (13) at 1920