]> git.sesse.net Git - kdenlive/commitdiff
project tree fixes
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 19 Jan 2008 13:18:19 +0000 (13:18 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 19 Jan 2008 13:18:19 +0000 (13:18 +0000)
svn path=/branches/KDE4/; revision=1804

src/projectitem.cpp
src/projectitem.h
src/projectlist.cpp
src/projectlistview.cpp

index db4c4ca7f76d4411ab7b37a7eb676b80a1b98ea0..7ac2a3eb642b9284db66acbb9abb9659d6b00e0a 100644 (file)
@@ -37,7 +37,7 @@
   const int ClipTypeRole = NameRole + 3;
 
 ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, QDomElement xml, int clipId)
-    : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(DocClipBase::NONE), m_clipId(clipId), m_isGroup(false)
+    : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(DocClipBase::NONE), m_clipId(clipId), m_isGroup(false), m_groupName(QString::null)
 {
   m_element = xml.cloneNode().toElement();
   setSizeHint(0, QSize(65, 45));
@@ -53,7 +53,7 @@ ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, QDom
 }
 
 ProjectItem::ProjectItem(QTreeWidgetItem * parent, const QStringList & strings, QDomElement xml, int clipId)
-    : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(DocClipBase::NONE), m_clipId(clipId), m_isGroup(false)
+    : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(DocClipBase::NONE), m_clipId(clipId), m_isGroup(false), m_groupName(QString::null)
 {
   m_element = xml.cloneNode().toElement();
   setSizeHint(0, QSize(65, 45));
@@ -69,7 +69,7 @@ ProjectItem::ProjectItem(QTreeWidgetItem * parent, const QStringList & strings,
 }
 
 ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, int clipId)
-    : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_element(QDomElement()), m_clipType(DocClipBase::NONE), m_clipId(clipId), m_isGroup(true)
+    : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_element(QDomElement()), m_clipType(DocClipBase::NONE), m_clipId(clipId), m_isGroup(true), m_groupName(strings.at(1))
 {
   setSizeHint(0, QSize(65, 45));
   setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled);
@@ -80,22 +80,6 @@ ProjectItem::~ProjectItem()
 {
 }
 
-ProjectItem *ProjectItem::clone() const
-{
-  ProjectItem *item = (ProjectItem *) this->QTreeWidgetItem::clone();
-  /*if (isGroup())
-  {
-    item = new ProjectItem(new QTreeWidget(), names(), clipId());
-  }  
-  else {
-    if (parent())
-      item = new ProjectItem(new QTreeWidgetItem(), names(), toXml().cloneNode().toElement(), clipId());
-    else 
-      item = new ProjectItem(new QTreeWidget(), names(), toXml().cloneNode().toElement(), clipId());
-  }*/
-  return item;
-}
-
 int ProjectItem::clipId() const
 {
   return m_clipId;
@@ -106,10 +90,9 @@ bool ProjectItem::isGroup() const
   return m_isGroup;
 }
 
-const QString &ProjectItem::groupName() const
+const QString ProjectItem::groupName() const
 {
-  if (isGroup()) return text(1);
-  else return QString::null;
+  return m_groupName;
 }
 
 QStringList ProjectItem::names() const
@@ -126,6 +109,14 @@ QDomElement ProjectItem::toXml() const
     return m_element;
 }
 
+const KUrl ProjectItem::clipUrl() const
+{
+    if (m_clipType != DocClipBase::COLOR && m_clipType != DocClipBase::VIRTUAL && m_clipType != DocClipBase::NONE)
+      return KUrl(m_element.attribute("resouce"));
+    else return KUrl();
+}
+
+
 void ProjectItem::slotSetToolTip()
 {
   QString tip = "<qt><b>";
index 23d0acf203709bcc2e558246459ba2a4c4bc478f..21b8b603842dc34705365509521294e6643dd0c5 100644 (file)
@@ -42,8 +42,8 @@ class ProjectItem : public QTreeWidgetItem
     int clipId() const;
     QStringList names() const;
     bool isGroup() const;
-    const QString &groupName() const;
-    virtual ProjectItem *clone() const;
+    const QString groupName() const;
+    const KUrl clipUrl() const;
 
   private:
     QDomElement m_element;
@@ -53,6 +53,7 @@ class ProjectItem : public QTreeWidgetItem
     int m_clipId;
     void slotSetToolTip();
     bool m_isGroup;
+    QString m_groupName;
 };
 
 #endif
