Skip to content

Commit

Permalink
fix #25422 next try
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed May 22, 2014
1 parent 1cd4416 commit c66fe22
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 40 deletions.
8 changes: 4 additions & 4 deletions libmscore/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1561,11 +1561,11 @@ void Measure::adjustToLen(Fraction nf)
}
}
}
Score* s = score()->rootScore();
Measure* m = this;
int staves = s->nstaves();
Score* s = score()->rootScore();
Measure* m = this;
QList<int> sl = s->uniqueStaves();

for (int staffIdx = 0; staffIdx < staves; ++staffIdx) {
for (int staffIdx : sl) {
int rests = 0;
int chords = 0;
Rest* rest = 0;
Expand Down
26 changes: 26 additions & 0 deletions libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3511,5 +3511,31 @@ void Score::setPos(POS pos, int tick)
}
}

//---------------------------------------------------------
// uniqueStaves
//---------------------------------------------------------

QList<int> Score::uniqueStaves() const
{
QList<int> sl;

for (int staffIdx = 0; staffIdx < nstaves(); ++staffIdx) {
Staff* s = staff(staffIdx);
if (s->linkedStaves()) {
bool alreadyInList = false;
for (int idx : sl) {
if (s->linkedStaves()->staves().contains(staff(idx))) {
alreadyInList = true;
break;
}
}
if (alreadyInList)
continue;
}
sl.append(staffIdx);
}
return sl;
}

}

2 changes: 2 additions & 0 deletions libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,8 @@ class Score : public QObject {
qreal noteHeadWidth() const { return _noteHeadWidth; }
void setNoteHeadWidth( qreal n) { _noteHeadWidth = n; }

QList<int> uniqueStaves() const;

friend class ChangeSynthesizerState;
friend class Chord;
};
Expand Down
2 changes: 2 additions & 0 deletions libmscore/staff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,8 @@ void Staff::linkTo(Staff* staff)
}
else {
_linkedStaves->add(staff);
if (!staff->linkedStaves())
staff->_linkedStaves = _linkedStaves;
}
}

Expand Down
43 changes: 30 additions & 13 deletions mscore/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,9 @@ void MuseScore::newFile()
continue;
Measure* measure = static_cast<Measure*>(mb);
int ticks = measure->ticks();

QList<int> sl = score->uniqueStaves();

