]> git.sesse.net Git - kdenlive/blobdiff - src/projectitem.cpp
Make 2 pass option available to custom profiles
[kdenlive] / src / projectitem.cpp
index 9de4b8e814f0170019b87e9e5b26209d2d62138f..018655c9f31038f5dfb19c22a1c92f10ed542828 100644 (file)
@@ -32,33 +32,27 @@ const int ProxyRole = Qt::UserRole + 5;
 const int itemHeight = 38;
 
 ProjectItem::ProjectItem(QTreeWidget * parent, DocClipBase *clip) :
-        QTreeWidgetItem(parent, PROJECTCLIPTYPE)
+        QTreeWidgetItem(parent, PROJECTCLIPTYPE),
+        m_clip(clip),
+        m_clipId(clip->getId())
 {
-    setSizeHint(0, QSize(itemHeight * 3, itemHeight));
-    if (clip->isPlaceHolder()) setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
-    else setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
-    m_clip = clip;
-    m_clipId = clip->getId();
-    QString name = m_clip->getProperty("name");
-    if (name.isEmpty()) name = KUrl(m_clip->getProperty("resource")).fileName();
-    m_clipType = (CLIPTYPE) m_clip->getProperty("type").toInt();
-    if (m_clipType != UNKNOWN) slotSetToolTip();
-    setText(0, name);
-    setText(1, m_clip->description());
-    GenTime duration = m_clip->duration();
-    if (duration != GenTime()) setData(0, DurationRole, Timecode::getEasyTimecode(duration, KdenliveSettings::project_fps()));
-    //setFlags(Qt::NoItemFlags);
-    //kDebug() << "Constructed with clipId: " << m_clipId;
+    buildItem();
 }
 
 ProjectItem::ProjectItem(QTreeWidgetItem * parent, DocClipBase *clip) :
-        QTreeWidgetItem(parent, PROJECTCLIPTYPE)
+        QTreeWidgetItem(parent, PROJECTCLIPTYPE),
+        m_clip(clip),
+        m_clipId(clip->getId())
+        
+{
+    buildItem();
+}
+
+void ProjectItem::buildItem()
 {
     setSizeHint(0, QSize(itemHeight * 3, itemHeight));
-    if (clip->isPlaceHolder()) setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
+    if (m_clip->isPlaceHolder()) setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
     else setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
-    m_clip = clip;
-    m_clipId = clip->getId();
     QString name = m_clip->getProperty("name");
     if (name.isEmpty()) name = KUrl(m_clip->getProperty("resource")).fileName();
     m_clipType = (CLIPTYPE) m_clip->getProperty("type").toInt();
@@ -66,11 +60,8 @@ ProjectItem::ProjectItem(QTreeWidgetItem * parent, DocClipBase *clip) :
     setText(1, m_clip->description());
     GenTime duration = m_clip->duration();
     if (duration != GenTime()) setData(0, DurationRole, Timecode::getEasyTimecode(duration, KdenliveSettings::project_fps()));
-    //setFlags(Qt::NoItemFlags);
-    //kDebug() << "Constructed with clipId: " << m_clipId;
 }
 
-
 ProjectItem::~ProjectItem()
 {
 }
@@ -239,21 +230,27 @@ void ProjectItem::setProperties(const QMap < QString, QString > &attributes, con
     }
 }
 
-void ProjectItem::setProxyStatus(int status)
+void ProjectItem::setProxyStatus(PROXYSTATUS status)
 {
-    if (status == data(0, ProxyRole).toInt()) return;
     setData(0, ProxyRole, status);
-    if (m_clip && status == 0) m_clip->abortProxy();
 }
 
 bool ProjectItem::hasProxy() const
 {
     if (m_clip == NULL) return false;
-    return !m_clip->getProperty("proxy").isEmpty();
+    if (m_clip->getProperty("proxy").isEmpty() || m_clip->getProperty("proxy") == "-" || data(0, ProxyRole).toInt() == PROXYCRASHED) return false;
+    return true;
+}
+
+bool ProjectItem::isProxyReady() const
+{
+     return (data(0, ProxyRole).toInt() == PROXYDONE);
 }
 
 bool ProjectItem::isProxyRunning() const
 {
-     return (data(0, ProxyRole).toInt() == 1);
+    PROXYSTATUS s = (PROXYSTATUS) data(0, ProxyRole).toInt();
+    if (s == PROXYWAITING || s == CREATINGPROXY) return true;
+    return false;
 }