]> git.sesse.net Git - kdenlive/blob - src/projectitem.cpp
Starting KDE4 porting
[kdenlive] / src / projectitem.cpp
1
2 #include <QMouseEvent>
3 #include <QStylePainter>
4 #include <QLabel>
5 #include <QLayout>
6
7 #include <KDebug>
8 #include <KLocale>
9
10
11 #include "projectitem.h"
12 #include "timecode.h"
13
14   const int NameRole = Qt::UserRole;
15   const int DurationRole = NameRole + 1;
16   const int FullPathRole = NameRole + 2;
17   const int ClipTypeRole = NameRole + 3;
18
19 ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, QDomElement xml, int type)
20     : QTreeWidgetItem(parent, strings, type), m_element(xml), m_clipType(DocClipBase::NONE)
21 {
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();
27     slotSetToolTip();
28   }
29   
30 }
31
32 ProjectItem::~ProjectItem()
33 {
34 }
35
36 QDomElement ProjectItem::toXml()
37 {
38     return m_element;
39 }
40
41 void ProjectItem::slotSetToolTip()
42 {
43   QString tip = "<qt><b>";
44   switch (m_clipType) {
45     case 1:
46       tip.append(i18n("Audio clip"));
47       break;
48     case 2:
49       tip.append(i18n("Mute video clip"));
50       break;
51     case 3:
52       tip.append(i18n("Video clip"));
53       break;
54     case 4:
55       tip.append(i18n("Color clip"));
56       break;
57     case 5:
58       tip.append(i18n("Image clip"));
59       break;
60     case 6:
61       tip.append(i18n("Text clip"));
62       break;
63     case 7:
64       tip.append(i18n("Slideshow clip"));
65       break;
66     case 8:
67       tip.append(i18n("Virtual clip"));
68       break;
69     case 9:
70       tip.append(i18n("Playlist clip"));
71       break;
72     default:
73       tip.append(i18n("Unknown clip"));
74     break;
75   }
76
77   setToolTip(1, tip);
78 }
79
80 void ProjectItem::setProperties(const QMap < QString, QString > &attributes, const QMap < QString, QString > &metadata)
81 {
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;
86         } else {
87             // No duration known, use an arbitrary one until it is.
88             m_duration = GenTime(0.0);
89             m_durationKnown = false;
90         }
91
92
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;
103         } else {
104             m_clipType = DocClipBase::AV;
105         }
106         slotSetToolTip();
107
108         if (m_element.isNull()) {
109           QDomDocument doc;
110           m_element = doc.createElement("producer");
111           m_element.setAttribute("resource", attributes["filename"]);
112           m_element.setAttribute("type", (int) m_clipType);
113         }
114 /*
115         if (attributes.contains("height")) {
116             m_height = attributes["height"].toInt();
117         } else {
118             m_height = 0;
119         }
120         if (attributes.contains("width")) {
121             m_width = attributes["width"].toInt();
122         } else {
123             m_width = 0;
124         }
125         //decoder name
126         if (attributes.contains("name")) {
127             m_decompressor = attributes["name"];
128         } else {
129             m_decompressor = "n/a";
130         }
131         //video type ntsc/pal
132         if (attributes.contains("system")) {
133             m_system = attributes["system"];
134         } else {
135             m_system = "n/a";
136         }
137         if (attributes.contains("fps")) {
138             m_framesPerSecond = attributes["fps"].toInt();
139         } else {
140             // No frame rate known.
141             m_framesPerSecond = 0;
142         }
143         //audio attributes -reh
144         if (attributes.contains("channels")) {
145             m_channels = attributes["channels"].toInt();
146         } else {
147             m_channels = 0;
148         }
149         if (attributes.contains("format")) {
150             m_format = attributes["format"];
151         } else {
152             m_format = "n/a";
153         }
154         if (attributes.contains("frequency")) {
155             m_frequency = attributes["frequency"].toInt();
156         } else {
157             m_frequency = 0;
158         }
159         if (attributes.contains("videocodec")) {
160             m_videoCodec = attributes["videocodec"];
161         }
162         if (attributes.contains("audiocodec")) {
163             m_audioCodec = attributes["audiocodec"];
164         }
165
166         m_metadata = metadata;
167
168         if (m_metadata.contains("description")) {
169             setDescription (m_metadata["description"]);
170         }
171         else if (m_metadata.contains("comment")) {
172             setDescription (m_metadata["comment"]);
173         }
174 */
175
176 }
177
178 #include "projectitem.moc"