- int start = cropStart().frames(m_fps);
- int end = (cropStart() + cropDuration()).frames(m_fps) - 1;
- if (editedKeyFramePos() > start && newpos <= start) newpos = start + 1;
- if (editedKeyFramePos() < end && newpos >= end) newpos = end - 1;
- newpos = qMax(newpos, start);
- newpos = qMin(newpos, end);
+ int min = (int) cropStart().frames(m_fps) - 1;
+ int max = (int)(cropStart() + cropDuration()).frames(m_fps);
+ QMap<int, int>::const_iterator i = m_keyframes.constBegin();
+ while (i.key() < m_editedKeyframe) {
+ min = qMax(i.key(), min);
+ ++i;
+ }
+ i = m_keyframes.constEnd() - 1;
+ while (i.key() > m_editedKeyframe) {
+ max = qMin(i.key(), max);
+ --i;
+ }
+ if (newpos <= min)
+ newpos = min + 1;
+ if (newpos >= max)
+ newpos = max - 1;