]> git.sesse.net Git - kdenlive/blob - src/projectlist.cpp
don't forget to cleanup clipmanager
[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     ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
131     if (item && !item->isGroup()) emit clipSelected(item->toXml());
132     emit showClipProperties(item->referencedClip());
133 }
134
135
136
137 void ProjectList::setRenderer(Render *projectRender) {
138     m_render = projectRender;
139 }
140
141 void ProjectList::slotClipSelected() {
142     ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
143     if (item && !item->isGroup()) emit clipSelected(item->toXml());
144 }
145
146 void ProjectList::slotUpdateClipProperties(int id, QMap <QString, QString> properties) {
147     ProjectItem *item = getItemById(id);
148     if (item) {
149         slotUpdateClipProperties(item, properties);
150         if (properties.contains("colour") || properties.contains("resource")) slotRefreshClipThumbnail(item);
151         if (properties.contains("out")) item->changeDuration(properties.value("out").toInt());
152     }
153 }
154
155 void ProjectList::slotUpdateClipProperties(ProjectItem *clip, QMap <QString, QString> properties) {
156     if (!clip) return;
157     clip->setProperties(properties);
158     if (properties.contains("description")) {
159         CLIPTYPE type = clip->clipType();
160         clip->setText(2, properties.value("description"));
161         if (type == AUDIO || type == VIDEO || type == AV || type == IMAGE || type == PLAYLIST) {
162             // Use Nepomuk system to store clip description
163             Nepomuk::Resource f(clip->clipUrl().path());
164             if (f.isValid()) f.setDescription(properties.value("description"));
165         }
166     }
167 }
168
169 void ProjectList::slotItemEdited(QTreeWidgetItem *item, int column) {
170     ProjectItem *clip = static_cast <ProjectItem*>(item);
171     if (column == 2) {
172         QMap <QString, QString> props;
173         props["description"] = item->text(2);
174         slotUpdateClipProperties(clip, props);
175     } else if (column == 1 && clip->clipType() == FOLDER) {
176         m_doc->slotEditFolder(item->text(1), clip->groupName(), clip->clipId());
177     }
178 }
179
180 void ProjectList::slotContextMenu(const QPoint &pos, QTreeWidgetItem *item) {
181     bool enable = false;
182     if (item) {
183         enable = true;
184     }
185     m_editAction->setEnabled(enable);
186     m_deleteAction->setEnabled(enable);
187
188     m_menu->popup(pos);
189 }
190
191 void ProjectList::slotRemoveClip() {
192     if (!listView->currentItem()) return;
193     ProjectItem *item = static_cast <ProjectItem *>(listView->currentItem());
194     QList <int> ids;
195     QMap <QString, int> folderids;
196     if (item->clipType() == FOLDER) folderids[item->groupName()] = item->clipId();
197     else ids << item->clipId();
198     if (item->numReferences() > 0) {
199         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;
200     } else if (item->clipType() == FOLDER && item->childCount() > 0) {
201         int children = item->childCount();
202         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;
203         for (int i = 0; i < children; ++i) {
204             ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
205             ids << child->clipId();
206         }
207     }
208     if (!ids.isEmpty()) m_doc->deleteProjectClip(ids);
209     if (!folderids.isEmpty()) m_doc->deleteProjectFolder(folderids);
210 }
211
212 void ProjectList::selectItemById(const int clipId) {
213     ProjectItem *item = getItemById(clipId);
214     if (item) listView->setCurrentItem(item);
215 }
216
217 void ProjectList::addClip(const QStringList &name, const QDomElement &elem, const int clipId, const KUrl &url, const QString &group, int parentId) {
218     kDebug() << "/////////  ADDING VCLIP=: " << name;
219     ProjectItem *item;
220     ProjectItem *groupItem = NULL;
221     QString groupName;
222     if (group.isEmpty()) groupName = elem.attribute("groupname", QString::null);
223     else groupName = group;
224     if (elem.isNull() && url.isEmpty()) {
225         // this is a folder
226         groupName = name.at(1);
227         QList<QTreeWidgetItem *> groupList = listView->findItems(groupName, Qt::MatchExactly, 1);
228         if (groupList.isEmpty())  {
229             (void) new ProjectItem(listView, name, m_doc->getFreeClipId());
230         }
231         return;
232     }
233
234     if (parentId != -1) {
235         groupItem = getItemById(parentId);
236     } else if (!groupName.isEmpty()) {
237         // Clip is in a group
238         QList<QTreeWidgetItem *> groupList = listView->findItems(groupName, Qt::MatchExactly, 1);
239
240         if (groupList.isEmpty())  {
241             QStringList itemName;
242             itemName << QString::null << groupName;
243             kDebug() << "-------  CREATING NEW GRP: " << itemName;
244             groupItem = new ProjectItem(listView, itemName, m_doc->getFreeClipId());
245         } else groupItem = (ProjectItem *) groupList.first();
246     }
247     if (groupItem) item = new ProjectItem(groupItem, name, elem, clipId);
248     else item = new ProjectItem(listView, name, elem, clipId);
249     if (!url.isEmpty()) {
250         // if file has Nepomuk comment, use it
251         Nepomuk::Resource f(url.path());
252         QString annotation;
253         if (f.isValid()) annotation = f.description();
254
255         if (!annotation.isEmpty()) item->setText(2, annotation);
256         QString resource = url.path();
257         if (resource.endsWith("westley") || resource.endsWith("kdenlive")) {
258             QString tmpfile;
259             QDomDocument doc;
260             if (KIO::NetAccess::download(url, tmpfile, 0)) {
261                 QFile file(tmpfile);
262                 if (file.open(QIODevice::ReadOnly)) {
263                     doc.setContent(&file, false);
264                     file.close();
265                 }
266                 KIO::NetAccess::removeTempFile(tmpfile);
267
268                 QDomNodeList subProds = doc.elementsByTagName("producer");
269                 int ct = subProds.count();
270                 for (int i = 0; i <  ct ; i++) {
271                     QDomElement e = subProds.item(i).toElement();
272                     if (!e.isNull()) {
273                         addProducer(e, clipId);
274                     }
275                 }
276             }
277         }
278
279     }
280
281     if (elem.isNull()) {
282         QDomDocument doc;
283         QDomElement element = doc.createElement("producer");
284         element.setAttribute("resource", url.path());
285         emit getFileProperties(element, clipId);
286     } else emit getFileProperties(elem, clipId);
287     selectItemById(clipId);
288 }
289
290 void ProjectList::slotDeleteClip(int clipId) {
291     ProjectItem *item = getItemById(clipId);
292     QTreeWidgetItem *p = item->parent();
293     if (p) {
294         kDebug() << "///////  DELETEED CLIP HAS A PARENT... " << p->indexOfChild(item);
295         QTreeWidgetItem *clone = p->takeChild(p->indexOfChild(item));
296     } else if (item) delete item;
297 }
298
299 void ProjectList::slotAddFolder() {
300
301     // QString folderName = KInputDialog::getText(i18n("New Folder"), i18n("Enter new folder name: "));
302     // if (folderName.isEmpty()) return;
303     m_doc->slotAddFolder(i18n("Folder")); //folderName);
304 }
305
306 void ProjectList::slotAddFolder(const QString foldername, int clipId, bool remove, bool edit) {
307     if (remove) {
308         ProjectItem *item;
309         QTreeWidgetItemIterator it(listView);
310         while (*it) {
311             item = static_cast <ProjectItem *>(*it);
312             if (item->clipType() == FOLDER && item->clipId() == clipId) {
313                 delete item;
314                 break;
315             }
316             ++it;
317         }
318     } else {
319         if (edit) {
320             disconnect(listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotUpdateItemDescription(QTreeWidgetItem *, int)));
321             ProjectItem *item;
322             QTreeWidgetItemIterator it(listView);
323             while (*it) {
324                 item = static_cast <ProjectItem *>(*it);
325                 if (item->clipType() == FOLDER && item->clipId() == clipId) {
326                     item->setText(1, foldername);
327                     break;
328                 }
329                 ++it;
330             }
331             connect(listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotUpdateItemDescription(QTreeWidgetItem *, int)));
332         } else {
333             QStringList text;
334             text << QString() << foldername;
335             (void) new ProjectItem(listView, text, clipId);
336         }
337     }
338 }
339
340 void ProjectList::slotAddClip(DocClipBase *clip) {
341     const int parent = clip->toXML().attribute("groupid").toInt();
342     ProjectItem *item = NULL;
343     if (parent != 0) {
344         ProjectItem *parentitem = getItemById(parent);
345         if (parentitem) item = new ProjectItem(parentitem, clip);
346     }
347     if (item == NULL) item = new ProjectItem(listView, clip);
348
349     KUrl url = clip->fileURL();
350     if (!url.isEmpty()) {
351         // if file has Nepomuk comment, use it
352         Nepomuk::Resource f(url.path());
353         QString annotation;
354         if (f.isValid()) {
355             annotation = f.description();
356             /*
357             Nepomuk::Tag tag("test");
358             f.addTag(tag);*/
359         } else kDebug() << "---  CANNOT CONTACT NEPOMUK";
360         if (!annotation.isEmpty()) item->setText(2, annotation);
361     }
362     emit getFileProperties(clip->toXML(), clip->getId());
363 }
364
365 void ProjectList::slotUpdateClip(int id) {
366     ProjectItem *item = getItemById(id);
367     item->setData(1, UsageRole, QString::number(item->numReferences()));
368 }
369
370 void ProjectList::slotAddClip(QUrl givenUrl, QString group) {
371     if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!!  NO CMD STK";
372     KUrl::List list;
373     if (givenUrl.isEmpty())
374         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");
375     else list.append(givenUrl);
376     if (list.isEmpty()) return;
377     KUrl::List::Iterator it;
378     int groupId = -1;
379     if (group.isEmpty()) {
380         ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
381         if (item && item->clipType() != FOLDER) {
382             while (item->parent()) {
383                 item = static_cast <ProjectItem*>(item->parent());
384                 if (item->clipType() == FOLDER) break;
385             }
386         }
387         if (item && item->clipType() == FOLDER) {
388             group = item->groupName();
389             groupId = item->clipId();
390         }
391     }
392     for (it = list.begin(); it != list.end(); it++) {
393         m_doc->slotAddClipFile(*it, group, groupId);
394     }
395 }
396
397 void ProjectList::slotAddColorClip() {
398     if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!!  NO CMD STK";
399     QDialog *dia = new QDialog(this);
400     Ui::ColorClip_UI *dia_ui = new Ui::ColorClip_UI();
401     dia_ui->setupUi(dia);
402     dia_ui->clip_name->setText(i18n("Color Clip"));
403     dia_ui->clip_duration->setText(KdenliveSettings::color_duration());
404     if (dia->exec() == QDialog::Accepted) {
405         QString color = dia_ui->clip_color->color().name();
406         color = color.replace(0, 1, "0x") + "ff";
407
408         QString group = QString();
409         int groupId = -1;
410         ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
411         if (item && item->clipType() != FOLDER) {
412             while (item->parent()) {
413                 item = static_cast <ProjectItem*>(item->parent());
414                 if (item->clipType() == FOLDER) break;
415             }
416         }
417         if (item && item->clipType() == FOLDER) {
418             group = item->groupName();
419             groupId = item->clipId();
420         }
421
422         m_doc->slotAddColorClipFile(dia_ui->clip_name->text(), color, dia_ui->clip_duration->text(), group, groupId);
423     }
424     delete dia_ui;
425     delete dia;
426 }
427
428
429 void ProjectList::slotAddSlideshowClip() {
430     if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!!  NO CMD STK";
431     SlideshowClip *dia = new SlideshowClip(this);
432
433     if (dia->exec() == QDialog::Accepted) {
434
435         QString group = QString();
436         int groupId = -1;
437         ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
438         if (item && item->clipType() != FOLDER) {
439             while (item->parent()) {
440                 item = static_cast <ProjectItem*>(item->parent());
441                 if (item->clipType() == FOLDER) break;
442             }
443         }
444         if (item && item->clipType() == FOLDER) {
445             group = item->groupName();
446             groupId = item->clipId();
447         }
448
449         m_doc->slotAddSlideshowClipFile(dia->clipName(), dia->selectedPath(), dia->imageCount(), dia->clipDuration(), dia->loop(), group, groupId);
450     }
451     delete dia;
452 }
453 void ProjectList::slotAddTitleClip() {
454     QString group = QString();
455     int groupId = -1;
456     ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
457     if (item && item->clipType() != FOLDER) {
458         while (item->parent()) {
459             item = static_cast <ProjectItem*>(item->parent());
460             if (item->clipType() == FOLDER) break;
461         }
462     }
463     if (item && item->clipType() == FOLDER) {
464         group = item->groupName();
465         groupId = item->clipId();
466     }
467
468     m_doc->slotCreateTextClip(group, groupId);
469 }
470
471 void ProjectList::setDocument(KdenliveDoc *doc) {
472     listView->clear();
473     QList <DocClipBase*> list = doc->clipManager()->documentClipList();
474     for (int i = 0; i < list.count(); i++) {
475         slotAddClip(list.at(i));
476     }
477
478     m_fps = doc->fps();
479     m_timecode = doc->timecode();
480     m_commandStack = doc->commandStack();
481     m_doc = doc;
482     /*    QDomNodeList prods = doc->producersList();
483         int ct = prods.count();
484         kDebug() << "////////////  SETTING DOC, FOUND CLIPS: " << prods.count();
485         listView->clear();
486         for (int i = 0; i <  ct ; i++) {
487             QDomElement e = prods.item(i).toElement();
488             kDebug() << "// IMPORT: " << i << ", :" << e.attribute("id", "non") << ", NAME: " << e.attribute("name", "non");
489             if (!e.isNull()) addProducer(e);
490         }*/
491     QTreeWidgetItem *first = listView->topLevelItem(0);
492     if (first) listView->setCurrentItem(first);
493     m_toolbar->setEnabled(true);
494 }
495
496 QDomElement ProjectList::producersList() {
497     QDomDocument doc;
498     QDomElement prods = doc.createElement("producerlist");
499     doc.appendChild(prods);
500     kDebug() << "////////////  PRO LIST BUILD PRDSLIST ";
501     QTreeWidgetItemIterator it(listView);
502     while (*it) {
503         if (!((ProjectItem *)(*it))->isGroup())
504             prods.appendChild(doc.importNode(((ProjectItem *)(*it))->toXml(), true));
505         ++it;
506     }
507     return prods;
508 }
509
510 void ProjectList::slotRefreshClipThumbnail(int clipId) {
511     ProjectItem *item = getItemById(clipId);
512     if (item) slotRefreshClipThumbnail(item);
513 }
514
515 void ProjectList::slotRefreshClipThumbnail(ProjectItem *item) {
516     if (item) {
517         int height = 40;
518         int width = (int)(height  * (double) m_render->renderWidth() / m_render->renderHeight());
519         QPixmap pix = KThumb::getImage(item->toXml(), item->referencedClip()->getProjectThumbFrame(), width, height);
520         //QPixmap pix = KThumb::getFrame(item->toXml()), 0, width, height);
521         item->setIcon(0, pix);
522     }
523 }
524
525 void ProjectList::slotReplyGetFileProperties(int clipId, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata) {
526     ProjectItem *item = getItemById(clipId);
527     if (item) {
528         item->setProperties(properties, metadata);
529         listView->setCurrentItem(item);
530         emit receivedClipDuration(clipId, item->clipMaxDuration());
531     }
532 }
533
534 void ProjectList::slotReplyGetImage(int clipId, int pos, const QPixmap &pix, int w, int h) {
535     ProjectItem *item = getItemById(clipId);
536     if (item) item->setIcon(0, pix);
537 }
538
539 ProjectItem *ProjectList::getItemById(int id) {
540     QTreeWidgetItemIterator it(listView);
541     while (*it) {
542         if (((ProjectItem *)(*it))->clipId() == id)
543             break;
544         ++it;
545     }
546     if (*it) return ((ProjectItem *)(*it));
547     return NULL;
548 }
549
550
551 void ProjectList::addProducer(QDomElement producer, int parentId) {
552     if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!!  NO CMD STK";
553     CLIPTYPE type = (CLIPTYPE) producer.attribute("type").toInt();
554
555     /*QDomDocument doc;
556     QDomElement prods = doc.createElement("list");
557     doc.appendChild(prods);
558     prods.appendChild(doc.importNode(producer, true));*/
559
560
561     //kDebug()<<"//////  ADDING PRODUCER:\n "<<doc.toString()<<"\n+++++++++++++++++";
562     int id = producer.attribute("id").toInt();
563     QString groupName = producer.attribute("groupname");
564     if (id >= m_clipIdCounter) m_clipIdCounter = id + 1;
565     else if (id == 0) id = m_clipIdCounter++;
566
567     if (parentId != -1) {
568         // item is a westley playlist, adjust subproducers ids
569         id = (parentId + 1) * 10000 + id;
570     }
571     if (type == AUDIO || type == VIDEO || type == AV || type == IMAGE  || type == PLAYLIST) {
572         KUrl resource = KUrl(producer.attribute("resource"));
573         if (!resource.isEmpty()) {
574             QStringList itemEntry;
575             itemEntry.append(QString::null);
576             itemEntry.append(resource.fileName());
577             addClip(itemEntry, producer, id, resource, groupName, parentId);
578         }
579     } else if (type == COLOR) {
580         QString colour = producer.attribute("colour");
581         QPixmap pix(60, 40);
582         colour = colour.replace(0, 2, "#");
583         pix.fill(QColor(colour.left(7)));
584         QStringList itemEntry;
585         itemEntry.append(QString::null);
586         itemEntry.append(producer.attribute("name", i18n("Color clip")));
587         addClip(itemEntry, producer, id, KUrl(), groupName, parentId);
588     }
589
590 }
591
592 #include "projectlist.moc"