]> git.sesse.net Git - kdenlive/commitdiff
improve handling of missing luma files:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 6 Jul 2011 00:12:50 +0000 (00:12 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 6 Jul 2011 00:12:50 +0000 (00:12 +0000)
http://kdenlive.org/mantis/view.php?id=2216

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

src/documentchecker.cpp

index 153cceaaa5cb4fe15324ae8030bf08b022bd0b80..7b36f7784d45edb340d22f1e26c7fe0720a27b1c 100644 (file)
@@ -137,8 +137,9 @@ bool DocumentChecker::hasErrorInClips()
     for (int i = 0; i < trans.count(); i++) {
         QString luma = getProperty(trans.at(i).toElement(), "luma");
         if (!luma.isEmpty()) {
-            if (!luma.startsWith('/')) luma.prepend(root);
-            if (!QFile::exists(luma) && !missingLumas.contains(luma)) {
+            QString lumaPath = luma;
+            if (!lumaPath.startsWith('/')) lumaPath.prepend(root);
+            if (!QFile::exists(lumaPath) && !missingLumas.contains(luma)) {
                 missingLumas.append(luma);
             }
         }
@@ -418,6 +419,13 @@ QString DocumentChecker::searchLuma(QString file) const
     else
         searchPath.cd("../lumas/NTSC");
     QString result = searchPath.path(KUrl::AddTrailingSlash) + KUrl(file).fileName();
+    if (QFile::exists(result))
+        return result;
+    // try to find luma in application path
+    searchPath.clear();
+    searchPath = KUrl(QCoreApplication::applicationDirPath());
+    searchPath.cd("../share/apps/kdenlive/lumas");
+    result = searchPath.path(KUrl::AddTrailingSlash) + KUrl(file).fileName();
     if (QFile::exists(result))
         return result;
     return QString();
@@ -576,6 +584,7 @@ void DocumentChecker::acceptDialog()
         } else if (child->data(0, statusRole).toInt() == LUMAOK) {
             for (int i = 0; i < trans.count(); i++) {
                 QString luma = getProperty(trans.at(i).toElement(), "luma");
+                
                 kDebug() << "luma: " << luma;
                 if (!luma.isEmpty() && luma == child->data(0, idRole).toString()) {
                     setProperty(trans.at(i).toElement(), "luma", child->text(1));
@@ -665,15 +674,32 @@ void DocumentChecker::slotDeleteSelected()
     if (KMessageBox::warningContinueCancel(m_dialog, i18np("This will remove the selected clip from this project", "This will remove the selected clips from this project", m_ui.treeWidget->selectedItems().count()), i18n("Remove clips")) == KMessageBox::Cancel)
         return;
     QStringList deletedIds;
+    QStringList deletedLumas;
     QDomNodeList playlists = m_doc.elementsByTagName("playlist");
 
     foreach(QTreeWidgetItem *child, m_ui.treeWidget->selectedItems()) {
-        if (child->data(0, statusRole).toInt() < 10) {
+        int id = child->data(0, statusRole).toInt();
+        if (id == CLIPMISSING) {
             deletedIds.append(child->data(0, idRole).toString());
             delete child;
         }
+        else if (id == LUMAMISSING) {
+            deletedLumas.append(child->data(0, idRole).toString());
+            delete child;
+        }
+    }
+
+    if (!deletedLumas.isEmpty()) {
+        QDomElement e;
+        QDomNodeList transitions = m_doc.elementsByTagName("transition");
+        foreach (QString lumaPath, deletedLumas) {
+            for (int i = 0; i < transitions.count(); i++) {
+                e = transitions.item(i).toElement();
+                QString resource = EffectsList::property(e, "luma");
+                if (resource == lumaPath) EffectsList::removeProperty(e, "luma");
+            }
+        }
     }
-    kDebug() << "// Clips to delete: " << deletedIds;
 
     if (!deletedIds.isEmpty()) {
         QDomElement e;