本文整理汇总了C++中MasterScore::undoInsertStaff方法的典型用法代码示例。如果您正苦于以下问题:C++ MasterScore::undoInsertStaff方法的具体用法?C++ MasterScore::undoInsertStaff怎么用?C++ MasterScore::undoInsertStaff使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MasterScore
的用法示例。
在下文中一共展示了MasterScore::undoInsertStaff方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readScore
void TestSpanners::spanners04()
{
MasterScore* score = readScore(DIR + "glissando-cloning01.mscx");
QVERIFY(score);
score->doLayout();
// add a linked staff to the existing staff
// (copied and adapted from void MuseScore::editInstrList() in mscore/instrdialog.cpp)
Staff* oldStaff = score->staff(0);
Staff* newStaff = new Staff(score);
newStaff->setPart(oldStaff->part());
newStaff->initFromStaffType(oldStaff->staffType());
newStaff->setDefaultClefType(ClefTypeList(ClefType::G));
KeySigEvent ke;
ke.setKey(Key::C);
newStaff->setKey(0, ke);
score->undoInsertStaff(newStaff, 1, false);
cloneStaff(oldStaff, newStaff);
QVERIFY(saveCompareScore(score, "glissando-cloning01.mscx", DIR + "glissando-cloning01-ref.mscx"));
delete score;
}
示例2: ex
void TestLinks::test5LinkedParts_94911()
{
MCursor c;
c.setTimeSig(Fraction(4,4));
c.createScore("test");
c.addPart("electric-guitar");
c.move(0, 0); // move to track 0 tick 0
c.addKeySig(Key(1));
c.addTimeSig(Fraction(4,4));
c.addChord(60, TDuration(TDuration::DurationType::V_WHOLE));
MasterScore* score = c.score();
score->addText("title", "Title");
score->doLayout();
// delete chord
Measure* m = score->firstMeasure();
Segment* s = m->first(Segment::Type::ChordRest);
Element* e = s->element(0);
QVERIFY(e->type() == ElementType::CHORD);
score->select(e);
score->cmdDeleteSelection();
e = s->element(0);
QVERIFY(e->type() == ElementType::REST);
QVERIFY(e->links() == nullptr);
// create parts//
score->startCmd();
QList<Part*> parts;
parts.append(score->parts().at(0));
Score* nscore = new Score(score);
Excerpt ex(score);
ex.setPartScore(nscore);
ex.setTitle("Guitar");
ex.setParts(parts);
Excerpt::createExcerpt(&ex);
QVERIFY(nscore);
score->undo(new AddExcerpt(&ex));
score->endCmd();
// we should have now 1 staff and 2 linked rests
QVERIFY(score->staves().size() == 1);
e = s->element(0);
QVERIFY(e->type() == ElementType::REST);
QVERIFY(e->links()->size() == 2);
// add a linked staff
score->startCmd();
Staff* oStaff = score->staff(0);
Staff* staff = new Staff(score);
staff->setPart(oStaff->part());
score->undoInsertStaff(staff, 1);
Excerpt::cloneStaff(oStaff, staff);
score->endCmd();
// we should have now 2 staves and 3 linked rests
QCOMPARE(score->staves().size(), 2);
QCOMPARE(nscore->staves().size(), 1);
QVERIFY(score->staves()[0]->linkedStaves()->staves().size() == 3);
e = s->element(0);
QVERIFY(e->type() == ElementType::REST);
QVERIFY(e->links()->size() == 3);
e = s->element(4);
QVERIFY(e->type() == ElementType::REST);
QVERIFY(e->links()->size() == 3);
QVERIFY(score->excerpts().size() == 1);
// undo
score->undoStack()->undo();
// we should have now 1 staves and 2 linked rests
QVERIFY(score->staves().size() == 1);
QVERIFY(score->staves()[0]->linkedStaves()->staves().size() == 2);
e = s->element(0);
QVERIFY(e->type() == ElementType::REST);
QVERIFY(e->links()->size() == 2);
QVERIFY(score->excerpts().size() == 1);
// redo
score->undoStack()->redo();
// we should have now 2 staves and 3 linked rests
QVERIFY(score->staves().size() == 2);
QVERIFY(score->staves()[0]->linkedStaves()->staves().size() == 3);
e = s->element(0);
QVERIFY(e->type() == ElementType::REST);
QVERIFY(e->links()->size() == 3);
e = s->element(4);
QVERIFY(e->type() == ElementType::REST);
QVERIFY(e->links()->size() == 3);
QVERIFY(score->excerpts().size() == 1);
}
示例3: editInstrList
//.........这里部分代码省略.........
StaffListItem* sli = static_cast<StaffListItem*>(ci);
if (sli->op() != ListItemOp::I_DELETE)
++staves;
}
if (staves == 0)
pli->op = ListItemOp::I_DELETE;
}
item = 0;
for (int idx = 0; (item = pl->topLevelItem(idx)); ++idx) {
int rstaff = 0;
PartListItem* pli = static_cast<PartListItem*>(item);
if (pli->op == ListItemOp::I_DELETE)
masterScore->cmdRemovePart(pli->part);
else if (pli->op == ListItemOp::ADD) {
const InstrumentTemplate* t = ((PartListItem*)item)->it;
part = new Part(masterScore);
part->initFromInstrTemplate(t);
masterScore->undo(new InsertPart(part, staffIdx));
pli->part = part;
QList<Staff*> linked;
for (int cidx = 0; pli->child(cidx); ++cidx) {
StaffListItem* sli = static_cast<StaffListItem*>(pli->child(cidx));
Staff* staff = new Staff(masterScore);
staff->setPart(part);
sli->setStaff(staff);
staff->init(t, sli->staffType(), cidx);
staff->setDefaultClefType(sli->defaultClefType());
if (staffIdx > 0)
staff->setBarLineSpan(masterScore->staff(staffIdx - 1)->barLineSpan());
masterScore->undoInsertStaff(staff, cidx);
++staffIdx;
Staff* linkedStaff = part->staves()->front();
if (sli->linked() && linkedStaff != staff) {
Excerpt::cloneStaff(linkedStaff, staff);
linked.append(staff);
}
}
//insert keysigs
int sidx = masterScore->staffIdx(part);
int eidx = sidx + part->nstaves();
if (firstStaff)
masterScore->adjustKeySigs(sidx, eidx, tmpKeymap);
}
else {
part = pli->part;
if (part->show() != pli->visible())
part->undoChangeProperty(Pid::VISIBLE, pli->visible());
for (int cidx = 0; pli->child(cidx); ++cidx) {
StaffListItem* sli = static_cast<StaffListItem*>(pli->child(cidx));
if (sli->op() == ListItemOp::I_DELETE) {
Staff* staff = sli->staff();
int sidx = staff->idx();
masterScore->cmdRemoveStaff(sidx);
}
else if (sli->op() == ListItemOp::ADD) {
Staff* staff = new Staff(masterScore);
staff->setPart(part);
staff->initFromStaffType(sli->staffType());
sli->setStaff(staff);
staff->setDefaultClefType(sli->defaultClefType());