Mercurial > hg > svgui
comparison 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 |
comparison
equal
deleted
inserted
replaced
337:813170c57b13 | 373:0895517bb2d1 |
---|---|
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() : |
914 | 915 |
915 command->finish(); | 916 command->finish(); |
916 } | 917 } |
917 | 918 |
918 void | 919 void |
919 NoteLayer::copy(Selection s, Clipboard &to) | 920 NoteLayer::copy(View *v, Selection s, Clipboard &to) |
920 { | 921 { |
921 if (!m_model) return; | 922 if (!m_model) return; |
922 | 923 |
923 NoteModel::PointList points = | 924 NoteModel::PointList points = |
924 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | 925 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); |
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 |
936 bool | 937 bool |
937 NoteLayer::paste(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() + |