]> git.sesse.net Git - kdenlive/blobdiff - src/projectitem.cpp
* Fix wrong resizing in composite transition when using "Fit to width / height"
[kdenlive] / src / projectitem.cpp
index 1f26d0f7ceb88ef2c9b68d05e1f57b7dac4908eb..bf02065b2d8a4be2169d661b0b26d1e246c7c55b 100644 (file)
 #include <KIcon>
 
 const int DurationRole = Qt::UserRole + 1;
+const int ProxyRole = Qt::UserRole + 5;
 const int itemHeight = 38;
 
 ProjectItem::ProjectItem(QTreeWidget * parent, DocClipBase *clip) :
+        m_clip(clip),
+        m_clipId(clip->getId()),
         QTreeWidgetItem(parent, PROJECTCLIPTYPE)
 {
-    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) :
+        m_clip(clip),
+        m_clipId(clip->getId()),
         QTreeWidgetItem(parent, PROJECTCLIPTYPE)
+        
+{
+    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();
@@ -65,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()
 {
 }
@@ -238,3 +230,21 @@ void ProjectItem::setProperties(const QMap < QString, QString > &attributes, con
     }
 }
 
+void ProjectItem::setProxyStatus(int 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();
+}
+
+bool ProjectItem::isProxyRunning() const
+{
+     return (data(0, ProxyRole).toInt() == 1);
+}
+