-ProjectItem::ProjectItem(QTreeWidgetItem * parent, const QStringList & strings, QDomElement xml, int clipId)
- : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(UNKNOWN), m_clipId(clipId) {
- QDomElement element = xml.cloneNode().toElement();
- setSizeHint(0, QSize(65, 45));
- setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
- if (!element.isNull()) {
- element.setAttribute("id", clipId);
- QString cType = element.attribute("type", QString::null);
- if (!cType.isEmpty()) {
- m_clipType = (CLIPTYPE) cType.toInt();
- slotSetToolTip();
+void ProjectItem::buildItem(const QSize &pixmapSize)
+{
+ setSizeHint(0, QSize(itemHeight * 3, itemHeight));
+ if (m_clip->isPlaceHolder()) setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
+ else setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
+ QString name = m_clip->getProperty("name");
+ if (name.isEmpty()) name = KUrl(m_clip->getProperty("resource")).fileName();
+ m_clipType = (ClipType) m_clip->getProperty("type").toInt();
+ switch(m_clipType) {
+ case Audio:
+ setData(0, Qt::DecorationRole, KIcon("audio-x-generic").pixmap(pixmapSize));
+ m_pixmapSet = true;
+ break;
+ case Image:
+ case SlideShow:
+ setData(0, Qt::DecorationRole, KIcon("image-x-generic").pixmap(pixmapSize));
+ break;
+ default:
+ setData(0, Qt::DecorationRole, KIcon("video-x-generic").pixmap(pixmapSize));
+ }
+ if (m_clipType != Unknown) slotSetToolTip();
+
+ setText(0, name);
+ setText(1, m_clip->description());
+ GenTime duration = m_clip->duration();
+ QString durationText;
+ if (duration != GenTime()) {
+ durationText = Timecode::getEasyTimecode(duration, KdenliveSettings::project_fps());
+ }
+ if (m_clipType == Playlist) {
+ // Check if the playlist xml contains a proxy inside, and inform user
+ if (playlistHasProxies(m_clip->fileURL().path())) {
+ durationText.prepend(i18n("Contains proxies") + " / ");