]> git.sesse.net Git - kdenlive/commitdiff
Fixes for document switching
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 5 Jan 2008 22:17:58 +0000 (22:17 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 5 Jan 2008 22:17:58 +0000 (22:17 +0000)
svn path=/branches/KDE4/; revision=1796

src/kdenlivedoc.cpp
src/projectitem.cpp
src/projectlist.cpp

index 3971e62460abec44ade21015b51043ebd2e42a52..95a81b304d4c959438393bada9fe01c55a7a137f 100644 (file)
@@ -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: "<<ct;
-  for (int i = 0; i < ct; i++) {
-    kdenlivedocument.removeChild(list.item(0));
+  for (int i = ct; i > 0; i--) {
+    kdenlivedocument.removeChild(list.item(i));
    }
 
   QDomNode n = doc.firstChild();
index 16022a2831ca7ae8909e3e1dc309fda38cb253cc..a900404125810d5ad61e120d3bd23f6f9eb0e639 100644 (file)
@@ -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();
 
index 41a28d7f3774e1780be07ad13c75035e82a58ce0..a20b953351b68218a54e247f43014fc0baa4fdd0 100644 (file)
@@ -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=: "<<name;
   ProjectItem *item = new ProjectItem(listView, name, elem, clipId);
   if (!url.isEmpty()) {
     item->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: "<<prods.count();
   listView->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: "<<i<<", :"<<e.attribute("id", "non")<<", NAME: "<<e.attribute("name", "non");
+    if (!e.isNull()) addProducer(e);
   }
   QTreeWidgetItem *first = listView->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 "<<doc.toString()<<"\n+++++++++++++++++";
+  //kDebug()<<"//////  ADDING PRODUCER:\n "<<doc.toString()<<"\n+++++++++++++++++";
   int id = producer.attribute("id").toInt();
   if (id >= m_clipIdCounter) m_clipIdCounter = id + 1;