]> git.sesse.net Git - kdenlive/blob - src/projectlist.cpp
Add center-crop option 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()), false, false, false, m_timecode.getTimecodeFromFrames(int(ceil(m_timecode.fps()))), QString(), 0, groupInfo.at(0), groupInfo.at(1));
1107                         return;
1108                     }
1109                 }
1110             }
1111         }
1112         delete d;
1113     } else {
1114         for (int i = 0; i < givenList.count(); i++)
1115             list << givenList.at(i);
1116     }
1117
1118     foreach(const KUrl &file, list) {
1119         // Check there is no folder here
1120         KMimeType::Ptr type = KMimeType::findByUrl(file);
1121         if (type->is("inode/directory")) {
1122             // user dropped a folder
1123             list.removeAll(file);
1124         }
1125     }
1126
1127     if (list.isEmpty())
1128         return;
1129
1130     if (givenList.isEmpty()) {
1131         QStringList groupInfo = getGroup();
1132         m_doc->slotAddClipList(list, groupInfo.at(0), groupInfo.at(1));
1133     } else {
1134         m_doc->slotAddClipList(list, groupName, groupId);
1135     }
1136 }
1137
1138 void ProjectList::slotRemoveInvalidClip(const QString &id, bool replace)
1139 {
1140     ProjectItem *item = getItemById(id);
1141     QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
1142     if (item) {
1143         const QString path = item->referencedClip()->fileURL().path();
1144         if (item->referencedClip()->isPlaceHolder()) replace = false;
1145         if (!path.isEmpty()) {
1146             if (replace)
1147                 KMessageBox::sorry(this, i18n("Clip <b>%1</b><br />is invalid, will be removed from project.", path));
1148             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)
1149                 replace = true;
1150         }
1151         if (replace)
1152             emit deleteProjectClips(QStringList() << id, QMap <QString, QString>());
1153     }
1154 }
1155
1156 void ProjectList::slotAddColorClip()
1157 {
1158     if (!m_commandStack)
1159         kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
1160
1161     QDialog *dia = new QDialog(this);
1162     Ui::ColorClip_UI dia_ui;
1163     dia_ui.setupUi(dia);
1164     dia->setWindowTitle(i18n("Color Clip"));
1165     dia_ui.clip_name->setText(i18n("Color Clip"));
1166
1167     TimecodeDisplay *t = new TimecodeDisplay(m_timecode);
1168     t->setValue(KdenliveSettings::color_duration());
1169     t->setTimeCodeFormat(false);
1170     dia_ui.clip_durationBox->addWidget(t);
1171     dia_ui.clip_color->setColor(KdenliveSettings::colorclipcolor());
1172
1173     if (dia->exec() == QDialog::Accepted) {
1174         QString color = dia_ui.clip_color->color().name();
1175         KdenliveSettings::setColorclipcolor(color);
1176         color = color.replace(0, 1, "0x") + "ff";
1177         QStringList groupInfo = getGroup();
1178         m_doc->slotCreateColorClip(dia_ui.clip_name->text(), color, m_timecode.getTimecode(t->gentime()), groupInfo.at(0), groupInfo.at(1));
1179     }
1180     delete t;
1181     delete dia;
1182 }
1183
1184
1185 void ProjectList::slotAddSlideshowClip()
1186 {
1187     if (!m_commandStack)
1188         kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
1189
1190     SlideshowClip *dia = new SlideshowClip(m_timecode, this);
1191
1192     if (dia->exec() == QDialog::Accepted) {
1193         QStringList groupInfo = getGroup();
1194         m_doc->slotCreateSlideshowClipFile(dia->clipName(), dia->selectedPath(), dia->imageCount(), dia->clipDuration(), dia->loop(), dia->crop(), dia->fade(),
1195                                            dia->lumaDuration(), dia->lumaFile(), dia->softness(), groupInfo.at(0), groupInfo.at(1));
1196     }
1197     delete dia;
1198 }
1199
1200 void ProjectList::slotAddTitleClip()
1201 {
1202     QStringList groupInfo = getGroup();
1203     m_doc->slotCreateTextClip(groupInfo.at(0), groupInfo.at(1));
1204 }
1205
1206 void ProjectList::slotAddTitleTemplateClip()
1207 {
1208     if (!m_commandStack)
1209         kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
1210
1211     QStringList groupInfo = getGroup();
1212
1213     // Get the list of existing templates
1214     QStringList filter;
1215     filter << "*.kdenlivetitle";
1216     const QString path = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
1217     QStringList templateFiles = QDir(path).entryList(filter, QDir::Files);
1218
1219     QDialog *dia = new QDialog(this);
1220     Ui::TemplateClip_UI dia_ui;
1221     dia_ui.setupUi(dia);
1222     for (int i = 0; i < templateFiles.size(); ++i)
1223         dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), path + templateFiles.at(i));
1224
1225     if (!templateFiles.isEmpty())
1226         dia_ui.buttonBox->button(QDialogButtonBox::Ok)->setFocus();
1227     dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
1228     //warning: setting base directory doesn't work??
1229     KUrl startDir(path);
1230     dia_ui.template_list->fileDialog()->setUrl(startDir);
1231     dia_ui.text_box->setHidden(true);
1232     if (dia->exec() == QDialog::Accepted) {
1233         QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
1234         if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
1235         // Create a cloned template clip
1236         m_doc->slotCreateTextTemplateClip(groupInfo.at(0), groupInfo.at(1), KUrl(textTemplate));
1237     }
1238     delete dia;
1239 }
1240
1241 QStringList ProjectList::getGroup() const
1242 {
1243     QStringList result;
1244     QTreeWidgetItem *item = m_listView->currentItem();
1245     while (item && item->type() != PROJECTFOLDERTYPE)
1246         item = item->parent();
1247
1248     if (item) {
1249         FolderProjectItem *folder = static_cast <FolderProjectItem *>(item);
1250         result << folder->groupName() << folder->clipId();
1251     } else {
1252         result << QString() << QString();
1253     }
1254     return result;
1255 }
1256
1257 void ProjectList::setDocument(KdenliveDoc *doc)
1258 {
1259     m_listView->blockSignals(true);
1260     m_listView->clear();
1261     m_listView->setSortingEnabled(false);
1262     emit clipSelected(NULL);
1263     m_thumbnailQueue.clear();
1264     m_infoQueue.clear();
1265     m_refreshed = false;
1266     m_fps = doc->fps();
1267     m_timecode = doc->timecode();
1268     m_commandStack = doc->commandStack();
1269     m_doc = doc;
1270
1271     QMap <QString, QString> flist = doc->clipManager()->documentFolderList();
1272     QMapIterator<QString, QString> f(flist);
1273     while (f.hasNext()) {
1274         f.next();
1275         (void) new FolderProjectItem(m_listView, QStringList() << f.value(), f.key());
1276     }
1277
1278     QList <DocClipBase*> list = doc->clipManager()->documentClipList();
1279     for (int i = 0; i < list.count(); i++)
1280         slotAddClip(list.at(i), false);
1281
1282     m_listView->blockSignals(false);
1283     m_toolbar->setEnabled(true);
1284     connect(m_doc->clipManager(), SIGNAL(reloadClip(const QString &)), this, SLOT(slotReloadClip(const QString &)));
1285     connect(m_doc->clipManager(), SIGNAL(modifiedClip(const QString &)), this, SLOT(slotModifiedClip(const QString &)));
1286     connect(m_doc->clipManager(), SIGNAL(missingClip(const QString &)), this, SLOT(slotMissingClip(const QString &)));
1287     connect(m_doc->clipManager(), SIGNAL(availableClip(const QString &)), this, SLOT(slotAvailableClip(const QString &)));
1288     connect(m_doc->clipManager(), SIGNAL(checkAllClips()), this, SLOT(updateAllClips()));
1289 }
1290
1291 QList <DocClipBase*> ProjectList::documentClipList() const
1292 {
1293     if (m_doc == NULL)
1294         return QList <DocClipBase*> ();
1295
1296     return m_doc->clipManager()->documentClipList();
1297 }
1298
1299 QDomElement ProjectList::producersList()
1300 {
1301     QDomDocument doc;
1302     QDomElement prods = doc.createElement("producerlist");
1303     doc.appendChild(prods);
1304     kDebug() << "////////////  PRO LIST BUILD PRDSLIST ";
1305     QTreeWidgetItemIterator it(m_listView);
1306     while (*it) {
1307         if ((*it)->type() != PROJECTCLIPTYPE) {
1308             // subitem
1309             ++it;
1310             continue;
1311         }
1312         prods.appendChild(doc.importNode(((ProjectItem *)(*it))->toXml(), true));
1313         ++it;
1314     }
1315     return prods;
1316 }
1317
1318 void ProjectList::slotCheckForEmptyQueue()
1319 {
1320     if (!m_refreshed && m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) {
1321         m_refreshed = true;
1322         emit loadingIsOver();
1323         emit displayMessage(QString(), -1);
1324         m_listView->blockSignals(false);
1325         m_listView->setEnabled(true);
1326         updateButtons();
1327     } else if (!m_refreshed) {
1328         QTimer::singleShot(300, this, SLOT(slotCheckForEmptyQueue()));
1329     }
1330 }
1331
1332 void ProjectList::reloadClipThumbnails()
1333 {
1334     kDebug() << "//////////////  RELOAD CLIPS THUMBNAILS!!!";
1335     m_thumbnailQueue.clear();
1336     QTreeWidgetItemIterator it(m_listView);
1337     while (*it) {
1338         if ((*it)->type() != PROJECTCLIPTYPE) {
1339             // subitem
1340             ++it;
1341             continue;
1342         }
1343         m_thumbnailQueue << ((ProjectItem *)(*it))->clipId();
1344         ++it;
1345     }
1346     QTimer::singleShot(300, this, SLOT(slotProcessNextThumbnail()));
1347 }
1348
1349 void ProjectList::requestClipThumbnail(const QString id)
1350 {
1351     if (!m_thumbnailQueue.contains(id)) m_thumbnailQueue.append(id);
1352 }
1353
1354 void ProjectList::slotProcessNextThumbnail()
1355 {
1356     if (m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) {
1357         slotCheckForEmptyQueue();
1358         return;
1359     }
1360     if (!m_infoQueue.isEmpty()) {
1361         //QTimer::singleShot(300, this, SLOT(slotProcessNextThumbnail()));
1362         return;
1363     }
1364     if (m_thumbnailQueue.count() > 1) {
1365         int max = m_doc->clipManager()->clipsCount();
1366         emit displayMessage(i18n("Loading thumbnails"), (int)(100 *(max - m_thumbnailQueue.count()) / max));
1367     }
1368     slotRefreshClipThumbnail(m_thumbnailQueue.takeFirst(), false);
1369 }
1370
1371 void ProjectList::slotRefreshClipThumbnail(const QString &clipId, bool update)
1372 {
1373     QTreeWidgetItem *item = getAnyItemById(clipId);
1374     if (item)
1375         slotRefreshClipThumbnail(item, update);
1376     else
1377         slotProcessNextThumbnail();
1378 }
1379
1380 void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update)
1381 {
1382     if (it == NULL) return;
1383     ProjectItem *item = NULL;
1384     bool isSubItem = false;
1385     int frame;
1386     if (it->type() == PROJECTFOLDERTYPE) return;
1387     if (it->type() == PROJECTSUBCLIPTYPE) {
1388         item = static_cast <ProjectItem *>(it->parent());
1389         frame = static_cast <SubProjectItem *>(it)->zone().x();
1390         isSubItem = true;
1391     } else {
1392         item = static_cast <ProjectItem *>(it);
1393         frame = item->referencedClip()->getClipThumbFrame();
1394     }
1395
1396     if (item) {
1397         DocClipBase *clip = item->referencedClip();
1398         if (!clip) {
1399             slotProcessNextThumbnail();
1400             return;
1401         }
1402         QPixmap pix;
1403         int height = m_listView->iconSize().height();
1404         int width = (int)(height  * m_render->dar());
1405         if (clip->clipType() == AUDIO)
1406             pix = KIcon("audio-x-generic").pixmap(QSize(width, height));
1407         else if (clip->clipType() == IMAGE)
1408             pix = QPixmap::fromImage(KThumb::getFrame(item->referencedClip()->producer(), 0, width, height));
1409         else
1410             pix = item->referencedClip()->thumbProducer()->extractImage(frame, width, height);
1411
1412         if (!pix.isNull()) {
1413             m_listView->blockSignals(true);
1414             it->setData(0, Qt::DecorationRole, pix);
1415             if (m_listView->isEnabled())
1416                 m_listView->blockSignals(false);
1417             if (!isSubItem)
1418                 m_doc->cachePixmap(item->getClipHash(), pix);
1419             else
1420                 m_doc->cachePixmap(item->getClipHash() + '#' + QString::number(frame), pix);
1421         }
1422         if (update)
1423             emit projectModified();
1424         QTimer::singleShot(30, this, SLOT(slotProcessNextThumbnail()));
1425     }
1426 }
1427
1428 void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata, bool replace)
1429 {
1430     QString toReload;
1431     ProjectItem *item = getItemById(clipId);
1432     if (item && producer) {
1433         m_listView->blockSignals(true);
1434         item->setProperties(properties, metadata);
1435         if (item->referencedClip()->isPlaceHolder() && producer->is_valid()) {
1436             item->referencedClip()->setValid();
1437             item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
1438             toReload = clipId;
1439         }
1440         //Q_ASSERT_X(item->referencedClip(), "void ProjectList::slotReplyGetFileProperties", QString("Item with groupName %1 does not have a clip associated").arg(item->groupName()).toLatin1());
1441         item->referencedClip()->setProducer(producer, replace);
1442         item->referencedClip()->askForAudioThumbs();
1443         if (!replace && item->data(0, Qt::DecorationRole).isNull())
1444             requestClipThumbnail(clipId);
1445         if (!toReload.isEmpty())
1446             item->slotSetToolTip();
1447
1448         //emit receivedClipDuration(clipId);
1449         if (m_listView->isEnabled() && replace) {
1450             // update clip in clip monitor
1451             emit clipSelected(NULL);
1452             emit clipSelected(item->referencedClip());
1453             //TODO: Make sure the line below has no side effect
1454             toReload = clipId;
1455         }
1456         /*else {
1457             // Check if duration changed.
1458             emit receivedClipDuration(clipId);
1459             delete producer;
1460         }*/
1461         if (m_listView->isEnabled())
1462             m_listView->blockSignals(false);
1463         /*if (item->icon(0).isNull()) {
1464             requestClipThumbnail(clipId);
1465         }*/
1466     } else kDebug() << "////////  COULD NOT FIND CLIP TO UPDATE PRPS...";
1467     int max = m_doc->clipManager()->clipsCount();
1468     if (item && m_infoQueue.isEmpty() && m_thumbnailQueue.isEmpty()) {
1469         m_listView->setCurrentItem(item);
1470         if (item->parent()) {
1471             if (item->parent()->type() == PROJECTFOLDERTYPE)
1472                 static_cast <FolderProjectItem *>(item->parent())->switchIcon();
1473         }
1474         emit clipSelected(item->referencedClip());
1475     } else {
1476         emit displayMessage(i18n("Loading clips"), (int)(100 *(max - m_infoQueue.count()) / max));
1477     }
1478     if (!toReload.isEmpty())
1479         emit clipNeedsReload(toReload, true);
1480     // small delay so that the app can display the progress info
1481     QTimer::singleShot(30, this, SLOT(slotProcessNextClipInQueue()));
1482 }
1483
1484 void ProjectList::slotReplyGetImage(const QString &clipId, const QPixmap &pix)
1485 {
1486     ProjectItem *item = getItemById(clipId);
1487     if (item && !pix.isNull()) {
1488         m_listView->blockSignals(true);
1489         item->setData(0, Qt::DecorationRole, pix);
1490         m_doc->cachePixmap(item->getClipHash(), pix);
1491         if (m_listView->isEnabled())
1492             m_listView->blockSignals(false);
1493     }
1494 }
1495
1496 QTreeWidgetItem *ProjectList::getAnyItemById(const QString &id)
1497 {
1498     QTreeWidgetItemIterator it(m_listView);
1499     QString lookId = id;
1500     if (id.contains('#'))
1501         lookId = id.section('#', 0, 0);
1502
1503     ProjectItem *result = NULL;
1504     while (*it) {
1505         if ((*it)->type() != PROJECTCLIPTYPE) {
1506             // subitem
1507             ++it;
1508             continue;
1509         }
1510         ProjectItem *item = static_cast<ProjectItem *>(*it);
1511         if (item->clipId() == lookId) {
1512             result = item;
1513             break;
1514         }
1515         ++it;
1516     }
1517     if (result == NULL || !id.contains('#')) {
1518         return result;
1519     } else {
1520         for (int i = 0; i < result->childCount(); i++) {
1521             SubProjectItem *sub = static_cast <SubProjectItem *>(result->child(i));
1522             if (sub && sub->zone().x() == id.section('#', 1, 1).toInt())
1523                 return sub;
1524         }
1525     }
1526
1527     return NULL;
1528 }
1529
1530
1531 ProjectItem *ProjectList::getItemById(const QString &id)
1532 {
1533     ProjectItem *item;
1534     QTreeWidgetItemIterator it(m_listView);
1535     while (*it) {
1536         if ((*it)->type() != PROJECTCLIPTYPE) {
1537             // subitem
1538             ++it;
1539             continue;
1540         }
1541         item = static_cast<ProjectItem *>(*it);
1542         if (item->clipId() == id)
1543             return item;
1544         ++it;
1545     }
1546     return NULL;
1547 }
1548
1549 FolderProjectItem *ProjectList::getFolderItemById(const QString &id)
1550 {
1551     FolderProjectItem *item;
1552     QTreeWidgetItemIterator it(m_listView);
1553     while (*it) {
1554         if ((*it)->type() == PROJECTFOLDERTYPE) {
1555             item = static_cast<FolderProjectItem *>(*it);
1556             if (item->clipId() == id)
1557                 return item;
1558         }
1559         ++it;
1560     }
1561     return NULL;
1562 }
1563
1564 void ProjectList::slotSelectClip(const QString &ix)
1565 {
1566     ProjectItem *clip = getItemById(ix);
1567     if (clip) {
1568         m_listView->setCurrentItem(clip);
1569         m_listView->scrollToItem(clip);
1570         m_editAction->setEnabled(true);
1571         m_deleteAction->setEnabled(true);
1572         m_reloadAction->setEnabled(true);
1573         m_transcodeAction->setEnabled(true);
1574         if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
1575             m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp()));
1576             m_openAction->setEnabled(true);
1577         } else if (clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
1578             m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp()));
1579             m_openAction->setEnabled(true);
1580         } else {
1581             m_openAction->setEnabled(false);
1582         }
1583     }
1584 }
1585
1586 QString ProjectList::currentClipUrl() const
1587 {
1588     ProjectItem *item;
1589     if (!m_listView->currentItem() || m_listView->currentItem()->type() == PROJECTFOLDERTYPE) return QString();
1590     if (m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE) {
1591         // subitem
1592         item = static_cast <ProjectItem*>(m_listView->currentItem()->parent());
1593     } else {
1594         item = static_cast <ProjectItem*>(m_listView->currentItem());
1595     }
1596     if (item == NULL)
1597         return QString();
1598     return item->clipUrl().path();
1599 }
1600
1601 KUrl::List ProjectList::getConditionalUrls(const QString &condition) const
1602 {
1603     KUrl::List result;
1604     ProjectItem *item;
1605     QList<QTreeWidgetItem *> list = m_listView->selectedItems();
1606     for (int i = 0; i < list.count(); i++) {
1607         if (list.at(i)->type() == PROJECTFOLDERTYPE)
1608             continue;
1609         if (list.at(i)->type() == PROJECTSUBCLIPTYPE) {
1610             // subitem
1611             item = static_cast <ProjectItem*>(list.at(i)->parent());
1612         } else {
1613             item = static_cast <ProjectItem*>(list.at(i));
1614         }
1615         if (item == NULL || item->type() == COLOR || item->type() == SLIDESHOW || item->type() == TEXT)
1616             continue;
1617         DocClipBase *clip = item->referencedClip();
1618         if (!condition.isEmpty()) {
1619             if (condition.startsWith("vcodec") && !clip->hasVideoCodec(condition.section("=", 1, 1)))
1620                 continue;
1621             else if (condition.startsWith("acodec") && !clip->hasAudioCodec(condition.section("=", 1, 1)))
1622                 continue;
1623         }
1624         result.append(item->clipUrl());
1625     }
1626     return result;
1627 }
1628
1629 void ProjectList::regenerateTemplate(const QString &id)
1630 {
1631     ProjectItem *clip = getItemById(id);
1632     if (clip)
1633         regenerateTemplate(clip);
1634 }
1635
1636 void ProjectList::regenerateTemplate(ProjectItem *clip)
1637 {
1638     //TODO: remove this unused method, only force_reload is necessary
1639     clip->referencedClip()->producer()->set("force_reload", 1);
1640 }
1641
1642 QDomDocument ProjectList::generateTemplateXml(QString path, const QString &replaceString)
1643 {
1644     QDomDocument doc;
1645     QFile file(path);
1646     if (!file.open(QIODevice::ReadOnly)) {
1647         kWarning() << "ERROR, CANNOT READ: " << path;
1648         return doc;
1649     }
1650     if (!doc.setContent(&file)) {
1651         kWarning() << "ERROR, CANNOT READ: " << path;
1652         file.close();
1653         return doc;
1654     }
1655     file.close();
1656     QDomNodeList texts = doc.elementsByTagName("content");
1657     for (int i = 0; i < texts.count(); i++) {
1658         QString data = texts.item(i).firstChild().nodeValue();
1659         data.replace("%s", replaceString);
1660         texts.item(i).firstChild().setNodeValue(data);
1661     }
1662     return doc;
1663 }
1664
1665
1666 void ProjectList::slotAddClipCut(const QString &id, int in, int out)
1667 {
1668     ProjectItem *clip = getItemById(id);
1669     if (clip == NULL || clip->referencedClip()->hasCutZone(QPoint(in, out)))
1670         return;
1671     AddClipCutCommand *command = new AddClipCutCommand(this, id, in, out, QString(), true, false);
1672     m_commandStack->push(command);
1673 }
1674
1675 void ProjectList::addClipCut(const QString &id, int in, int out, const QString desc, bool newItem)
1676 {
1677     ProjectItem *clip = getItemById(id);
1678     if (clip) {
1679         DocClipBase *base = clip->referencedClip();
1680         base->addCutZone(in, out);
1681         m_listView->blockSignals(true);
1682         SubProjectItem *sub = new SubProjectItem(clip, in, out, desc);
1683         if (newItem && desc.isEmpty() && !m_listView->isColumnHidden(1)) {
1684             if (!clip->isExpanded())
1685                 clip->setExpanded(true);
1686             m_listView->scrollToItem(sub);
1687             m_listView->editItem(sub, 1);
1688         }
1689         QPixmap p = clip->referencedClip()->thumbProducer()->extractImage(in, (int)(sub->sizeHint(0).height()  * m_render->dar()), sub->sizeHint(0).height() - 2);
1690         sub->setData(0, Qt::DecorationRole, p);
1691         m_doc->cachePixmap(clip->getClipHash() + '#' + QString::number(in), p);
1692         m_listView->blockSignals(false);
1693     }
1694     emit projectModified();
1695 }
1696
1697 void ProjectList::removeClipCut(const QString &id, int in, int out)
1698 {
1699     ProjectItem *clip = getItemById(id);
1700     if (clip) {
1701         DocClipBase *base = clip->referencedClip();
1702         base->removeCutZone(in, out);
1703         SubProjectItem *sub = getSubItem(clip, QPoint(in, out));
1704         if (sub) {
1705             m_listView->blockSignals(true);
1706             delete sub;
1707             m_listView->blockSignals(false);
1708         }
1709     }
1710     emit projectModified();
1711 }
1712
1713 SubProjectItem *ProjectList::getSubItem(ProjectItem *clip, QPoint zone)
1714 {
1715     SubProjectItem *sub = NULL;
1716     if (clip) {
1717         for (int i = 0; i < clip->childCount(); i++) {
1718             QTreeWidgetItem *it = clip->child(i);
1719             if (it->type() == PROJECTSUBCLIPTYPE) {
1720                 sub = static_cast <SubProjectItem*>(it);
1721                 if (sub->zone() == zone)
1722                     break;
1723                 else
1724                     sub = NULL;
1725             }
1726         }
1727     }
1728     return sub;
1729 }
1730
1731 void ProjectList::slotUpdateClipCut(QPoint p)
1732 {
1733     if (!m_listView->currentItem() || m_listView->currentItem()->type() != PROJECTSUBCLIPTYPE)
1734         return;
1735     SubProjectItem *sub = static_cast <SubProjectItem*>(m_listView->currentItem());
1736     ProjectItem *item = static_cast <ProjectItem *>(sub->parent());
1737     EditClipCutCommand *command = new EditClipCutCommand(this, item->clipId(), sub->zone(), p, sub->text(1), sub->text(1), true);
1738     m_commandStack->push(command);
1739 }
1740
1741 void ProjectList::doUpdateClipCut(const QString &id, const QPoint oldzone, const QPoint zone, const QString &comment)
1742 {
1743     ProjectItem *clip = getItemById(id);
1744     SubProjectItem *sub = getSubItem(clip, oldzone);
1745     if (sub == NULL || clip == NULL)
1746         return;
1747     DocClipBase *base = clip->referencedClip();
1748     base->updateCutZone(oldzone.x(), oldzone.y(), zone.x(), zone.y(), comment);
1749     m_listView->blockSignals(true);
1750     sub->setZone(zone);
1751     sub->setDescription(comment);
1752     m_listView->blockSignals(false);
1753     emit projectModified();
1754 }
1755
1756 void ProjectList::slotForceProcessing(const QString &id)
1757 {
1758     while (m_infoQueue.contains(id)) {
1759         slotProcessNextClipInQueue();
1760     }
1761 }
1762
1763 #include "projectlist.moc"