]> git.sesse.net Git - kdenlive/commitdiff
Fix handling of invalid clips when opening a project
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 8 Apr 2009 22:43:22 +0000 (22:43 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 8 Apr 2009 22:43:22 +0000 (22:43 +0000)
svn path=/trunk/kdenlive/; revision=3262

src/docclipbase.h
src/kdenlivedoc.cpp
src/projectitem.cpp
src/projectlist.cpp
src/projectlistview.cpp
src/trackview.cpp

index 2f52b72547f976d18f385cac2e8471f25000b29a..ce847f5413ace74b3f4a700f1de7ac98779e9b42 100644 (file)
@@ -56,7 +56,7 @@ Q_OBJECT public:
      *   done here. If a new clip type is added then it should be possible to combine it with both audio
      *   and video. */
 
-    DocClipBase(ClipManager *clipManager, QDomElement xml, const QString &id);
+    DocClipBase(ClipManager *clipManager, QDomElement xml, const QString &id, bool placeHolder = false);
 //    DocClipBase & operator=(const DocClipBase & clip);
     virtual ~ DocClipBase();
 
@@ -180,6 +180,9 @@ Q_OBJECT public:
     /** Get default play zone for clip monitor */
     QPoint zone() const;
 
+    /** Returns true is clip is missing but user wants to keep it as placeholder */
+    bool isPlaceHolder() const;
+
 private:   // Private attributes
 
     /** A description of this clip */
@@ -205,6 +208,10 @@ private:   // Private attributes
 
     /** a unique numeric id */
     QString m_id;
+
+    /** Wheter the clip is a placeholder (clip missing but user wants to see it) */
+    bool m_placeHolder;
+
     void setAudioThumbCreated(bool isDone);
     /** Holds clip infos like fps, size,... */
     QMap <QString, QString> m_properties;
index 312ef1555f0d336967320d109c0f4019a47fe3e7..af49bf710daf189a0d05081611cc053c359b2385 100644 (file)
@@ -1380,6 +1380,7 @@ void KdenliveDoc::addClip(QDomElement elem, QString clipId, bool createClipItem)
 {
     const QString producerId = clipId.section('_', 0, 0);
     DocClipBase *clip = m_clipManager->getClipById(producerId);
+    bool placeHolder = false;
     if (clip == NULL) {
         elem.setAttribute("id", producerId);
         QString path = elem.attribute("resource");
@@ -1411,6 +1412,7 @@ void KdenliveDoc::addClip(QDomElement elem, QString clipId, bool createClipItem)
             setNewClipResource(clipId, titleresource);
             delete dia_ui;
         }
+
         if (path.isEmpty() == false && QFile::exists(path) == false && elem.attribute("type").toInt() != TEXT) {
             kDebug() << "// FOUND MISSING CLIP: " << path << ", TYPE: " << elem.attribute("type").toInt();
             const QString size = elem.attribute("file_size");
@@ -1425,17 +1427,17 @@ void KdenliveDoc::addClip(QDomElement elem, QString clipId, bool createClipItem)
                     int res = KMessageBox::questionYesNoCancel(kapp->activeWindow(), i18n("Clip <b>%1</b><br>is invalid or missing, what do you want to do?", path), i18n("File not found"), KGuiItem(i18n("Search manually")), KGuiItem(i18n("Keep as placeholder")));
                     if (res == KMessageBox::Yes)
                         newpath = KFileDialog::getExistingDirectory(KUrl("kfiledialog:///clipfolder"), kapp->activeWindow(), i18n("Looking for %1", path));
-                    else if (res == KMessageBox::Cancel) {
+                    else {
                         // Abort project loading
-                        action = KMessageBox::Cancel;
+                        action = res;
                     }
                 } else {
                     int res = KMessageBox::questionYesNoCancel(kapp->activeWindow(), i18n("Clip <b>%1</b><br>is invalid or missing, what do you want to do?", path), i18n("File not found"), KGuiItem(i18n("Search manually")), KGuiItem(i18n("Keep as placeholder")));
                     if (res == KMessageBox::Yes)
                         newpath = KFileDialog::getOpenFileName(KUrl("kfiledialog:///clipfolder"), QString(), kapp->activeWindow(), i18n("Looking for %1", path));
-                    else if (res == KMessageBox::Cancel) {
+                    else {
                         // Abort project loading
-                        action = KMessageBox::Cancel;
+                        action = res;
                     }
                 }
             }
@@ -1448,6 +1450,9 @@ void KdenliveDoc::addClip(QDomElement elem, QString clipId, bool createClipItem)
             } else if (action == KMessageBox::Cancel) {
                 m_abortLoading = true;
                 return;
+            } else if (action == KMessageBox::No) {
+                // Keep clip as placeHolder
+                placeHolder = true;
             }
             if (!newpath.isEmpty()) {
                 if (elem.attribute("type").toInt() == SLIDESHOW) newpath.append('/' + extension);
@@ -1456,7 +1461,7 @@ void KdenliveDoc::addClip(QDomElement elem, QString clipId, bool createClipItem)
                 setModified(true);
             }
         }
-        clip = new DocClipBase(m_clipManager, elem, producerId);
+        clip = new DocClipBase(m_clipManager, elem, producerId, placeHolder);
         m_clipManager->addClip(clip);
     }
 
