]> git.sesse.net Git - kdenlive/commitdiff
Prepare checking of removed / deleted files in a project:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 11 Apr 2010 15:52:29 +0000 (15:52 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 11 Apr 2010 15:52:29 +0000 (15:52 +0000)
http://www.kdenlive.org/mantis/view.php?id=685

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

src/clipmanager.cpp
src/clipmanager.h

index 056bfce923bedeef0eb2fa0b50fb2c7689cfd2e2..13f2b1bd27d44ea7ce888b94b3d185749c44bfe5 100644 (file)
@@ -44,6 +44,8 @@ ClipManager::ClipManager(KdenliveDoc *doc) :
     m_clipIdCounter = 1;
     m_folderIdCounter = 1;
     connect(&m_fileWatcher, SIGNAL(dirty(const QString &)), this, SLOT(slotClipModified(const QString &)));
+    connect(&m_fileWatcher, SIGNAL(deleted(const QString &)), this, SLOT(slotClipMissing(const QString &)));
+    connect(&m_fileWatcher, SIGNAL(created(const QString &)), this, SLOT(slotClipAvailable(const QString &)));
 }
 
 ClipManager::~ClipManager()
@@ -140,8 +142,9 @@ QMap <QString, QString> ClipManager::documentFolderList() const
 void ClipManager::addClip(DocClipBase *clip)
 {
     m_clipList.append(clip);
-    if (clip->clipType() == IMAGE || clip->clipType() == AUDIO || (clip->clipType() == TEXT && !clip->fileURL().isEmpty())) {
+    if (clip->clipType() != COLOR && clip->clipType() != SLIDESHOW  && !clip->fileURL().isEmpty()) {
         // listen for file change
+        //kDebug() << "// LISTEN FOR: " << clip->fileURL().path();
         m_fileWatcher.addFile(clip->fileURL().path());
     }
     const QString id = clip->getId();
@@ -168,7 +171,8 @@ void ClipManager::deleteClip(const QString &clipId)
 {
     for (int i = 0; i < m_clipList.count(); i++) {
         if (m_clipList.at(i)->getId() == clipId) {
-            if (m_clipList.at(i)->clipType() == IMAGE || m_clipList.at(i)->clipType() == AUDIO || (m_clipList.at(i)->clipType() == TEXT && !m_clipList.at(i)->fileURL().isEmpty())) {
+            if (m_clipList.at(i)->clipType() != COLOR && m_clipList.at(i)->clipType() != SLIDESHOW  && !m_clipList.at(i)->fileURL().isEmpty()) {
+                //if (m_clipList.at(i)->clipType() == IMAGE || m_clipList.at(i)->clipType() == AUDIO || (m_clipList.at(i)->clipType() == TEXT && !m_clipList.at(i)->fileURL().isEmpty())) {
                 // listen for file change
                 m_fileWatcher.removeFile(m_clipList.at(i)->fileURL().path());
             }
@@ -518,7 +522,7 @@ QDomElement ClipManager::groupsXml() const
 
 void ClipManager::slotClipModified(const QString &path)
 {
-    //kDebug()<<"// CLIP: "<<path<<" WAS MODIFIED";
+    // kDebug() << "// CLIP: " << path << " WAS MODIFIED";
     const QList <DocClipBase *> list = getClipByResource(path);
     for (int i = 0; i < list.count(); i++) {
         DocClipBase *clip = list.at(i);
@@ -526,6 +530,26 @@ void ClipManager::slotClipModified(const QString &path)
     }
 }
 
+void ClipManager::slotClipMissing(const QString &path)
+{
+    // kDebug() << "// CLIP: " << path << " WAS MISSING";
+    const QList <DocClipBase *> list = getClipByResource(path);
+    for (int i = 0; i < list.count(); i++) {
+        DocClipBase *clip = list.at(i);
+        if (clip != NULL) emit missingClip(clip->getId());
+    }
+}
+
+void ClipManager::slotClipAvailable(const QString &path)
+{
+    // kDebug() << "// CLIP: " << path << " WAS ADDED";
+    const QList <DocClipBase *> list = getClipByResource(path);
+    for (int i = 0; i < list.count(); i++) {
+        DocClipBase *clip = list.at(i);
+        if (clip != NULL) emit availableClip(clip->getId());
+    }
+}
+
 int ClipManager::clipsCount() const
 {
     return m_clipList.count();
index 09d2c2c08c0cedf691c6648cba4e13a2070e78f6..b3f06e649ccbfdf7c7be89bca8efa3bbf46f49d4 100644 (file)
@@ -90,6 +90,8 @@ public slots:
 
 private slots:
     void slotClipModified(const QString &path);
+    void slotClipMissing(const QString &path);
+    void slotClipAvailable(const QString &path);
 
 private:   // Private attributes
     /** the list of clips in the document */
@@ -108,6 +110,8 @@ private:   // Private attributes
 
 signals:
     void reloadClip(const QString &);
+    void missingClip(const QString &);
+    void availableClip(const QString &);
     void checkAllClips();
 };