From: Jean-Baptiste Mardelle Date: Sun, 11 Apr 2010 15:52:29 +0000 (+0000) Subject: Prepare checking of removed / deleted files in a project: X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=ead7176d2ab818ec3a1275aeca2b2fc0c1ea1276;p=kdenlive Prepare checking of removed / deleted files in a project: http://www.kdenlive.org/mantis/view.php?id=685 svn path=/trunk/kdenlive/; revision=4381 --- diff --git a/src/clipmanager.cpp b/src/clipmanager.cpp index 056bfce9..13f2b1bd 100644 --- a/src/clipmanager.cpp +++ b/src/clipmanager.cpp @@ -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 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: "< 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 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 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(); diff --git a/src/clipmanager.h b/src/clipmanager.h index 09d2c2c0..b3f06e64 100644 --- a/src/clipmanager.h +++ b/src/clipmanager.h @@ -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(); };