index f4a9111528565794509de969dbf5249c3af32367..3006b8fa9689b9d932db10e793a6d4b54ae0474b 100644 (file)
@@ -31,6 +31,7 @@
 #include <KInputDialog>
 #include <nepomuk/resourcemanager.h>
 #include <kio/netaccess.h>
+#include <KMessageBox>
 
 #include "projectlist.h"
 #include "projectitem.h"
@@ -203,9 +204,10 @@ void ProjectList::slotRemoveClip()
   if (!m_commandStack) kDebug()<<"!!!!!!!!!!!!!!!!  NO CMD STK";
   if (!listView->currentItem()) return;
   ProjectItem *item = ((ProjectItem *)listView->currentItem());
-  AddClipCommand *command = new AddClipCommand(this, item->names(), item->toXml(), item->clipId(), KUrl(item->data(1, FullPathRole).toString()), item->groupName(), false);
+  if (!item) kDebug()<<"///////////////  ERROR NOT FOUND";
+  if (KMessageBox::questionYesNo(this, i18n("Delete clip <b>%1</b> ?").arg(item->names().at(1)), i18n("Delete Clip")) != KMessageBox::Yes) return;
+  AddClipCommand *command = new AddClipCommand(this, item->names(), item->toXml(), item->clipId(), item->clipUrl(), item->groupName(), false);
   m_commandStack->push(command);
-
 }
 
 void ProjectList::selectItemById(const int clipId)
@@ -446,6 +448,10 @@ void ProjectList::addProducer(QDomElement producer, int parentId)
   if (id >= m_clipIdCounter) m_clipIdCounter = id + 1;
   else if (id == 0) id = m_clipIdCounter++;
 
+  if (parentId != -1) {
+    // item is a westley playlist, adjust subproducers ids 
+    id = (parentId + 1) * 10000 + id;
+  }
   if (type == DocClipBase::AUDIO || type == DocClipBase::VIDEO || type == DocClipBase::AV || type == DocClipBase::IMAGE  || type == DocClipBase::PLAYLIST)
   {
     KUrl resource = KUrl(producer.attribute("resource"));
index a6338a024df93d8edb312eb8100829ada3aa77f0..83bb7a6f7ead392ca10bca8ad954b79067713506 100644 (file)
@@ -86,13 +86,13 @@ void ProjectListView::dropEvent(QDropEvent *event)
       if (item->parent()) item = item->parent();
       if (((ProjectItem *) item)->isGroup()) {
       //emit addClip(event->mimeData->text());
-      kDebug()<<"////////////////  DROPPED RIGHT 1";
+      kDebug()<<"////////////////  DROPPED RIGHT 1 ";
       QList <QTreeWidgetItem *> list;
       list = selectedItems ();
       ProjectItem *clone;
       foreach (QTreeWidgetItem *it, list) {
-       // TODO allow dragging of folders
-       if (!((ProjectItem *) it)->isGroup()) {
+       // TODO allow dragging of folders ?
+       if (!((ProjectItem *) it)->isGroup() && ((ProjectItem *) it)->clipId() < 10000) {
          if (it->parent()) clone = (ProjectItem* ) it->parent()->takeChild(it->parent()->indexOfChild(it));
          else clone = (ProjectItem* ) takeTopLevelItem(indexOfTopLevelItem(it));
          if (clone) item->addChild(clone);
@@ -109,7 +109,7 @@ void ProjectListView::dropEvent(QDropEvent *event)
       ProjectItem *clone;
       foreach (QTreeWidgetItem *it, list) {
          QTreeWidgetItem *parent = it->parent();
-         if (parent)  {
+         if (parent && ((ProjectItem *) it)->clipId() < 10000)  {
            kDebug()<<"++ item parent: "<<parent->text(1);
            clone = (ProjectItem* ) parent->takeChild(parent->indexOfChild(it));
            if (clone) addTopLevelItem(clone);