-void TrackView::slotChangeZoom(int factor)
-{
- m_ruler->setPixelPerMark(factor);
- //m_scale = m_ruler->pixelPerMark();
- m_scale = (double) m_ruler->comboScale[m_currentZoom] / m_ruler->comboScale[factor];
- //else m_scale = (double) m_ruler->comboScale[m_currentZoom] / m_ruler->comboScale[factor];
- m_currentZoom = factor;
- kDebug()<<"///// ZOOMING: "<<m_scale;
- m_trackview->scale(m_scale, 1);
- /*
- for (int i = 0; i < documentTracks.count(); i++) {
- kDebug()<<"------REPAINTING OBJECT";
- documentTracks.at(i)->update();
- //documentTracks.at(i)->setFixedWidth(300 * zoomFactor());
- }
- m_scrollBox->setFixedWidth(( m_projectDuration + 300) * zoomFactor());*/
- /*m_scrollArea->horizontalScrollBar()->setMaximum(300 * zoomFactor());
- m_scrollArea->horizontalScrollBar()->setPageStep(FRAME_SIZE * zoomFactor());*/
+void TrackView::parseDocument(QDomDocument doc) {
+ int cursorPos = 0;
+ //kDebug() << "//// DOCUMENT: " << doc.toString();
+ QDomNode props = doc.elementsByTagName("properties").item(0);
+ if (!props.isNull()) {
+ cursorPos = props.toElement().attribute("timeline_position").toInt();
+ }
+
+ // parse project tracks
+ QDomNodeList tracks = doc.elementsByTagName("track");
+ QDomNodeList playlists = doc.elementsByTagName("playlist");
+ int duration = 300;
+ m_projectTracks = tracks.count();
+ int trackduration = 0;
+ QDomElement e;
+ QDomElement p;
+ bool videotrack;
+
+ int pos = m_projectTracks - 1;
+
+ for (int i = 0; i < m_projectTracks; i++) {
+ e = tracks.item(i).toElement();
+ QString playlist_name = e.attribute("producer");
+ if (playlist_name != "black_track" && playlist_name != "playlistmain") {
+ // find playlist related to this track
+ p = QDomElement();
+ for (int j = 0; j < m_projectTracks; j++) {
+ p = playlists.item(j).toElement();
+ if (p.attribute("id") == playlist_name) break;
+ }
+ videotrack = (e.attribute("hide") != "video");
+ trackduration = slotAddProjectTrack(pos, p, videotrack);
+ pos--;
+ //kDebug() << " PRO DUR: " << trackduration << ", TRACK DUR: " << duration;
+ if (trackduration > duration) duration = trackduration;
+ } else {
+ // background black track
+ for (int j = 0; j < m_projectTracks; j++) {
+ p = playlists.item(j).toElement();
+ if (p.attribute("id") == playlist_name) break;
+ }
+ int black_clips = p.childNodes().count();
+ for (int i = 0; i < black_clips; i++)
+ m_doc->loadingProgressed();
+ qApp->processEvents();
+ pos--;
+ }
+ }
+
+ // parse transitions
+ QDomNodeList transitions = doc.elementsByTagName("transition");
+ int projectTransitions = transitions.count();
+ //kDebug() << "//////////// TIMELINE FOUND: " << projectTransitions << " transitions";
+ for (int i = 0; i < projectTransitions; i++) {
+ e = transitions.item(i).toElement();
+ QDomNodeList transitionparams = e.childNodes();
+ bool transitionAdd = true;
+ int a_track = 0;
+ int b_track = 0;
+ QString mlt_service;
+ for (int k = 0; k < transitionparams.count(); k++) {
+ p = transitionparams.item(k).toElement();
+ if (!p.isNull()) {
+ // do not add audio mixing transitions
+ if (p.attribute("name") == "internal_added" && p.text() == "237") {
+ transitionAdd = false;
+ //kDebug() << "// TRANSITRION " << i << " IS NOT VALID (INTERN ADDED)";
+ break;
+ } else if (p.attribute("name") == "a_track") a_track = p.text().toInt();
+ else if (p.attribute("name") == "b_track") b_track = m_projectTracks - 1 - p.text().toInt();
+ else if (p.attribute("name") == "mlt_service") mlt_service = p.text();
+ }
+ }
+ if (transitionAdd) {
+ // Transition should be added to the scene
+ ItemInfo transitionInfo;
+ transitionInfo.startPos = GenTime(e.attribute("in").toInt(), m_doc->fps());
+ transitionInfo.endPos = GenTime(e.attribute("out").toInt(), m_doc->fps());
+ transitionInfo.track = b_track;
+ //kDebug() << "/////////////// +++++++++++ ADDING TRANSITION ON TRACK: " << b_track << ", TOTAL TRKA: " << m_projectTracks;
+ Transition *tr = new Transition(transitionInfo, a_track, m_scale, m_doc->fps(), QDomElement());
+ m_scene->addItem(tr);
+ }
+ }
+
+
+ m_trackview->setDuration(duration);
+ kDebug() << "/////////// TOTAL PROJECT DURATION: " << duration;
+ slotRebuildTrackHeaders();
+ //m_trackview->setCursorPos(cursorPos);
+ //m_scrollBox->setGeometry(0, 0, 300 * zoomFactor(), m_scrollArea->height());