for (int staffIdx = 0; staffIdx < score->nstaves(); ++staffIdx) {
Staff* staff = score->staff(staffIdx);
if (tick == 0) {
Expand Down Expand Up @@ -610,36 +613,49 @@ void MuseScore::newFile()
}
if (staff->primaryStaff()) {
if (measure->timesig() != measure->len()) {
int tick = measure->tick();
QList<TDuration> dList = toDurationList(measure->len(), false);
if (!dList.isEmpty()) {
foreach(TDuration d, dList) {
Rest* rest = new Rest(score, d);
rest->setDuration(d.fraction());
rest->setTrack(staffIdx * VOICES);
Segment* s = measure->getSegment(rest, tick);
s->add(rest);
int tick = measure->tick();
foreach (TDuration d, dList) {
Rest* rest = 0;
for (Staff* s : staff->staffList()) {
if (rest)
rest = static_cast<Rest*>(rest->linkedClone());
else
rest = new Rest(score, d);
rest->setDuration(d.fraction());
rest->setTrack(s->idx() * VOICES);
Segment* seg = measure->getSegment(rest, tick);
seg->add(rest);
}
tick += rest->actualTicks();
}
}
}
else {
Rest* rest = new Rest(score, TDuration(TDuration::V_MEASURE));
rest->setDuration(measure->len());
rest->setTrack(staffIdx * VOICES);
Segment* s = measure->getSegment(rest, tick);
s->add(rest);
Rest* rest = 0;
for (Staff* s : staff->staffList()) {
if (rest)
rest = static_cast<Rest*>(rest->linkedClone());
else
rest = new Rest(score, TDuration(TDuration::V_MEASURE));
rest->setDuration(measure->len());
rest->setTrack(s->idx() * VOICES);
Segment* seg = measure->getSegment(rest, tick);
seg->add(rest);
}
}
}
}
tick += ticks;
}
score->fixTicks();
#if 0
//
// ceate linked staves
//
QMap<Score*, QList<int>> scoremap;
foreach(Staff* staff, score->staves()) {
foreach (Staff* staff, score->staves()) {
if (!staff->linkedStaves())
continue;
foreach(Staff* lstaff, staff->linkedStaves()->staves()) {
Expand All @@ -661,6 +677,7 @@ void MuseScore::newFile()
cloneStaves(score, it.key(), it.value());
++it;
}
#endif

//
// select first rest
Expand Down
2 changes: 1 addition & 1 deletion mscore/newwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ void InstrumentWizard::createInstruments(Score* cs)

if (sli->linked() && !part->staves()->isEmpty()) {
Staff* linkedStaff = part->staves()->back();
linkedStaff->linkTo(staff);
staff->linkTo(linkedStaff);
}
part->staves()->push_back(staff);
cs->staves().insert(staffIdx + rstaff, staff);
Expand Down
34 changes: 12 additions & 22 deletions mtest/libmscore/parts/tst_parts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class TestParts : public QObject, public MTest
// void stylePartDefault();
// void styleScoreDefault();
// void staffStyles();

void measureProperties();
};

//---------------------------------------------------------
Expand Down Expand Up @@ -186,7 +188,6 @@ void TestParts::appendMeasure()

score->undo()->undo();
score->endUndoRedo();
score->doLayout();

QVERIFY(saveCompareScore(score, "part-all-uappendmeasures.mscx", DIR + "part-all-uappendmeasures.mscx"));
delete score;
Expand All @@ -212,7 +213,6 @@ void TestParts::insertMeasure()

score->undo()->undo();
score->endUndoRedo();
score->doLayout();

QVERIFY(saveCompareScore(score, "part-all-uinsertmeasures.mscx", DIR + "part-all-uinsertmeasures.mscx"));
delete score;
Expand Down Expand Up @@ -370,7 +370,6 @@ void TestParts::undoAddBreath()

score->undo()->undo();
score->endUndoRedo();
score->doLayout();

QVERIFY(saveCompareScore(score, "part-breath-uadd.mscx", DIR + "part-breath-uadd.mscx"));
delete score;
Expand All @@ -390,7 +389,6 @@ void TestParts::undoRedoAddBreath()

score->undo()->redo();
score->endUndoRedo();
score->doLayout();

QVERIFY(saveCompareScore(score, "part-breath-uradd.mscx", DIR + "part-breath-uradd.mscx"));
delete score;
Expand Down Expand Up @@ -439,7 +437,6 @@ void TestParts::undoRemoveBreath()
Score* score = doRemoveBreath();
score->undo()->undo();
score->endUndoRedo();
score->doLayout();
QVERIFY(saveCompareScore(score, "part-breath-udel.mscx", DIR + "part-breath-udel.mscx"));
delete score;
}
Expand All @@ -457,7 +454,6 @@ void TestParts::undoRedoRemoveBreath()

score->undo()->redo();
score->endUndoRedo();
score->doLayout();

