]> git.sesse.net Git - kdenlive/commitdiff
* Make sure project tree is enabled when creating new project
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 8 Nov 2011 11:04:17 +0000 (12:04 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 8 Nov 2011 11:04:17 +0000 (12:04 +0100)
* Don't parse project tree like hell when creating proxy clips

src/projectlist.cpp
src/projectlist.h

index ce63215e13db5b75d00b1c222f92a5a896ee3b0f..6923f3896fec6c87ffa342eeabab1959a6c58144 100644 (file)
@@ -1172,6 +1172,7 @@ void ProjectList::slotResetProjectList()
     m_proxyThreads.clearFutures();
     m_thumbnailQueue.clear();
     m_listView->clear();
+    m_listView->setEnabled(true);
     emit clipSelected(NULL);
     m_refreshed = false;
     m_allClipsProcessed = false;
@@ -1665,11 +1666,11 @@ void ProjectList::slotCheckForEmptyQueue()
 {
     if (m_render->processingItems() == 0 && m_thumbnailQueue.isEmpty()) {
         if (!m_refreshed && m_allClipsProcessed) {
+            m_refreshed = true;
             m_listView->setEnabled(true);
             slotClipSelected();
             QTimer::singleShot(500, this, SIGNAL(loadingIsOver()));
             emit displayMessage(QString(), -1);
-            m_refreshed = true;
         }
         updateButtons();
     } else if (!m_refreshed) {
@@ -1837,17 +1838,16 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
             }
         } else {
             int max = m_doc->clipManager()->clipsCount();
-            emit displayMessage(i18n("Loading clips"), (int)(100 *(max - queue) / max));
+            if (max > 0) emit displayMessage(i18n("Loading clips"), (int)(100 *(max - queue) / max));
         }
         if (m_allClipsProcessed) emit processNextThumbnail();
     }
-    if (replace && item) {
-        toReload = clipId;
-    }
     if (!item) {
         // no item for producer, delete it
         delete producer;
+        return;
     }
+    if (replace) toReload = clipId;
     if (!toReload.isEmpty())
         emit clipNeedsReload(toReload);
 }
@@ -2338,6 +2338,19 @@ void ProjectList::slotGenerateProxy()
     QFile::remove(info.dest);
     
     setProxyStatus(info.dest, CREATINGPROXY);
+    
+    // Get the list of clips that will need to get progress info
+    QTreeWidgetItemIterator it(m_listView);
+    QList <ProjectItem *> processingItems;
+    while (*it && !m_abortAllProxies) {
+        if ((*it)->type() == PROJECTCLIPTYPE) {
+            ProjectItem *item = static_cast <ProjectItem *>(*it);
+            if (item->referencedClip()->getProperty("proxy") == info.dest) {
+                processingItems.append(item);
+            }
+        }
+        ++it;
+    }
 
     // Special case: playlist clips (.mlt or .kdenlive project files)
     if (info.type == PLAYLIST) {
@@ -2382,7 +2395,7 @@ void ProjectList::slotGenerateProxy()
             }
             else {
                 QString log = QString(myProcess.readAll());
-                processLogInfo(info.dest, &duration, log);
+                processLogInfo(processingItems, &duration, log);
             }
             myProcess.waitForFinished(500);
         }
@@ -2465,13 +2478,13 @@ void ProjectList::slotGenerateProxy()
     // Make sure we don't block when proxy file already exists
     parameters << "-y";
     parameters << info.dest;
-    kDebug()<<"// STARTING PROXY GEN: "<<parameters;
     QProcess myProcess;
     myProcess.setProcessChannelMode(QProcess::MergedChannels);
     myProcess.start("ffmpeg", parameters);
     myProcess.waitForStarted();
     int result = -1;
     int duration = 0;
+   
     while (myProcess.state() != QProcess::NotRunning) {
         // building proxy file
         if (m_abortProxy.contains(info.dest) || m_abortAllProxies) {
@@ -2486,11 +2499,13 @@ void ProjectList::slotGenerateProxy()
         }
         else {
             QString log = QString(myProcess.readAll());
-            processLogInfo(info.dest, &duration, log);
+            processLogInfo(processingItems, &duration, log);
         }
         myProcess.waitForFinished(500);
     }
     myProcess.waitForFinished();
+    m_abortProxy.removeAll(info.dest);
+    m_processingProxy.removeAll(info.dest);
     if (result == -1) result = myProcess.exitStatus();
     if (result == 0) {
         // proxy successfully created
@@ -2502,12 +2517,10 @@ void ProjectList::slotGenerateProxy()
         QFile::remove(info.dest);
         setProxyStatus(info.dest, PROXYCRASHED);
     }
-    m_abortProxy.removeAll(info.dest);
-    m_processingProxy.removeAll(info.dest);
 }
 
 
-void ProjectList::processLogInfo(const QString &path, int *duration, const QString &log)
+void ProjectList::processLogInfo(QList <ProjectItem *>items, int *duration, const QString &log)
 {
     int progress;
     if (*duration == 0) {
@@ -2524,7 +2537,8 @@ void ProjectList::processLogInfo(const QString &path, int *duration, const QStri
             progress = numbers.at(0).toInt() * 3600 + numbers.at(1).toInt() * 60 + numbers.at(2).toDouble();
         }
         else progress = (int) time.toDouble();
-        setProxyStatus(path, CREATINGPROXY, (int) (100.0 * progress / (*duration)));
+        for (int i = 0; i < items.count(); i++)
+            setProxyStatus(items.at(i), CREATINGPROXY, (int) (100.0 * progress / (*duration)));
     }
 }
 
index 2bc2f950a962f411956744f1b12c894f325207ad..6f1815e44506c074393550c6a95efd609bff0466 100644 (file)
@@ -338,7 +338,7 @@ private:
     void setProxyStatus(const QString proxyPath, PROXYSTATUS status, int progress = 0);
     void setProxyStatus(ProjectItem *item, PROXYSTATUS status, int progress = 0);
     /** @brief Process ffmpeg output to find out process progress. */
-    void processLogInfo(const QString &path, int *duration, const QString &log);
+    void processLogInfo(QList <ProjectItem *>items, int *duration, const QString &log);
     void monitorItemEditing(bool enable);
     /** @brief Set thumbnail for a project's clip. */
     void setThumbnail(const QString &clipId, const QPixmap &pix);