]> git.sesse.net Git - kdenlive/blob - src/projectlist.cpp
Add animation feature to Slideshow Clip.
[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 #include "projectlist.h"
21 #include "projectitem.h"
22 #include "addfoldercommand.h"
23 #include "kdenlivesettings.h"
24 #include "slideshowclip.h"
25 #include "ui_colorclip_ui.h"
26 #include "titlewidget.h"
27 #include "definitions.h"
28 #include "clipmanager.h"
29 #include "docclipbase.h"
30 #include "kdenlivedoc.h"
31 #include "renderer.h"
32 #include "kthumb.h"
33 #include "projectlistview.h"
34 #include "timecodedisplay.h"
35 #include "editclipcommand.h"
36 #include "editclipcutcommand.h"
37 #include "editfoldercommand.h"
38 #include "addclipcutcommand.h"
39
40 #include "ui_templateclip_ui.h"
41
42 #include <KDebug>
43 #include <KAction>
44 #include <KLocale>
45 #include <KFileDialog>
46 #include <KInputDialog>
47 #include <KMessageBox>
48 #include <KIO/NetAccess>
49 #include <KFileItem>
50 #ifdef NEPOMUK
51 #include <nepomuk/global.h>
52 #include <nepomuk/resourcemanager.h>
53 //#include <nepomuk/tag.h>
54 #endif
55
56 #include <QMouseEvent>
57 #include <QStylePainter>
58 #include <QPixmap>
59 #include <QIcon>
60 #include <QMenu>
61 #include <QProcess>
62 #include <QHeaderView>
63 #include <QInputDialog>
64
65 ProjectList::ProjectList(QWidget *parent) :
66         QWidget(parent),
67         m_render(NULL),
68         m_fps(-1),
69         m_commandStack(NULL),
70         m_editAction(NULL),
71         m_deleteAction(NULL),
72         m_openAction(NULL),
73         m_reloadAction(NULL),
74         m_transcodeAction(NULL),
75         m_doc(NULL),
76         m_refreshed(false),
77         m_infoQueue(),
78         m_thumbnailQueue()
79 {
80
81     m_listView = new ProjectListView(this);;
82     QVBoxLayout *layout = new QVBoxLayout;
83     layout->setContentsMargins(0, 0, 0, 0);
84     layout->setSpacing(0);
85
86     // setup toolbar
87     KTreeWidgetSearchLine *searchView = new KTreeWidgetSearchLine(this);
88     m_toolbar = new QToolBar("projectToolBar", this);
89     m_toolbar->addWidget(searchView);
90     int s = style()->pixelMetric(QStyle::PM_SmallIconSize);
91     m_toolbar->setIconSize(QSize(s, s));
92     searchView->setTreeWidget(m_listView);
93
94     m_addButton = new QToolButton(m_toolbar);
95     m_addButton->setPopupMode(QToolButton::MenuButtonPopup);
96     m_toolbar->addWidget(m_addButton);
97
98     layout->addWidget(m_toolbar);
99     layout->addWidget(m_listView);
100     setLayout(layout);
101
102     m_queueTimer.setInterval(100);
103     connect(&m_queueTimer, SIGNAL(timeout()), this, SLOT(slotProcessNextClipInQueue()));
104     m_queueTimer.setSingleShot(true);
105
106
107     connect(m_listView, SIGNAL(projectModified()), this, SIGNAL(projectModified()));
108     connect(m_listView, SIGNAL(itemSelectionChanged()), this, SLOT(slotClipSelected()));
109     connect(m_listView, SIGNAL(focusMonitor()), this, SLOT(slotClipSelected()));
110     connect(m_listView, SIGNAL(pauseMonitor()), this, SLOT(slotPauseMonitor()));
111     connect(m_listView, SIGNAL(requestMenu(const QPoint &, QTreeWidgetItem *)), this, SLOT(slotContextMenu(const QPoint &, QTreeWidgetItem *)));
112     connect(m_listView, SIGNAL(addClip()), this, SLOT(slotAddClip()));
113     connect(m_listView, SIGNAL(addClip(const QList <QUrl>, const QString &, const QString &)), this, SLOT(slotAddClip(const QList <QUrl>, const QString &, const QString &)));
114     connect(m_listView, SIGNAL(addClipCut(const QString &, int, int)), this, SLOT(slotAddClipCut(const QString &, int, int)));
115     connect(m_listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotItemEdited(QTreeWidgetItem *, int)));
116     connect(m_listView, SIGNAL(showProperties(DocClipBase *)), this, SIGNAL(showClipProperties(DocClipBase *)));
117
118     m_listViewDelegate = new ItemDelegate(m_listView);
119     m_listView->setItemDelegate(m_listViewDelegate);
120 #ifdef NEPOMUK
121     if (KdenliveSettings::activate_nepomuk()) {
122         Nepomuk::ResourceManager::instance()->init();
123         if (!Nepomuk::ResourceManager::instance()->initialized()) {
124             kDebug() << "Cannot communicate with Nepomuk, DISABLING it";
125             KdenliveSettings::setActivate_nepomuk(false);
126         }
127     }
128 #endif
129 }
130
131 ProjectList::~ProjectList()
132 {
133     delete m_menu;
134     delete m_toolbar;
135     m_listView->blockSignals(true);
136     m_listView->clear();
137     delete m_listViewDelegate;
138 }
139
140 void ProjectList::focusTree() const
141 {
142     m_listView->setFocus();
143 }
144
145 void ProjectList::setupMenu(QMenu *addMenu, QAction *defaultAction)
146 {
147     QList <QAction *> actions = addMenu->actions();
148     for (int i = 0; i < actions.count(); i++) {
149         if (actions.at(i)->data().toString() == "clip_properties") {
150             m_editAction = actions.at(i);
151             m_toolbar->addAction(m_editAction);
152             actions.removeAt(i);
153             i--;
154         } else if (actions.at(i)->data().toString() == "delete_clip") {
155             m_deleteAction = actions.at(i);
156             m_toolbar->addAction(m_deleteAction);
157             actions.removeAt(i);
158             i--;
159         } else if (actions.at(i)->data().toString() == "edit_clip") {
160             m_openAction = actions.at(i);
161             actions.removeAt(i);
162             i--;
163         } else if (actions.at(i)->data().toString() == "reload_clip") {
164             m_reloadAction = actions.at(i);
165             actions.removeAt(i);
166             i--;
167         }
168     }
169
170     QMenu *m = new QMenu();
171     m->addActions(actions);
172     m_addButton->setMenu(m);
173     m_addButton->setDefaultAction(defaultAction);
174     m_menu = new QMenu();
175     m_menu->addActions(addMenu->actions());
176 }
177
178 void ProjectList::setupGeneratorMenu(QMenu *addMenu, QMenu *transcodeMenu, QMenu *inTimelineMenu)
179 {
180     if (!addMenu)
181         return;
182     QMenu *menu = m_addButton->menu();
183     menu->addMenu(addMenu);
184     m_addButton->setMenu(menu);
185
186     m_menu->addMenu(addMenu);
187     if (addMenu->isEmpty())
188         addMenu->setEnabled(false);
189     m_menu->addMenu(transcodeMenu);
190     if (transcodeMenu->isEmpty())
191         transcodeMenu->setEnabled(false);
192     m_transcodeAction = transcodeMenu;
193     m_menu->addAction(m_reloadAction);
194     m_menu->addMenu(inTimelineMenu);
195     inTimelineMenu->setEnabled(false);
196     m_menu->addAction(m_editAction);
197     m_menu->addAction(m_openAction);
198     m_menu->addAction(m_deleteAction);
199     m_menu->insertSeparator(m_deleteAction);
200 }
201
202
203 QByteArray ProjectList::headerInfo() const
204 {
205     return m_listView->header()->saveState();
206 }
207
208 void ProjectList::setHeaderInfo(const QByteArray &state)
209 {
210     m_listView->header()->restoreState(state);
211 }
212
213 void ProjectList::updateProjectFormat(Timecode t)
214 {
215     m_timecode = t;
216 }
217
218 void ProjectList::slotEditClip()
219 {
220     QList<QTreeWidgetItem *> list = m_listView->selectedItems();
221     if (list.count() > 1) {
222         editClipSelection(list);
223         return;
224     }
225     ProjectItem *item;
226     if (!m_listView->currentItem() || m_listView->currentItem()->type() == PROJECTFOLDERTYPE)
227         return;
228     if (m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE)
229         item = static_cast <ProjectItem*>(m_listView->currentItem()->parent());
230     else
231         item = static_cast <ProjectItem*>(m_listView->currentItem());
232     if (item && (item->flags() & Qt::ItemIsDragEnabled)) {
233         emit clipSelected(item->referencedClip());
234         emit showClipProperties(item->referencedClip());
235     }
236 }
237
238 void ProjectList::editClipSelection(QList<QTreeWidgetItem *> list)
239 {
240     // Gather all common properties
241     QMap <QString, QString> commonproperties;
242     QList <DocClipBase *> clipList;
243     commonproperties.insert("force_aspect_ratio", "-");
244     commonproperties.insert("force_fps", "-");
245     commonproperties.insert("force_progressive", "-");
246     commonproperties.insert("threads", "-");
247     commonproperties.insert("video_index", "-");
248     commonproperties.insert("audio_index", "-");
249
250     bool allowDurationChange = true;
251     int commonDuration = -1;
252     ProjectItem *item;
253     for (int i = 0; i < list.count(); i++) {
254         item = NULL;
255         if (list.at(i)->type() == PROJECTFOLDERTYPE)
256             continue;
257         if (list.at(i)->type() == PROJECTSUBCLIPTYPE)
258             item = static_cast <ProjectItem*>(list.at(i)->parent());
259         else
260             item = static_cast <ProjectItem*>(list.at(i));
261         if (!(item->flags() & Qt::ItemIsDragEnabled))
262             continue;
263         if (item) {
264             // check properties
265             DocClipBase *clip = item->referencedClip();
266             if (clipList.contains(clip)) continue;
267             if (clip->clipType() != COLOR && clip->clipType() != IMAGE && clip->clipType() != TEXT)
268                 allowDurationChange = false;
269             if (allowDurationChange && commonDuration != 0) {
270                 if (commonDuration == -1)
271                     commonDuration = clip->duration().frames(m_fps);
272                 else if (commonDuration != clip->duration().frames(m_fps))
273                     commonDuration = 0;
274             }
275             clipList.append(clip);
276             QMap <QString, QString> clipprops = clip->properties();
277             QMapIterator<QString, QString> p(commonproperties);
278             while (p.hasNext()) {
279                 p.next();
280                 if (p.value().isEmpty()) continue;
281                 if (clipprops.contains(p.key())) {
282                     if (p.value() == "-")
283                         commonproperties.insert(p.key(), clipprops.value(p.key()));
284                     else if (p.value() != clipprops.value(p.key()))
285                         commonproperties.insert(p.key(), QString());
286                 } else {
287                     commonproperties.insert(p.key(), QString());
288                 }
289             }
290         }
291     }
292     if (allowDurationChange)
293         commonproperties.insert("out", QString::number(commonDuration));
294     QMapIterator<QString, QString> p(commonproperties);
295     while (p.hasNext()) {
296         p.next();
297         kDebug() << "Result: " << p.key() << " = " << p.value();
298     }
299     emit showClipProperties(clipList, commonproperties);
300 }
301
302 void ProjectList::slotOpenClip()
303 {
304     ProjectItem *item;
305     if (!m_listView->currentItem() || m_listView->currentItem()->type() == PROJECTFOLDERTYPE)
306         return;
307     if (m_listView->currentItem()->type() == QTreeWidgetItem::UserType + 1)
308         item = static_cast <ProjectItem*>(m_listView->currentItem()->parent());
309     else
310         item = static_cast <ProjectItem*>(m_listView->currentItem());
311     if (item) {
312         if (item->clipType() == IMAGE) {
313             if (KdenliveSettings::defaultimageapp().isEmpty())
314                 KMessageBox::sorry(this, i18n("Please set a default application to open images in the Settings dialog"));
315             else
316                 QProcess::startDetached(KdenliveSettings::defaultimageapp(), QStringList() << item->clipUrl().path());
317         }
318         if (item->clipType() == AUDIO) {
319             if (KdenliveSettings::defaultaudioapp().isEmpty())
320                 KMessageBox::sorry(this, i18n("Please set a default application to open audio files in the Settings dialog"));
321             else
322                 QProcess::startDetached(KdenliveSettings::defaultaudioapp(), QStringList() << item->clipUrl().path());
323         }
324     }
325 }
326
327 void ProjectList::cleanup()
328 {
329     m_listView->clearSelection();
330     QTreeWidgetItemIterator it(m_listView);
331     ProjectItem *item;
332     while (*it) {
333         if ((*it)->type() != PROJECTCLIPTYPE) {
334             it++;
335             continue;
336         }
337         item = static_cast <ProjectItem *>(*it);
338         if (item->numReferences() == 0)
339             item->setSelected(true);
340         it++;
341     }
342     slotRemoveClip();
343 }
344
345 void ProjectList::trashUnusedClips()
346 {
347     QTreeWidgetItemIterator it(m_listView);
348     ProjectItem *item;
349     QStringList ids;
350     QStringList urls;
351     while (*it) {
352         if ((*it)->type() != PROJECTCLIPTYPE) {
353             it++;
354             continue;
355         }
356         item = static_cast <ProjectItem *>(*it);
357         if (item->numReferences() == 0) {
358             ids << item->clipId();
359             KUrl url = item->clipUrl();
360             if (!url.isEmpty() && !urls.contains(url.path()))
361                 urls << url.path();
362         }
363         it++;
364     }
365
366     // Check that we don't use the URL in another clip
367     QTreeWidgetItemIterator it2(m_listView);
368     while (*it2) {
369         if ((*it2)->type() != PROJECTCLIPTYPE) {
370             it2++;
371             continue;
372         }
373         item = static_cast <ProjectItem *>(*it2);
374         if (item->numReferences() > 0) {
375             KUrl url = item->clipUrl();
376             if (!url.isEmpty() && urls.contains(url.path())) urls.removeAll(url.path());
377         }
378         it2++;
379     }
380
381     emit deleteProjectClips(ids, QMap <QString, QString>());
382     for (int i = 0; i < urls.count(); i++)
383         KIO::NetAccess::del(KUrl(urls.at(i)), this);
384 }
385
386 void ProjectList::slotReloadClip(const QString &id)
387 {
388     QList<QTreeWidgetItem *> selected;
389     if (id.isEmpty())
390         selected = m_listView->selectedItems();
391     else
392         selected.append(getItemById(id));
393     ProjectItem *item;
394     for (int i = 0; i < selected.count(); i++) {
395         if (selected.at(i)->type() != PROJECTCLIPTYPE) {
396             if (selected.at(i)->type() == PROJECTFOLDERTYPE) {
397                 for (int j = 0; j < selected.at(i)->childCount(); j++)
398                     selected.append(selected.at(i)->child(j));
399             }
400             continue;
401         }
402         item = static_cast <ProjectItem *>(selected.at(i));
403         if (item) {
404             if (item->clipType() == TEXT) {
405                 if (!item->referencedClip()->getProperty("xmltemplate").isEmpty())
406                     regenerateTemplate(item);
407             } else if (item->clipType() != COLOR && item->clipType() != SLIDESHOW && item->referencedClip() &&  item->referencedClip()->checkHash() == false) {
408                 item->referencedClip()->setPlaceHolder(true);
409                 item->setProperty("file_hash", QString());
410             } else if (item->clipType() == IMAGE) {
411                 item->referencedClip()->producer()->set("force_reload", 1);
412             }
413             //requestClipInfo(item->toXml(), item->clipId(), true);
414             // Clear the file_hash value, which will cause a complete reload of the clip
415             emit getFileProperties(item->toXml(), item->clipId(), m_listView->iconSize().height(), true);
416         }
417     }
418 }
419
420 void ProjectList::slotModifiedClip(const QString &id)
421 {
422     ProjectItem *item = getItemById(id);
423     if (item) {
424         QPixmap pixmap = qVariantValue<QPixmap>(item->data(0, Qt::DecorationRole));
425         if (!pixmap.isNull()) {
426             QPainter p(&pixmap);
427             p.fillRect(0, 0, pixmap.width(), pixmap.height(), QColor(255, 255, 255, 200));
428             p.drawPixmap(0, 0, KIcon("view-refresh").pixmap(m_listView->iconSize()));
429             p.end();
430         } else {
431             pixmap = KIcon("view-refresh").pixmap(m_listView->iconSize());
432         }
433         item->setData(0, Qt::DecorationRole, pixmap);
434     }
435 }
436
437 void ProjectList::slotMissingClip(const QString &id)
438 {
439     ProjectItem *item = getItemById(id);
440     if (item) {
441         item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
442         if (item->referencedClip()) {
443             item->referencedClip()->setPlaceHolder(true);
444             if (m_render == NULL) kDebug() << "*********  ERROR, NULL RENDR";
445             item->referencedClip()->setProducer(m_render->invalidProducer(id), true);
446             item->slotSetToolTip();
447             emit clipNeedsReload(id, true);
448         }
449     }
450     update();
451     emit displayMessage(i18n("Check missing clips"), -2);
452     emit updateRenderStatus();
453 }
454
455 void ProjectList::slotAvailableClip(const QString &id)
456 {
457     ProjectItem *item = getItemById(id);
458     if (item == NULL)
459         return;
460     item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
461     if (item->referencedClip()) { // && item->referencedClip()->checkHash() == false) {
462         item->setProperty("file_hash", QString());
463         slotReloadClip(id);
464     }
465     /*else {
466     item->referencedClip()->setValid();
467     item->slotSetToolTip();
468     }
469     update();*/
470     emit updateRenderStatus();
471 }
472
473 bool ProjectList::hasMissingClips()
474 {
475     bool missing = false;
476     QTreeWidgetItemIterator it(m_listView);
477     while (*it) {
478         if ((*it)->type() == PROJECTCLIPTYPE && !((*it)->flags() & Qt::ItemIsDragEnabled)) {
479             missing = true;
480             break;
481         }
482         it++;
483     }
484     return missing;
485 }
486
487 void ProjectList::setRenderer(Render *projectRender)
488 {
489     m_render = projectRender;
490     m_listView->setIconSize(QSize((ProjectItem::itemDefaultHeight() - 2) * m_render->dar(), ProjectItem::itemDefaultHeight() - 2));
491 }
492
493 void ProjectList::slotClipSelected()
494 {
495     if (!m_listView->isEnabled()) return;
496     if (m_listView->currentItem()) {
497         if (m_listView->currentItem()->type() == PROJECTFOLDERTYPE) {
498             emit clipSelected(NULL);
499             m_editAction->setEnabled(false);
500             m_deleteAction->setEnabled(true);
501             m_openAction->setEnabled(false);
502             m_reloadAction->setEnabled(false);
503             m_transcodeAction->setEnabled(false);
504         } else {
505             ProjectItem *clip;
506             if (m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE) {
507                 // this is a sub item, use base clip
508                 m_deleteAction->setEnabled(true);
509                 clip = static_cast <ProjectItem*>(m_listView->currentItem()->parent());
510                 if (clip == NULL) kDebug() << "-----------ERROR";
511                 SubProjectItem *sub = static_cast <SubProjectItem*>(m_listView->currentItem());
512                 emit clipSelected(clip->referencedClip(), sub->zone());
513                 m_transcodeAction->setEnabled(false);
514                 return;
515             }
516             clip = static_cast <ProjectItem*>(m_listView->currentItem());
517             if (clip)
518                 emit clipSelected(clip->referencedClip());
519             m_editAction->setEnabled(true);
520             m_deleteAction->setEnabled(true);
521             m_reloadAction->setEnabled(true);
522             m_transcodeAction->setEnabled(true);
523             if (clip && clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
524                 m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp()));
525                 m_openAction->setEnabled(true);
526             } else if (clip && clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
527                 m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp()));
528                 m_openAction->setEnabled(true);
529             } else {
530                 m_openAction->setEnabled(false);
531             }
532             // Display relevant transcoding actions only
533             adjustTranscodeActions(clip);
534             // Display uses in timeline
535             emit findInTimeline(clip->clipId());
536         }
537     } else {
538         emit clipSelected(NULL);
539         m_editAction->setEnabled(false);
540         m_deleteAction->setEnabled(false);
541         m_openAction->setEnabled(false);
542         m_reloadAction->setEnabled(false);
543         m_transcodeAction->setEnabled(false);
544     }
545 }
546
547 void ProjectList::adjustTranscodeActions(ProjectItem *clip) const
548 {
549     if (clip == NULL || clip->type() != PROJECTCLIPTYPE || clip->clipType() == COLOR || clip->clipType() == TEXT || clip->clipType() == PLAYLIST || clip->clipType() == SLIDESHOW) {
550         m_transcodeAction->setEnabled(false);
551         return;
552     }
553     m_transcodeAction->setEnabled(true);
554     QList<QAction *> transcodeActions = m_transcodeAction->actions();
555     QStringList data;
556     QString condition;
557     for (int i = 0; i < transcodeActions.count(); i++) {
558         data = transcodeActions.at(i)->data().toStringList();
559         if (data.count() > 2) {
560             condition = data.at(2);
561             if (condition.startsWith("vcodec"))
562                 transcodeActions.at(i)->setEnabled(clip->referencedClip()->hasVideoCodec(condition.section("=", 1, 1)));
563             else if (condition.startsWith("acodec"))
564                 transcodeActions.at(i)->setEnabled(clip->referencedClip()->hasVideoCodec(condition.section("=", 1, 1)));
565         }
566     }
567
568 }
569
570 void ProjectList::slotPauseMonitor()
571 {
572     if (m_render)
573         m_render->pause();
574 }
575
576 void ProjectList::slotUpdateClipProperties(const QString &id, QMap <QString, QString> properties)
577 {
578     ProjectItem *item = getItemById(id);
579     if (item) {
580         slotUpdateClipProperties(item, properties);
581         if (properties.contains("out") || properties.contains("force_fps")) {
582             slotReloadClip(id);
583         } else if (properties.contains("colour") || properties.contains("resource") || properties.contains("xmldata") || properties.contains("force_aspect_ratio") || properties.contains("templatetext")) {
584             slotRefreshClipThumbnail(item);
585             emit refreshClip();
586         }
587     }
588 }
589
590 void ProjectList::slotUpdateClipProperties(ProjectItem *clip, QMap <QString, QString> properties)
591 {
592     if (!clip)
593         return;
594     clip->setProperties(properties);
595     if (properties.contains("name")) {
596         m_listView->blockSignals(true);
597         clip->setText(0, properties.value("name"));
598         m_listView->blockSignals(false);
599         emit clipNameChanged(clip->clipId(), properties.value("name"));
600     }
601     if (properties.contains("description")) {
602         CLIPTYPE type = clip->clipType();
603         m_listView->blockSignals(true);
604         clip->setText(1, properties.value("description"));
605         m_listView->blockSignals(false);
606 #ifdef NEPOMUK
607         if (KdenliveSettings::activate_nepomuk() && (type == AUDIO || type == VIDEO || type == AV || type == IMAGE || type == PLAYLIST)) {
608             // Use Nepomuk system to store clip description
609             Nepomuk::Resource f(clip->clipUrl().path());
610             f.setDescription(properties.value("description"));
611         }
612 #endif
613         emit projectModified();
614     }
615 }
616
617 void ProjectList::slotItemEdited(QTreeWidgetItem *item, int column)
618 {
619     if (item->type() == PROJECTSUBCLIPTYPE) {
620         // this is a sub-item
621         if (column == 1) {
622             // user edited description
623             SubProjectItem *sub = static_cast <SubProjectItem*>(item);
624             ProjectItem *item = static_cast <ProjectItem *>(sub->parent());
625             EditClipCutCommand *command = new EditClipCutCommand(this, item->clipId(), sub->zone(), sub->zone(), sub->description(), sub->text(1), true);
626             m_commandStack->push(command);
627             //slotUpdateCutClipProperties(sub->clipId(), sub->zone(), sub->text(1), sub->text(1));
628         }
629         return;
630     }
631     if (item->type() == PROJECTFOLDERTYPE) {
632         if (column == 0) {
633             FolderProjectItem *folder = static_cast <FolderProjectItem*>(item);
634             editFolder(item->text(0), folder->groupName(), folder->clipId());
635             folder->setGroupName(item->text(0));
636             m_doc->clipManager()->addFolder(folder->clipId(), item->text(0));
637             const int children = item->childCount();
638             for (int i = 0; i < children; i++) {
639                 ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
640                 child->setProperty("groupname", item->text(0));
641             }
642         }
643         return;
644     }
645
646     ProjectItem *clip = static_cast <ProjectItem*>(item);
647     if (column == 1) {
648         if (clip->referencedClip()) {
649             QMap <QString, QString> oldprops;
650             QMap <QString, QString> newprops;
651             oldprops["description"] = clip->referencedClip()->getProperty("description");
652             newprops["description"] = item->text(1);
653
654             if (clip->clipType() == TEXT) {
655                 // This is a text template clip, update the image
656                 /*oldprops.insert("xmldata", clip->referencedClip()->getProperty("xmldata"));
657                 newprops.insert("xmldata", generateTemplateXml(clip->referencedClip()->getProperty("xmltemplate"), item->text(2)).toString());*/
658                 oldprops.insert("templatetext", clip->referencedClip()->getProperty("templatetext"));
659                 newprops.insert("templatetext", item->text(1));
660             }
661             slotUpdateClipProperties(clip->clipId(), newprops);
662             EditClipCommand *command = new EditClipCommand(this, clip->clipId(), oldprops, newprops, false);
663             m_commandStack->push(command);
664         }
665     } else if (column == 0) {
666         if (clip->referencedClip()) {
667             QMap <QString, QString> oldprops;
668             QMap <QString, QString> newprops;
669             oldprops["name"] = clip->referencedClip()->getProperty("name");
670             newprops["name"] = item->text(0);
671             slotUpdateClipProperties(clip, newprops);
672             emit projectModified();
673             EditClipCommand *command = new EditClipCommand(this, clip->clipId(), oldprops, newprops, false);
674             m_commandStack->push(command);
675         }
676     }
677 }
678
679 void ProjectList::slotContextMenu(const QPoint &pos, QTreeWidgetItem *item)
680 {
681     bool enable = item ? true : false;
682     m_editAction->setEnabled(enable);
683     m_deleteAction->setEnabled(enable);
684     m_reloadAction->setEnabled(enable);
685     m_transcodeAction->setEnabled(enable);
686     if (enable) {
687         ProjectItem *clip = NULL;
688         if (m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE) {
689             clip = static_cast <ProjectItem*>(item->parent());
690             m_transcodeAction->setEnabled(false);
691         } else if (m_listView->currentItem()->type() == PROJECTCLIPTYPE) {
692             clip = static_cast <ProjectItem*>(item);
693             // Display relevant transcoding actions only
694             adjustTranscodeActions(clip);
695             // Display uses in timeline
696             emit findInTimeline(clip->clipId());
697         } else {
698             m_transcodeAction->setEnabled(false);
699         }
700         if (clip && clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
701             m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp()));
702             m_openAction->setEnabled(true);
703         } else if (clip && clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
704             m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp()));
705             m_openAction->setEnabled(true);
706         } else {
707             m_openAction->setEnabled(false);
708         }
709
710     } else {
711         m_openAction->setEnabled(false);
712     }
713     m_menu->popup(pos);
714 }
715
716 void ProjectList::slotRemoveClip()
717 {
718     if (!m_listView->currentItem())
719         return;
720     QStringList ids;
721     QMap <QString, QString> folderids;
722     QList<QTreeWidgetItem *> selected = m_listView->selectedItems();
723
724     QUndoCommand *delCommand = new QUndoCommand();
725     delCommand->setText(i18n("Delete Clip Zone"));
726
727     for (int i = 0; i < selected.count(); i++) {
728         if (selected.at(i)->type() == PROJECTSUBCLIPTYPE) {
729             // subitem
730             SubProjectItem *sub = static_cast <SubProjectItem *>(selected.at(i));
731             ProjectItem *item = static_cast <ProjectItem *>(sub->parent());
732             new AddClipCutCommand(this, item->clipId(), sub->zone().x(), sub->zone().y(), sub->description(), false, true, delCommand);
733         } else if (selected.at(i)->type() == PROJECTFOLDERTYPE) {
734             // folder
735             FolderProjectItem *folder = static_cast <FolderProjectItem *>(selected.at(i));
736             folderids[folder->groupName()] = folder->clipId();
737             int children = folder->childCount();
738
739             if (children > 0 && KMessageBox::questionYesNo(this, i18np("Delete folder <b>%2</b>?<br />This will also remove the clip in that folder", "Delete folder <b>%2</b>?<br />This will also remove the %1 clips in that folder",  children, folder->text(1)), i18n("Delete Folder")) != KMessageBox::Yes)
740                 return;
741             for (int i = 0; i < children; ++i) {
742                 ProjectItem *child = static_cast <ProjectItem *>(folder->child(i));
743                 ids << child->clipId();
744             }
745         } else {
746             ProjectItem *item = static_cast <ProjectItem *>(selected.at(i));
747             ids << item->clipId();
748             if (item->numReferences() > 0 && 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)
749                 return;
750         }
751     }
752
753     if (delCommand->childCount() == 0)
754         delete delCommand;
755     else
756         m_commandStack->push(delCommand);
757     emit deleteProjectClips(ids, folderids);
758 }
759
760 void ProjectList::updateButtons() const
761 {
762     if (m_listView->topLevelItemCount() == 0) {
763         m_deleteAction->setEnabled(false);
764     } else {
765         m_deleteAction->setEnabled(true);
766         if (!m_listView->currentItem())
767             m_listView->setCurrentItem(m_listView->topLevelItem(0));
768         QTreeWidgetItem *item = m_listView->currentItem();
769         if (item && item->type() == PROJECTCLIPTYPE) {
770             m_editAction->setEnabled(true);
771             m_openAction->setEnabled(true);
772             m_reloadAction->setEnabled(true);
773             m_transcodeAction->setEnabled(true);
774             return;
775         }
776     }
777
778     m_editAction->setEnabled(false);
779     m_openAction->setEnabled(false);
780     m_reloadAction->setEnabled(false);
781     m_transcodeAction->setEnabled(false);
782 }
783
784 void ProjectList::selectItemById(const QString &clipId)
785 {
786     ProjectItem *item = getItemById(clipId);
787     if (item)
788         m_listView->setCurrentItem(item);
789 }
790
791
792 void ProjectList::slotDeleteClip(const QString &clipId)
793 {
794     ProjectItem *item = getItemById(clipId);
795     if (!item) {
796         kDebug() << "/// Cannot find clip to delete";
797         return;
798     }
799     m_listView->blockSignals(true);
800     QTreeWidgetItem *newSelectedItem = m_listView->itemAbove(item);
801     if (!newSelectedItem)
802         newSelectedItem = m_listView->itemBelow(item);
803     delete item;
804     m_doc->clipManager()->deleteClip(clipId);
805     m_listView->blockSignals(false);
806     if (newSelectedItem) {
807         m_listView->setCurrentItem(newSelectedItem);
808     } else {
809         updateButtons();
810         emit clipSelected(NULL);
811     }
812 }
813
814
815 void ProjectList::editFolder(const QString folderName, const QString oldfolderName, const QString &clipId)
816 {
817     EditFolderCommand *command = new EditFolderCommand(this, folderName, oldfolderName, clipId, false);
818     m_commandStack->push(command);
819     m_doc->setModified(true);
820 }
821
822 void ProjectList::slotAddFolder()
823 {
824     AddFolderCommand *command = new AddFolderCommand(this, i18n("Folder"), QString::number(m_doc->clipManager()->getFreeFolderId()), true);
825     m_commandStack->push(command);
826 }
827
828 void ProjectList::slotAddFolder(const QString foldername, const QString &clipId, bool remove, bool edit)
829 {
830     if (remove) {
831         FolderProjectItem *item = getFolderItemById(clipId);
832         if (item) {
833             m_doc->clipManager()->deleteFolder(clipId);
834             QTreeWidgetItem *newSelectedItem = m_listView->itemAbove(item);
835             if (!newSelectedItem)
836                 newSelectedItem = m_listView->itemBelow(item);
837             delete item;
838             if (newSelectedItem)
839                 m_listView->setCurrentItem(newSelectedItem);
840             else
841                 updateButtons();
842         }
843     } else {
844         if (edit) {
845             FolderProjectItem *item = getFolderItemById(clipId);
846             if (item) {
847                 m_listView->blockSignals(true);
848                 item->setGroupName(foldername);
849                 m_listView->blockSignals(false);
850                 m_doc->clipManager()->addFolder(clipId, foldername);
851                 const int children = item->childCount();
852                 for (int i = 0; i < children; i++) {
853                     ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
854                     child->setProperty("groupname", foldername);
855                 }
856             }
857         } else {
858             m_listView->blockSignals(true);
859             m_listView->setCurrentItem(new FolderProjectItem(m_listView, QStringList() << foldername, clipId));
860             m_doc->clipManager()->addFolder(clipId, foldername);
861             m_listView->blockSignals(false);
862             m_listView->editItem(m_listView->currentItem(), 0);
863         }
864         updateButtons();
865     }
866     m_doc->setModified(true);
867 }
868
869
870
871 void ProjectList::deleteProjectFolder(QMap <QString, QString> map)
872 {
873     QMapIterator<QString, QString> i(map);
874     QUndoCommand *delCommand = new QUndoCommand();
875     delCommand->setText(i18n("Delete Folder"));
876     while (i.hasNext()) {
877         i.next();
878         new AddFolderCommand(this, i.key(), i.value(), false, delCommand);
879     }
880     m_commandStack->push(delCommand);
881 }
882
883 void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
884 {
885     m_listView->setEnabled(false);
886     if (getProperties) {
887         m_listView->blockSignals(true);
888         m_refreshed = false;
889         // remove file_hash so that we load all properties for the clip
890         QDomElement e = clip->toXML().cloneNode().toElement();
891         e.removeAttribute("file_hash");
892         m_infoQueue.insert(clip->getId(), e);
893         //m_render->getFileProperties(clip->toXML(), clip->getId(), true);
894     }
895     clip->askForAudioThumbs();
896     const QString parent = clip->getProperty("groupid");
897     ProjectItem *item = NULL;
898     if (!parent.isEmpty()) {
899         FolderProjectItem *parentitem = getFolderItemById(parent);
900         if (!parentitem) {
901             QStringList text;
902             QString groupName = clip->getProperty("groupname");
903             //kDebug() << "Adding clip to new group: " << groupName;
904             if (groupName.isEmpty()) groupName = i18n("Folder");
905             text << groupName;
906             parentitem = new FolderProjectItem(m_listView, text, parent);
907         }
908
909         if (parentitem)
910             item = new ProjectItem(parentitem, clip);
911     }
912     if (item == NULL)
913         item = new ProjectItem(m_listView, clip);
914     KUrl url = clip->fileURL();
915
916     if (getProperties == false && !clip->getClipHash().isEmpty()) {
917         QString cachedPixmap = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "thumbs/" + clip->getClipHash() + ".png";
918         if (QFile::exists(cachedPixmap)) {
919             QPixmap pix(cachedPixmap);
920             if (pix.isNull())
921                 KIO::NetAccess::del(KUrl(cachedPixmap), this);
922             item->setData(0, Qt::DecorationRole, pix);
923         }
924     }
925 #ifdef NEPOMUK
926     if (!url.isEmpty() && KdenliveSettings::activate_nepomuk()) {
927         // if file has Nepomuk comment, use it
928         Nepomuk::Resource f(url.path());
929         QString annotation = f.description();
930         if (!annotation.isEmpty()) item->setText(1, annotation);
931         item->setText(2, QString::number(f.rating()));
932     }
933 #endif
934     // Add cut zones
935     QList <CutZoneInfo> cuts = clip->cutZones();
936     if (!cuts.isEmpty()) {
937         for (int i = 0; i < cuts.count(); i++) {
938             SubProjectItem *sub = new SubProjectItem(item, cuts.at(i).zone.x(), cuts.at(i).zone.y(), cuts.at(i).description);
939             if (!clip->getClipHash().isEmpty()) {
940                 QString cachedPixmap = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "thumbs/" + clip->getClipHash() + '#' + QString::number(cuts.at(i).zone.x()) + ".png";
941                 if (QFile::exists(cachedPixmap)) {
942                     QPixmap pix(cachedPixmap);
943                     if (pix.isNull())
944                         KIO::NetAccess::del(KUrl(cachedPixmap), this);
945                     sub->setData(0, Qt::DecorationRole, pix);
946                 }
947             }
948         }
949     }
950     if (m_listView->isEnabled()) {
951         updateButtons();
952         if (getProperties)
953             m_listView->blockSignals(false);
954     }
955     if (getProperties && !m_queueTimer.isActive())
956         slotProcessNextClipInQueue();
957 }
958
959 void ProjectList::slotResetProjectList()
960 {
961     m_listView->clear();
962     emit clipSelected(NULL);
963     m_thumbnailQueue.clear();
964     m_infoQueue.clear();
965     m_refreshed = false;
966 }
967
968 void ProjectList::requestClipInfo(const QDomElement xml, const QString id)
969 {
970     m_refreshed = false;
971     m_infoQueue.insert(id, xml);
972     //if (m_infoQueue.count() == 1 || ) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
973 }
974
975 void ProjectList::slotProcessNextClipInQueue()
976 {
977     if (m_infoQueue.isEmpty()) {
978         slotProcessNextThumbnail();
979         return;
980     }
981
982     QMap<QString, QDomElement>::const_iterator j = m_infoQueue.constBegin();
983     if (j != m_infoQueue.constEnd()) {
984         const QDomElement dom = j.value();
985         const QString id = j.key();
986         m_infoQueue.remove(j.key());
987         emit getFileProperties(dom, id, m_listView->iconSize().height(), false);
988     }
989     if (!m_infoQueue.isEmpty()) m_queueTimer.start();
990 }
991
992 void ProjectList::slotUpdateClip(const QString &id)
993 {
994     ProjectItem *item = getItemById(id);
995     m_listView->blockSignals(true);
996     if (item) item->setData(0, UsageRole, QString::number(item->numReferences()));
997     m_listView->blockSignals(false);
998 }
999
1000 void ProjectList::updateAllClips()
1001 {
1002     m_listView->setSortingEnabled(false);
1003     kDebug() << "// UPDATE ALL CLPY";
1004
1005     QTreeWidgetItemIterator it(m_listView);
1006     DocClipBase *clip;
1007     ProjectItem *item;
1008     m_listView->blockSignals(true);
1009     while (*it) {
1010         if ((*it)->type() == PROJECTSUBCLIPTYPE) {
1011             // subitem
1012             SubProjectItem *sub = static_cast <SubProjectItem *>(*it);
1013             if (sub->data(0, Qt::DecorationRole).isNull()) {
1014                 item = static_cast <ProjectItem *>((*it)->parent());
1015                 requestClipThumbnail(item->clipId() + '#' + QString::number(sub->zone().x()));
1016             }
1017             ++it;
1018             continue;
1019         } else if ((*it)->type() == PROJECTFOLDERTYPE) {
1020             // folder
1021             ++it;
1022             continue;
1023         } else {
1024             item = static_cast <ProjectItem *>(*it);
1025             clip = item->referencedClip();
1026             if (item->referencedClip()->producer() == NULL) {
1027                 if (clip->isPlaceHolder() == false)
1028                     requestClipInfo(clip->toXML(), clip->getId());
1029                 else if (!clip->isPlaceHolder())
1030                     item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
1031             } else {
1032                 if (item->data(0, Qt::DecorationRole).isNull())
1033                     requestClipThumbnail(clip->getId());
1034                 if (item->data(0, DurationRole).toString().isEmpty())
1035                     item->changeDuration(item->referencedClip()->producer()->get_playtime());
1036             }
1037             item->setData(0, UsageRole, QString::number(item->numReferences()));
1038         }
1039         //qApp->processEvents();
1040         ++it;
1041     }
1042     if (!m_queueTimer.isActive())
1043         m_queueTimer.start();
1044     if (m_listView->isEnabled())
1045         m_listView->blockSignals(false);
1046     m_listView->setSortingEnabled(true);
1047     if (m_infoQueue.isEmpty())
1048         slotProcessNextThumbnail();
1049 }
1050
1051 // static
1052 QString ProjectList::getExtensions()
1053 {
1054     // Build list of mime types
1055     QStringList mimeTypes = QStringList() << "application/x-kdenlive" << "application/x-kdenlivetitle" << "video/mlt-playlist" << "text/plain"
1056                             << "video/x-flv" << "application/vnd.rn-realmedia" << "video/x-dv" << "video/dv" << "video/x-msvideo" << "video/x-matroska" << "video/mpeg" << "video/ogg" << "video/x-ms-wmv" << "video/mp4" << "video/quicktime"
1057                             << "audio/x-flac" << "audio/x-matroska" << "audio/mp4" << "audio/mpeg" << "audio/x-mp3" << "audio/ogg" << "audio/x-wav" << "application/ogg"
1058                             << "image/gif" << "image/jpeg" << "image/png" << "image/x-tga" << "image/x-bmp" << "image/svg+xml" << "image/tiff" << "image/x-xcf" << "image/x-xcf-gimp" << "image/x-vnd.adobe.photoshop" << "image/x-pcx" << "image/x-exr";
1059
1060     QString allExtensions;
1061     foreach(const QString& mimeType, mimeTypes) {
1062         KMimeType::Ptr mime(KMimeType::mimeType(mimeType));
1063         if (mime) {
1064             allExtensions.append(mime->patterns().join(" "));
1065             allExtensions.append(' ');
1066         }
1067     }
1068     return allExtensions.simplified();
1069 }
1070
1071 void ProjectList::slotAddClip(const QList <QUrl> givenList, const QString &groupName, const QString &groupId)
1072 {
1073     if (!m_commandStack)
1074         kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
1075
1076     KUrl::List list;
1077     if (givenList.isEmpty()) {
1078         QString allExtensions = getExtensions();
1079         const QString dialogFilter = allExtensions + ' ' + QLatin1Char('|') + i18n("All Supported Files") + "\n* " + QLatin1Char('|') + i18n("All Files");
1080         QCheckBox *b = new QCheckBox(i18n("Import image sequence"));
1081         b->setChecked(KdenliveSettings::autoimagesequence());
1082         KFileDialog *d = new KFileDialog(KUrl("kfiledialog:///clipfolder"), dialogFilter, this, b);
1083         d->setOperationMode(KFileDialog::Opening);
1084         d->setMode(KFile::Files);
1085         d->exec();
1086         list = d->selectedUrls();
1087         if (b->isChecked() && list.count() == 1) {
1088             // Check for image sequence
1089             KUrl url = list.at(0);
1090             QString fileName = url.fileName().section('.', 0, -2);
1091             if (fileName.at(fileName.size() - 1).isDigit()) {
1092                 KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
1093                 if (item.mimetype().startsWith("image")) {
1094                     int count = 0;
1095                     // import as sequence if we found at least 5 images in the sequence
1096                     QString pattern = SlideshowClip::selectedPath(url.path(), false, QString(), &count);
1097                     if (count > 1) {
1098                         delete d;
1099                         QStringList groupInfo = getGroup();
1100
1101                         // get image sequence base name
1102                         while (fileName.at(fileName.size() - 1).isDigit()) {
1103                             fileName.chop(1);
1104                         }
1105
1106                         m_doc->slotCreateSlideshowClipFile(fileName, pattern, count, m_timecode.reformatSeparators(KdenliveSettings::sequence_duration()),
1107                                                            false, false, false,
1108                                                            m_timecode.getTimecodeFromFrames(int(ceil(m_timecode.fps()))), QString(), 0,
1109                                                            QString(), groupInfo.at(0), groupInfo.at(1));
1110                         return;
1111                     }
1112                 }
1113             }
1114         }
1115         delete d;
1116     } else {
1117         for (int i = 0; i < givenList.count(); i++)
1118             list << givenList.at(i);
1119     }
1120
1121     foreach(const KUrl &file, list) {
1122         // Check there is no folder here
1123         KMimeType::Ptr type = KMimeType::findByUrl(file);
1124         if (type->is("inode/directory")) {
1125             // user dropped a folder
1126             list.removeAll(file);
1127         }
1128     }
1129
1130     if (list.isEmpty())
1131         return;
1132
1133     if (givenList.isEmpty()) {
1134         QStringList groupInfo = getGroup();
1135         m_doc->slotAddClipList(list, groupInfo.at(0), groupInfo.at(1));
1136     } else {
1137         m_doc->slotAddClipList(list, groupName, groupId);
1138     }
1139 }
1140
1141 void ProjectList::slotRemoveInvalidClip(const QString &id, bool replace)
1142 {
1143     ProjectItem *item = getItemById(id);
1144     QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
1145     if (item) {
1146         const QString path = item->referencedClip()->fileURL().path();
1147         if (item->referencedClip()->isPlaceHolder()) replace = false;
1148         if (!path.isEmpty()) {
1149             if (replace)
1150                 KMessageBox::sorry(this, i18n("Clip <b>%1</b><br />is invalid, will be removed from project.", path));
1151             else if (KMessageBox::questionYesNo(this, i18n("Clip <b>%1</b><br />is missing or invalid. Remove it from project?", path), i18n("Invalid clip")) == KMessageBox::Yes)
1152                 replace = true;
1153         }
1154         if (replace)
1155             emit deleteProjectClips(QStringList() << id, QMap <QString, QString>());
1156     }
1157 }
1158
1159 void ProjectList::slotAddColorClip()
1160 {
1161     if (!m_commandStack)
1162         kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
1163
1164     QDialog *dia = new QDialog(this);
1165     Ui::ColorClip_UI dia_ui;
1166     dia_ui.setupUi(dia);
1167     dia->setWindowTitle(i18n("Color Clip"));
1168     dia_ui.clip_name->setText(i18n("Color Clip"));
1169
1170     TimecodeDisplay *t = new TimecodeDisplay(m_timecode);
1171     t->setValue(KdenliveSettings::color_duration());
1172     t->setTimeCodeFormat(false);
1173     dia_ui.clip_durationBox->addWidget(t);
1174     dia_ui.clip_color->setColor(KdenliveSettings::colorclipcolor());
1175
1176     if (dia->exec() == QDialog::Accepted) {
1177         QString color = dia_ui.clip_color->color().name();
1178         KdenliveSettings::setColorclipcolor(color);
1179         color = color.replace(0, 1, "0x") + "ff";
1180         QStringList groupInfo = getGroup();
1181         m_doc->slotCreateColorClip(dia_ui.clip_name->text(), color, m_timecode.getTimecode(t->gentime()), groupInfo.at(0), groupInfo.at(1));
1182     }
1183     delete t;
1184     delete dia;
1185 }
1186
1187
1188 void ProjectList::slotAddSlideshowClip()
1189 {
1190     if (!m_commandStack)
1191         kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
1192
1193     SlideshowClip *dia = new SlideshowClip(m_timecode, this);
1194
1195     if (dia->exec() == QDialog::Accepted) {
1196         QStringList groupInfo = getGroup();
1197         m_doc->slotCreateSlideshowClipFile(dia->clipName(), dia->selectedPath(), dia->imageCount(), dia->clipDuration(),
1198                                            dia->loop(), dia->crop(), dia->fade(),
1199                                            dia->lumaDuration(), dia->lumaFile(), dia->softness(),
1200                                            dia->animation(), groupInfo.at(0), groupInfo.at(1));
1201     }
1202     delete dia;
1203 }
1204
1205 void ProjectList::slotAddTitleClip()
1206 {
1207     QStringList groupInfo = getGroup();
1208     m_doc->slotCreateTextClip(groupInfo.at(0), groupInfo.at(1));
1209 }
1210
1211 void ProjectList::slotAddTitleTemplateClip()
1212 {
1213     if (!m_commandStack)
1214         kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
1215
1216     QStringList groupInfo = getGroup();
1217
1218     // Get the list of existing templates
1219     QStringList filter;
1220     filter << "*.kdenlivetitle";
1221     const QString path = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
1222     QStringList templateFiles = QDir(path).entryList(filter, QDir::Files);
1223
1224     QDialog *dia = new QDialog(this);
1225     Ui::TemplateClip_UI dia_ui;
1226     dia_ui.setupUi(dia);
1227     for (int i = 0; i < templateFiles.size(); ++i)
1228         dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), path + templateFiles.at(i));
1229
1230     if (!templateFiles.isEmpty())
1231         dia_ui.buttonBox->button(QDialogButtonBox::Ok)->setFocus();
1232     dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
1233     //warning: setting base directory doesn't work??
1234     KUrl startDir(path);
1235     dia_ui.template_list->fileDialog()->setUrl(startDir);
1236     dia_ui.text_box->setHidden(true);
1237     if (dia->exec() == QDialog::Accepted) {
1238         QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
1239         if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
1240         // Create a cloned template clip
1241         m_doc->slotCreateTextTemplateClip(groupInfo.at(0), groupInfo.at(1), KUrl(textTemplate));
1242     }
1243     delete dia;
1244 }
1245
1246 QStringList ProjectList::getGroup() const
1247 {
1248     QStringList result;
1249     QTreeWidgetItem *item = m_listView->currentItem();
1250     while (item && item->type() != PROJECTFOLDERTYPE)
1251         item = item->parent();
1252
1253     if (item) {
1254         FolderProjectItem *folder = static_cast <FolderProjectItem *>(item);
1255         result << folder->groupName() << folder->clipId();
1256     } else {
1257         result << QString() << QString();
1258     }
1259     return result;
1260 }
1261
1262 void ProjectList::setDocument(KdenliveDoc *doc)
1263 {
1264     m_listView->blockSignals(true);
1265     m_listView->clear();
1266     m_listView->setSortingEnabled(false);
1267     emit clipSelected(NULL);
1268     m_thumbnailQueue.clear();
1269     m_infoQueue.clear();
1270     m_refreshed = false;
1271     m_fps = doc->fps();
1272     m_timecode = doc->timecode();
1273     m_commandStack = doc->commandStack();
1274     m_doc = doc;
1275
1276     QMap <QString, QString> flist = doc->clipManager()->documentFolderList();
1277     QMapIterator<QString, QString> f(flist);
1278     while (f.hasNext()) {
1279         f.next();
1280         (void) new FolderProjectItem(m_listView, QStringList() << f.value(), f.key());
1281     }
1282
1283     QList <DocClipBase*> list = doc->clipManager()->documentClipList();
1284     for (int i = 0; i < list.count(); i++)
1285         slotAddClip(list.at(i), false);
1286
1287     m_listView->blockSignals(false);
1288     m_toolbar->setEnabled(true);
1289     connect(m_doc->clipManager(), SIGNAL(reloadClip(const QString &)), this, SLOT(slotReloadClip(const QString &)));
1290     connect(m_doc->clipManager(), SIGNAL(modifiedClip(const QString &)), this, SLOT(slotModifiedClip(const QString &)));
1291     connect(m_doc->clipManager(), SIGNAL(missingClip(const QString &)), this, SLOT(slotMissingClip(const QString &)));
1292     connect(m_doc->clipManager(), SIGNAL(availableClip(const QString &)), this, SLOT(slotAvailableClip(const QString &)));
1293     connect(m_doc->clipManager(), SIGNAL(checkAllClips()), this, SLOT(updateAllClips()));
1294 }
1295
1296 QList <DocClipBase*> ProjectList::documentClipList() const
1297 {
1298     if (m_doc == NULL)
1299         return QList <DocClipBase*> ();
1300
1301     return m_doc->clipManager()->documentClipList();
1302 }
1303
1304 QDomElement ProjectList::producersList()
1305 {
1306     QDomDocument doc;
1307     QDomElement prods = doc.createElement("producerlist");
1308     doc.appendChild(prods);
1309     kDebug() << "////////////  PRO LIST BUILD PRDSLIST ";
1310     QTreeWidgetItemIterator it(m_listView);
1311     while (*it) {
1312         if ((*it)->type() != PROJECTCLIPTYPE) {
1313             // subitem
1314             ++it;
1315             continue;
1316         }
1317         prods.appendChild(doc.importNode(((ProjectItem *)(*it))->toXml(), true));
1318         ++it;
1319     }
1320     return prods;
1321 }
1322
1323 void ProjectList::slotCheckForEmptyQueue()
1324 {
1325     if (!m_refreshed && m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) {
1326         m_refreshed = true;
1327         emit loadingIsOver();
1328         emit displayMessage(QString(), -1);
1329         m_listView->blockSignals(false);
1330         m_listView->setEnabled(true);
1331         updateButtons();
1332     } else if (!m_refreshed) {
1333         QTimer::singleShot(300, this, SLOT(slotCheckForEmptyQueue()));
1334     }
1335 }
1336
1337 void ProjectList::reloadClipThumbnails()
1338 {
1339     kDebug() << "//////////////  RELOAD CLIPS THUMBNAILS!!!";
1340     m_thumbnailQueue.clear();
1341     QTreeWidgetItemIterator it(m_listView);
1342     while (*it) {
1343         if ((*it)->type() != PROJECTCLIPTYPE) {
1344             // subitem
1345             ++it;
1346             continue;
1347         }
1348         m_thumbnailQueue << ((ProjectItem *)(*it))->clipId();
1349         ++it;
1350     }
1351     QTimer::singleShot(300, this, SLOT(slotProcessNextThumbnail()));
1352 }
1353
1354 void ProjectList::requestClipThumbnail(const QString id)
1355 {
1356     if (!m_thumbnailQueue.contains(id)) m_thumbnailQueue.append(id);
1357 }
1358
1359 void ProjectList::slotProcessNextThumbnail()
1360 {
1361     if (m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) {
1362         slotCheckForEmptyQueue();
1363         return;
1364     }
1365     if (!m_infoQueue.isEmpty()) {
1366         //QTimer::singleShot(300, this, SLOT(slotProcessNextThumbnail()));
1367         return;
1368     }
1369     if (m_thumbnailQueue.count() > 1) {
1370         int max = m_doc->clipManager()->clipsCount();
1371         emit displayMessage(i18n("Loading thumbnails"), (int)(100 *(max - m_thumbnailQueue.count()) / max));
1372     }
1373     slotRefreshClipThumbnail(m_thumbnailQueue.takeFirst(), false);
1374 }
1375
1376 void ProjectList::slotRefreshClipThumbnail(const QString &clipId, bool update)
1377 {
1378     QTreeWidgetItem *item = getAnyItemById(clipId);
1379     if (item)
1380         slotRefreshClipThumbnail(item, update);
1381     else
1382         slotProcessNextThumbnail();
1383 }
1384
1385 void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update)
1386 {
1387     if (it == NULL) return;
1388     ProjectItem *item = NULL;
1389     bool isSubItem = false;
1390     int frame;
1391     if (it->type() == PROJECTFOLDERTYPE) return;
1392     if (it->type() == PROJECTSUBCLIPTYPE) {
1393         item = static_cast <ProjectItem *>(it->parent());
1394         frame = static_cast <SubProjectItem *>(it)->zone().x();
1395         isSubItem = true;
1396     } else {
1397         item = static_cast <ProjectItem *>(it);
1398         frame = item->referencedClip()->getClipThumbFrame();
1399     }
1400
1401     if (item) {
1402         DocClipBase *clip = item->referencedClip();
1403         if (!clip) {
1404             slotProcessNextThumbnail();
1405             return;
1406         }
1407         QPixmap pix;
1408         int height = m_listView->iconSize().height();
1409         int width = (int)(height  * m_render->dar());
1410         if (clip->clipType() == AUDIO)
1411             pix = KIcon("audio-x-generic").pixmap(QSize(width, height));
1412         else if (clip->clipType() == IMAGE)
1413             pix = QPixmap::fromImage(KThumb::getFrame(item->referencedClip()->producer(), 0, width, height));
1414         else
1415             pix = item->referencedClip()->thumbProducer()->extractImage(frame, width, height);
1416
1417         if (!pix.isNull()) {
1418             m_listView->blockSignals(true);
1419             it->setData(0, Qt::DecorationRole, pix);
1420             if (m_listView->isEnabled())
1421                 m_listView->blockSignals(false);
1422             if (!isSubItem)
1423                 m_doc->cachePixmap(item->getClipHash(), pix);
1424             else
1425                 m_doc->cachePixmap(item->getClipHash() + '#' + QString::number(frame), pix);
1426         }
1427         if (update)
1428             emit projectModified();
1429         QTimer::singleShot(30, this, SLOT(slotProcessNextThumbnail()));
1430     }
1431 }
1432
1433 void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata, bool replace)
1434 {
1435     QString toReload;
1436     ProjectItem *item = getItemById(clipId);
1437     if (item && producer) {
1438         m_listView->blockSignals(true);
1439         item->setProperties(properties, metadata);
1440         if (item->referencedClip()->isPlaceHolder() && producer->is_valid()) {
1441             item->referencedClip()->setValid();
1442             item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
1443             toReload = clipId;
1444         }
1445         //Q_ASSERT_X(item->referencedClip(), "void ProjectList::slotReplyGetFileProperties", QString("Item with groupName %1 does not have a clip associated").arg(item->groupName()).toLatin1());
1446         item->referencedClip()->setProducer(producer, replace);
1447         item->referencedClip()->askForAudioThumbs();
1448         if (!replace && item->data(0, Qt::DecorationRole).isNull())
1449             requestClipThumbnail(clipId);
1450         if (!toReload.isEmpty())
1451             item->slotSetToolTip();
1452
1453         //emit receivedClipDuration(clipId);
1454         if (m_listView->isEnabled() && replace) {
1455             // update clip in clip monitor
1456             emit clipSelected(NULL);
1457             emit clipSelected(item->referencedClip());
1458             //TODO: Make sure the line below has no side effect
1459             toReload = clipId;
1460         }
1461         /*else {
1462             // Check if duration changed.
1463             emit receivedClipDuration(clipId);
1464             delete producer;
1465         }*/
1466         if (m_listView->isEnabled())
1467             m_listView->blockSignals(false);
1468         /*if (item->icon(0).isNull()) {
1469             requestClipThumbnail(clipId);
1470         }*/
1471     } else kDebug() << "////////  COULD NOT FIND CLIP TO UPDATE PRPS...";
1472     int max = m_doc->clipManager()->clipsCount();
1473     if (item && m_infoQueue.isEmpty() && m_thumbnailQueue.isEmpty()) {
1474         m_listView->setCurrentItem(item);
1475         if (item->parent()) {
1476             if (item->parent()->type() == PROJECTFOLDERTYPE)
1477                 static_cast <FolderProjectItem *>(item->parent())->switchIcon();
1478         }
1479         emit clipSelected(item->referencedClip());
1480     } else {
1481         emit displayMessage(i18n("Loading clips"), (int)(100 *(max - m_infoQueue.count()) / max));
1482     }
1483     if (!toReload.isEmpty())
1484         emit clipNeedsReload(toReload, true);
1485     // small delay so that the app can display the progress info
1486     QTimer::singleShot(30, this, SLOT(slotProcessNextClipInQueue()));
1487 }
1488
1489 void ProjectList::slotReplyGetImage(const QString &clipId, const QPixmap &pix)
1490 {
1491     ProjectItem *item = getItemById(clipId);
1492     if (item && !pix.isNull()) {
1493         m_listView->blockSignals(true);
1494         item->setData(0, Qt::DecorationRole, pix);
1495         m_doc->cachePixmap(item->getClipHash(), pix);
1496         if (m_listView->isEnabled())
1497             m_listView->blockSignals(false);
1498     }
1499 }
1500
1501 QTreeWidgetItem *ProjectList::getAnyItemById(const QString &id)
1502 {
1503     QTreeWidgetItemIterator it(m_listView);
1504     QString lookId = id;
1505     if (id.contains('#'))
1506         lookId = id.section('#', 0, 0);
1507
1508     ProjectItem *result = NULL;
1509     while (*it) {
1510         if ((*it)->type() != PROJECTCLIPTYPE) {
1511             // subitem
1512             ++it;
1513             continue;
1514         }
1515         ProjectItem *item = static_cast<ProjectItem *>(*it);
1516         if (item->clipId() == lookId) {
1517             result = item;
1518             break;
1519         }
1520         ++it;
1521     }
1522     if (result == NULL || !id.contains('#')) {
1523         return result;
1524     } else {
1525         for (int i = 0; i < result->childCount(); i++) {
1526             SubProjectItem *sub = static_cast <SubProjectItem *>(result->child(i));
1527             if (sub && sub->zone().x() == id.section('#', 1, 1).toInt())
1528                 return sub;
1529         }
1530     }
1531
1532     return NULL;
1533 }
1534
1535
1536 ProjectItem *ProjectList::getItemById(const QString &id)
1537 {
1538     ProjectItem *item;
1539     QTreeWidgetItemIterator it(m_listView);
1540     while (*it) {
1541         if ((*it)->type() != PROJECTCLIPTYPE) {
1542             // subitem
1543             ++it;
1544             continue;
1545         }
1546         item = static_cast<ProjectItem *>(*it);
1547         if (item->clipId() == id)
1548             return item;
1549         ++it;
1550     }
1551     return NULL;
1552 }
1553
1554 FolderProjectItem *ProjectList::getFolderItemById(const QString &id)
1555 {
1556     FolderProjectItem *item;
1557     QTreeWidgetItemIterator it(m_listView);
1558     while (*it) {
1559         if ((*it)->type() == PROJECTFOLDERTYPE) {
1560             item = static_cast<FolderProjectItem *>(*it);
1561             if (item->clipId() == id)
1562                 return item;
1563         }
1564         ++it;
1565     }
1566     return NULL;
1567 }
1568
1569 void ProjectList::slotSelectClip(const QString &ix)
1570 {
1571     ProjectItem *clip = getItemById(ix);
1572     if (clip) {
1573         m_listView->setCurrentItem(clip);
1574         m_listView->scrollToItem(clip);
1575         m_editAction->setEnabled(true);
1576         m_deleteAction->setEnabled(true);
1577         m_reloadAction->setEnabled(true);
1578         m_transcodeAction->setEnabled(true);
1579         if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
1580             m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp()));
1581             m_openAction->setEnabled(true);
1582         } else if (clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
1583             m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp()));
1584             m_openAction->setEnabled(true);
1585         } else {
1586             m_openAction->setEnabled(false);
1587         }
1588     }
1589 }
1590
1591 QString ProjectList::currentClipUrl() const
1592 {
1593     ProjectItem *item;
1594     if (!m_listView->currentItem() || m_listView->currentItem()->type() == PROJECTFOLDERTYPE) return QString();
1595     if (m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE) {
1596         // subitem
1597         item = static_cast <ProjectItem*>(m_listView->currentItem()->parent());
1598     } else {
1599         item = static_cast <ProjectItem*>(m_listView->currentItem());
1600     }
1601     if (item == NULL)
1602         return QString();
1603     return item->clipUrl().path();
1604 }
1605
1606 KUrl::List ProjectList::getConditionalUrls(const QString &condition) const
1607 {
1608     KUrl::List result;
1609     ProjectItem *item;
1610     QList<QTreeWidgetItem *> list = m_listView->selectedItems();
1611     for (int i = 0; i < list.count(); i++) {
1612         if (list.at(i)->type() == PROJECTFOLDERTYPE)
1613             continue;
1614         if (list.at(i)->type() == PROJECTSUBCLIPTYPE) {
1615             // subitem
1616             item = static_cast <ProjectItem*>(list.at(i)->parent());
1617         } else {
1618             item = static_cast <ProjectItem*>(list.at(i));
1619         }
1620         if (item == NULL || item->type() == COLOR || item->type() == SLIDESHOW || item->type() == TEXT)
1621             continue;
1622         DocClipBase *clip = item->referencedClip();
1623         if (!condition.isEmpty()) {
1624             if (condition.startsWith("vcodec") && !clip->hasVideoCodec(condition.section("=", 1, 1)))
1625                 continue;
1626             else if (condition.startsWith("acodec") && !clip->hasAudioCodec(condition.section("=", 1, 1)))
1627                 continue;
1628         }
1629         result.append(item->clipUrl());
1630     }
1631     return result;
1632 }
1633
1634 void ProjectList::regenerateTemplate(const QString &id)
1635 {
1636     ProjectItem *clip = getItemById(id);
1637     if (clip)
1638         regenerateTemplate(clip);
1639 }
1640
1641 void ProjectList::regenerateTemplate(ProjectItem *clip)
1642 {
1643     //TODO: remove this unused method, only force_reload is necessary
1644     clip->referencedClip()->producer()->set("force_reload", 1);
1645 }
1646
1647 QDomDocument ProjectList::generateTemplateXml(QString path, const QString &replaceString)
1648 {
1649     QDomDocument doc;
1650     QFile file(path);
1651     if (!file.open(QIODevice::ReadOnly)) {
1652         kWarning() << "ERROR, CANNOT READ: " << path;
1653         return doc;
1654     }
1655     if (!doc.setContent(&file)) {
1656         kWarning() << "ERROR, CANNOT READ: " << path;
1657         file.close();
1658         return doc;
1659     }
1660     file.close();
1661     QDomNodeList texts = doc.elementsByTagName("content");
1662     for (int i = 0; i < texts.count(); i++) {
1663         QString data = texts.item(i).firstChild().nodeValue();
1664         data.replace("%s", replaceString);
1665         texts.item(i).firstChild().setNodeValue(data);
1666     }
1667     return doc;
1668 }
1669
1670
1671 void ProjectList::slotAddClipCut(const QString &id, int in, int out)
1672 {
1673     ProjectItem *clip = getItemById(id);
1674     if (clip == NULL || clip->referencedClip()->hasCutZone(QPoint(in, out)))
1675         return;
1676     AddClipCutCommand *command = new AddClipCutCommand(this, id, in, out, QString(), true, false);
1677     m_commandStack->push(command);
1678 }
1679
1680 void ProjectList::addClipCut(const QString &id, int in, int out, const QString desc, bool newItem)
1681 {
1682     ProjectItem *clip = getItemById(id);
1683     if (clip) {
1684         DocClipBase *base = clip->referencedClip();
1685         base->addCutZone(in, out);
1686         m_listView->blockSignals(true);
1687         SubProjectItem *sub = new SubProjectItem(clip, in, out, desc);
1688         if (newItem && desc.isEmpty() && !m_listView->isColumnHidden(1)) {
1689             if (!clip->isExpanded())
1690                 clip->setExpanded(true);
1691             m_listView->scrollToItem(sub);
1692             m_listView->editItem(sub, 1);
1693         }
1694         QPixmap p = clip->referencedClip()->thumbProducer()->extractImage(in, (int)(sub->sizeHint(0).height()  * m_render->dar()), sub->sizeHint(0).height() - 2);
1695         sub->setData(0, Qt::DecorationRole, p);
1696         m_doc->cachePixmap(clip->getClipHash() + '#' + QString::number(in), p);
1697         m_listView->blockSignals(false);
1698     }
1699     emit projectModified();
1700 }
1701
1702 void ProjectList::removeClipCut(const QString &id, int in, int out)
1703 {
1704     ProjectItem *clip = getItemById(id);
1705     if (clip) {
1706         DocClipBase *base = clip->referencedClip();
1707         base->removeCutZone(in, out);
1708         SubProjectItem *sub = getSubItem(clip, QPoint(in, out));
1709         if (sub) {
1710             m_listView->blockSignals(true);
1711             delete sub;
1712             m_listView->blockSignals(false);
1713         }
1714     }
1715     emit projectModified();
1716 }
1717
1718 SubProjectItem *ProjectList::getSubItem(ProjectItem *clip, QPoint zone)
1719 {
1720     SubProjectItem *sub = NULL;
1721     if (clip) {
1722         for (int i = 0; i < clip->childCount(); i++) {
1723             QTreeWidgetItem *it = clip->child(i);
1724             if (it->type() == PROJECTSUBCLIPTYPE) {
1725                 sub = static_cast <SubProjectItem*>(it);
1726                 if (sub->zone() == zone)
1727                     break;
1728                 else
1729                     sub = NULL;
1730             }
1731         }
1732     }
1733     return sub;
1734 }
1735
1736 void ProjectList::slotUpdateClipCut(QPoint p)
1737 {
1738     if (!m_listView->currentItem() || m_listView->currentItem()->type() != PROJECTSUBCLIPTYPE)
1739         return;
1740     SubProjectItem *sub = static_cast <SubProjectItem*>(m_listView->currentItem());
1741     ProjectItem *item = static_cast <ProjectItem *>(sub->parent());
1742     EditClipCutCommand *command = new EditClipCutCommand(this, item->clipId(), sub->zone(), p, sub->text(1), sub->text(1), true);
1743     m_commandStack->push(command);
1744 }
1745
1746 void ProjectList::doUpdateClipCut(const QString &id, const QPoint oldzone, const QPoint zone, const QString &comment)
1747 {
1748     ProjectItem *clip = getItemById(id);
1749     SubProjectItem *sub = getSubItem(clip, oldzone);
1750     if (sub == NULL || clip == NULL)
1751         return;
1752     DocClipBase *base = clip->referencedClip();
1753     base->updateCutZone(oldzone.x(), oldzone.y(), zone.x(), zone.y(), comment);
1754     m_listView->blockSignals(true);
1755     sub->setZone(zone);
1756     sub->setDescription(comment);
1757     m_listView->blockSignals(false);
1758     emit projectModified();
1759 }
1760
1761 void ProjectList::slotForceProcessing(const QString &id)
1762 {
1763     while (m_infoQueue.contains(id)) {
1764         slotProcessNextClipInQueue();
1765     }
1766 }
1767
1768 #include "projectlist.moc"