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"
36 KdenliveDoc::KdenliveDoc(KUrl url, double fps, int width, int height, QWidget *parent):QObject(parent), m_url(url), m_fps(fps), m_width(width), m_height(height), m_projectName(NULL)
40 if(KIO::NetAccess::download(url.path(), tmpFile, parent))
43 m_document.setContent(&file, false);
45 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 if (fps == 30000.0 / 1001.0 ) m_timecode.setFormat(30, true);
69 else m_timecode.setFormat((int) fps);
72 KdenliveDoc::~KdenliveDoc()
76 Timecode KdenliveDoc::timecode()
81 QString KdenliveDoc::documentName()
86 QDomNodeList KdenliveDoc::producersList()
88 return m_document.elementsByTagName("producer");
91 void KdenliveDoc::setProducers(QDomElement doc)
93 QDomNode kdenlivedocument = m_document.elementsByTagName("kdenlivedoc").item(0);
95 QDomNodeList list = m_document.elementsByTagName("producer");
96 int ct = list.count();
97 kDebug()<<"DELETING CHILD PRODUCERS: "<<ct;
98 for (int i = 0; i < ct; i++) {
99 kdenlivedocument.removeChild(list.item(0));
102 QDomNode n = doc.firstChild();
105 QDomElement e = n.toElement(); // try to convert the node to an element.
106 if(!e.isNull() && e.tagName() == "producer") {
107 kdenlivedocument.appendChild(m_document.importNode(e, true));
112 kDebug()<<"ADDING CHILD PRODS: "<<ct<<"\n";
113 //kDebug()<<m_document.toString();
116 double KdenliveDoc::fps()
121 int KdenliveDoc::width()
126 int KdenliveDoc::height()
131 #include "kdenlivedoc.moc"