]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.cpp
Check that the proxy has same length as original clip, otherwise mark it as "crashed...
[kdenlive] / src / projectlist.cpp
index 286121b30e698b919fb959822601d808cf4b671d..3ca48c99b7d2b5af156a5b6dd3e3d6b9860af396 100644 (file)
@@ -998,7 +998,6 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
     connect(clip, SIGNAL(abortProxy(const QString)), this, SLOT(slotAbortProxy(const QString)));
     if (getProperties) {
         m_listView->processLayout();
-        m_refreshed = false;
         QDomElement e = clip->toXML().cloneNode().toElement();
         e.removeAttribute("file_hash");
         m_infoQueue.insert(clip->getId(), e);
@@ -1085,7 +1084,6 @@ void ProjectList::slotResetProjectList()
 
 void ProjectList::requestClipInfo(const QDomElement xml, const QString id)
 {
-    m_refreshed = false;
     m_infoQueue.insert(id, xml);
     //if (m_infoQueue.count() == 1 || ) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
 }
@@ -1297,10 +1295,12 @@ void ProjectList::slotRemoveInvalidClip(const QString &id, bool replace)
     }
 }
 
-void ProjectList::slotRemoveInvalidProxy(const QString &id)
+void ProjectList::slotRemoveInvalidProxy(const QString &id, bool durationError)
 {
     ProjectItem *item = getItemById(id);
     if (item) {
+        //TODO: use durationError to display correct message to user after 0.8 release
+        if (durationError) kDebug() << "Proxy duration is wrong, try changing transcoding parameters.";
         item->setProxyStatus(PROXYCRASHED);
         QString path = item->referencedClip()->getProperty("proxy");
         KUrl proxyFolder(m_doc->projectFolder().path( KUrl::AddTrailingSlash) + "proxy/");
@@ -1434,10 +1434,12 @@ void ProjectList::setDocument(KdenliveDoc *doc)
     m_proxyList.clear();
 
     QMap <QString, QString> flist = doc->clipManager()->documentFolderList();
+    QStringList openedFolders = doc->getExpandedFolders();
     QMapIterator<QString, QString> f(flist);
     while (f.hasNext()) {
         f.next();
-        (void) new FolderProjectItem(m_listView, QStringList() << f.value(), f.key());
+        FolderProjectItem *folder = new FolderProjectItem(m_listView, QStringList() << f.value(), f.key());
+        folder->setExpanded(openedFolders.contains(f.key()));
     }
 
     QList <DocClipBase*> list = doc->clipManager()->documentClipList();
@@ -1481,7 +1483,7 @@ QDomElement ProjectList::producersList()
 
 void ProjectList::slotCheckForEmptyQueue()
 {
-    if (!m_refreshed && m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) {
+    if (!m_refreshed && m_processingClips.isEmpty() && m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) {
         m_refreshed = true;
         emit loadingIsOver();
         emit displayMessage(QString(), -1);
@@ -1593,6 +1595,10 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
 {
     QString toReload;
     ProjectItem *item = getItemById(clipId);
+    if (!m_refreshed) {
+        // we are still finishing to load the document
+        selectClip = false;
+    }
     m_processingClips.removeAll(clipId);
     if (m_infoQueue.isEmpty() && m_processingClips.isEmpty()) m_listView->setEnabled(true);
     if (item && producer) {
@@ -1615,6 +1621,8 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
                 QString proxydir = m_doc->projectFolder().path( KUrl::AddTrailingSlash) + "proxy/";
                 QMap <QString, QString> newProps;
                 newProps.insert("proxy", proxydir + item->referencedClip()->getClipHash() + "." + m_doc->getDocumentProperty("proxyextension"));
+                // insert required duration for proxy
+                newProps.insert("proxy_out", item->referencedClip()->producerProperty("out"));
                 QMap <QString, QString> oldProps = clip->properties();
                 oldProps.insert("proxy", QString());
                 EditClipCommand *command = new EditClipCommand(this, clipId, oldProps, newProps, true);
@@ -2269,6 +2277,8 @@ void ProjectList::updateProxyConfig()
                 QMap <QString, QString> newProps;
                 newProps.insert("proxy", QString());
                 newProps.insert("replace", "1");
+                // insert required duration for proxy
+                newProps.insert("proxy_out", item->referencedClip()->producerProperty("out"));
                 new EditClipCommand(this, item->clipId(), item->referencedClip()->properties(), newProps, true, command);
             }
         }
@@ -2334,6 +2344,8 @@ void ProjectList::slotProxyCurrentItem(bool doProxy)
                     newProps.clear();
                     QString path = proxydir + item->referencedClip()->getClipHash() + "." + (t == IMAGE ? "png" : m_doc->getDocumentProperty("proxyextension"));
                     newProps.insert("proxy", path);
+                    // insert required duration for proxy
+                    newProps.insert("proxy_out", item->referencedClip()->producerProperty("out"));
                     // We need to insert empty proxy so that undo will work
                     oldProps.insert("proxy", QString());
                 }
@@ -2368,4 +2380,23 @@ void ProjectList::monitorItemEditing(bool enable)
     else disconnect(m_listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotItemEdited(QTreeWidgetItem *, int)));     
 }
 
+QStringList ProjectList::expandedFolders() const
+{
+    QStringList result;
+    FolderProjectItem *item;
+    QTreeWidgetItemIterator it(m_listView);
+    while (*it) {
+        if ((*it)->type() != PROJECTFOLDERTYPE) {
+            ++it;
+            continue;
+        }
+        if ((*it)->isExpanded()) {
+            item = static_cast<FolderProjectItem *>(*it);
+            result.append(item->clipId());
+        }
+        ++it;
+    }
+    return result;
+}
+
 #include "projectlist.moc"