X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fprojectitem.cpp;h=018655c9f31038f5dfb19c22a1c92f10ed542828;hb=c8a0bb427a030b1dab68182426e58c3c651543df;hp=12b46be2bff0dde6d12d8a3b5fe4dcc3a74f9139;hpb=e7cc204174b626f1970483faf36ec6d9033b1a7f;p=kdenlive diff --git a/src/projectitem.cpp b/src/projectitem.cpp index 12b46be2..018655c9 100644 --- a/src/projectitem.cpp +++ b/src/projectitem.cpp @@ -28,36 +28,31 @@ #include const int DurationRole = Qt::UserRole + 1; +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); - else setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable); - 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); - else setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable); - m_clip = clip; - m_clipId = clip->getId(); + if (m_clip->isPlaceHolder()) setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled); + else setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled); 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,27 @@ void ProjectItem::setProperties(const QMap < QString, QString > &attributes, con } } +void ProjectItem::setProxyStatus(PROXYSTATUS status) +{ + setData(0, ProxyRole, 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() == PROXYCRASHED) return false; + return true; +} + +bool ProjectItem::isProxyReady() const +{ + return (data(0, ProxyRole).toInt() == PROXYDONE); +} + +bool ProjectItem::isProxyRunning() const +{ + PROXYSTATUS s = (PROXYSTATUS) data(0, ProxyRole).toInt(); + if (s == PROXYWAITING || s == CREATINGPROXY) return true; + return false; +} +