X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fkdenlivedoc.cpp;h=4af830ffe66c4db520057a3997dd97555ff94443;hb=c6d43344e195571ecc784897310c02a7125623d0;hp=ca358cc404d803ffcd61c43b268fc5e36df2445f;hpb=87a3fbf3806addaabd2fecb83f5578f855b52c08;p=kdenlive diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index ca358cc4..4af830ff 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -1,28 +1,22 @@ /*************************************************************************** - kdenlivedoc.cpp - description - ------------------- - begin : Fri Nov 22 2002 - copyright : (C) 2002 by Jason Wood - email : jasonwood@blueyonder.co.uk - copyright : (C) 2005 Lucio Flavio Correa - email : lucio.correa@gmail.com - copyright : (C) Marco Gittler - email : g.marco@freenet.de - copyright : (C) 2006 Jean-Baptiste Mardelle - email : jb@ader.ch - -***************************************************************************/ - -/*************************************************************************** + * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ - #include #include #include @@ -34,8 +28,10 @@ #include "kdenlivedoc.h" -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) +KdenliveDoc::KdenliveDoc(const 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) { + + m_commandStack = new KUndoStack(); if (!url.isEmpty()) { QString tmpFile; if(KIO::NetAccess::download(url.path(), tmpFile, parent)) @@ -53,7 +49,7 @@ KdenliveDoc::KdenliveDoc(KUrl url, double fps, int width, int height, QWidget *p } else { // Creating new document - /*QDomElement westley = m_document.createElement("westley"); + QDomElement westley = m_document.createElement("westley"); m_document.appendChild(westley); QDomElement doc = m_document.createElement("kdenlivedoc"); doc.setAttribute("version", "0.6"); @@ -62,11 +58,11 @@ KdenliveDoc::KdenliveDoc(KUrl url, double fps, int width, int height, QWidget *p doc.setAttribute("width", m_width); doc.setAttribute("height", m_height); doc.setAttribute("projectfps", m_fps); - doc.appendChild(props);*/ + doc.appendChild(props); - QDomElement westley = m_document.createElement("westley"); - m_document.appendChild(westley); + /*QDomElement westley = m_document.createElement("westley"); + m_document.appendChild(westley);*/ QDomElement prod = m_document.createElement("producer"); prod.setAttribute("resource", "colour"); prod.setAttribute("colour", "red"); @@ -79,19 +75,24 @@ KdenliveDoc::KdenliveDoc(KUrl url, double fps, int width, int height, QWidget *p QDomElement playlist1 = m_document.createElement("playlist"); playlist1.appendChild(prod); + playlist1.setAttribute("id", "playlist1"); multitrack.appendChild(playlist1); QDomElement playlist2 = m_document.createElement("playlist"); + playlist2.setAttribute("id", "playlist2"); multitrack.appendChild(playlist2); QDomElement playlist3 = m_document.createElement("playlist"); multitrack.appendChild(playlist3); + playlist3.setAttribute("id", "playlist3"); QDomElement playlist4 = m_document.createElement("playlist"); playlist4.setAttribute("hide", "video"); multitrack.appendChild(playlist4); + playlist1.setAttribute("id", "playlist4"); QDomElement playlist5 = m_document.createElement("playlist"); playlist5.setAttribute("hide", "video"); multitrack.appendChild(playlist5); + playlist1.setAttribute("id", "playlist5"); tractor.appendChild(multitrack); - westley.appendChild(tractor); + doc.appendChild(tractor); } if (fps == 30000.0 / 1001.0 ) m_timecode.setFormat(30, true); @@ -100,6 +101,12 @@ KdenliveDoc::KdenliveDoc(KUrl url, double fps, int width, int height, QWidget *p KdenliveDoc::~KdenliveDoc() { + delete m_commandStack; +} + +KUndoStack *KdenliveDoc::commandStack() +{ + return m_commandStack; } void KdenliveDoc::setRenderer(Render *render) @@ -108,6 +115,54 @@ void KdenliveDoc::setRenderer(Render *render) if (m_render) m_render->setSceneList(m_document); } +QString KdenliveDoc::producerName(int id) +{ + QString result = "unnamed"; + QDomNodeList prods = producersList(); + int ct = prods.count(); + for (int i = 0; i < ct ; i++) + { + QDomElement e = prods.item(i).toElement(); + if (e.attribute("id") != "black" && e.attribute("id").toInt() == id) { + result = e.attribute("name"); + if (result.isEmpty()) result = KUrl(e.attribute("resource")).fileName(); + break; + } + } + return result; +} + +void KdenliveDoc::setProducerDuration(int id, int duration) +{ + QDomNodeList prods = producersList(); + int ct = prods.count(); + for (int i = 0; i < ct ; i++) + { + QDomElement e = prods.item(i).toElement(); + if (e.attribute("id") != "black" && e.attribute("id").toInt() == id) { + e.setAttribute("duration", QString::number(duration)); + break; + } + } +} + +int KdenliveDoc::getProducerDuration(int id) +{ + int result = 0; + QDomNodeList prods = producersList(); + int ct = prods.count(); + for (int i = 0; i < ct ; i++) + { + QDomElement e = prods.item(i).toElement(); + if (e.attribute("id") != "black" && e.attribute("id").toInt() == id) { + result = e.attribute("duration").toInt(); + break; + } + } + return result; +} + + QDomDocument KdenliveDoc::generateSceneList() { QDomDocument doc; @@ -143,8 +198,8 @@ void KdenliveDoc::setProducers(QDomElement doc) QDomNodeList list = m_document.elementsByTagName("producer"); int ct = list.count(); kDebug()<<"DELETING CHILD PRODUCERS: "< 0; i--) { + kdenlivedocument.removeChild(list.item(i)); } QDomNode n = doc.firstChild(); @@ -176,5 +231,10 @@ int KdenliveDoc::height() return m_height; } +KUrl KdenliveDoc::url() +{ + return m_url; +} + #include "kdenlivedoc.moc"