]> git.sesse.net Git - kdenlive/blobdiff - src/projectitem.cpp
* Fix missing proxy not re-created on project opening
[kdenlive] / src / projectitem.cpp
index 469d7e29a3b9db55caa9c2d235967896e2e533e1..6c08423650288d032d96007c1b8befa96cfc23d6 100644 (file)
@@ -30,7 +30,9 @@
 #include <QFile>
 
 const int DurationRole = Qt::UserRole + 1;
-const int ProxyRole = Qt::UserRole + 5;
+const int JobProgressRole = Qt::UserRole + 5;
+const int JobTypeRole = Qt::UserRole + 6;
+const int JobStatusMessage = Qt::UserRole + 7;
 const int itemHeight = 38;
 
 ProjectItem::ProjectItem(QTreeWidget * parent, DocClipBase *clip) :
@@ -167,14 +169,11 @@ void ProjectItem::slotSetToolTip()
 {
     QString tip;
     if (m_clip->isPlaceHolder()) tip.append(i18n("Missing") + " | ");
-    int s = data(0, ProxyRole).toInt();
-    if (s == CREATINGJOB || s > 0) {
-        tip.append(i18n("Building proxy clip") + " | ");
+    QString jobInfo = data(0, JobStatusMessage).toString();
+    if (!jobInfo.isEmpty()) {
+        tip.append(jobInfo + " | ");
     }
-    else if (s == JOBWAITING) {
-        tip.append(i18n("Waiting - proxy clip") + " | ");
-    }
-    else if (hasProxy()) {
+    if (hasProxy() && data(0, JobTypeRole).toInt() != PROXYJOB) {
         tip.append(i18n("Proxy clip") + " | ");
     }
     tip.append("<b>");
@@ -263,31 +262,47 @@ void ProjectItem::setProperties(const QMap < QString, QString > &attributes, con
     }
 }
 
-void ProjectItem::setProxyStatus(CLIPJOBSTATUS status, int progress)
+void ProjectItem::setJobStatus(JOBTYPE jobType, CLIPJOBSTATUS status, int progress, const QString &statusMessage)
 {
-    if (progress > 0) setData(0, ProxyRole, progress);
+    setData(0, JobTypeRole, jobType);
+    if (progress > 0) setData(0, JobProgressRole, progress);
     else {
-        setData(0, ProxyRole, status);
+        setData(0, JobProgressRole, status);
+        setData(0, JobStatusMessage, statusMessage);
         slotSetToolTip();
     }
 }
 
+void ProjectItem::setConditionalJobStatus(CLIPJOBSTATUS status, JOBTYPE requestedJobType)
+{
+    if (data(0, JobTypeRole).toInt() == requestedJobType) {
+        setData(0, JobProgressRole, status);
+    }
+}
+
 bool ProjectItem::hasProxy() const
 {
     if (m_clip == NULL) return false;
-    if (m_clip->getProperty("proxy").isEmpty() || m_clip->getProperty("proxy") == "-" || data(0, ProxyRole).toInt() == JOBCRASHED) return false;
+    if (m_clip->getProperty("proxy").size() < 2 || data(0, JobProgressRole).toInt() == JOBCRASHED) return false;
     return true;
 }
 
 bool ProjectItem::isProxyReady() const
 {
-     return (data(0, ProxyRole).toInt() == JOBDONE);
+     return (data(0, JobProgressRole).toInt() == JOBDONE);
+}
+
+bool ProjectItem::isJobRunning() const
+{
+    int s = data(0, JobProgressRole).toInt();
+    if (s == JOBWAITING || s == JOBWORKING || s > 0) return true;
+    return false;
 }
 
 bool ProjectItem::isProxyRunning() const
 {
-    int s = data(0, ProxyRole).toInt();
-    if (s == JOBWAITING || s == CREATINGJOB || s > 0) return true;
+    int s = data(0, JobProgressRole).toInt();
+    if ((s == JOBWORKING || s > 0) && data(0, JobTypeRole).toInt() == (int) PROXYJOB) return true;
     return false;
 }