comparison layer/NoteLayer.cpp @ 360:d58701996fae

* Update remaining editable layers to support proper realignment on copy/paste * Permit pasting when no suitable layer is current: create a new layer on paste * Add preference for showing the splash screen or not * Rename spectrogram smoothing prefs (partly following Craig's suggestions)
author Chris Cannam
date Wed, 06 Feb 2008 14:15:09 +0000
parents 020c485aa7e0
children e1a9e478b7f2
comparison
equal deleted inserted replaced
359:020c485aa7e0 360:d58701996fae
31 31
32 #include <QPainter> 32 #include <QPainter>
33 #include <QPainterPath> 33 #include <QPainterPath>
34 #include <QMouseEvent> 34 #include <QMouseEvent>
35 #include <QTextStream> 35 #include <QTextStream>
36 #include <QMessageBox>
36 37
37 #include <iostream> 38 #include <iostream>
38 #include <cmath> 39 #include <cmath>
39 40
40 NoteLayer::NoteLayer() : 41 NoteLayer::NoteLayer() :
925 926
926 for (NoteModel::PointList::iterator i = points.begin(); 927 for (NoteModel::PointList::iterator i = points.begin();
927 i != points.end(); ++i) { 928 i != points.end(); ++i) {
928 if (s.contains(i->frame)) { 929 if (s.contains(i->frame)) {
929 Clipboard::Point point(i->frame, i->value, i->duration, i->level, i->label); 930 Clipboard::Point point(i->frame, i->value, i->duration, i->level, i->label);
930 point.setReferenceFrame(m_model->alignToReference(i->frame)); 931 point.setReferenceFrame(alignToReference(v, i->frame));
931 to.addPoint(point); 932 to.addPoint(point);
932 } 933 }
933 } 934 }
934 } 935 }
935 936
937 NoteLayer::paste(View *v, const Clipboard &from, int frameOffset, bool /* interactive */) 938 NoteLayer::paste(View *v, const Clipboard &from, int frameOffset, bool /* interactive */)
938 { 939 {
939 if (!m_model) return false; 940 if (!m_model) return false;
940 941
941 const Clipboard::PointList &points = from.getPoints(); 942 const Clipboard::PointList &points = from.getPoints();
943
944 bool realign = false;
945
946 if (clipboardHasDifferentAlignment(v, from)) {
947
948 QMessageBox::StandardButton button =
949 QMessageBox::question(v, tr("Re-align pasted items?"),
950 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?"),
951 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
952 QMessageBox::Yes);
953
954 if (button == QMessageBox::Cancel) {
955 return false;
956 }
957
958 if (button == QMessageBox::Yes) {
959 realign = true;
960 }
961 }
942 962
943 NoteModel::EditCommand *command = 963 NoteModel::EditCommand *command =
944 new NoteModel::EditCommand(m_model, tr("Paste")); 964 new NoteModel::EditCommand(m_model, tr("Paste"));
945 965
946 for (Clipboard::PointList::const_iterator i = points.begin(); 966 for (Clipboard::PointList::const_iterator i = points.begin();
947 i != points.end(); ++i) { 967 i != points.end(); ++i) {
948 968
949 if (!i->haveFrame()) continue; 969 if (!i->haveFrame()) continue;
950 size_t frame = 0; 970 size_t frame = 0;
951 if (frameOffset > 0 || -frameOffset < i->getFrame()) { 971
952 frame = i->getFrame() + frameOffset; 972 if (!realign) {
973
974 frame = i->getFrame();
975
976 } else {
977
978 if (i->haveReferenceFrame()) {
979 frame = i->getReferenceFrame();
980 frame = alignFromReference(v, frame);
981 } else {
982 frame = i->getFrame();
983 }
953 } 984 }
985
954 NoteModel::Point newPoint(frame); 986 NoteModel::Point newPoint(frame);
955 987
956 if (i->haveLabel()) newPoint.label = i->getLabel(); 988 if (i->haveLabel()) newPoint.label = i->getLabel();
957 if (i->haveValue()) newPoint.value = i->getValue(); 989 if (i->haveValue()) newPoint.value = i->getValue();
958 else newPoint.value = (m_model->getValueMinimum() + 990 else newPoint.value = (m_model->getValueMinimum() +