1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include <KStandardDirs>
22 #include <KMessageBox>
24 #include <KFileDialog>
25 #include <KIO/NetAccess>
28 #include "kdenlivedoc.h"
31 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)
34 m_commandStack = new KUndoStack();
37 if(KIO::NetAccess::download(url.path(), tmpFile, parent))
40 m_document.setContent(&file, false);
42 m_projectName = url.fileName();
43 KIO::NetAccess::removeTempFile(tmpFile);
47 KMessageBox::error(parent, KIO::NetAccess::lastErrorString());
51 // Creating new document
52 QDomElement westley = m_document.createElement("westley");
53 m_document.appendChild(westley);
54 QDomElement doc = m_document.createElement("kdenlivedoc");
55 doc.setAttribute("version", "0.6");
56 westley.appendChild(doc);
57 QDomElement props = m_document.createElement("properties");
58 doc.setAttribute("width", m_width);
59 doc.setAttribute("height", m_height);
60 doc.setAttribute("projectfps", m_fps);
61 doc.appendChild(props);
64 /*QDomElement westley = m_document.createElement("westley");
65 m_document.appendChild(westley);*/
66 QDomElement prod = m_document.createElement("producer");
67 prod.setAttribute("resource", "colour");
68 prod.setAttribute("colour", "red");
69 prod.setAttribute("id", "black");
70 prod.setAttribute("in", "0");
71 prod.setAttribute("out", "0");
73 QDomElement tractor = m_document.createElement("tractor");
74 QDomElement multitrack = m_document.createElement("multitrack");
76 QDomElement playlist1 = m_document.createElement("playlist");
77 playlist1.appendChild(prod);
78 multitrack.appendChild(playlist1);
79 QDomElement playlist2 = m_document.createElement("playlist");
80 multitrack.appendChild(playlist2);
81 QDomElement playlist3 = m_document.createElement("playlist");
82 multitrack.appendChild(playlist3);
83 QDomElement playlist4 = m_document.createElement("playlist");
84 playlist4.setAttribute("hide", "video");
85 multitrack.appendChild(playlist4);
86 QDomElement playlist5 = m_document.createElement("playlist");
87 playlist5.setAttribute("hide", "video");
88 multitrack.appendChild(playlist5);
89 tractor.appendChild(multitrack);
90 doc.appendChild(tractor);
93 if (fps == 30000.0 / 1001.0 ) m_timecode.setFormat(30, true);
94 else m_timecode.setFormat((int) fps);
97 KdenliveDoc::~KdenliveDoc()
99 delete m_commandStack;
102 KUndoStack *KdenliveDoc::commandStack()
104 return m_commandStack;
107 void KdenliveDoc::setRenderer(Render *render)
110 if (m_render) m_render->setSceneList(m_document);
113 QDomDocument KdenliveDoc::generateSceneList()
116 QDomElement westley = doc.createElement("westley");
117 doc.appendChild(westley);
118 QDomElement prod = doc.createElement("producer");
121 QDomDocument KdenliveDoc::toXml()
126 Timecode KdenliveDoc::timecode()
131 QString KdenliveDoc::documentName()
133 return m_projectName;
136 QDomNodeList KdenliveDoc::producersList()
138 return m_document.elementsByTagName("producer");
141 void KdenliveDoc::setProducers(QDomElement doc)
143 QDomNode kdenlivedocument = m_document.elementsByTagName("kdenlivedoc").item(0);
145 QDomNodeList list = m_document.elementsByTagName("producer");
146 int ct = list.count();
147 kDebug()<<"DELETING CHILD PRODUCERS: "<<ct;
148 for (int i = ct; i > 0; i--) {
149 kdenlivedocument.removeChild(list.item(i));
152 QDomNode n = doc.firstChild();
155 QDomElement e = n.toElement(); // try to convert the node to an element.
156 if(!e.isNull() && e.tagName() == "producer") {
157 kdenlivedocument.appendChild(m_document.importNode(e, true));
162 kDebug()<<"ADDING CHILD PRODS: "<<ct<<"\n";
163 //kDebug()<<m_document.toString();
166 double KdenliveDoc::fps()
171 int KdenliveDoc::width()
176 int KdenliveDoc::height()
181 KUrl KdenliveDoc::url()
186 #include "kdenlivedoc.moc"