#include "projectitem.h"
#include "timecode.h"
+
const int NameRole = Qt::UserRole;
const int DurationRole = NameRole + 1;
const int FullPathRole = NameRole + 2;
const int ClipTypeRole = NameRole + 3;
ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, QDomElement xml, int clipId)
- : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(DocClipBase::NONE), m_clipId(clipId), m_isGroup(false), m_groupName(QString::null)
+ : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(UNKNOWN), m_clipId(clipId), m_isGroup(false), m_groupName(QString::null)
{
m_element = xml.cloneNode().toElement();
setSizeHint(0, QSize(65, 45));
m_element.setAttribute("id", clipId);
QString cType = m_element.attribute("type", QString::null);
if (!cType.isEmpty()) {
- m_clipType = (DocClipBase::CLIPTYPE) cType.toInt();
+ m_clipType = (CLIPTYPE) cType.toInt();
slotSetToolTip();
}
+
+ if (m_clipType == COLOR || m_clipType == IMAGE) m_element.setAttribute("duration", MAXCLIPDURATION);
+ else if (m_element.attribute("duration").isEmpty() && !m_element.attribute("out").isEmpty()) {
+ m_element.setAttribute("duration", m_element.attribute("out").toInt() - m_element.attribute("in").toInt());
+ }
}
}
ProjectItem::ProjectItem(QTreeWidgetItem * parent, const QStringList & strings, QDomElement xml, int clipId)
- : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(DocClipBase::NONE), m_clipId(clipId), m_isGroup(false), m_groupName(QString::null)
+ : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(UNKNOWN), m_clipId(clipId), m_isGroup(false), m_groupName(QString::null)
{
m_element = xml.cloneNode().toElement();
setSizeHint(0, QSize(65, 45));
m_element.setAttribute("id", clipId);
QString cType = m_element.attribute("type", QString::null);
if (!cType.isEmpty()) {
- m_clipType = (DocClipBase::CLIPTYPE) cType.toInt();
+ m_clipType = (CLIPTYPE) cType.toInt();
slotSetToolTip();
}
}
}
ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, int clipId)
- : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_element(QDomElement()), m_clipType(DocClipBase::NONE), m_clipId(clipId), m_isGroup(true), m_groupName(strings.at(1))
+ : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_element(QDomElement()), m_clipType(UNKNOWN), m_clipId(clipId), m_isGroup(true), m_groupName(strings.at(1))
{
setSizeHint(0, QSize(65, 45));
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled);
const KUrl ProjectItem::clipUrl() const
{
- if (m_clipType != DocClipBase::COLOR && m_clipType != DocClipBase::VIRTUAL && m_clipType != DocClipBase::NONE)
+ if (m_clipType != COLOR && m_clipType != VIRTUAL && m_clipType != UNKNOWN)
return KUrl(m_element.attribute("resouce"));
else return KUrl();
}
void ProjectItem::setProperties(const QMap < QString, QString > &attributes, const QMap < QString, QString > &metadata)
{
if (attributes.contains("duration")) {
- if (m_clipType == DocClipBase::AUDIO || m_clipType == DocClipBase::VIDEO || m_clipType == DocClipBase::AV) m_element.setAttribute("duration", attributes["duration"].toInt());
+ if (m_clipType == AUDIO || m_clipType == VIDEO || m_clipType == AV) m_element.setAttribute("duration", attributes["duration"].toInt());
m_duration = GenTime(attributes["duration"].toInt(), 25);
setData(1, DurationRole, Timecode::getEasyTimecode(m_duration, 25));
m_durationKnown = true;
//extend attributes -reh
- if (m_clipType == DocClipBase::NONE) {
+ if (m_clipType == UNKNOWN) {
if (attributes.contains("type")) {
if (attributes["type"] == "audio")
- m_clipType = DocClipBase::AUDIO;
+ m_clipType = AUDIO;
else if (attributes["type"] == "video")
- m_clipType = DocClipBase::VIDEO;
+ m_clipType = VIDEO;
else if (attributes["type"] == "av")
- m_clipType = DocClipBase::AV;
+ m_clipType = AV;
else if (attributes["type"] == "playlist")
- m_clipType = DocClipBase::PLAYLIST;
+ m_clipType = PLAYLIST;
} else {
- m_clipType = DocClipBase::AV;
+ m_clipType = AV;
}
}
slotSetToolTip();
if (m_element.isNull()) {
QDomDocument doc;
m_element = doc.createElement("producer");
- m_element.setAttribute("duration", attributes["duration"].toInt());
}
+ if (m_element.attribute("duration") == QString::null) m_element.setAttribute("duration", attributes["duration"].toInt());
m_element.setAttribute("resource", attributes["filename"]);
m_element.setAttribute("type", (int) m_clipType);
/*