Mercurial > hg > svgui
diff layer/NoteLayer.cpp @ 373:0895517bb2d1 1.2-stable
* merge from trunk (1.2 ended up being tracked from trunk, but we may want
this branch for fixes later)
author | Chris Cannam |
---|---|
date | Wed, 27 Feb 2008 10:32:45 +0000 |
parents | 2f83b6e3b8ca |
children |
line wrap: on
line diff
--- a/layer/NoteLayer.cpp Thu Nov 29 10:43:54 2007 +0000 +++ b/layer/NoteLayer.cpp Wed Feb 27 10:32:45 2008 +0000 @@ -33,6 +33,7 @@ #include <QPainterPath> #include <QMouseEvent> #include <QTextStream> +#include <QMessageBox> #include <iostream> #include <cmath> @@ -916,7 +917,7 @@ } void -NoteLayer::copy(Selection s, Clipboard &to) +NoteLayer::copy(View *v, Selection s, Clipboard &to) { if (!m_model) return; @@ -927,19 +928,38 @@ i != points.end(); ++i) { if (s.contains(i->frame)) { Clipboard::Point point(i->frame, i->value, i->duration, i->level, i->label); - point.setReferenceFrame(m_model->alignToReference(i->frame)); + point.setReferenceFrame(alignToReference(v, i->frame)); to.addPoint(point); } } } bool -NoteLayer::paste(const Clipboard &from, int frameOffset, bool /* interactive */) +NoteLayer::paste(View *v, const Clipboard &from, int frameOffset, bool /* interactive */) { if (!m_model) return false; const Clipboard::PointList &points = from.getPoints(); + bool realign = false; + + if (clipboardHasDifferentAlignment(v, from)) { + + QMessageBox::StandardButton button = + QMessageBox::question(v, tr("Re-align pasted items?"), + tr("The items you are pasting came from a layer with different source material from this one. Do you want to re-align them in time, to match the source material for this layer?"), + QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, + QMessageBox::Yes); + + if (button == QMessageBox::Cancel) { + return false; + } + + if (button == QMessageBox::Yes) { + realign = true; + } + } + NoteModel::EditCommand *command = new NoteModel::EditCommand(m_model, tr("Paste")); @@ -948,9 +968,21 @@ if (!i->haveFrame()) continue; size_t frame = 0; - if (frameOffset > 0 || -frameOffset < i->getFrame()) { - frame = i->getFrame() + frameOffset; + + if (!realign) { + + frame = i->getFrame(); + + } else { + + if (i->haveReferenceFrame()) { + frame = i->getReferenceFrame(); + frame = alignFromReference(v, frame); + } else { + frame = i->getFrame(); + } } + NoteModel::Point newPoint(frame); if (i->haveLabel()) newPoint.label = i->getLabel();