Skip to content

Commit

Permalink
fix #124912: Mass insert single measure repeats
Browse files Browse the repository at this point in the history
  • Loading branch information
lasconic committed Sep 26, 2013
1 parent fb9de0a commit 3226ca6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 32 deletions.
70 changes: 38 additions & 32 deletions libmscore/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1488,39 +1488,8 @@ qDebug("drop staffList");
case REPEAT_MEASURE:
{
delete e;
//
// see also cmdDeleteSelection()
//
_score->select(0, SELECT_SINGLE, 0);
for (Segment* s = first(); s; s = s->next()) {
if (s->segmentType() & Segment::SegChordRest) {
int strack = staffIdx * VOICES;
int etrack = strack + VOICES;
for (int track = strack; track < etrack; ++track) {
Element* el = s->element(track);
if (el)
_score->undoRemoveElement(el);
}
if (s->isEmpty())
_score->undoRemoveElement(s);
}
}
//
// add repeat measure
//

Segment* seg = undoGetSegment(Segment::SegChordRest, tick());
RepeatMeasure* rm = new RepeatMeasure(_score);
rm->setTrack(staffIdx * VOICES);
rm->setParent(seg);
_score->undoAddElement(rm);
foreach(Element* el, _el) {
if (el->type() == SLUR && el->staffIdx() == staffIdx)
_score->undoRemoveElement(el);
}
return rm;
return cmdInsertRepeatMeasure(staffIdx);
}

case ICON:
switch(static_cast<Icon*>(e)->iconType()) {
case ICON_VFRAME:
Expand Down Expand Up @@ -1559,6 +1528,43 @@ void Measure::cmdRemoveEmptySegment(Segment* s)
_score->undoRemoveElement(s);
}

//---------------------------------------------------------
// cmdInsertRepeatMeasure
//---------------------------------------------------------
RepeatMeasure* Measure::cmdInsertRepeatMeasure(int staffIdx)
{
//
// see also cmdDeleteSelection()
//
_score->select(0, SELECT_SINGLE, 0);
for (Segment* s = first(); s; s = s->next()) {
if (s->segmentType() & Segment::SegChordRest) {
int strack = staffIdx * VOICES;
int etrack = strack + VOICES;
for (int track = strack; track < etrack; ++track) {
Element* el = s->element(track);
if (el)
_score->undoRemoveElement(el);
}
if (s->isEmpty())
_score->undoRemoveElement(s);
}
}
//
// add repeat measure
//
Segment* seg = undoGetSegment(Segment::SegChordRest, tick());
RepeatMeasure* rm = new RepeatMeasure(_score);
rm->setTrack(staffIdx * VOICES);
rm->setParent(seg);
_score->undoAddElement(rm);
foreach(Element* el, _el) {
if (el->type() == SLUR && el->staffIdx() == staffIdx)
_score->undoRemoveElement(el);
}
return rm;
}

//---------------------------------------------------------
// adjustToLen
// change actual measure len, adjust elements to
Expand Down
3 changes: 3 additions & 0 deletions libmscore/measure.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class TieMap;
class AccidentalState;
class Spanner;
class Part;
class RepeatMeasure;

//---------------------------------------------------------
// MStaff
Expand Down Expand Up @@ -248,6 +249,8 @@ class Measure : public MeasureBase {
QColor endBarLineColor() const { return _endBarLineColor; }

void cmdRemoveEmptySegment(Segment* s);
RepeatMeasure* cmdInsertRepeatMeasure(int staffIdx);

virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true) override;
void createVoice(int track);
void adjustToLen(Fraction);
Expand Down
8 changes: 8 additions & 0 deletions libmscore/rest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ bool Rest::acceptDrop(MuseScoreView*, const QPointF&, Element* e) const
) {
return true;
}
if(type == REPEAT_MEASURE && durationType().type() == TDuration::V_MEASURE)
return true;
return false;
}

Expand Down Expand Up @@ -255,6 +257,12 @@ Element* Rest::drop(const DropData& data)
delete e;
}
break;
case REPEAT_MEASURE:
delete e;
if (durationType().type() == TDuration::V_MEASURE) {
measure()->cmdInsertRepeatMeasure(staffIdx());
}
break;
default:
return ChordRest::drop(data);
}
Expand Down

0 comments on commit 3226ca6

Please sign in to comment.