1 /***************************************************************************
2 kdenlivedoc.cpp - description
4 begin : Fri Nov 22 2002
5 copyright : (C) 2002 by Jason Wood
6 email : jasonwood@blueyonder.co.uk
7 copyright : (C) 2005 Lucio Flavio Correa
8 email : lucio.correa@gmail.com
9 copyright : (C) Marco Gittler
10 email : g.marco@freenet.de
11 copyright : (C) 2006 Jean-Baptiste Mardelle
14 ***************************************************************************/
16 /***************************************************************************
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 ***************************************************************************/
27 #include <KStandardDirs>
28 #include <KMessageBox>
30 #include <KFileDialog>
31 #include <KIO/NetAccess>
34 #include "kdenlivedoc.h"
37 KdenliveDoc::KdenliveDoc(KUrl url, double fps, int width, int height, QWidget *parent):QObject(parent), m_render(NULL), m_url(url), m_fps(fps), m_width(width), m_height(height), m_projectName(NULL)
41 if(KIO::NetAccess::download(url.path(), tmpFile, parent))
44 m_document.setContent(&file, false);
46 m_projectName = url.fileName();
47 KIO::NetAccess::removeTempFile(tmpFile);
51 KMessageBox::error(parent, KIO::NetAccess::lastErrorString());
55 // Creating new document
56 /*QDomElement westley = m_document.createElement("westley");
57 m_document.appendChild(westley);
58 QDomElement doc = m_document.createElement("kdenlivedoc");
59 doc.setAttribute("version", "0.6");
60 westley.appendChild(doc);
61 QDomElement props = m_document.createElement("properties");
62 doc.setAttribute("width", m_width);
63 doc.setAttribute("height", m_height);
64 doc.setAttribute("projectfps", m_fps);
65 doc.appendChild(props);*/
68 QDomElement westley = m_document.createElement("westley");
69 m_document.appendChild(westley);
70 QDomElement prod = m_document.createElement("producer");
71 prod.setAttribute("resource", "colour");
72 prod.setAttribute("colour", "red");
73 prod.setAttribute("id", "black");
74 prod.setAttribute("in", "0");
75 prod.setAttribute("out", "0");
77 QDomElement tractor = m_document.createElement("tractor");
78 QDomElement multitrack = m_document.createElement("multitrack");
80 QDomElement playlist1 = m_document.createElement("playlist");
81 playlist1.appendChild(prod);
82 multitrack.appendChild(playlist1);
83 QDomElement playlist2 = m_document.createElement("playlist");
84 multitrack.appendChild(playlist2);
85 QDomElement playlist3 = m_document.createElement("playlist");
86 multitrack.appendChild(playlist3);
87 QDomElement playlist4 = m_document.createElement("playlist");
88 playlist4.setAttribute("hide", "video");
89 multitrack.appendChild(playlist4);
90 QDomElement playlist5 = m_document.createElement("playlist");
91 playlist5.setAttribute("hide", "video");
92 multitrack.appendChild(playlist5);
93 tractor.appendChild(multitrack);
94 westley.appendChild(tractor);
97 if (fps == 30000.0 / 1001.0 ) m_timecode.setFormat(30, true);
98 else m_timecode.setFormat((int) fps);
101 KdenliveDoc::~KdenliveDoc()
105 void KdenliveDoc::setRenderer(Render *render)
108 if (m_render) m_render->setSceneList(m_document);
111 QDomDocument KdenliveDoc::generateSceneList()
114 QDomElement westley = doc.createElement("westley");
115 doc.appendChild(westley);
116 QDomElement prod = doc.createElement("producer");
119 QDomDocument KdenliveDoc::toXml()
124 Timecode KdenliveDoc::timecode()
129 QString KdenliveDoc::documentName()
131 return m_projectName;
134 QDomNodeList KdenliveDoc::producersList()
136 return m_document.elementsByTagName("producer");
139 void KdenliveDoc::setProducers(QDomElement doc)
141 QDomNode kdenlivedocument = m_document.elementsByTagName("kdenlivedoc").item(0);
143 QDomNodeList list = m_document.elementsByTagName("producer");
144 int ct = list.count();
145 kDebug()<<"DELETING CHILD PRODUCERS: "<<ct;
146 for (int i = 0; i < ct; i++) {
147 kdenlivedocument.removeChild(list.item(0));
150 QDomNode n = doc.firstChild();
153 QDomElement e = n.toElement(); // try to convert the node to an element.
154 if(!e.isNull() && e.tagName() == "producer") {
155 kdenlivedocument.appendChild(m_document.importNode(e, true));
160 kDebug()<<"ADDING CHILD PRODS: "<<ct<<"\n";
161 //kDebug()<<m_document.toString();
164 double KdenliveDoc::fps()
169 int KdenliveDoc::width()
174 int KdenliveDoc::height()
179 #include "kdenlivedoc.moc"