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()) m_element.setAttribute("id", clipId);
25 QString cType = m_element.attribute("type", 0);
26 if (!cType.isEmpty()) {
27 m_clipType = (DocClipBase::CLIPTYPE) cType.toInt();
33 ProjectItem::~ProjectItem()
37 int ProjectItem::clipId()
42 QStringList ProjectItem::names()
45 result.append(text(0));
46 result.append(text(1));
47 result.append(text(2));
51 QDomElement ProjectItem::toXml()
56 void ProjectItem::slotSetToolTip()
58 QString tip = "<qt><b>";
61 tip.append(i18n("Audio clip"));
64 tip.append(i18n("Mute video clip"));
67 tip.append(i18n("Video clip"));
70 tip.append(i18n("Color clip"));
71 setData(1, DurationRole, Timecode::getEasyTimecode(GenTime(m_element.attribute("out", "250").toInt(), 25), 25));
74 tip.append(i18n("Image clip"));
77 tip.append(i18n("Text clip"));
80 tip.append(i18n("Slideshow clip"));
83 tip.append(i18n("Virtual clip"));
86 tip.append(i18n("Playlist clip"));
89 tip.append(i18n("Unknown clip"));
96 void ProjectItem::setProperties(const QMap < QString, QString > &attributes, const QMap < QString, QString > &metadata)
98 if (attributes.contains("duration")) {
99 m_duration = GenTime(attributes["duration"].toInt(), 25);
100 setData(1, DurationRole, Timecode::getEasyTimecode(m_duration, 25));
101 m_durationKnown = true;
103 // No duration known, use an arbitrary one until it is.
104 m_duration = GenTime(0.0);
105 m_durationKnown = false;
109 //extend attributes -reh
110 if (attributes.contains("type")) {
111 if (attributes["type"] == "audio")
112 m_clipType = DocClipBase::AUDIO;
113 else if (attributes["type"] == "video")
114 m_clipType = DocClipBase::VIDEO;
115 else if (attributes["type"] == "av")
116 m_clipType = DocClipBase::AV;
117 else if (attributes["type"] == "playlist")
118 m_clipType = DocClipBase::PLAYLIST;
120 m_clipType = DocClipBase::AV;
124 if (m_element.isNull()) {
126 m_element = doc.createElement("producer");
128 m_element.setAttribute("resource", attributes["filename"]);
129 m_element.setAttribute("type", (int) m_clipType);
131 if (attributes.contains("height")) {
132 m_height = attributes["height"].toInt();
136 if (attributes.contains("width")) {
137 m_width = attributes["width"].toInt();
142 if (attributes.contains("name")) {
143 m_decompressor = attributes["name"];
145 m_decompressor = "n/a";
147 //video type ntsc/pal
148 if (attributes.contains("system")) {
149 m_system = attributes["system"];
153 if (attributes.contains("fps")) {
154 m_framesPerSecond = attributes["fps"].toInt();
156 // No frame rate known.
157 m_framesPerSecond = 0;
159 //audio attributes -reh
160 if (attributes.contains("channels")) {
161 m_channels = attributes["channels"].toInt();
165 if (attributes.contains("format")) {
166 m_format = attributes["format"];
170 if (attributes.contains("frequency")) {
171 m_frequency = attributes["frequency"].toInt();
175 if (attributes.contains("videocodec")) {
176 m_videoCodec = attributes["videocodec"];
178 if (attributes.contains("audiocodec")) {
179 m_audioCodec = attributes["audiocodec"];
182 m_metadata = metadata;
184 if (m_metadata.contains("description")) {
185 setDescription (m_metadata["description"]);
187 else if (m_metadata.contains("comment")) {
188 setDescription (m_metadata["comment"]);
194 #include "projectitem.moc"