fix #29751
This commit is contained in:
parent
efcb97648f
commit
570a8094fe
20 changed files with 90 additions and 91 deletions
|
@ -123,7 +123,8 @@ Score* createExcerpt(const QList<Part*>& parts)
|
|||
p->setInstrument(*part->instr(), 0);
|
||||
|
||||
foreach (Staff* staff, *part->staves()) {
|
||||
Staff* s = new Staff(score, p);
|
||||
Staff* s = new Staff(score);
|
||||
s->setPart(p);
|
||||
s->setStaffType(staff->staffType());
|
||||
s->linkTo(staff);
|
||||
p->staves()->append(s);
|
||||
|
|
|
@ -154,7 +154,8 @@ void MCursor::move(int t, int tick)
|
|||
void MCursor::addPart(const QString& instrument)
|
||||
{
|
||||
Part* part = new Part(_score);
|
||||
Staff* staff = new Staff(_score, part);
|
||||
Staff* staff = new Staff(_score);
|
||||
staff->setPart(part);
|
||||
InstrumentTemplate* it = searchTemplate(instrument);
|
||||
if (it == 0) {
|
||||
qFatal("Did not find instrument <%s>", qPrintable(instrument));
|
||||
|
|
|
@ -66,7 +66,8 @@ void Part::read(XmlReader& e)
|
|||
while (e.readNextStartElement()) {
|
||||
const QStringRef& tag(e.name());
|
||||
if (tag == "Staff") {
|
||||
Staff* staff = new Staff(_score, this);
|
||||
Staff* staff = new Staff(_score);
|
||||
staff->setPart(this);
|
||||
_score->staves().push_back(staff);
|
||||
_staves.push_back(staff);
|
||||
staff->read(e);
|
||||
|
@ -131,7 +132,8 @@ void Part::setStaves(int n)
|
|||
}
|
||||
int staffIdx = _score->staffIdx(this) + ns;
|
||||
for (int i = ns; i < n; ++i) {
|
||||
Staff* staff = new Staff(_score, this);
|
||||
Staff* staff = new Staff(_score);
|
||||
staff->setPart(this);
|
||||
_staves.push_back(staff);
|
||||
_score->staves().insert(staffIdx, staff);
|
||||
for (Measure* m = _score->firstMeasure(); m; m = m->nextMeasure()) {
|
||||
|
|
|
@ -217,7 +217,8 @@ void Part::read114(XmlReader& e)
|
|||
while (e.readNextStartElement()) {
|
||||
const QStringRef& tag(e.name());
|
||||
if (tag == "Staff") {
|
||||
Staff* staff = new Staff(_score, this);
|
||||
Staff* staff = new Staff(_score);
|
||||
staff->setPart(this);
|
||||
_score->staves().push_back(staff);
|
||||
_staves.push_back(staff);
|
||||
staff->read114(e);
|
||||
|
|
|
@ -2155,7 +2155,8 @@ void Score::splitStaff(int staffIdx, int splitPoint)
|
|||
//
|
||||
Staff* s = staff(staffIdx);
|
||||
Part* p = s->part();
|
||||
Staff* ns = new Staff(this, p);
|
||||
Staff* ns = new Staff(this);
|
||||
ns->setPart(p);
|
||||
undoInsertStaff(ns, staffIdx+1);
|
||||
|
||||
for (Measure* m = firstMeasure(); m; m = m->nextMeasure()) {
|
||||
|
@ -2284,6 +2285,7 @@ void Score::cmdInsertPart(Part* part, int staffIdx)
|
|||
{
|
||||
undoInsertPart(part, staffIdx);
|
||||
|
||||
#if 0
|
||||
int sidx = this->staffIdx(part);
|
||||
int eidx = sidx + part->nstaves();
|
||||
for (Measure* m = firstMeasure(); m; m = m->nextMeasure()) {
|
||||
|
@ -2293,6 +2295,7 @@ void Score::cmdInsertPart(Part* part, int staffIdx)
|
|||
}
|
||||
|
||||
adjustBracketsIns(sidx, eidx);
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -2303,8 +2306,8 @@ void Score::cmdRemovePart(Part* part)
|
|||
{
|
||||
int sidx = staffIdx(part);
|
||||
int n = part->nstaves();
|
||||
#if 0
|
||||
int eidx = sidx + n;
|
||||
|
||||
//
|
||||
// adjust measures
|
||||
//
|
||||
|
@ -2313,7 +2316,7 @@ void Score::cmdRemovePart(Part* part)
|
|||
if (m->hasMMRest())
|
||||
m->mmRest()->cmdRemoveStaves(sidx, eidx);
|
||||
}
|
||||
|
||||
#endif
|
||||
for (int i = 0; i < n; ++i)
|
||||
cmdRemoveStaff(sidx);
|
||||
|
||||
|
@ -2352,15 +2355,18 @@ void Score::removePart(Part* part)
|
|||
|
||||
void Score::insertStaff(Staff* staff, int ridx)
|
||||
{
|
||||
int idx = 0; // new index in _staves
|
||||
for (Part* p : _parts) {
|
||||
if (p == staff->part())
|
||||
break;
|
||||
idx += p->nstaves();
|
||||
}
|
||||
idx += ridx;
|
||||
int idx = staffIdx(staff->part()) + ridx;
|
||||
_staves.insert(idx, staff);
|
||||
staff->part()->insertStaff(staff, ridx);
|
||||
|
||||
for (Measure* m = firstMeasure(); m; m = m->nextMeasure()) {
|
||||
m->cmdAddStaves(idx, idx+1, true);
|
||||
if (m->hasMMRest())
|
||||
m->mmRest()->cmdAddStaves(idx, idx+1, true);
|
||||
}
|
||||
|
||||
adjustBracketsIns(idx, idx+1);
|
||||
|
||||
for (auto i = staff->score()->spanner().cbegin(); i != staff->score()->spanner().cend(); ++i) {
|
||||
Spanner* s = i->second;
|
||||
if (s->staffIdx() >= idx) {
|
||||
|
@ -2516,6 +2522,15 @@ void Score::removeStaff(Staff* staff)
|
|||
}
|
||||
_staves.removeAll(staff);
|
||||
staff->part()->removeStaff(staff);
|
||||
//
|
||||
// adjust measures
|
||||
//
|
||||
for (Measure* m = firstMeasure(); m; m = m->nextMeasure()) {
|
||||
m->cmdRemoveStaves(idx, idx+1);
|
||||
if (m->hasMMRest())
|
||||
m->mmRest()->cmdRemoveStaves(idx, idx+1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -3346,7 +3361,8 @@ void Score::appendPart(const QString& name)
|
|||
part->initFromInstrTemplate(t);
|
||||
int n = nstaves();
|
||||
for (int i = 0; i < t->nstaves(); ++i) {
|
||||
Staff* staff = new Staff(this, part);
|
||||
Staff* staff = new Staff(this);
|
||||
staff->setPart(part);
|
||||
staff->setLines(t->staffLines[i]);
|
||||
staff->setSmall(t->smallStaff[i]);
|
||||
if (i == 0) {
|
||||
|
|
|
@ -159,16 +159,8 @@ QString Staff::partName() const
|
|||
|
||||
Staff::Staff(Score* s)
|
||||
{
|
||||
_score = s;
|
||||
_part = 0;
|
||||
_barLineTo = (lines()-1)*2;
|
||||
}
|
||||
|
||||
Staff::Staff(Score* s, Part* p)
|
||||
{
|
||||
_score = s;
|
||||
_part = p;
|
||||
_barLineTo = (lines()-1)*2;
|
||||
_score = s;
|
||||
_barLineTo = (lines()-1)*2;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
|
|
@ -96,8 +96,8 @@ struct SwingParameters {
|
|||
class Staff : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Score* _score;
|
||||
Part* _part;
|
||||
Score* _score ;
|
||||
Part* _part { 0 };
|
||||
|
||||
ClefList clefs;
|
||||
ClefTypeList _defaultClefType;
|
||||
|
@ -127,7 +127,6 @@ class Staff : public QObject {
|
|||
|
||||
public:
|
||||
Staff(Score* = 0);
|
||||
Staff(Score*, Part*);
|
||||
~Staff();
|
||||
void init(const InstrumentTemplate*, const StaffType *staffType, int);
|
||||
void initFromStaffType(const StaffType* staffType);
|
||||
|
|
|
@ -393,7 +393,8 @@ Score::FileError importBB(Score* score, const QString& name)
|
|||
ntracks = 1;
|
||||
for (int i = 0; i < ntracks; ++i) {
|
||||
Part* part = new Part(score);
|
||||
Staff* s = new Staff(score, part);
|
||||
Staff* s = new Staff(score);
|
||||
s->setPart(part);
|
||||
part->insertStaff(s, 0);
|
||||
score->staves().append(s);
|
||||
score->appendPart(part);
|
||||
|
|
|
@ -855,7 +855,8 @@ void convertCapella(Score* score, Capella* cap, bool capxMode)
|
|||
}
|
||||
midiPatch = cl->sound;
|
||||
|
||||
Staff* s = new Staff(score, part);
|
||||
Staff* s = new Staff(score);
|
||||
s->setPart(part);
|
||||
if (cl->bPercussion)
|
||||
part->setMidiProgram(0, 128);
|
||||
else
|
||||
|
|
|
@ -552,7 +552,8 @@ Score::FileError importBww(Score* score, const QString& path)
|
|||
Part* part = new Part(score);
|
||||
part->setId(id);
|
||||
score->appendPart(part);
|
||||
Staff* staff = new Staff(score, part);
|
||||
Staff* staff = new Staff(score);
|
||||
staff->setPart(part);
|
||||
part->staves()->push_back(staff);
|
||||
score->staves().push_back(staff);
|
||||
|
||||
|
|
|
@ -562,7 +562,8 @@ void GuitarPro4::read(QFile* fp)
|
|||
//
|
||||
for (int staffIdx = 0; staffIdx < staves; ++staffIdx) {
|
||||
Part* part = new Part(score);
|
||||
Staff* s = new Staff(score, part);
|
||||
Staff* s = new Staff(score);
|
||||
s->setPart(part);
|
||||
part->insertStaff(s, 0);
|
||||
score->staves().push_back(s);
|
||||
score->appendPart(part);
|
||||
|
|
|
@ -556,7 +556,8 @@ void GuitarPro5::read(QFile* fp)
|
|||
//
|
||||
for (int staffIdx = 0; staffIdx < staves; ++staffIdx) {
|
||||
Part* part = new Part(score);
|
||||
Staff* s = new Staff(score, part);
|
||||
Staff* s = new Staff(score);
|
||||
s->setPart(part);
|
||||
part->insertStaff(s, -1);
|
||||
score->staves().push_back(s);
|
||||
score->appendPart(part);
|
||||
|
|
|
@ -368,7 +368,8 @@ void GuitarPro6::readTracks(QDomNode* track)
|
|||
while (!nextTrack.isNull()) {
|
||||
QDomNode currentNode = nextTrack.firstChild();
|
||||
Part* part = new Part(score);
|
||||
Staff* s = new Staff(score, part);
|
||||
Staff* s = new Staff(score);
|
||||
s->setPart(part);
|
||||
while (!currentNode.isNull()) {
|
||||
QString nodeName = currentNode.nodeName();
|
||||
if (nodeName == "Name")
|
||||
|
|
|
@ -809,7 +809,8 @@ void GuitarPro1::read(QFile* fp)
|
|||
//
|
||||
for (int staffIdx = 0; staffIdx < staves; ++staffIdx) {
|
||||
Part* part = new Part(score);
|
||||
Staff* s = new Staff(score, part);
|
||||
Staff* s = new Staff(score);
|
||||
s->setPart(part);
|
||||
part->insertStaff(s, 0);
|
||||
score->staves().push_back(s);
|
||||
score->appendPart(part);
|
||||
|
@ -1202,7 +1203,8 @@ void GuitarPro2::read(QFile* fp)
|
|||
//
|
||||
for (int staffIdx = 0; staffIdx < staves; ++staffIdx) {
|
||||
Part* part = new Part(score);
|
||||
Staff* s = new Staff(score, part);
|
||||
Staff* s = new Staff(score);
|
||||
s->setPart(part);
|
||||
part->insertStaff(s, 0);
|
||||
score->staves().push_back(s);
|
||||
score->appendPart(part);
|
||||
|
@ -1766,7 +1768,8 @@ void GuitarPro3::read(QFile* fp)
|
|||
//
|
||||
for (int staffIdx = 0; staffIdx < staves; ++staffIdx) {
|
||||
Part* part = new Part(score);
|
||||
Staff* s = new Staff(score, part);
|
||||
Staff* s = new Staff(score);
|
||||
s->setPart(part);
|
||||
part->insertStaff(s, 0);
|
||||
score->staves().push_back(s);
|
||||
score->appendPart(part);
|
||||
|
@ -2260,7 +2263,8 @@ Score::FileError importGTP(Score* score, const QString& name)
|
|||
|
||||
Staff* staff = part->staves()->front();
|
||||
|
||||
Staff* s = new Staff(pscore, p);
|
||||
Staff* s = new Staff(pscore);
|
||||
s->setPart(p);
|
||||
StaffType* st = staff->staffType();
|
||||
s->setStaffType(st);
|
||||
// int idx = pscore->staffTypeIdx(st);
|
||||
|
|
|
@ -716,7 +716,8 @@ void createInstruments(Score *score, QList<MTrack> &tracks)
|
|||
for (int idx = 0; idx < ntracks; ++idx) {
|
||||
MTrack& track = tracks[idx];
|
||||
Part* part = new Part(score);
|
||||
Staff* s = new Staff(score, part);
|
||||
Staff* s = new Staff(score);
|
||||
s->setPart(part);
|
||||
part->insertStaff(s, 0);
|
||||
score->staves().push_back(s);
|
||||
track.staff = s;
|
||||
|
@ -734,7 +735,8 @@ void createInstruments(Score *score, QList<MTrack> &tracks)
|
|||
s->setBracket(0, BracketType::BRACE);
|
||||
s->setBracketSpan(0, 2);
|
||||
|
||||
Staff* ss = new Staff(score, part);
|
||||
Staff* ss = new Staff(score);
|
||||
ss->setPart(part);
|
||||
part->insertStaff(ss, 1);
|
||||
score->staves().push_back(ss);
|
||||
++idx;
|
||||
|
|
|
@ -283,7 +283,8 @@ void OveToMScore::createStructure() {
|
|||
|
||||
for(int j=0; j<partStaffCount; ++j){
|
||||
//OVE::Track* track = ove_->getTrack(i, j);
|
||||
Staff* staff = new Staff(score_, part);
|
||||
Staff* staff = new Staff(score_);
|
||||
staff->setPart(part);
|
||||
|
||||
part->staves()->push_back(staff);
|
||||
score_->staves().push_back(staff);
|
||||
|
|
|
@ -1084,7 +1084,8 @@ void MusicXml::scorePartwise(QDomElement ee)
|
|||
Part* part = new Part(score);
|
||||
part->setId(id);
|
||||
score->appendPart(part);
|
||||
Staff* staff = new Staff(score, part);
|
||||
Staff* staff = new Staff(score);
|
||||
staff->setPart(part);
|
||||
part->staves()->push_back(staff);
|
||||
score->staves().push_back(staff);
|
||||
tuplets.resize(VOICES); // part now contains one staff, thus VOICES voices
|
||||
|
|
|
@ -256,41 +256,37 @@ void MuseScore::editInstrList()
|
|||
const InstrumentTemplate* t = ((PartListItem*)item)->it;
|
||||
part = new Part(rootScore);
|
||||
part->initFromInstrTemplate(t);
|
||||
rootScore->cmdInsertPart(part, staffIdx);
|
||||
|
||||
pli->part = part;
|
||||
QTreeWidgetItem* ci = 0;
|
||||
rstaff = 0;
|
||||
QList<Staff*> linked;
|
||||
QList<Staff*> nonLinked;
|
||||
for (int cidx = 0; (ci = pli->child(cidx)); ++cidx) {
|
||||
StaffListItem* sli = static_cast<StaffListItem*>(ci);
|
||||
Staff* staff = new Staff(rootScore, part);
|
||||
Staff* staff = new Staff(rootScore);
|
||||
staff->setPart(part);
|
||||
sli->setStaff(staff);
|
||||
|
||||
staff->init(t, sli->staffType(), cidx);
|
||||
staff->setDefaultClefType(sli->defaultClefType());
|
||||
rootScore->undoInsertStaff(staff, staffIdx + rstaff);
|
||||
|
||||
rootScore->undoInsertStaff(staff, cidx);
|
||||
++staffIdx;
|
||||
|
||||
Staff* linkedStaff = part->staves()->front();
|
||||
if (sli->linked() && linkedStaff != staff) {
|
||||
cloneStaff(linkedStaff, staff);
|
||||
linked.append(staff);
|
||||
}
|
||||
else {
|
||||
nonLinked.append(staff);
|
||||
}
|
||||
++rstaff;
|
||||
}
|
||||
if (linked.size() == 0)
|
||||
part->staves()->front()->setBarLineSpan(part->nstaves());
|
||||
|
||||
rootScore->cmdInsertPart(part, staffIdx);
|
||||
|
||||
//insert keysigs
|
||||
int sidx = rootScore->staffIdx(part);
|
||||
int eidx = sidx + part->nstaves();
|
||||
if (firstStaff)
|
||||
rootScore->adjustKeySigs(sidx, eidx, tmpKeymap);
|
||||
staffIdx += rstaff;
|
||||
}
|
||||
else {
|
||||
part = pli->part;
|
||||
|
@ -304,29 +300,16 @@ void MuseScore::editInstrList()
|
|||
rootScore->systems()->clear();
|
||||
Staff* staff = sli->staff();
|
||||
int sidx = staff->idx();
|
||||
int eidx = sidx + 1;
|
||||
for (Measure* m = rootScore->firstMeasure(); m; m = m->nextMeasure()) {
|
||||
m->cmdRemoveStaves(sidx, eidx);
|
||||
if (m->hasMMRest())
|
||||
m->mmRest()->cmdRemoveStaves(sidx, eidx);
|
||||
}
|
||||
rootScore->cmdRemoveStaff(sidx);
|
||||
}
|
||||
else if (sli->op() == ListItemOp::ADD) {
|
||||
Staff* staff = new Staff(rootScore, part);
|
||||
Staff* staff = new Staff(rootScore);
|
||||
staff->setPart(part);
|
||||
staff->initFromStaffType(sli->staffType());
|
||||
sli->setStaff(staff);
|
||||
|
||||
rootScore->undoInsertStaff(staff, rstaff);
|
||||
|
||||
for (Measure* m = rootScore->firstMeasure(); m; m = m->nextMeasure()) {
|
||||
// do not create whole measure rests for linked staves
|
||||
m->cmdAddStaves(staffIdx, staffIdx+1, !sli->linked());
|
||||
if (m->hasMMRest())
|
||||
m->mmRest()->cmdAddStaves(staffIdx, staffIdx+1, !sli->linked());
|
||||
}
|
||||
|
||||
rootScore->adjustBracketsIns(staffIdx, staffIdx+1);
|
||||
staff->initFromStaffType(sli->staffType());
|
||||
Key nKey = part->staff(0)->key(0);
|
||||
staff->setKey(0, nKey);
|
||||
|
||||
|
@ -395,15 +378,21 @@ void MuseScore::editInstrList()
|
|||
}
|
||||
|
||||
QList<int> dl;
|
||||
int idx2 = 0;
|
||||
bool sort = false;
|
||||
for(Staff* staff : dst) {
|
||||
int idx = rootScore->staves().indexOf(staff);
|
||||
if (idx == -1)
|
||||
qDebug("staff in dialog(%p) not found in score", staff);
|
||||
else
|
||||
dl.push_back(idx);
|
||||
if (idx != idx2)
|
||||
sort = true;
|
||||
++idx2;
|
||||
}
|
||||
|
||||
rootScore->undo(new SortStaves(rootScore, dl));
|
||||
if (sort)
|
||||
rootScore->undo(new SortStaves(rootScore, dl));
|
||||
|
||||
//
|
||||
// check for valid barLineSpan and bracketSpan
|
||||
|
|
|
@ -923,7 +923,8 @@ void InstrumentsWidget::createInstruments(Score* cs)
|
|||
if (ci->isHidden())
|
||||
continue;
|
||||
StaffListItem* sli = (StaffListItem*)ci;
|
||||
Staff* staff = new Staff(cs, part);
|
||||
Staff* staff = new Staff(cs);
|
||||
staff->setPart(part);
|
||||
sli->setStaff(staff);
|
||||
++rstaff;
|
||||
|
||||
|
@ -952,23 +953,6 @@ void InstrumentsWidget::createInstruments(Score* cs)
|
|||
staffIdx += rstaff;
|
||||
}
|
||||
//
|
||||
// sort staves
|
||||
//
|
||||
QList<Staff*> dst;
|
||||
for (int idx = 0; (item = pl->topLevelItem(idx)); ++idx) {
|
||||
PartListItem* pli = (PartListItem*)item;
|
||||
if (pli->op == ListItemOp::I_DELETE)
|
||||
continue;
|
||||
QTreeWidgetItem* ci = 0;
|
||||
for (int cidx = 0; (ci = item->child(cidx)); ++cidx) {
|
||||
StaffListItem* sli = (StaffListItem*) ci;
|
||||
if (sli->op() == ListItemOp::I_DELETE)
|
||||
continue;
|
||||
dst.push_back(sli->staff());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// check for bar lines
|
||||
//
|
||||
for (int staffIdx = 0; staffIdx < cs->nstaves();) {
|
||||
|
@ -1015,5 +999,4 @@ QTreeWidget* InstrumentsWidget::getPartiturList()
|
|||
{
|
||||
return partiturList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -682,7 +682,8 @@ bool MuseData::read(const QString& name)
|
|||
Part* mpart = new Part(score);
|
||||
int staves = countStaves(part);
|
||||
for (int i = 0; i < staves; ++i) {
|
||||
Staff* staff = new Staff(score, mpart);
|
||||
Staff* staff = new Staff(score);
|
||||
staff->setPart(mpart);
|
||||
mpart->insertStaff(staff, i);
|
||||
score->staves().push_back(staff);
|
||||
if ((staves == 2) && (i == 0)) {
|
||||
|
|
Loading…
Reference in a new issue