3 #include <QStylePainter>
11 #include "projectitem.h"
14 const int NameRole = Qt::UserRole;
15 const int DurationRole = NameRole + 1;
16 const int FullPathRole = NameRole + 2;
17 const int ClipTypeRole = NameRole + 3;
19 ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, QDomElement xml, int clipId)
20 : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_element(xml), m_clipType(DocClipBase::NONE), m_clipId(clipId)
22 setSizeHint(0, QSize(65, 45));
23 setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled);
24 if (!m_element.isNull()) {
25 m_element.setAttribute("id", clipId);
26 QString cType = m_element.attribute("type", QString::null);
27 if (!cType.isEmpty()) {
28 m_clipType = (DocClipBase::CLIPTYPE) cType.toInt();
35 ProjectItem::~ProjectItem()
39 int ProjectItem::clipId()
44 QStringList ProjectItem::names()
47 result.append(text(0));
48 result.append(text(1));
49 result.append(text(2));
53 QDomElement ProjectItem::toXml()
58 void ProjectItem::slotSetToolTip()
60 QString tip = "<qt><b>";
63 tip.append(i18n("Audio clip"));
66 tip.append(i18n("Mute video clip"));
69 tip.append(i18n("Video clip"));
72 tip.append(i18n("Color clip"));
73 setData(1, DurationRole, Timecode::getEasyTimecode(GenTime(m_element.attribute("out", "250").toInt(), 25), 25));
76 tip.append(i18n("Image clip"));
79 tip.append(i18n("Text clip"));
82 tip.append(i18n("Slideshow clip"));
85 tip.append(i18n("Virtual clip"));
88 tip.append(i18n("Playlist clip"));
91 tip.append(i18n("Unknown clip"));
98 void ProjectItem::setProperties(const QMap < QString, QString > &attributes, const QMap < QString, QString > &metadata)
100 if (attributes.contains("duration")) {
101 m_duration = GenTime(attributes["duration"].toInt(), 25);
102 setData(1, DurationRole, Timecode::getEasyTimecode(m_duration, 25));
103 m_durationKnown = true;
105 // No duration known, use an arbitrary one until it is.
106 m_duration = GenTime(0.0);
107 m_durationKnown = false;
111 //extend attributes -reh
113 if (m_clipType == DocClipBase::NONE) {
114 if (attributes.contains("type")) {
115 if (attributes["type"] == "audio")
116 m_clipType = DocClipBase::AUDIO;
117 else if (attributes["type"] == "video")
118 m_clipType = DocClipBase::VIDEO;
119 else if (attributes["type"] == "av")
120 m_clipType = DocClipBase::AV;
121 else if (attributes["type"] == "playlist")
122 m_clipType = DocClipBase::PLAYLIST;
124 m_clipType = DocClipBase::AV;
129 if (m_element.isNull()) {
131 m_element = doc.createElement("producer");
133 m_element.setAttribute("resource", attributes["filename"]);
134 m_element.setAttribute("type", (int) m_clipType);
136 if (attributes.contains("height")) {
137 m_height = attributes["height"].toInt();
141 if (attributes.contains("width")) {
142 m_width = attributes["width"].toInt();
147 if (attributes.contains("name")) {
148 m_decompressor = attributes["name"];
150 m_decompressor = "n/a";
152 //video type ntsc/pal
153 if (attributes.contains("system")) {
154 m_system = attributes["system"];
158 if (attributes.contains("fps")) {
159 m_framesPerSecond = attributes["fps"].toInt();
161 // No frame rate known.
162 m_framesPerSecond = 0;
164 //audio attributes -reh
165 if (attributes.contains("channels")) {
166 m_channels = attributes["channels"].toInt();
170 if (attributes.contains("format")) {
171 m_format = attributes["format"];
175 if (attributes.contains("frequency")) {
176 m_frequency = attributes["frequency"].toInt();
180 if (attributes.contains("videocodec")) {
181 m_videoCodec = attributes["videocodec"];
183 if (attributes.contains("audiocodec")) {
184 m_audioCodec = attributes["audiocodec"];
187 m_metadata = metadata;
189 if (m_metadata.contains("description")) {
190 setDescription (m_metadata["description"]);
192 else if (m_metadata.contains("comment")) {
193 setDescription (m_metadata["comment"]);
199 #include "projectitem.moc"