+void CustomTrackView::adjustKeyfames(GenTime oldstart, GenTime newstart, GenTime duration, QDomElement xml)
+{
+ // parse parameters to check if we need to adjust to the new crop start
+ int diff = (newstart - oldstart).frames(m_document->fps());
+ int max = (newstart + duration).frames(m_document->fps());
+ QDomNodeList params = xml.elementsByTagName("parameter");
+ for (int i = 0; i < params.count(); i++) {
+ QDomElement e = params.item(i).toElement();
+ if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
+ QString def = e.attribute("default");
+ // Effect has a keyframe type parameter, we need to adjust the values
+ QStringList keys = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
+ QStringList newKeyFrames;
+ foreach(const QString &str, keys) {
+ int pos = str.section(':', 0, 0).toInt();
+ double val = str.section(':', 1, 1).toDouble();
+ pos += diff;
+ if (pos > max) {
+ newKeyFrames.append(QString::number(max) + ':' + QString::number(val));
+ break;
+ } else newKeyFrames.append(QString::number(pos) + ':' + QString::number(val));
+ }
+ //kDebug()<<"ORIGIN: "<<keys<<", FIXED: "<<newKeyFrames;
+ e.setAttribute("keyframes", newKeyFrames.join(";"));
+ }
+ }
+}
+