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();
46 KIO::NetAccess::removeTempFile(tmpFile);
50 KMessageBox::error(parent, KIO::NetAccess::lastErrorString());
54 // Creating new document
55 QDomElement westley = m_document.createElement("westley");
56 m_document.appendChild(westley);
57 QDomElement doc = m_document.createElement("kdenlivedoc");
58 doc.setAttribute("version", "0.6");
59 westley.appendChild(doc);
60 QDomElement props = m_document.createElement("properties");
61 doc.setAttribute("width", m_width);
62 doc.setAttribute("height", m_height);
63 doc.setAttribute("projectfps", m_fps);
64 doc.appendChild(props);
67 if (fps == 30000.0 / 1001.0 ) m_timecode.setFormat(30, true);
68 else m_timecode.setFormat((int) fps);
71 KdenliveDoc::~KdenliveDoc()
75 QDomDocument KdenliveDoc::toXml()
80 Timecode KdenliveDoc::timecode()
85 QString KdenliveDoc::documentName()
90 QDomNodeList KdenliveDoc::producersList()
92 return m_document.elementsByTagName("producer");
95 void KdenliveDoc::setProducers(QDomElement doc)
97 QDomNode kdenlivedocument = m_document.elementsByTagName("kdenlivedoc").item(0);
99 QDomNodeList list = m_document.elementsByTagName("producer");
100 int ct = list.count();
101 kDebug()<<"DELETING CHILD PRODUCERS: "<<ct;
102 for (int i = 0; i < ct; i++) {
103 kdenlivedocument.removeChild(list.item(0));
106 QDomNode n = doc.firstChild();
109 QDomElement e = n.toElement(); // try to convert the node to an element.
110 if(!e.isNull() && e.tagName() == "producer") {
111 kdenlivedocument.appendChild(m_document.importNode(e, true));
116 kDebug()<<"ADDING CHILD PRODS: "<<ct<<"\n";
117 //kDebug()<<m_document.toString();
120 double KdenliveDoc::fps()
125 int KdenliveDoc::width()
130 int KdenliveDoc::height()
135 #include "kdenlivedoc.moc"