]> git.sesse.net Git - kdenlive/blob - src/projectlist.cpp
8b2633044144763fc4390b311c1c3a120d07ed7e
[kdenlive] / src / projectlist.cpp
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20
21 #include <QMouseEvent>
22 #include <QStylePainter>
23 #include <QPixmap>
24 #include <QIcon>
25 #include <QDialog>
26 #include <QtGui>
27
28 #include <KDebug>
29 #include <KAction>
30 #include <KLocale>
31 #include <KFileDialog>
32 #include <KInputDialog>
33 #include <kio/netaccess.h>
34 #include <KMessageBox>
35
36 #include <nepomuk/global.h>
37 #include <nepomuk/resource.h>
38 #include <nepomuk/tag.h>
39
40 #include "projectlist.h"
41 #include "projectitem.h"
42 #include "kdenlivesettings.h"
43 #include "slideshowclip.h"
44 #include "ui_colorclip_ui.h"
45
46
47 #include "definitions.h"
48 #include "clipmanager.h"
49 #include "docclipbase.h"
50 #include "kdenlivedoc.h"
51 #include "renderer.h"
52 #include "kthumb.h"
53 #include "projectlistview.h"
54
55 ProjectList::ProjectList(QWidget *parent)
56         : QWidget(parent), m_render(NULL), m_fps(-1), m_commandStack(NULL) {
57
58     QWidget *vbox = new QWidget;
59     listView = new ProjectListView(this);;
60     QVBoxLayout *layout = new QVBoxLayout;
61     m_clipIdCounter = 0;
62
63     // setup toolbar
64     searchView = new KTreeWidgetSearchLine(this);
65     m_toolbar = new QToolBar("projectToolBar", this);
66     m_toolbar->addWidget(searchView);
67
68     QToolButton *addButton = new QToolButton(m_toolbar);
69     QMenu *addMenu = new QMenu(this);
70     addButton->setMenu(addMenu);
71     addButton->setPopupMode(QToolButton::MenuButtonPopup);
72     m_toolbar->addWidget(addButton);
73
74     QAction *addClipButton = addMenu->addAction(KIcon("document-new"), i18n("Add Clip"));
75     connect(addClipButton, SIGNAL(triggered()), this, SLOT(slotAddClip()));
76
77     QAction *addColorClip = addMenu->addAction(KIcon("document-new"), i18n("Add Color Clip"));
78     connect(addColorClip, SIGNAL(triggered()), this, SLOT(slotAddColorClip()));
79
80     QAction *addSlideClip = addMenu->addAction(KIcon("document-new"), i18n("Add Slideshow Clip"));
81     connect(addSlideClip, SIGNAL(triggered()), this, SLOT(slotAddSlideshowClip()));
82
83     QAction *addTitleClip = addMenu->addAction(KIcon("document-new"), i18n("Add Title Clip"));
84     connect(addTitleClip, SIGNAL(triggered()), this, SLOT(slotAddTitleClip()));
85
86     m_deleteAction = m_toolbar->addAction(KIcon("edit-delete"), i18n("Delete Clip"));
87     connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(slotRemoveClip()));
88
89     m_editAction = m_toolbar->addAction(KIcon("document-properties"), i18n("Edit Clip"));
90     connect(m_editAction, SIGNAL(triggered()), this, SLOT(slotEditClip()));
91
92     QAction *addFolderButton = addMenu->addAction(KIcon("folder-new"), i18n("Create Folder"));
93     connect(addFolderButton, SIGNAL(triggered()), this, SLOT(slotAddFolder()));
94
95     addButton->setDefaultAction(addClipButton);
96
97     layout->addWidget(m_toolbar);
98     layout->addWidget(listView);
99     setLayout(layout);
100     //m_toolbar->setEnabled(false);
101
102     searchView->setTreeWidget(listView);
103
104     m_menu = new QMenu();
105     m_menu->addAction(addClipButton);
106     m_menu->addAction(addColorClip);
107     m_menu->addAction(addTitleClip);
108     m_menu->addAction(m_editAction);
109     m_menu->addAction(m_deleteAction);
110     m_menu->addAction(addFolderButton);
111     m_menu->insertSeparator(m_deleteAction);
112
113     connect(listView, SIGNAL(itemSelectionChanged()), this, SLOT(slotClipSelected()));
114     connect(listView, SIGNAL(requestMenu(const QPoint &, QTreeWidgetItem *)), this, SLOT(slotContextMenu(const QPoint &, QTreeWidgetItem *)));
115     connect(listView, SIGNAL(addClip()), this, SLOT(slotAddClip()));
116     connect(listView, SIGNAL(addClip(QUrl, const QString &)), this, SLOT(slotAddClip(QUrl, const QString &)));
117     connect(listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotItemEdited(QTreeWidgetItem *, int)));
118     connect(listView, SIGNAL(showProperties(DocClipBase *)), this, SIGNAL(showClipProperties(DocClipBase *)));
119
120     m_listViewDelegate = new ItemDelegate(listView);
121     listView->setItemDelegate(m_listViewDelegate);
122 }
123
124 ProjectList::~ProjectList() {
125     delete m_menu;
126     delete m_toolbar;
127 }
128
129 void ProjectList::slotEditClip()
130 {
131     ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
132     if (item && !item->isGroup()) emit clipSelected(item->toXml());
133     emit showClipProperties(item->referencedClip());
134 }
135
136
137
138 void ProjectList::setRenderer(Render *projectRender) {
139     m_render = projectRender;
140 }
141
142 void ProjectList::slotClipSelected() {
143     ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
144     if (item && !item->isGroup()) emit clipSelected(item->toXml());
145 }
146
147 void ProjectList::slotUpdateClipProperties(int id, QMap <QString, QString> properties) {
148     ProjectItem *item = getItemById(id);
149     if (item) {
150         slotUpdateClipProperties(item, properties);
151         if (properties.contains("colour") || properties.contains("resource")) slotRefreshClipThumbnail(item);
152         if (properties.contains("out")) item->changeDuration(properties.value("out").toInt());
153     }
154 }
155
156 void ProjectList::slotUpdateClipProperties(ProjectItem *clip, QMap <QString, QString> properties) {
157     if (!clip) return;
158     clip->setProperties(properties);
159     if (properties.contains("description")) {
160         CLIPTYPE type = clip->clipType();
161         clip->setText(2, properties.value("description"));
162         if (type == AUDIO || type == VIDEO || type == AV || type == IMAGE || type == PLAYLIST) {
163             // Use Nepomuk system to store clip description
164             Nepomuk::Resource f(clip->clipUrl().path());
165             if (f.isValid()) f.setDescription(properties.value("description"));
166         }
167     }
168 }
169
170 void ProjectList::slotItemEdited(QTreeWidgetItem *item, int column) {
171     ProjectItem *clip = static_cast <ProjectItem*>(item);
172     if (column == 2) {
173         QMap <QString, QString> props;
174         props["description"] = item->text(2);
175         slotUpdateClipProperties(clip, props);
176     } else if (column == 1 && clip->clipType() == FOLDER) {
177         m_doc->slotEditFolder(item->text(1), clip->groupName(), clip->clipId());
178     }
179 }
180
181 void ProjectList::slotContextMenu(const QPoint &pos, QTreeWidgetItem *item) {
182     bool enable = false;
183     if (item) {
184         enable = true;
185     }
186     m_editAction->setEnabled(enable);
187     m_deleteAction->setEnabled(enable);
188
189     m_menu->popup(pos);
190 }
191
192 void ProjectList::slotRemoveClip() {
193     if (!listView->currentItem()) return;
194     ProjectItem *item = static_cast <ProjectItem *>(listView->currentItem());
195     QList <int> ids;
196     QMap <QString, int> folderids;
197     if (item->clipType() == FOLDER) folderids[item->groupName()] = item->clipId();
198     else ids << item->clipId();
199     if (item->numReferences() > 0) {
200         if (KMessageBox::questionYesNo(this, i18np("Delete clip <b>%2</b> ?<br>This will also remove the clip in timeline", "Delete clip <b>%2</b> ?<br>This will also remove its %1 clips in timeline", item->numReferences(), item->names().at(1)), i18n("Delete Clip")) != KMessageBox::Yes) return;
201     } else if (item->clipType() == FOLDER && item->childCount() > 0) {
202         int children = item->childCount();
203         if (KMessageBox::questionYesNo(this, i18n("Delete folder <b>%2</b> ?<br>This will also remove the %1 clips in that folder", children, item->names().at(1)), i18n("Delete Folder")) != KMessageBox::Yes) return;
204         for (int i = 0; i < children; ++i) {
205             ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
206             ids << child->clipId();
207         }
208     }
209     if (!ids.isEmpty()) m_doc->deleteProjectClip(ids);
210     if (!folderids.isEmpty()) m_doc->deleteProjectFolder(folderids);
211 }
212
213 void ProjectList::selectItemById(const int clipId) {
214     ProjectItem *item = getItemById(clipId);
215     if (item) listView->setCurrentItem(item);
216 }
217
218 void ProjectList::addClip(const QStringList &name, const QDomElement &elem, const int clipId, const KUrl &url, const QString &group, int parentId) {
219     kDebug() << "/////////  ADDING VCLIP=: " << name;
220     ProjectItem *item;
221     ProjectItem *groupItem = NULL;
222     QString groupName;
223     if (group.isEmpty()) groupName = elem.attribute("groupname", QString::null);
224     else groupName = group;
225     if (elem.isNull() && url.isEmpty()) {
226         // this is a folder
227         groupName = name.at(1);
228         QList<QTreeWidgetItem *> groupList = listView->findItems(groupName, Qt::MatchExactly, 1);
229         if (groupList.isEmpty())  {
230             (void) new ProjectItem(listView, name, m_doc->getFreeClipId());
231         }
232         return;
233     }
234
235     if (parentId != -1) {
236         groupItem = getItemById(parentId);
237     } else if (!groupName.isEmpty()) {
238         // Clip is in a group
239         QList<QTreeWidgetItem *> groupList = listView->findItems(groupName, Qt::MatchExactly, 1);
240
241         if (groupList.isEmpty())  {
242             QStringList itemName;
243             itemName << QString::null << groupName;
244             kDebug() << "-------  CREATING NEW GRP: " << itemName;
245             groupItem = new ProjectItem(listView, itemName, m_doc->getFreeClipId());
246         } else groupItem = (ProjectItem *) groupList.first();
247     }
248     if (groupItem) item = new ProjectItem(groupItem, name, elem, clipId);
249     else item = new ProjectItem(listView, name, elem, clipId);
250     if (!url.isEmpty()) {
251         // if file has Nepomuk comment, use it
252         Nepomuk::Resource f(url.path());
253         QString annotation;
254         if (f.isValid()) annotation = f.description();
255
256         if (!annotation.isEmpty()) item->setText(2, annotation);
257         QString resource = url.path();
258         if (resource.endsWith("westley") || resource.endsWith("kdenlive")) {
259             QString tmpfile;
260             QDomDocument doc;
261             if (KIO::NetAccess::download(url, tmpfile, 0)) {
262                 QFile file(tmpfile);
263                 if (file.open(QIODevice::ReadOnly)) {
264                     doc.setContent(&file, false);
265                     file.close();
266                 }
267                 KIO::NetAccess::removeTempFile(tmpfile);
268
269                 QDomNodeList subProds = doc.elementsByTagName("producer");
270                 int ct = subProds.count();
271                 for (int i = 0; i <  ct ; i++) {
272                     QDomElement e = subProds.item(i).toElement();
273                     if (!e.isNull()) {
274                         addProducer(e, clipId);
275                     }
276                 }
277             }
278         }
279
280     }
281
282     if (elem.isNull()) {
283         QDomDocument doc;
284         QDomElement element = doc.createElement("producer");
285         element.setAttribute("resource", url.path());
286         emit getFileProperties(element, clipId);
287     } else emit getFileProperties(elem, clipId);
288     selectItemById(clipId);
289 }
290
291 void ProjectList::slotDeleteClip(int clipId) {
292     ProjectItem *item = getItemById(clipId);
293     QTreeWidgetItem *p = item->parent();
294     if (p) {
295         kDebug() << "///////  DELETEED CLIP HAS A PARENT... " << p->indexOfChild(item);
296         QTreeWidgetItem *clone = p->takeChild(p->indexOfChild(item));
297     } else if (item) delete item;
298 }
299
300 void ProjectList::slotAddFolder() {
301
302     // QString folderName = KInputDialog::getText(i18n("New Folder"), i18n("Enter new folder name: "));
303     // if (folderName.isEmpty()) return;
304     m_doc->slotAddFolder(i18n("Folder")); //folderName);
305 }
306
307 void ProjectList::slotAddFolder(const QString foldername, int clipId, bool remove, bool edit) {
308     if (remove) {
309         ProjectItem *item;
310         QTreeWidgetItemIterator it(listView);
311         while (*it) {
312             item = static_cast <ProjectItem *>(*it);
313             if (item->clipType() == FOLDER && item->clipId() == clipId) {
314                 delete item;
315                 break;
316             }
317             ++it;
318         }
319     } else {
320         if (edit) {
321             disconnect(listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotUpdateItemDescription(QTreeWidgetItem *, int)));
322             ProjectItem *item;
323             QTreeWidgetItemIterator it(listView);
324             while (*it) {
325                 item = static_cast <ProjectItem *>(*it);
326                 if (item->clipType() == FOLDER && item->clipId() == clipId) {
327                     item->setText(1, foldername);
328                     break;
329                 }
330                 ++it;
331             }
332             connect(listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotUpdateItemDescription(QTreeWidgetItem *, int)));
333         } else {
334             QStringList text;
335             text << QString() << foldername;
336             (void) new ProjectItem(listView, text, clipId);
337         }
338     }
339 }
340
341 void ProjectList::slotAddClip(DocClipBase *clip) {
342     const int parent = clip->toXML().attribute("groupid").toInt();
343     ProjectItem *item = NULL;
344     if (parent != 0) {
345         ProjectItem *parentitem = getItemById(parent);
346         if (parentitem) item = new ProjectItem(parentitem, clip);
347     }
348     if (item == NULL) item = new ProjectItem(listView, clip);
349
350     KUrl url = clip->fileURL();
351     if (!url.isEmpty()) {
352         // if file has Nepomuk comment, use it
353         Nepomuk::Resource f(url.path());
354         QString annotation;
355         if (f.isValid()) {
356             annotation = f.description();
357             /*
358             Nepomuk::Tag tag("test");
359             f.addTag(tag);*/
360         } else kDebug() << "---  CANNOT CONTACT NEPOMUK";
361         if (!annotation.isEmpty()) item->setText(2, annotation);
362     }
363     emit getFileProperties(clip->toXML(), clip->getId());
364 }
365
366 void ProjectList::slotUpdateClip(int id) {
367     ProjectItem *item = getItemById(id);
368     item->setData(1, UsageRole, QString::number(item->numReferences()));
369 }
370
371 void ProjectList::slotAddClip(QUrl givenUrl, QString group) {
372     if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!!  NO CMD STK";
373     KUrl::List list;
374     if (givenUrl.isEmpty())
375         list = KFileDialog::getOpenUrls(KUrl(), "application/vnd.kde.kdenlive application/vnd.westley.scenelist application/flv application/vnd.rn-realmedia video/x-dv video/x-msvideo video/mpeg video/x-ms-wmv audio/mpeg audio/x-mp3 audio/x-wav application/ogg *.m2t *.dv video/mp4 video/quicktime image/gif image/jpeg image/png image/x-bmp image/svg+xml image/tiff image/x-xcf-gimp image/x-vnd.adobe.photoshop image/x-pcx image/x-exr");
376     else list.append(givenUrl);
377     if (list.isEmpty()) return;
378     KUrl::List::Iterator it;
379     int groupId = -1;
380     if (group.isEmpty()) {
381         ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
382         if (item && item->clipType() != FOLDER) {
383             while (item->parent()) {
384                 item = static_cast <ProjectItem*>(item->parent());
385                 if (item->clipType() == FOLDER) break;
386             }
387         }
388         if (item && item->clipType() == FOLDER) {
389             group = item->groupName();
390             groupId = item->clipId();
391         }
392     }
393     for (it = list.begin(); it != list.end(); it++) {
394         m_doc->slotAddClipFile(*it, group, groupId);
395     }
396 }
397
398 void ProjectList::slotAddColorClip() {
399     if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!!  NO CMD STK";
400     QDialog *dia = new QDialog(this);
401     Ui::ColorClip_UI *dia_ui = new Ui::ColorClip_UI();
402     dia_ui->setupUi(dia);
403     dia_ui->clip_name->setText(i18n("Color Clip"));
404     dia_ui->clip_duration->setText(KdenliveSettings::color_duration());
405     if (dia->exec() == QDialog::Accepted) {
406         QString color = dia_ui->clip_color->color().name();
407         color = color.replace(0, 1, "0x") + "ff";
408
409         QString group = QString();
410         int groupId = -1;
411         ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
412         if (item && item->clipType() != FOLDER) {
413             while (item->parent()) {
414                 item = static_cast <ProjectItem*>(item->parent());
415                 if (item->clipType() == FOLDER) break;
416             }
417         }
418         if (item && item->clipType() == FOLDER) {
419             group = item->groupName();
420             groupId = item->clipId();
421         }
422
423         m_doc->slotAddColorClipFile(dia_ui->clip_name->text(), color, dia_ui->clip_duration->text(), group, groupId);
424     }
425     delete dia_ui;
426     delete dia;
427 }
428
429
430 void ProjectList::slotAddSlideshowClip() {
431     if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!!  NO CMD STK";
432     SlideshowClip *dia = new SlideshowClip(this);
433
434     if (dia->exec() == QDialog::Accepted) {
435
436         QString group = QString();
437         int groupId = -1;
438         ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
439         if (item && item->clipType() != FOLDER) {
440             while (item->parent()) {
441                 item = static_cast <ProjectItem*>(item->parent());
442                 if (item->clipType() == FOLDER) break;
443             }
444         }
445         if (item && item->clipType() == FOLDER) {
446             group = item->groupName();
447             groupId = item->clipId();
448         }
449
450         m_doc->slotAddSlideshowClipFile(dia->clipName(), dia->selectedPath(), dia->imageCount(), dia->clipDuration(), dia->loop(), group, groupId);
451     }
452     delete dia;
453 }
454 void ProjectList::slotAddTitleClip() {
455     QString group = QString();
456     int groupId = -1;
457     ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
458     if (item && item->clipType() != FOLDER) {
459         while (item->parent()) {
460             item = static_cast <ProjectItem*>(item->parent());
461             if (item->clipType() == FOLDER) break;
462         }
463     }
464     if (item && item->clipType() == FOLDER) {
465         group = item->groupName();
466         groupId = item->clipId();
467     }
468
469     m_doc->slotCreateTextClip(group, groupId);
470 }
471
472 void ProjectList::setDocument(KdenliveDoc *doc) {
473     listView->clear();
474     QList <DocClipBase*> list = doc->clipManager()->documentClipList();
475     for (int i = 0; i < list.count(); i++) {
476         slotAddClip(list.at(i));
477     }
478
479     m_fps = doc->fps();
480     m_timecode = doc->timecode();
481     m_commandStack = doc->commandStack();
482     m_doc = doc;
483     /*    QDomNodeList prods = doc->producersList();
484         int ct = prods.count();
485         kDebug() << "////////////  SETTING DOC, FOUND CLIPS: " << prods.count();
486         listView->clear();
487         for (int i = 0; i <  ct ; i++) {
488             QDomElement e = prods.item(i).toElement();
489             kDebug() << "// IMPORT: " << i << ", :" << e.attribute("id", "non") << ", NAME: " << e.attribute("name", "non");
490             if (!e.isNull()) addProducer(e);
491         }*/
492     QTreeWidgetItem *first = listView->topLevelItem(0);
493     if (first) listView->setCurrentItem(first);
494     m_toolbar->setEnabled(true);
495 }
496
497 QDomElement ProjectList::producersList() {
498     QDomDocument doc;
499     QDomElement prods = doc.createElement("producerlist");
500     doc.appendChild(prods);
501     kDebug() << "////////////  PRO LIST BUILD PRDSLIST ";
502     QTreeWidgetItemIterator it(listView);
503     while (*it) {
504         if (!((ProjectItem *)(*it))->isGroup())
505             prods.appendChild(doc.importNode(((ProjectItem *)(*it))->toXml(), true));
506         ++it;
507     }
508     return prods;
509 }
510
511 void ProjectList::slotRefreshClipThumbnail(int clipId) {
512     ProjectItem *item = getItemById(clipId);
513     if (item) slotRefreshClipThumbnail(item);
514 }
515
516 void ProjectList::slotRefreshClipThumbnail(ProjectItem *item) {
517     if (item) {
518         int height = 40;
519         int width = (int)(height  * (double) m_render->renderWidth() / m_render->renderHeight());
520         QPixmap pix = KThumb::getImage(item->toXml(), item->referencedClip()->getProjectThumbFrame(), width, height);
521         //QPixmap pix = KThumb::getFrame(item->toXml()), 0, width, height);
522         item->setIcon(0, pix);
523     }
524 }
525
526 void ProjectList::slotReplyGetFileProperties(int clipId, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata) {
527     ProjectItem *item = getItemById(clipId);
528     if (item) {
529         item->setProperties(properties, metadata);
530         listView->setCurrentItem(item);
531         emit receivedClipDuration(clipId, item->clipMaxDuration());
532     }
533 }
534
535 void ProjectList::slotReplyGetImage(int clipId, int pos, const QPixmap &pix, int w, int h) {
536     ProjectItem *item = getItemById(clipId);
537     if (item) item->setIcon(0, pix);
538 }
539
540 ProjectItem *ProjectList::getItemById(int id) {
541     QTreeWidgetItemIterator it(listView);
542     while (*it) {
543         if (((ProjectItem *)(*it))->clipId() == id)
544             break;
545         ++it;
546     }
547     if (*it) return ((ProjectItem *)(*it));
548     return NULL;
549 }
550
551
552 void ProjectList::addProducer(QDomElement producer, int parentId) {
553     if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!!  NO CMD STK";
554     CLIPTYPE type = (CLIPTYPE) producer.attribute("type").toInt();
555
556     /*QDomDocument doc;
557     QDomElement prods = doc.createElement("list");
558     doc.appendChild(prods);
559     prods.appendChild(doc.importNode(producer, true));*/
560
561
562     //kDebug()<<"//////  ADDING PRODUCER:\n "<<doc.toString()<<"\n+++++++++++++++++";
563     int id = producer.attribute("id").toInt();
564     QString groupName = producer.attribute("groupname");
565     if (id >= m_clipIdCounter) m_clipIdCounter = id + 1;
566     else if (id == 0) id = m_clipIdCounter++;
567
568     if (parentId != -1) {
569         // item is a westley playlist, adjust subproducers ids
570         id = (parentId + 1) * 10000 + id;
571     }
572     if (type == AUDIO || type == VIDEO || type == AV || type == IMAGE  || type == PLAYLIST) {
573         KUrl resource = KUrl(producer.attribute("resource"));
574         if (!resource.isEmpty()) {
575             QStringList itemEntry;
576             itemEntry.append(QString::null);
577             itemEntry.append(resource.fileName());
578             addClip(itemEntry, producer, id, resource, groupName, parentId);
579         }
580     } else if (type == COLOR) {
581         QString colour = producer.attribute("colour");
582         QPixmap pix(60, 40);
583         colour = colour.replace(0, 2, "#");
584         pix.fill(QColor(colour.left(7)));
585         QStringList itemEntry;
586         itemEntry.append(QString::null);
587         itemEntry.append(producer.attribute("name", i18n("Color clip")));
588         addClip(itemEntry, producer, id, KUrl(), groupName, parentId);
589     }
590
591 }
592
593 #include "projectlist.moc"