QVERIFY(saveCompareScore(score, "part-breath-urdel.mscx", DIR + "part-breath-urdel.mscx"));
delete score;
Expand Down Expand Up @@ -510,7 +506,6 @@ void TestParts::undoAddFingering()
Score* score = doAddFingering();
score->undo()->undo();
score->endUndoRedo();
score->doLayout();
QVERIFY(saveCompareScore(score, "part-fingering-uadd.mscx", DIR + "part-fingering-uadd.mscx"));
delete score;
}
Expand All @@ -526,7 +521,6 @@ void TestParts::undoRedoAddFingering()
score->endUndoRedo();
score->undo()->redo();
score->endUndoRedo();
score->doLayout();
QVERIFY(saveCompareScore(score, "part-fingering-uradd.mscx", DIR + "part-fingering-uradd.mscx"));
delete score;
}
Expand Down Expand Up @@ -582,7 +576,6 @@ void TestParts::undoRemoveFingering()
Score* score = doRemoveFingering();
score->undo()->undo();
score->endUndoRedo();
score->doLayout();
QVERIFY(saveCompareScore(score, "part-fingering-udel.mscx", DIR + "part-fingering-udel.mscx"));
delete score;
}
Expand All @@ -598,7 +591,6 @@ void TestParts::undoRedoRemoveFingering()
score->endUndoRedo();
score->undo()->redo();
score->endUndoRedo();
score->doLayout();
QVERIFY(saveCompareScore(score, "part-fingering-urdel.mscx", DIR + "part-fingering-urdel.mscx"));
delete score;
}
Expand Down Expand Up @@ -650,7 +642,6 @@ void TestParts::undoAddSymbol()
Score* score = doAddSymbol();
score->undo()->undo();
score->endUndoRedo();
score->doLayout();
QVERIFY(saveCompareScore(score, "part-symbol-uadd.mscx", DIR + "part-symbol-uadd.mscx"));
delete score;
}
Expand All @@ -666,7 +657,6 @@ void TestParts::undoRedoAddSymbol()
score->endUndoRedo();
score->undo()->redo();
score->endUndoRedo();
score->doLayout();
QVERIFY(saveCompareScore(score, "part-symbol-uradd.mscx", DIR + "part-symbol-uradd.mscx"));
delete score;
}
Expand Down Expand Up @@ -722,7 +712,6 @@ void TestParts::undoRemoveSymbol()
Score* score = doRemoveSymbol();
score->undo()->undo();
score->endUndoRedo();
score->doLayout();
QVERIFY(saveCompareScore(score, "part-symbol-udel.mscx", DIR + "part-symbol-udel.mscx"));
delete score;
}
Expand All @@ -738,7 +727,6 @@ void TestParts::undoRedoRemoveSymbol()
score->endUndoRedo();
score->undo()->redo();
score->endUndoRedo();
score->doLayout();
QVERIFY(saveCompareScore(score, "part-symbol-urdel.mscx", DIR + "part-symbol-urdel.mscx"));
delete score;
}
Expand Down Expand Up @@ -790,7 +778,6 @@ void TestParts::undoAddChordline()
Score* score = doAddChordline();
score->undo()->undo();
score->endUndoRedo();
score->doLayout();
QVERIFY(saveCompareScore(score, "part-chordline-uadd.mscx", DIR + "part-chordline-uadd.mscx"));
delete score;
}
Expand All @@ -806,7 +793,6 @@ void TestParts::undoRedoAddChordline()
score->endUndoRedo();
score->undo()->redo();
score->endUndoRedo();
score->doLayout();
QVERIFY(saveCompareScore(score, "part-chordline-uradd.mscx", DIR + "part-chordline-uradd.mscx"));
delete score;
}
Expand Down Expand Up @@ -863,7 +849,7 @@ void TestParts::undoRemoveChordline()
Score* score = doRemoveChordline();
score->undo()->undo();
score->endUndoRedo();
score->doLayout();
// score->doLayout();
QVERIFY(saveCompareScore(score, "part-chordline-udel.mscx", DIR + "part-chordline-udel.mscx"));
delete score;
}
Expand All @@ -879,7 +865,6 @@ void TestParts::undoRedoRemoveChordline()
score->endUndoRedo();
score->undo()->redo();
score->endUndoRedo();
score->doLayout();
QVERIFY(saveCompareScore(score, "part-chordline-urdel.mscx", DIR + "part-chordline-urdel.mscx"));
delete score;
}
Expand Down Expand Up @@ -931,7 +916,6 @@ void TestParts::undoAddImage()
Score* score = doAddImage();
score->undo()->undo();
score->endUndoRedo();
score->doLayout();
QVERIFY(saveCompareScore(score, "part26.mscx", DIR + "part26o.mscx"));
delete score;
}
Expand All @@ -947,7 +931,6 @@ void TestParts::undoRedoAddImage()
score->endUndoRedo();
score->undo()->redo();
score->endUndoRedo();
score->doLayout();
QVERIFY(saveCompareScore(score, "part27.mscx", DIR + "part27o.mscx"));
delete score;
}
Expand Down Expand Up @@ -1003,7 +986,6 @@ void TestParts::undoRemoveImage()
Score* score = doRemoveImage();
score->undo()->undo();
score->endUndoRedo();
score->doLayout();
QVERIFY(saveCompareScore(score, "part29.mscx", DIR + "part29o.mscx"));
delete score;
}
Expand All @@ -1019,7 +1001,6 @@ void TestParts::undoRedoRemoveImage()
score->endUndoRedo();
score->undo()->redo();
score->endUndoRedo();
score->doLayout();
QVERIFY(saveCompareScore(score, "part30.mscx", DIR + "part30o.mscx"));
delete score;
}
Expand Down Expand Up @@ -1055,6 +1036,15 @@ void TestParts::staffStyles()
#endif


//---------------------------------------------------------
// measureProperties
//---------------------------------------------------------

void TestParts::measureProperties()
{
}


QTEST_MAIN(TestParts)

#include "tst_parts.moc"
Expand Down

0 comments on commit c66fe22

Please sign in to comment.