diff options
author | Florian Jung <flo@windfisch.org> | 2011-08-31 17:04:21 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-08-31 17:04:21 +0000 |
commit | de47ea9a35af067cd3602f375174beb9a616c062 (patch) | |
tree | 03a077e3aa6abb54c0280df69518d118cf0e65e0 /muse2/muse | |
parent | a7fba3acdfaa382effcc02633708d7cf5a7ec2a4 (diff) |
added "copy in range" function
when pasting, the previously selected parts are now unselected
removed the structure operations "copy range" and "cut event", which were
unimplemented
Diffstat (limited to 'muse2/muse')
-rw-r--r-- | muse2/muse/CMakeLists.txt | 1 | ||||
-rw-r--r-- | muse2/muse/arranger/arranger.cpp | 3 | ||||
-rw-r--r-- | muse2/muse/arranger/arranger.h | 2 | ||||
-rw-r--r-- | muse2/muse/arranger/arrangerview.cpp | 21 | ||||
-rw-r--r-- | muse2/muse/arranger/arrangerview.h | 8 | ||||
-rw-r--r-- | muse2/muse/arranger/pcanvas.cpp | 66 | ||||
-rw-r--r-- | muse2/muse/arranger/pcanvas.h | 3 | ||||
-rw-r--r-- | muse2/muse/midiedit/scoreedit.cpp | 1 | ||||
-rw-r--r-- | muse2/muse/shortcuts.cpp | 2 | ||||
-rw-r--r-- | muse2/muse/shortcuts.h | 2 | ||||
-rw-r--r-- | muse2/muse/structure.cpp | 25 | ||||
-rw-r--r-- | muse2/muse/structure.h | 3 |
12 files changed, 85 insertions, 52 deletions
diff --git a/muse2/muse/CMakeLists.txt b/muse2/muse/CMakeLists.txt index ec370781..cea95083 100644 --- a/muse2/muse/CMakeLists.txt +++ b/muse2/muse/CMakeLists.txt @@ -60,7 +60,6 @@ QT4_WRAP_CPP ( muse_moc_headers midieditor.h miditransform.h plugin.h - structure.h song.h transport.h value.h diff --git a/muse2/muse/arranger/arranger.cpp b/muse2/muse/arranger/arranger.cpp index 502aa1b1..eaa05944 100644 --- a/muse2/muse/arranger/arranger.cpp +++ b/muse2/muse/arranger/arranger.cpp @@ -747,6 +747,9 @@ void Arranger::cmd(int cmd) case CMD_COPY_PART: ncmd = PartCanvas::CMD_COPY_PART; break; + case CMD_COPY_PART_IN_RANGE: + ncmd = PartCanvas::CMD_COPY_PART_IN_RANGE; + break; case CMD_PASTE_PART: ncmd = PartCanvas::CMD_PASTE_PART; break; diff --git a/muse2/muse/arranger/arranger.h b/muse2/muse/arranger/arranger.h index 433cf28f..4e91272e 100644 --- a/muse2/muse/arranger/arranger.h +++ b/muse2/muse/arranger/arranger.h @@ -150,7 +150,7 @@ class Arranger : public QWidget { void controllerChanged(Track *t); public: - enum { CMD_CUT_PART, CMD_COPY_PART, CMD_PASTE_PART, CMD_PASTE_CLONE_PART, CMD_PASTE_PART_TO_TRACK, CMD_PASTE_CLONE_PART_TO_TRACK, + enum { CMD_CUT_PART, CMD_COPY_PART, CMD_COPY_PART_IN_RANGE, CMD_PASTE_PART, CMD_PASTE_CLONE_PART, CMD_PASTE_PART_TO_TRACK, CMD_PASTE_CLONE_PART_TO_TRACK, CMD_INSERT_PART, CMD_INSERT_EMPTYMEAS }; Arranger(ArrangerView* parent, const char* name = 0); diff --git a/muse2/muse/arranger/arrangerview.cpp b/muse2/muse/arranger/arrangerview.cpp index d776198e..db1fdf2d 100644 --- a/muse2/muse/arranger/arrangerview.cpp +++ b/muse2/muse/arranger/arrangerview.cpp @@ -372,6 +372,7 @@ ArrangerView::ArrangerView(QWidget* parent) //-------- Edit Actions editCutAction = new QAction(QIcon(*editcutIconSet), tr("C&ut"), this); editCopyAction = new QAction(QIcon(*editcopyIconSet), tr("&Copy"), this); + editCopyRangeAction = new QAction(QIcon(*editcopyIconSet), tr("&Copy in range"), this); editPasteAction = new QAction(QIcon(*editpasteIconSet), tr("&Paste"), this); editInsertAction = new QAction(QIcon(*editpasteIconSet), tr("&Insert"), this); editInsertEMAction = new QAction(QIcon(*editpasteIconSet), tr("&Insert Empty Measure"), this); @@ -426,10 +427,6 @@ ArrangerView::ArrangerView(QWidget* parent) strGlobalCutAction = new QAction(tr("Global Cut"), this); strGlobalInsertAction = new QAction(tr("Global Insert"), this); strGlobalSplitAction = new QAction(tr("Global Split"), this); - strCopyRangeAction = new QAction(tr("Copy Range"), this); - strCopyRangeAction->setEnabled(false); - strCutEventsAction = new QAction(tr("Cut Events"), this); - strCutEventsAction->setEnabled(false); @@ -443,6 +440,7 @@ ArrangerView::ArrangerView(QWidget* parent) menuEdit->addAction(editCutAction); menuEdit->addAction(editCopyAction); + menuEdit->addAction(editCopyRangeAction); menuEdit->addAction(editPasteAction); menuEdit->addAction(editInsertAction); menuEdit->addAction(editInsertEMAction); @@ -484,9 +482,6 @@ ArrangerView::ArrangerView(QWidget* parent) menuStructure->addAction(strGlobalCutAction); menuStructure->addAction(strGlobalInsertAction); menuStructure->addAction(strGlobalSplitAction); - menuStructure->addAction(strCopyRangeAction); - menuStructure->addSeparator(); - menuStructure->addAction(strCutEventsAction); @@ -523,6 +518,7 @@ ArrangerView::ArrangerView(QWidget* parent) //-------- Edit connections connect(editCutAction, SIGNAL(triggered()), editSignalMapper, SLOT(map())); connect(editCopyAction, SIGNAL(triggered()), editSignalMapper, SLOT(map())); + connect(editCopyRangeAction, SIGNAL(triggered()), editSignalMapper, SLOT(map())); connect(editPasteAction, SIGNAL(triggered()), editSignalMapper, SLOT(map())); connect(editInsertAction, SIGNAL(triggered()), editSignalMapper, SLOT(map())); connect(editInsertEMAction, SIGNAL(triggered()), editSignalMapper, SLOT(map())); @@ -544,6 +540,7 @@ ArrangerView::ArrangerView(QWidget* parent) editSignalMapper->setMapping(editCutAction, CMD_CUT); editSignalMapper->setMapping(editCopyAction, CMD_COPY); + editSignalMapper->setMapping(editCopyRangeAction, CMD_COPY_RANGE); editSignalMapper->setMapping(editPasteAction, CMD_PASTE); editSignalMapper->setMapping(editInsertAction, CMD_INSERT); editSignalMapper->setMapping(editPasteCloneAction, CMD_PASTE_CLONE); @@ -582,8 +579,6 @@ ArrangerView::ArrangerView(QWidget* parent) connect(strGlobalCutAction, SIGNAL(activated()), SLOT(globalCut())); connect(strGlobalInsertAction, SIGNAL(activated()), SLOT(globalInsert())); connect(strGlobalSplitAction, SIGNAL(activated()), SLOT(globalSplit())); - connect(strCopyRangeAction, SIGNAL(activated()), SLOT(copyRange())); - connect(strCutEventsAction, SIGNAL(activated()), SLOT(cutEvents())); @@ -711,6 +706,9 @@ void ArrangerView::cmd(int cmd) case CMD_COPY: arranger->cmd(Arranger::CMD_COPY_PART); break; + case CMD_COPY_RANGE: + arranger->cmd(Arranger::CMD_COPY_PART_IN_RANGE); + break; case CMD_PASTE: arranger->cmd(Arranger::CMD_PASTE_PART); break; @@ -886,6 +884,7 @@ void ArrangerView::updateShortcuts() { editCutAction->setShortcut(shortcuts[SHRT_CUT].key); editCopyAction->setShortcut(shortcuts[SHRT_COPY].key); + editCopyRangeAction->setShortcut(shortcuts[SHRT_COPY_RANGE].key); editPasteAction->setShortcut(shortcuts[SHRT_PASTE].key); editInsertAction->setShortcut(shortcuts[SHRT_INSERT].key); editInsertEMAction->setShortcut(shortcuts[SHRT_INSERTMEAS].key); @@ -922,8 +921,6 @@ void ArrangerView::updateShortcuts() strGlobalCutAction->setShortcut(shortcuts[SHRT_GLOBAL_CUT].key); strGlobalInsertAction->setShortcut(shortcuts[SHRT_GLOBAL_INSERT].key); strGlobalSplitAction->setShortcut(shortcuts[SHRT_GLOBAL_SPLIT].key); - strCopyRangeAction->setShortcut(shortcuts[SHRT_COPY_RANGE].key); - strCutEventsAction->setShortcut(shortcuts[SHRT_CUT_EVENTS].key); } //--------------------------------------------------------- @@ -966,5 +963,3 @@ void ArrangerView::updateVisibleTracksButtons() void ArrangerView::globalCut() { globalCut(); } void ArrangerView::globalInsert() { globalInsert(); } void ArrangerView::globalSplit() { globalSplit(); } -void ArrangerView::copyRange() { copyRange(); } -void ArrangerView::cutEvents() { cutEvents(); } diff --git a/muse2/muse/arranger/arrangerview.h b/muse2/muse/arranger/arrangerview.h index 52e3273d..580173f9 100644 --- a/muse2/muse/arranger/arrangerview.h +++ b/muse2/muse/arranger/arrangerview.h @@ -48,7 +48,7 @@ class ArrangerView : public TopWin private: enum cmd_enum - {CMD_CUT, CMD_COPY, CMD_PASTE, CMD_INSERT, CMD_INSERTMEAS, CMD_PASTE_CLONE, + {CMD_CUT, CMD_COPY, CMD_COPY_RANGE, CMD_PASTE, CMD_INSERT, CMD_INSERTMEAS, CMD_PASTE_CLONE, CMD_PASTE_TO_TRACK, CMD_PASTE_CLONE_TO_TRACK, CMD_DELETE, CMD_SELECT_ALL, CMD_SELECT_NONE, CMD_SELECT_INVERT, CMD_SELECT_ILOOP, CMD_SELECT_OLOOP, CMD_SELECT_PARTS, @@ -71,10 +71,10 @@ class ArrangerView : public TopWin QMenu* addTrack; QMenu* master; - QAction *strGlobalCutAction, *strGlobalInsertAction, *strGlobalSplitAction, *strCopyRangeAction, *strCutEventsAction; + QAction *strGlobalCutAction, *strGlobalInsertAction, *strGlobalSplitAction; QAction *trackMidiAction, *trackDrumAction, *trackWaveAction, *trackAOutputAction, *trackAGroupAction; QAction *trackAInputAction, *trackAAuxAction; - QAction *editCutAction, *editCopyAction, *editPasteAction, *editInsertAction, *editPasteCloneAction, *editPaste2TrackAction; + QAction *editCutAction, *editCopyAction, *editCopyRangeAction, *editPasteAction, *editInsertAction, *editPasteCloneAction, *editPaste2TrackAction; QAction *editInsertEMAction, *editPasteC2TAction, *editDeleteSelectedAction, *editSelectAllAction, *editDeselectAllAction; QAction *editInvertSelectionAction, *editInsideLoopAction, *editOutsideLoopAction, *editAllPartsAction; QAction *masterGraphicAction, *masterListAction; @@ -101,8 +101,6 @@ class ArrangerView : public TopWin void globalCut(); void globalInsert(); void globalSplit(); - void copyRange(); - void cutEvents(); void cmd(int); signals: diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp index 19e53f2e..8380f446 100644 --- a/muse2/muse/arranger/pcanvas.cpp +++ b/muse2/muse/arranger/pcanvas.cpp @@ -2580,6 +2580,9 @@ void PartCanvas::cmd(int cmd) case CMD_COPY_PART: copy(&pl); break; + case CMD_COPY_PART_IN_RANGE: + copy_in_range(&pl); + break; case CMD_PASTE_PART: paste(false, false); break; @@ -2609,6 +2612,66 @@ void PartCanvas::cmd(int cmd) // cut copy paste //--------------------------------------------------------- +void PartCanvas::copy_in_range(PartList* pl_) +{ + PartList pl; + PartList result_pl; + unsigned int lpos = song->lpos(); + unsigned int rpos = song->rpos(); + + if (pl_->empty()) + { + for (iCItem i = items.begin(); i != items.end(); ++i) + { + Part* part=static_cast<NPart*>(i->second)->part(); + if ( (part->track()->isMidiTrack()) || (part->track()->type() == Track::WAVE) ) + pl.add(part); + } + } + else + { + for(ciPart p = pl_->begin(); p != pl_->end(); ++p) + if ( (p->second->track()->isMidiTrack()) || (p->second->track()->type() == Track::WAVE) ) + pl.add(p->second); + } + + if (!pl.empty() && (rpos>lpos)) + { + for(ciPart p = pl.begin(); p != pl.end(); ++p) + { + Part* part=p->second; + Track* track=part->track(); + + if ((part->tick() < rpos) && (part->endTick() > lpos)) //is the part in the range? + { + if ((lpos > part->tick()) && (lpos < part->endTick())) + { + Part* p1; + Part* p2; + + track->splitPart(part, lpos, p1, p2); + + part=p2; + } + + if ((rpos > part->tick()) && (rpos < part->endTick())) + { + Part* p1; + Part* p2; + + track->splitPart(part, rpos, p1, p2); + + part=p1; + } + + result_pl.add(part); + } + } + + copy(&result_pl); + } +} + void PartCanvas::copy(PartList* pl) { if (pl->empty()) @@ -2746,6 +2809,7 @@ Undo PartCanvas::pasteAt(const QString& pt, Track* track, unsigned int pos, bool if (p->tick()+p->lenTick()>finalPos) { finalPos=p->tick()+p->lenTick(); } + p->setSelected(true); operations.push_back(UndoOp(UndoOp::AddPart,p)); } else @@ -2866,6 +2930,7 @@ void PartCanvas::paste(bool clone, bool toTrack, bool doInsert) { int endPos=0; unsigned int startPos=song->vcpos(); + deselectAll(); Undo operations=pasteAt(txt, track, startPos, clone, toTrack, &endPos); Pos p(endPos, true); song->setPos(0, p); @@ -3002,6 +3067,7 @@ void PartCanvas::viewDropEvent(QDropEvent* event) track = tracks->index(trackNo); if (track) { + deselectAll(); Undo temp=pasteAt(text, track, x); song->applyOperationGroup(temp); } diff --git a/muse2/muse/arranger/pcanvas.h b/muse2/muse/arranger/pcanvas.h index eaa51190..188728e0 100644 --- a/muse2/muse/arranger/pcanvas.h +++ b/muse2/muse/arranger/pcanvas.h @@ -107,6 +107,7 @@ class PartCanvas : public Canvas { void splitItem(CItem* item, const QPoint&); void copy(PartList*); + void copy_in_range(PartList*); void paste(bool clone = false, bool toTrack = true, bool doInsert=false); Undo pasteAt(const QString&, Track*, unsigned int, bool clone = false, bool toTrack = true, int* finalPosPtr = NULL); //Part* readClone(Xml&, Track*, bool toTrack = true); @@ -145,7 +146,7 @@ class PartCanvas : public Canvas { void returnPressed(); public: - enum { CMD_CUT_PART, CMD_COPY_PART, CMD_PASTE_PART, CMD_PASTE_CLONE_PART, CMD_PASTE_PART_TO_TRACK, CMD_PASTE_CLONE_PART_TO_TRACK, + enum { CMD_CUT_PART, CMD_COPY_PART, CMD_COPY_PART_IN_RANGE, CMD_PASTE_PART, CMD_PASTE_CLONE_PART, CMD_PASTE_PART_TO_TRACK, CMD_PASTE_CLONE_PART_TO_TRACK, CMD_INSERT_PART, CMD_INSERT_EMPTYMEAS }; PartCanvas(int* raster, QWidget* parent, int, int); diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index da920a43..eb22342f 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -4456,7 +4456,6 @@ void staff_t::update_part_indices() * journey to the menu bar. try to find a way which does not involve duplicate code! * o implement borland-style maximize: free windows do not cover the main menu, even when maximized * - * o replace "insert empty measure" by a "global insert"-like operation * o replace "insert" and "paste" by a paste-dialog ("move other notes" or "overwrite notes" or "mix with notes") * skip dialog when there is nothing to erase, move or merge with (i.e., at the end of the song) * o remove movePartsTotheRight function diff --git a/muse2/muse/shortcuts.cpp b/muse2/muse/shortcuts.cpp index effdd03a..d677c15c 100644 --- a/muse2/muse/shortcuts.cpp +++ b/muse2/muse/shortcuts.cpp @@ -81,7 +81,7 @@ void initShortCuts() defShrt(SHRT_GLOBAL_CUT, 0, "Structure: Global cut", ARRANG_SHRT, "global_cut"); defShrt(SHRT_GLOBAL_INSERT, 0, "Structure: Global insert", ARRANG_SHRT, "global_insert"); defShrt(SHRT_GLOBAL_SPLIT, 0, "Structure: Global split", ARRANG_SHRT, "global_split"); - defShrt(SHRT_COPY_RANGE, 0, "Structure: Copy range", ARRANG_SHRT, "copy_range"); + defShrt(SHRT_COPY_RANGE, 0, "Edit: Copy in range", ARRANG_SHRT, "copy_range"); defShrt(SHRT_CUT_EVENTS, 0, "Structure: Cut events", ARRANG_SHRT, "cut_events"); //defShrt(SHRT_OPEN_MIXER, Qt::Key_F10, "View: Open mixer window", ARRANG_SHRT, "toggle_mixer"); defShrt(SHRT_OPEN_MIXER, Qt::Key_F10, "View: Open mixer #1 window", ARRANG_SHRT, "toggle_mixer"); diff --git a/muse2/muse/shortcuts.h b/muse2/muse/shortcuts.h index ee29a770..5acde313 100644 --- a/muse2/muse/shortcuts.h +++ b/muse2/muse/shortcuts.h @@ -104,7 +104,7 @@ enum { SHRT_GLOBAL_CUT, //Default: undefined SHRT_GLOBAL_INSERT, //Default: undefined SHRT_GLOBAL_SPLIT, //Default: undefined - SHRT_COPY_RANGE, //Default: undefined + SHRT_COPY_RANGE, //Default: Ctrl+Shift+C SHRT_CUT_EVENTS, //Default: undefined SHRT_OPEN_TRANSPORT, //F11 diff --git a/muse2/muse/structure.cpp b/muse2/muse/structure.cpp index 9cdf68aa..53180ddd 100644 --- a/muse2/muse/structure.cpp +++ b/muse2/muse/structure.cpp @@ -313,28 +313,3 @@ void globalSplit() song->applyOperationGroup(operations); } -//--------------------------------------------------------- -// copyRange -// - copy space between left and right locator position -// to song position pointer -// - dont process muted tracks -// - create a new part for every track containing the -// copied events -//--------------------------------------------------------- - -void copyRange() - { - QMessageBox::critical(muse, "Copy Range", "not implemented"); - } - -//--------------------------------------------------------- -// cutEvents -// - make sure that all events in a part end where the -// part ends -// - process only marked parts -//--------------------------------------------------------- - -void cutEvents() - { - QMessageBox::critical(muse, "Cut Events", "not implemented"); - } diff --git a/muse2/muse/structure.h b/muse2/muse/structure.h index 25cbb94e..955978dc 100644 --- a/muse2/muse/structure.h +++ b/muse2/muse/structure.h @@ -15,7 +15,4 @@ void adjustGlobalLists(Undo& operations, int startPos, int diff); void globalCut(); void globalInsert(); void globalSplit(); -void copyRange(); -void cutEvents(); - #endif |