|
25 | 25 | Handling of several GUI commands. |
26 | 26 | */ |
27 | 27 |
|
| 28 | +#include <QMimeData.h> |
28 | 29 | #include <assert.h> |
29 | 30 |
|
30 | 31 | #include "translation.h" |
|
39 | 40 | #include "barline.h" |
40 | 41 | #include "box.h" |
41 | 42 | #include "chord.h" |
| 43 | +#include "chordrest.h" |
42 | 44 | #include "clef.h" |
43 | 45 | #include "drumset.h" |
44 | 46 | #include "dynamic.h" |
@@ -3252,6 +3254,41 @@ void Score::cmdMirrorNoteHead() |
3252 | 3254 |
|
3253 | 3255 | void Score::cmdIncDecDuration(int nSteps, bool stepDotted) |
3254 | 3256 | { |
| 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 | + } |
3255 | 3292 | EngravingItem* el = selection().element(); |
3256 | 3293 | if (el == 0) { |
3257 | 3294 | return; |
|
0 commit comments