From: Jean-Baptiste Mardelle Date: Sat, 5 Jan 2008 22:17:58 +0000 (+0000) Subject: Fixes for document switching X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=8b53a1dae430f7467e766cdfb7dbe435fe13c637;p=kdenlive Fixes for document switching svn path=/branches/KDE4/; revision=1796 --- diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index 3971e624..95a81b30 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -55,7 +55,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"); @@ -64,11 +64,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"); @@ -93,7 +93,7 @@ KdenliveDoc::KdenliveDoc(KUrl url, double fps, int width, int height, QWidget *p playlist5.setAttribute("hide", "video"); multitrack.appendChild(playlist5); tractor.appendChild(multitrack); - westley.appendChild(tractor); + doc.appendChild(tractor); } if (fps == 30000.0 / 1001.0 ) m_timecode.setFormat(30, true); @@ -150,8 +150,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(); diff --git a/src/projectitem.cpp b/src/projectitem.cpp index 16022a28..a9004041 100644 --- a/src/projectitem.cpp +++ b/src/projectitem.cpp @@ -21,11 +21,13 @@ ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, QDom { setSizeHint(0, QSize(65, 45)); setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled); - if (m_element.isNull()) m_element.setAttribute("id", clipId); - QString cType = m_element.attribute("type", 0); - if (!cType.isEmpty()) { - m_clipType = (DocClipBase::CLIPTYPE) cType.toInt(); - slotSetToolTip(); + if (!m_element.isNull()) { + m_element.setAttribute("id", clipId); + QString cType = m_element.attribute("type", QString::null); + if (!cType.isEmpty()) { + m_clipType = (DocClipBase::CLIPTYPE) cType.toInt(); + slotSetToolTip(); + } } } @@ -107,7 +109,9 @@ void ProjectItem::setProperties(const QMap < QString, QString > &attributes, con //extend attributes -reh - if (attributes.contains("type")) { + + if (m_clipType == DocClipBase::NONE) { + if (attributes.contains("type")) { if (attributes["type"] == "audio") m_clipType = DocClipBase::AUDIO; else if (attributes["type"] == "video") @@ -116,8 +120,9 @@ void ProjectItem::setProperties(const QMap < QString, QString > &attributes, con m_clipType = DocClipBase::AV; else if (attributes["type"] == "playlist") m_clipType = DocClipBase::PLAYLIST; - } else { + } else { m_clipType = DocClipBase::AV; + } } slotSetToolTip(); diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 41a28d7f..a20b9533 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -169,6 +169,7 @@ void ProjectList::selectItemById(const int clipId) void ProjectList::addClip(const QStringList &name, const QDomElement &elem, const int clipId, const KUrl &url) { + kDebug()<<"///////// ADDING VCLIP=: "<setData(1, FullPathRole, url.path()); @@ -270,10 +271,14 @@ void ProjectList::setDocument(KdenliveDoc *doc) m_timecode = doc->timecode(); m_commandStack = doc->commandStack(); QDomNodeList prods = doc->producersList(); + int ct = prods.count(); + kDebug()<<"//////////// SETTING DOC, FOUND CLIPS: "<clear(); - for (int i = 0; i < prods.count () ; i++) + for (int i = 0; i < ct ; i++) { - addProducer(prods.item(i).toElement()); + QDomElement e = prods.item(i).cloneNode().toElement(); + kDebug()<<"// IMPORT: "<topLevelItem(0); if (first) listView->setCurrentItem(first); @@ -293,7 +298,7 @@ QDomElement ProjectList::producersList() { QTreeWidgetItem *item = parent ? parent->child(i) : listView->topLevelItem(i); - prods.appendChild(doc.importNode(((ProjectItem *)item)->toXml(), true)); + prods.appendChild(doc.importNode(((ProjectItem *)item)->toXml(), true)); } return prods; @@ -343,12 +348,13 @@ void ProjectList::addProducer(QDomElement producer) { DocClipBase::CLIPTYPE type = (DocClipBase::CLIPTYPE) producer.attribute("type").toInt(); - QDomDocument doc; + /*QDomDocument doc; QDomElement prods = doc.createElement("list"); - prods.appendChild(doc.importNode(producer, true)); + doc.appendChild(prods); + prods.appendChild(doc.importNode(producer, true));*/ - kDebug()<<"////// ADDING PRODUCER:\n "<= m_clipIdCounter) m_clipIdCounter = id + 1;