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 type)
20 : QTreeWidgetItem(parent, strings, type), m_element(xml), m_clipType(DocClipBase::NONE)
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 QDomElement ProjectItem::toXml()
41 void ProjectItem::slotSetToolTip()
43 QString tip = "<qt><b>";
46 tip.append(i18n("Audio clip"));
49 tip.append(i18n("Mute video clip"));
52 tip.append(i18n("Video clip"));
55 tip.append(i18n("Color clip"));
58 tip.append(i18n("Image clip"));
61 tip.append(i18n("Text clip"));
64 tip.append(i18n("Slideshow clip"));
67 tip.append(i18n("Virtual clip"));
70 tip.append(i18n("Playlist clip"));
73 tip.append(i18n("Unknown clip"));
80 void ProjectItem::setProperties(const QMap < QString, QString > &attributes, const QMap < QString, QString > &metadata)
82 if (attributes.contains("duration")) {
83 m_duration = GenTime(attributes["duration"].toInt(), 25);
84 setData(1, DurationRole, Timecode::getEasyTimecode(m_duration, 25));
85 m_durationKnown = true;
87 // No duration known, use an arbitrary one until it is.
88 m_duration = GenTime(0.0);
89 m_durationKnown = false;
93 //extend attributes -reh
94 if (attributes.contains("type")) {
95 if (attributes["type"] == "audio")
96 m_clipType = DocClipBase::AUDIO;
97 else if (attributes["type"] == "video")
98 m_clipType = DocClipBase::VIDEO;
99 else if (attributes["type"] == "av")
100 m_clipType = DocClipBase::AV;
101 else if (attributes["type"] == "playlist")
102 m_clipType = DocClipBase::PLAYLIST;
104 m_clipType = DocClipBase::AV;
108 if (m_element.isNull()) {
110 m_element = doc.createElement("producer");
111 m_element.setAttribute("resource", attributes["filename"]);
112 m_element.setAttribute("type", (int) m_clipType);
115 if (attributes.contains("height")) {
116 m_height = attributes["height"].toInt();
120 if (attributes.contains("width")) {
121 m_width = attributes["width"].toInt();
126 if (attributes.contains("name")) {
127 m_decompressor = attributes["name"];
129 m_decompressor = "n/a";
131 //video type ntsc/pal
132 if (attributes.contains("system")) {
133 m_system = attributes["system"];
137 if (attributes.contains("fps")) {
138 m_framesPerSecond = attributes["fps"].toInt();
140 // No frame rate known.
141 m_framesPerSecond = 0;
143 //audio attributes -reh
144 if (attributes.contains("channels")) {
145 m_channels = attributes["channels"].toInt();
149 if (attributes.contains("format")) {
150 m_format = attributes["format"];
154 if (attributes.contains("frequency")) {
155 m_frequency = attributes["frequency"].toInt();
159 if (attributes.contains("videocodec")) {
160 m_videoCodec = attributes["videocodec"];
162 if (attributes.contains("audiocodec")) {
163 m_audioCodec = attributes["audiocodec"];
166 m_metadata = metadata;
168 if (m_metadata.contains("description")) {
169 setDescription (m_metadata["description"]);
171 else if (m_metadata.contains("comment")) {
172 setDescription (m_metadata["comment"]);
178 #include "projectitem.moc"