index e1d66920eee7ee5ddf9e5c562335f33f6446beaa..c7abb63727836af083be4a7d34e43abc4876f33b 100644 (file)
@@ -207,7 +207,7 @@ void ProjectItem::slotSetToolTip()
         tip.append(i18n("Text clip") + "</b><br />" + clipUrl().path());
         break;
     case SLIDESHOW:
-        tip.append(i18n("Slideshow clip"));
+        tip.append(i18n("Slideshow clip") + "</b><br />" + clipUrl().directory());
         break;
     case VIRTUAL:
         tip.append(i18n("Virtual clip"));
index 9e984fee358ba566b953522e9b4237468899e5ce..44c200ae2bf202727947340f498e6eeada08e8df 100644 (file)
@@ -179,6 +179,7 @@ void ProjectList::setHeaderInfo(const QByteArray &state)
 void ProjectList::slotEditClip()
 {
     ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
+    if (!(item->flags() & Qt::ItemIsDragEnabled)) return;
     if (item && !item->isGroup()) {
         emit clipSelected(item->referencedClip());
         emit showClipProperties(item->referencedClip());
@@ -548,7 +549,8 @@ void ProjectList::updateAllClips()
                     pix.save(clip->fileURL().path());
                     delete dia_ui;
                 }
-                requestClipInfo(clip->toXML(), clip->getId());
+                if (clip->isPlaceHolder() == false) requestClipInfo(clip->toXML(), clip->getId());
+                else item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
             } else {
                 QString cachedPixmap = m_doc->projectFolder().path() + "/thumbs/" + item->getClipHash() + ".png";
                 if (QFile::exists(cachedPixmap)) {
index cc71757265d3acbb712e1dcade6c88c0f6c53f15..6b2b5abb2826365f8b781e57aa2b4c352d4e562c 100644 (file)
@@ -116,6 +116,7 @@ void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event)
 {
     ProjectItem *item = static_cast <ProjectItem *>(itemAt(event->pos()));
     if (!item) emit addClip();
+    if (!(item->flags() & Qt::ItemIsDragEnabled)) return;
     else if (item->isGroup()) {
         if ((columnAt(event->pos().x()) == 1)) QTreeWidget::mouseDoubleClickEvent(event);
     } else {
@@ -220,8 +221,8 @@ void ProjectListView::mouseMoveEvent(QMouseEvent *event)
         return;
 
     {
-        ProjectItem *clickItem = (ProjectItem *) itemAt(m_DragStartPosition); //event->pos());
-        if (clickItem) {
+        ProjectItem *clickItem = static_cast <ProjectItem *>(itemAt(m_DragStartPosition));
+        if (clickItem && (clickItem->flags() & Qt::ItemIsDragEnabled)) {
             QDrag *drag = new QDrag(this);
             QMimeData *mimeData = new QMimeData;
             const QList <QTreeWidgetItem *> list = selectedItems();
index 9d8f42b39389776d1692bb2ee3392ebd0b673464..6a53e1908b417c0e5ced113ea09a797da6103993 100644 (file)
@@ -651,7 +651,7 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
                     producerXml.setAttribute("length", "15000");
                     producerXml.setAttribute("id", id);
                     missingClip = new DocClipBase(m_doc->clipManager(), producerXml, id);
-                    m_documentErrors.append(i18n("Boken clip producer %1", id) + '\n');
+                    m_documentErrors.append(i18n("Broken clip producer %1", id) + '\n');
                 } else m_documentErrors.append(i18n("Replaced wrong clip producer %1 with %2", id, missingClip->getId()) + '\n');
                 ClipItem *item = new ClipItem(missingClip, clipinfo, m_doc->fps(), 1.0, false);
                 m_scene->addItem(item);
@@ -692,16 +692,15 @@ DocClipBase *TrackView::getMissingProducer(const QString id) const
 
     QDomNodeList params = missingXml.childNodes();
     QString resource;
-    QString mlt_service;
     for (int j = 0; j < params.count(); j++) {
         QDomElement e = params.item(j).toElement();
         if (e.attribute("name") == "resource") {
             resource = e.firstChild().nodeValue();
-        } else if (e.attribute("name") == "mlt_service") {
-            mlt_service = e.firstChild().nodeValue();
+            break;
         }
     }
-    resource.prepend(docRoot);
+    // prepend westley document root if no path in clip resource and not a color clip
+    if (!resource.contains('/') && !resource.startsWith("0x")) resource.prepend(docRoot);
     DocClipBase *missingClip = NULL;
     if (!resource.isEmpty())
         missingClip = m_doc->clipManager()->getClipByResource(resource);