Skip to content

Commit

Permalink
fix #13555: Copied tremolo between notes incorrectly pasted
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Jan 29, 2015
1 parent 3f5d291 commit 86e51ad
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 31 deletions.
60 changes: 41 additions & 19 deletions libmscore/select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ bool SelectionFilter::canSelect(const Element* e) const
return isFiltered(SelectionFilterType::OTHER_TEXT);
if (e->isSLine()) // NoteLine, Volta
return isFiltered(SelectionFilterType::OTHER_LINE);
if (e->type() == Element::Type::TREMOLO && static_cast<const Tremolo*>(e)->twoNotes() == false)
if (e->type() == Element::Type::TREMOLO && !static_cast<const Tremolo*>(e)->twoNotes())
return isFiltered(SelectionFilterType::TREMOLO);
if (e->type() == Element::Type::CHORD && static_cast<const Chord*>(e)->isGrace())
return isFiltered(SelectionFilterType::GRACE_NOTE);
Expand Down Expand Up @@ -969,24 +969,34 @@ QList<Note*> Selection::noteList(int selTrack) const

//---------------------------------------------------------
// checkStart
// return false if element is NOT a tuplet or is start of a tuplet
// return true if element is part of a tuplet, but not the start
// return false if element is NOT a tuplet or is start of a tuplet/tremolo
// return true if element is part of a tuplet/tremolo, but not the start
//---------------------------------------------------------

static bool checkStart(Element* e)
{
if (e == 0 || !e->isChordRest())
return false;
ChordRest* cr = static_cast<ChordRest*>(e);
if (!cr->tuplet())
return false;
Tuplet* tuplet = cr->tuplet();
while (tuplet) {
if (tuplet->elements().front() == e)
return false;
tuplet = tuplet->tuplet();
bool rv;
if (cr->tuplet()) {
rv = true;
Tuplet* tuplet = cr->tuplet();
while (tuplet) {
if (tuplet->elements().front() == e) {
rv = false;
break;
}
tuplet = tuplet->tuplet();
}
}
return true;
else if (e->type() == Element::Type::CHORD) {
rv = false;
Chord* chord = static_cast<Chord*>(e);
if (chord->tremolo() && chord->tremolo()->twoNotes())
rv = chord->tremolo()->chord2() == chord;
}
return rv;
}

//---------------------------------------------------------
Expand All @@ -1000,20 +1010,31 @@ static bool checkEnd(Element* e)
if (e == 0 || !e->isChordRest())
return false;
ChordRest* cr = static_cast<ChordRest*>(e);
if (!cr->tuplet())
return false;
Tuplet* tuplet = cr->tuplet();
while (tuplet) {
if (tuplet->elements().back() == e)
return false;
tuplet = tuplet->tuplet();
bool rv;
if (cr->tuplet()) {
rv = true;
Tuplet* tuplet = cr->tuplet();
while (tuplet) {
if (tuplet->elements().back() == e) {
rv = false;
break;
}
tuplet = tuplet->tuplet();
}
}
return true;
else if (e->type() == Element::Type::CHORD) {
rv = false;
Chord* chord = static_cast<Chord*>(e);
if (chord->tremolo() && chord->tremolo()->twoNotes())
rv = chord->tremolo()->chord1() == chord;
}
return rv;
}

//---------------------------------------------------------
// canCopy
// return false if range selection intersects a tuplet
// or a tremolo
//---------------------------------------------------------

bool Selection::canCopy() const
Expand All @@ -1032,6 +1053,7 @@ bool Selection::canCopy() const

// find last segment in the selection.
// Note that _endSegment is the first segment after the selection

Segment *endSegmentSelection = _startSegment;
while (endSegmentSelection->nextCR(track) &&
(endSegmentSelection->nextCR(track)->tick() < _endSegment->tick()))
Expand Down
29 changes: 17 additions & 12 deletions mscore/scoreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2421,18 +2421,28 @@ void ScoreView::editCut()
}

//---------------------------------------------------------
// normalCopy
// checkCopyOrCut
//---------------------------------------------------------

void ScoreView::normalCopy()
bool ScoreView::checkCopyOrCut()
{
if (!_score->selection().canCopy()) {
qDebug("cannot copy selection: intersects a tuplet");
QMessageBox::information(0, "MuseScore",
tr("Please select the complete tuplet and retry the copy operation"),
QMessageBox::Ok, QMessageBox::NoButton);
return;
tr("Please select the complete tuplet/tremolo and retry the command"),
QMessageBox::Ok, QMessageBox::NoButton);
return false;
}
return true;
}

//---------------------------------------------------------
// normalCopy
//---------------------------------------------------------

void ScoreView::normalCopy()
{
if (!checkCopyOrCut())
return;
QString mimeType = _score->selection().mimeType();
if (!mimeType.isEmpty()) {
QMimeData* mimeData = new QMimeData;
Expand All @@ -2449,13 +2459,8 @@ void ScoreView::normalCopy()

void ScoreView::normalCut()
{
if (!_score->selection().canCopy()) {
qDebug("cannot copy selection: intersects a tuplet");
QMessageBox::information(0, "MuseScore",
tr("Please select the complete tuplet and retry the cut operation"),
QMessageBox::Ok, QMessageBox::NoButton);
if (!checkCopyOrCut())
return;
}
_score->startCmd();
normalCopy();
_score->cmdDeleteSelection();
Expand Down
1 change: 1 addition & 0 deletions mscore/scoreview.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ class ScoreView : public QWidget, public MuseScoreView {
void setLoopCursor(PositionCursor* curLoop, int tick, bool isInPos);
void cmdMoveCR(bool left);
void cmdGotoElement(Element*);
bool checkCopyOrCut();

private slots:
void enterState();
Expand Down

0 comments on commit 86e51ad

Please sign in to comment.