Skip to content

Commit a1d76de

Browse files
mattmcclinchJojo-Schmitz
authored andcommitted
Fix #317188: Allow [Q] and [W] to work on a range selection.
Port of #7519
1 parent 7e34399 commit a1d76de

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/engraving/dom/cmd.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
Handling of several GUI commands.
2626
*/
2727

28+
#include <QMimeData.h>
2829
#include <assert.h>
2930

3031
#include "translation.h"
@@ -39,6 +40,7 @@
3940
#include "barline.h"
4041
#include "box.h"
4142
#include "chord.h"
43+
#include "chordrest.h"
4244
#include "clef.h"
4345
#include "drumset.h"
4446
#include "dynamic.h"
@@ -3252,6 +3254,41 @@ void Score::cmdMirrorNoteHead()
32523254

32533255
void Score::cmdIncDecDuration(int nSteps, bool stepDotted)
32543256
{
3257+
if (selection().isRange()) {
3258+
if (!selection().canCopy()) {
3259+
return;
3260+
}
3261+
QString mimeType = selection().mimeType();
3262+
if (mimeType.isEmpty()) {
3263+
return;
3264+
}
3265+
ChordRest* firstCR = selection().firstChordRest();
3266+
if (firstCR->isGrace()) {
3267+
firstCR = toChordRest(firstCR->parent());
3268+
}
3269+
TDuration initialDuration = firstCR->ticks();
3270+
TDuration d = initialDuration.shiftRetainDots(nSteps, stepDotted);
3271+
if (!d.isValid()) {
3272+
return;
3273+
}
3274+
Fraction scale = d.ticks() / initialDuration.ticks();
3275+
for (ChordRest* cr : getSelectedChordRests()) {
3276+
Fraction newTicks = cr->ticks() * scale;
3277+
if (newTicks < Fraction(1, 1024)
3278+
|| (stepDotted && cr->durationType().dots() != firstCR->durationType().dots()
3279+
&& !cr->isGrace())) {
3280+
return;
3281+
}
3282+
}
3283+
QMimeData* mimeData = new QMimeData;
3284+
mimeData->setData(mimeType, selection().mimeData().toQByteArray());
3285+
QByteArray data(mimeData->data(mimeStaffListFormat));
3286+
XmlReader e(data);
3287+
deleteRange(selection().startSegment(), selection().endSegment(), staff2track(selection().staffStart()),
3288+
staff2track(selection().staffEnd()), selectionFilter());
3289+
pasteStaff(e, selection().startSegment(), selection().staffStart(), scale);
3290+
return;
3291+
}
32553292
EngravingItem* el = selection().element();
32563293
if (el == 0) {
32573294
return;

0 commit comments

Comments
 (0)