]> git.sesse.net Git - kdenlive/commitdiff
Fix "Clean project" and "Delete unused files" removing folders and check for duplicat...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 16 Oct 2009 18:30:10 +0000 (18:30 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 16 Oct 2009 18:30:10 +0000 (18:30 +0000)
http://kdenlive.org/mantis/view.php?id=1215

svn path=/trunk/kdenlive/; revision=4040

src/projectlist.cpp
src/projectsettings.cpp

index a697e5f7fc536da7571f5aa50262e43c3e39861b..638c34c260fd4d0f989bd6bd3e6774d6fbb17b8b 100644 (file)
@@ -221,7 +221,7 @@ void ProjectList::cleanup()
     ProjectItem *item;
     while (*it) {
         item = static_cast <ProjectItem *>(*it);
-        if (item->numReferences() == 0) item->setSelected(true);
+        if (!item->isGroup() && item->numReferences() == 0) item->setSelected(true);
         it++;
     }
     slotRemoveClip();
@@ -235,13 +235,24 @@ void ProjectList::trashUnusedClips()
     KUrl::List urls;
     while (*it) {
         item = static_cast <ProjectItem *>(*it);
-        if (item->numReferences() == 0) {
+        if (!item->isGroup() && item->numReferences() == 0) {
             ids << item->clipId();
             KUrl url = item->clipUrl();
             if (!url.isEmpty()) urls << url;
         }
         it++;
     }
+    // Check that we don't use the URL in another clip
+    QTreeWidgetItemIterator it2(m_listView);
+    while (*it2) {
+        item = static_cast <ProjectItem *>(*it2);
+        if (item->numReferences() > 0) {
+            KUrl url = item->clipUrl();
+            if (!url.isEmpty() && urls.contains(url)) urls.removeAll(url);
+        }
+        it2++;
+    }
+
     m_doc->deleteProjectClip(ids);
     for (int i = 0; i < urls.count(); i++) {
         KIO::NetAccess::del(urls.at(i), this);
index ebd4bbc14b0bd29048203ea236a3af6e17749dbc..51d1bcd1f6c110a55b88611b685606952e0bdd12 100644 (file)
@@ -84,6 +84,16 @@ void ProjectSettings::slotDeleteUnused()
             if (!url.isEmpty()) toDelete << url.path();
         }
     }
+
+    // make sure our urls are not used in another clip
+    for (int i = 0; i < list.count(); i++) {
+        DocClipBase *clip = list.at(i);
+        if (clip->numReferences() > 0) {
+            KUrl url = clip->fileURL();
+            if (!url.isEmpty() && toDelete.contains(url.path())) toDelete.removeAll(url.path());
+        }
+    }
+
     if (toDelete.count() == 0) {
         KMessageBox::sorry(this, i18n("No clip to delete"));
         return;