diff layer/NoteLayer.cpp @ 125:999ae0f7d10c

* Change preferences dialog to ok/apply/cancel model * Make preferences persist in a config file * Change instance() to getInstance() for all singleton types * Make pasting to time-value layer with no values in clipboard ask you how to generate the values * Fix bad behaviour caused by importing "data"-type (i.e. 3d dense) model from annotation file without a fixed window size available
author Chris Cannam
date Thu, 27 Jul 2006 16:06:32 +0000
parents bd6e85b3d88b
children 33929e0c3c6b
line wrap: on
line diff
--- a/layer/NoteLayer.cpp	Wed Jul 26 16:48:07 2006 +0000
+++ b/layer/NoteLayer.cpp	Thu Jul 27 16:06:32 2006 +0000
@@ -924,10 +924,10 @@
     }
 }
 
-void
-NoteLayer::paste(const Clipboard &from, int frameOffset)
+bool
+NoteLayer::paste(const Clipboard &from, int frameOffset, bool interactive)
 {
-    if (!m_model) return;
+    if (!m_model) return false;
 
     const Clipboard::PointList &points = from.getPoints();
 
@@ -949,12 +949,28 @@
         else newPoint.value = (m_model->getValueMinimum() +
                                m_model->getValueMaximum()) / 2;
         if (i->haveDuration()) newPoint.duration = i->getDuration();
-        else newPoint.duration = m_model->getResolution(); //!!!
+        else {
+            size_t nextFrame = frame;
+            Clipboard::PointList::const_iterator j = i;
+            for (; j != points.end(); ++j) {
+                if (!j->haveFrame()) continue;
+                if (j != i) break;
+            }
+            if (j != points.end()) {
+                nextFrame = j->getFrame();
+            }
+            if (nextFrame == frame) {
+                newPoint.duration = m_model->getResolution();
+            } else {
+                newPoint.duration = nextFrame - frame;
+            }
+        }
         
         command->addPoint(newPoint);
     }
 
     command->finish();
+    return true;
 }
 
 QString