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)
40 m_commandStack = new KUndoStack(this);
43 if(KIO::NetAccess::download(url.path(), tmpFile, parent))
46 m_document.setContent(&file, false);
48 m_projectName = url.fileName();
49 KIO::NetAccess::removeTempFile(tmpFile);
53 KMessageBox::error(parent, KIO::NetAccess::lastErrorString());
57 // Creating new document
58 QDomElement westley = m_document.createElement("westley");
59 m_document.appendChild(westley);
60 QDomElement doc = m_document.createElement("kdenlivedoc");
61 doc.setAttribute("version", "0.6");
62 westley.appendChild(doc);
63 QDomElement props = m_document.createElement("properties");
64 doc.setAttribute("width", m_width);
65 doc.setAttribute("height", m_height);
66 doc.setAttribute("projectfps", m_fps);
67 doc.appendChild(props);
70 /*QDomElement westley = m_document.createElement("westley");
71 m_document.appendChild(westley);*/
72 QDomElement prod = m_document.createElement("producer");
73 prod.setAttribute("resource", "colour");
74 prod.setAttribute("colour", "red");
75 prod.setAttribute("id", "black");
76 prod.setAttribute("in", "0");
77 prod.setAttribute("out", "0");
79 QDomElement tractor = m_document.createElement("tractor");
80 QDomElement multitrack = m_document.createElement("multitrack");
82 QDomElement playlist1 = m_document.createElement("playlist");
83 playlist1.appendChild(prod);
84 multitrack.appendChild(playlist1);
85 QDomElement playlist2 = m_document.createElement("playlist");
86 multitrack.appendChild(playlist2);
87 QDomElement playlist3 = m_document.createElement("playlist");
88 multitrack.appendChild(playlist3);
89 QDomElement playlist4 = m_document.createElement("playlist");
90 playlist4.setAttribute("hide", "video");
91 multitrack.appendChild(playlist4);
92 QDomElement playlist5 = m_document.createElement("playlist");
93 playlist5.setAttribute("hide", "video");
94 multitrack.appendChild(playlist5);
95 tractor.appendChild(multitrack);
96 doc.appendChild(tractor);
99 if (fps == 30000.0 / 1001.0 ) m_timecode.setFormat(30, true);
100 else m_timecode.setFormat((int) fps);
103 KdenliveDoc::~KdenliveDoc()
107 KUndoStack *KdenliveDoc::commandStack()
109 return m_commandStack;
112 void KdenliveDoc::setRenderer(Render *render)
115 if (m_render) m_render->setSceneList(m_document);
118 QDomDocument KdenliveDoc::generateSceneList()
121 QDomElement westley = doc.createElement("westley");
122 doc.appendChild(westley);
123 QDomElement prod = doc.createElement("producer");
126 QDomDocument KdenliveDoc::toXml()
131 Timecode KdenliveDoc::timecode()
136 QString KdenliveDoc::documentName()
138 return m_projectName;
141 QDomNodeList KdenliveDoc::producersList()
143 return m_document.elementsByTagName("producer");
146 void KdenliveDoc::setProducers(QDomElement doc)
148 QDomNode kdenlivedocument = m_document.elementsByTagName("kdenlivedoc").item(0);
150 QDomNodeList list = m_document.elementsByTagName("producer");
151 int ct = list.count();
152 kDebug()<<"DELETING CHILD PRODUCERS: "<<ct;
153 for (int i = ct; i > 0; i--) {
154 kdenlivedocument.removeChild(list.item(i));
157 QDomNode n = doc.firstChild();
160 QDomElement e = n.toElement(); // try to convert the node to an element.
161 if(!e.isNull() && e.tagName() == "producer") {
162 kdenlivedocument.appendChild(m_document.importNode(e, true));
167 kDebug()<<"ADDING CHILD PRODS: "<<ct<<"\n";
168 //kDebug()<<m_document.toString();
171 double KdenliveDoc::fps()
176 int KdenliveDoc::width()
181 int KdenliveDoc::height()
186 KUrl KdenliveDoc::url()
191 #include "kdenlivedoc.moc"