summaryrefslogtreecommitdiff
path: root/muse2/muse/midiedit/dcanvas.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'muse2/muse/midiedit/dcanvas.cpp')
-rw-r--r--muse2/muse/midiedit/dcanvas.cpp37
1 files changed, 24 insertions, 13 deletions
diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp
index 03d38fbf..0d2f7640 100644
--- a/muse2/muse/midiedit/dcanvas.cpp
+++ b/muse2/muse/midiedit/dcanvas.cpp
@@ -380,20 +380,31 @@ CItem* DrumCanvas::newItem(int tick, int instrument, int velocity)
{
if (!old_style_drummap_mode && !instrument_map[instrument].tracks.contains(curPart->track()))
{
- printf("FINDMICH: tried to create a new Item which cannot be inside the current track. returning NULL\n");
- return NULL;
- }
- else
- {
- tick -= curPart->tick();
- MusECore::Event e(MusECore::Note);
- e.setTick(tick);
- e.setPitch(instrument_map[instrument].pitch);
- e.setVelo(velocity);
- e.setLenTick(ourDrumMap[instrument].len);
-
- return new DEvent(e, curPart, instrument);
+ if (debugMsg)
+ printf("tried to create a new Item which cannot be inside the current track. looking for destination part...\n");
+
+ QSet<MusECore::Part*> parts = parts_at_tick(tick, instrument_map[instrument].tracks);
+
+ if (parts.count() != 1)
+ {
+ QMessageBox::warning(this, tr("Creating event failed"), tr("Couldn't create the event, because the currently selected part isn't the same track, and the selected instrument could be either on no or on multiple parts, which is ambiguous.\nSelect the destination part, then try again."));
+ return NULL;
+ }
+ else
+ {
+ setCurrentPart(*parts.begin());
+ }
}
+ // else or if we found an alternative part (which has now been set as curPart)
+
+ tick -= curPart->tick();
+ MusECore::Event e(MusECore::Note);
+ e.setTick(tick);
+ e.setPitch(instrument_map[instrument].pitch);
+ e.setVelo(velocity);
+ e.setLenTick(ourDrumMap[instrument].len);
+
+ return new DEvent(e, curPart, instrument);
}
//---------------------------------------------------------