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