***************************************************************************/
-#include <QScrollBar>
-
-#include <KDebug>
-#include <KMessageBox>
-
+#include "trackview.h"
#include "definitions.h"
#include "headertrack.h"
-#include "trackview.h"
#include "clipitem.h"
#include "transition.h"
#include "kdenlivesettings.h"
#include "customtrackview.h"
#include "initeffects.h"
+#include <KDebug>
+#include <KMessageBox>
+
+#include <QScrollBar>
+
TrackView::TrackView(KdenliveDoc *doc, QWidget *parent)
: QWidget(parent), m_doc(doc), m_scale(1.0), m_projectTracks(0) {
}
void TrackView::parseDocument(QDomDocument doc) {
- int cursorPos = 0;
- m_documentErrors = QString();
+ //int cursorPos = 0;
+ m_documentErrors.clear();
// kDebug() << "//// DOCUMENT: " << doc.toString();
/*QDomNode props = doc.elementsByTagName("properties").item(0);
if (!props.isNull()) {
QDomElement p;
int pos = m_projectTracks - 1;
-
+ m_invalidProducers.clear();
+ QDomNodeList producers = doc.elementsByTagName("producer");
+ for (int i = 0; i < producers.count(); i++) {
+ // CHeck for invalid producers
+ QDomNode n = producers.item(i);
+ e = n.toElement();
+ int in = e.attribute("in").toInt();
+ int out = e.attribute("out").toInt();
+ if (in > out || in == out) {
+ // invalid producer, remove it
+ QString id = e.attribute("id");
+ m_invalidProducers.append(id);
+ m_documentErrors.append(i18n("Invalid clip producer %1\n", id));
+ doc.documentElement().removeChild(producers.at(i));
+ i--;
+ }
+ }
for (int i = 0; i < m_projectTracks; i++) {
e = tracks.item(i).toElement();
return i;
}
-const double TrackView::zoomFactor() const {
+double TrackView::zoomFactor() const {
return m_scale;
}
-const int TrackView::mapLocalToValue(int x) const {
+int TrackView::mapLocalToValue(int x) const {
return (int)(x * zoomFactor());
}
int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked) {
- int trackTop = KdenliveSettings::trackheight() * ix;
// parse track
int position = 0;
- for (QDomNode n = xml.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ QDomNodeList children = xml.childNodes();
+ for (int nodeindex = 0; nodeindex < children.count(); nodeindex++) {
+ QDomNode n = children.item(nodeindex);
QDomElement elem = n.toElement();
if (elem.tagName() == "blank") {
position += elem.attribute("length").toInt();
// Found a clip
int in = elem.attribute("in").toInt();
int out = elem.attribute("out").toInt();
- if (in > out || in == out) {
+ if (in > out || in == out || m_invalidProducers.contains(elem.attribute("producer"))) {
m_documentErrors.append(i18n("Invalid clip removed from track %1 at %2\n", ix, position));
+ xml.removeChild(children.at(nodeindex));
+ nodeindex--;
continue;
}
QString idString = elem.attribute("producer");
QString id = idString;
double speed = 1.0;
if (idString.startsWith("slowmotion")) {
- id = idString.section(":", 1, 1);
- speed = idString.section(":", 2, 2).toDouble();
+ id = idString.section(':', 1, 1);
+ speed = idString.section(':', 2, 2).toDouble();
} else id = id.section('_', 0, 0);
DocClipBase *clip = m_doc->clipManager()->getClipById(id);
if (clip != NULL) {
if (MainWindow::videoEffects.hasKeyFrames(currenteffect)) {
//kDebug() << " * * * * * * * * * * ** CLIP EFF WITH KFR FND * * * * * * * * * * *";
// effect is key-framable, read all effects to retrieve keyframes
- double factor;
+ double factor = 0;
QString starttag;
QString endtag;
QDomNodeList params = currenteffect.elementsByTagName("parameter");
QString keyframes;
int effectin = effect.attribute("in").toInt();
int effectout = effect.attribute("out").toInt();
- double startvalue;
- double endvalue;
+ double startvalue = 0;
+ double endvalue = 0;
for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
// parse effect parameters
QDomElement effectparam = n3.toElement();
endvalue = effectparam.text().toDouble() * factor;
}
// add first keyframe
- keyframes.append(QString::number(effectin) + ":" + QString::number(startvalue) + ";" + QString::number(effectout) + ":" + QString::number(endvalue) + ";");
+ keyframes.append(QString::number(effectin) + ':' + QString::number(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
QDomNode lastParsedEffect;
ix++;
QDomNode n2 = effects.at(ix);
}
}
if (continueParsing) {
- keyframes.append(QString::number(effectout) + ":" + QString::number(endvalue) + ";");
+ keyframes.append(QString::number(effectout) + ':' + QString::number(endvalue) + ';');
ix++;
}
}