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 QString cType = m_element.attribute("type", 0);
25 if (!cType.isEmpty()) {
26 m_clipType = (DocClipBase::CLIPTYPE) cType.toInt();
32 ProjectItem::~ProjectItem()
36 int ProjectItem::clipId()
41 QStringList ProjectItem::names()
44 result.append(text(0));
45 result.append(text(1));
46 result.append(text(2));
50 QDomElement ProjectItem::toXml()
55 void ProjectItem::slotSetToolTip()
57 QString tip = "<qt><b>";
60 tip.append(i18n("Audio clip"));
63 tip.append(i18n("Mute video clip"));
66 tip.append(i18n("Video clip"));
69 tip.append(i18n("Color clip"));
70 setData(1, DurationRole, Timecode::getEasyTimecode(GenTime(m_element.attribute("out", "250").toInt(), 25), 25));
73 tip.append(i18n("Image clip"));
76 tip.append(i18n("Text clip"));
79 tip.append(i18n("Slideshow clip"));
82 tip.append(i18n("Virtual clip"));
85 tip.append(i18n("Playlist clip"));
88 tip.append(i18n("Unknown clip"));
95 void ProjectItem::setProperties(const QMap < QString, QString > &attributes, const QMap < QString, QString > &metadata)
97 if (attributes.contains("duration")) {
98 m_duration = GenTime(attributes["duration"].toInt(), 25);
99 setData(1, DurationRole, Timecode::getEasyTimecode(m_duration, 25));
100 m_durationKnown = true;
102 // No duration known, use an arbitrary one until it is.
103 m_duration = GenTime(0.0);
104 m_durationKnown = false;
108 //extend attributes -reh
109 if (attributes.contains("type")) {
110 if (attributes["type"] == "audio")
111 m_clipType = DocClipBase::AUDIO;
112 else if (attributes["type"] == "video")
113 m_clipType = DocClipBase::VIDEO;
114 else if (attributes["type"] == "av")
115 m_clipType = DocClipBase::AV;
116 else if (attributes["type"] == "playlist")
117 m_clipType = DocClipBase::PLAYLIST;
119 m_clipType = DocClipBase::AV;
123 if (m_element.isNull()) {
125 m_element = doc.createElement("producer");
126 m_element.setAttribute("resource", attributes["filename"]);
127 m_element.setAttribute("type", (int) m_clipType);
130 if (attributes.contains("height")) {
131 m_height = attributes["height"].toInt();
135 if (attributes.contains("width")) {
136 m_width = attributes["width"].toInt();
141 if (attributes.contains("name")) {
142 m_decompressor = attributes["name"];
144 m_decompressor = "n/a";
146 //video type ntsc/pal
147 if (attributes.contains("system")) {
148 m_system = attributes["system"];
152 if (attributes.contains("fps")) {
153 m_framesPerSecond = attributes["fps"].toInt();
155 // No frame rate known.
156 m_framesPerSecond = 0;
158 //audio attributes -reh
159 if (attributes.contains("channels")) {
160 m_channels = attributes["channels"].toInt();
164 if (attributes.contains("format")) {
165 m_format = attributes["format"];
169 if (attributes.contains("frequency")) {
170 m_frequency = attributes["frequency"].toInt();
174 if (attributes.contains("videocodec")) {
175 m_videoCodec = attributes["videocodec"];
177 if (attributes.contains("audiocodec")) {
178 m_audioCodec = attributes["audiocodec"];
181 m_metadata = metadata;
183 if (m_metadata.contains("description")) {
184 setDescription (m_metadata["description"]);
186 else if (m_metadata.contains("comment")) {
187 setDescription (m_metadata["comment"]);
193 #include "projectitem.moc"