Skip to content

Commit

Permalink
fix regression for score creation from template
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Mar 3, 2015
1 parent 2aa4d8b commit 2dcd7b9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 19 deletions.
22 changes: 11 additions & 11 deletions libmscore/part.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ class Part : public QObject, public ScoreElement {
int startTrack() const;
int endTrack() const;

QString longName(int tick = -1) const;
QString shortName(int tick = -1) const;
QString instrumentName(int tick = -1) const;
QString instrumentId(int tick = -1) const;
QString longName(int tick = 0) const;
QString shortName(int tick = 0) const;
QString instrumentName(int tick = 0) const;
QString instrumentId(int tick = 0) const;

const QList<StaffName>& longNames(int tick = -1) const { return instr(tick)->longNames(); }
const QList<StaffName>& shortNames(int tick = -1) const { return instr(tick)->shortNames(); }
const QList<StaffName>& longNames(int tick = 0) const { return instr(tick)->longNames(); }
const QList<StaffName>& shortNames(int tick = 0) const { return instr(tick)->shortNames(); }

void setLongNames(QList<StaffName>& s, int tick = -1);
void setShortNames(QList<StaffName>& s, int tick = -1);
void setLongNames(QList<StaffName>& s, int tick = 0);
void setShortNames(QList<StaffName>& s, int tick = 0);

void setLongName(const QString& s);
void setShortName(const QString& s);
Expand Down Expand Up @@ -114,9 +114,9 @@ class Part : public QObject, public ScoreElement {
bool show() const { return _show; }
void setShow(bool val) { _show = val; }

Instrument* instr(int tick = -1);
const Instrument* instr(int tick = -1) const;
void setInstrument(const Instrument&, int tick = -1);
Instrument* instr(int tick = 0);
const Instrument* instr(int tick = 0) const;
void setInstrument(const Instrument&, int tick = 0);
void removeInstrument(int tick);

QString partName() const { return _partName; }
Expand Down
13 changes: 11 additions & 2 deletions libmscore/staff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,17 @@ void Staff::init(const InstrumentTemplate* t, const StaffType* staffType, int ci

setStaffType(pst);
setDefaultClefType(t->clefType(cidx));
// if (pst->group() == ArticulationShowIn::PITCHED_STAFF) // if PITCHED (in other staff groups num of lines is determined by style)
// setLines(t->staffLines[cidx]); // use number of lines from instr. template
}

//---------------------------------------------------------
// init
//---------------------------------------------------------

void Staff::init(const Staff* s)
{
setStaffType(s->staffType());
setDefaultClefType(s->defaultClefType());
setSmall(s->small());
}

//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions libmscore/staff.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class Staff : public QObject, public ScoreElement {
~Staff();
void init(const InstrumentTemplate*, const StaffType *staffType, int);
void initFromStaffType(const StaffType* staffType);
void init(const Staff*);

bool isTop() const;
QString partName() const;
Expand Down
2 changes: 1 addition & 1 deletion mscore/editstafftype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const char* g_groupNames[STAFF_GROUP_MAX] = {
QT_TRANSLATE_NOOP("staff group header name", "STANDARD STAFF"),
QT_TRANSLATE_NOOP("staff group header name", "PERCUSSION STAFF"),
QT_TRANSLATE_NOOP("staff group header name", "TABLATURE STAFF")
};
};

//---------------------------------------------------------
// EditStaffType
Expand Down
14 changes: 9 additions & 5 deletions mscore/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,18 +506,21 @@ void MuseScore::newFile()
// create instruments from template
for (Part* tpart : tscore->parts()) {
Part* part = new Part(score);
part->setInstrument(*tpart->instr(0), 0);

Instrument* i = tpart->instr(0);

part->setInstrument(*i, 0);
part->setPartName(tpart->partName());

for (Staff* tstaff : *tpart->staves()) {
Staff* staff = new Staff(score);
staff->setPart(part);
staff->setStaffType(tstaff->staffType());
staff->setDefaultClefType(tstaff->defaultClefType());
staff->setSmall(tstaff->small());
staff->init(tstaff);
if (tstaff->linkedStaves() && !part->staves()->isEmpty()) {
Staff* linkedStaff = part->staves()->back();
staff->linkTo(linkedStaff);
}
part->staves()->push_back(staff);
part->insertStaff(staff, -1);
score->staves().append(staff);
}
score->appendPart(part);
Expand All @@ -534,6 +537,7 @@ void MuseScore::newFile()
}
excerpts.append(x);
}
delete tscore;
}
else {
score = new Score(MScore::defaultStyle());
Expand Down

0 comments on commit 2dcd7b9

Please sign in to comment.