Skip to content

Commit

Permalink
fix #24305
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed May 15, 2014
1 parent 65af8f7 commit 5d0a607
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 38 deletions.
1 change: 0 additions & 1 deletion libmscore/score.h
Expand Up @@ -516,7 +516,6 @@ class Score : public QObject {
void undoChangeKeySig(Staff* ostaff, int tick, KeySigEvent st);
void undoChangeClef(Staff* ostaff, Segment*, ClefType st);
void undoChangeBarLine(Measure* m, BarLineType);
void undoSwapCR(ChordRest* cr1, ChordRest* cr2);
void undoChangeProperty(Element*, P_ID, const QVariant&, PropertyStyle ps = PropertyStyle::NOSTYLE);
void undoPropertyChanged(Element*, P_ID, const QVariant& v);
UndoStack* undo() const;
Expand Down
9 changes: 0 additions & 9 deletions libmscore/undo.cpp
Expand Up @@ -3041,15 +3041,6 @@ void ChangeBoxProperties::flip()
}
}

//---------------------------------------------------------
// undoSwapCR
//---------------------------------------------------------

void Score::undoSwapCR(ChordRest* cr1, ChordRest* cr2)
{
undo(new SwapCR(cr1, cr2));
}

//---------------------------------------------------------
// flip
//---------------------------------------------------------
Expand Down
61 changes: 33 additions & 28 deletions mscore/scoreview.cpp
Expand Up @@ -2762,34 +2762,10 @@ void ScoreView::cmd(const QAction* a)
}
else if (cmd == "insert-fretframe")
cmdInsertMeasure(Element::FBOX);
else if (cmd == "move-left") {
Element* e = _score->getSelectedElement();
if (e && (e->type() == Element::NOTE || e->type() == Element::REST)) {
if (e->type() == Element::NOTE)
e = e->parent();
ChordRest* cr1 = static_cast<ChordRest*>(e);
ChordRest* cr2 = prevChordRest(cr1);
if (cr2) {
_score->startCmd();
_score->undoSwapCR(cr1, cr2);
_score->endCmd();
}
}
}
else if (cmd == "move-right") {
Element* e = _score->getSelectedElement();
if (e && (e->type() == Element::NOTE || e->type() == Element::REST)) {
if (e->type() == Element::NOTE)
e = e->parent();
ChordRest* cr1 = static_cast<ChordRest*>(e);
ChordRest* cr2 = nextChordRest(cr1);
if (cr2) {
_score->startCmd();
_score->undoSwapCR(cr1, cr2);
_score->endCmd();
}
}
}
else if (cmd == "move-left")
cmdMoveCR(true);
else if (cmd == "move-right")
cmdMoveCR(false);
else if (cmd == "reset") {
if (editMode()) {
editObject->reset();
Expand Down Expand Up @@ -5572,5 +5548,34 @@ void ScoreView::loopToggled(bool val)
_curLoopOut->setVisible(val);
update();
}

//---------------------------------------------------------
// cmdMoveCR
//---------------------------------------------------------

void ScoreView::cmdMoveCR(bool left)
{
Element* e = _score->getSelectedElement();
if (e && (e->type() == Element::NOTE || e->type() == Element::REST)) {
if (e->type() == Element::NOTE)
e = e->parent();
QList<ChordRest*> crl;
if (e->links()) {
for (Element* cr : *e->links())
crl.append(static_cast<ChordRest*>(cr));
}
else
crl.append(static_cast<ChordRest*>(e));

for (ChordRest* cr1 : crl) {
ChordRest* cr2 = left ? prevChordRest(cr1) : nextChordRest(cr1);
if (cr2) {
_score->startCmd();
_score->undo(new SwapCR(cr1, cr2));
_score->endCmd();
}
}
}
}
}

1 change: 1 addition & 0 deletions mscore/scoreview.h
Expand Up @@ -251,6 +251,7 @@ class ScoreView : public QWidget, public MuseScoreView {
bool dropCanvas(Element*);
void editCmd(const QString&);
void setLoopCursor(PositionCursor* curLoop, int tick, bool isInPos);
void cmdMoveCR(bool left);

private slots:
void enterState();
Expand Down

0 comments on commit 5d0a607

Please sign in to comment.