1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
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. *
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. *
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 ***************************************************************************/
21 #include <QMouseEvent>
22 #include <QStylePainter>
31 #include <KFileDialog>
32 #include <KInputDialog>
33 #include <KMessageBox>
35 #include <nepomuk/global.h>
36 #include <nepomuk/resource.h>
37 #include <nepomuk/tag.h>
39 #include "projectlist.h"
40 #include "projectitem.h"
41 #include "addfoldercommand.h"
42 #include "kdenlivesettings.h"
43 #include "slideshowclip.h"
44 #include "ui_colorclip_ui.h"
45 #include "titlewidget.h"
46 #include "definitions.h"
47 #include "clipmanager.h"
48 #include "docclipbase.h"
49 #include "kdenlivedoc.h"
52 #include "projectlistview.h"
53 #include "editclipcommand.h"
54 #include "editfoldercommand.h"
56 ProjectList::ProjectList(QWidget *parent)
57 : QWidget(parent), m_render(NULL), m_fps(-1), m_commandStack(NULL), m_selectedItem(NULL), m_infoQueue(QMap <QString, QDomElement> ()), m_thumbnailQueue(QList <QString> ()), m_refreshed(false) {
59 QWidget *vbox = new QWidget;
60 listView = new ProjectListView(this);;
61 QVBoxLayout *layout = new QVBoxLayout;
62 layout->setContentsMargins(0, 0, 0, 0);
63 // mbd: I think this has died at some point: m_clipIdCounter = 0;
65 searchView = new KTreeWidgetSearchLine(this);
66 m_toolbar = new QToolBar("projectToolBar", this);
67 m_toolbar->addWidget(searchView);
69 m_addButton = new QToolButton(m_toolbar);
70 m_addButton->setPopupMode(QToolButton::MenuButtonPopup);
71 m_toolbar->addWidget(m_addButton);
73 m_deleteAction = m_toolbar->addAction(KIcon("edit-delete"), i18n("Delete Clip"));
74 connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(slotRemoveClip()));
76 m_editAction = m_toolbar->addAction(KIcon("document-properties"), i18n("Edit Clip"));
77 connect(m_editAction, SIGNAL(triggered()), this, SLOT(slotEditClip()));
79 layout->addWidget(m_toolbar);
80 layout->addWidget(listView);
82 //m_toolbar->setEnabled(false);
84 searchView->setTreeWidget(listView);
86 connect(listView, SIGNAL(itemSelectionChanged()), this, SLOT(slotClipSelected()));
87 connect(listView, SIGNAL(focusMonitor()), this, SLOT(slotClipSelected()));
88 connect(listView, SIGNAL(pauseMonitor()), this, SLOT(slotPauseMonitor()));
89 connect(listView, SIGNAL(requestMenu(const QPoint &, QTreeWidgetItem *)), this, SLOT(slotContextMenu(const QPoint &, QTreeWidgetItem *)));
90 connect(listView, SIGNAL(addClip()), this, SLOT(slotAddClip()));
91 connect(listView, SIGNAL(addClip(KUrl, const QString &)), this, SLOT(slotAddClip(KUrl, const QString &)));
92 connect(listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotItemEdited(QTreeWidgetItem *, int)));
93 connect(listView, SIGNAL(showProperties(DocClipBase *)), this, SIGNAL(showClipProperties(DocClipBase *)));
95 ItemDelegate *listViewDelegate = new ItemDelegate(listView);
96 listView->setItemDelegate(listViewDelegate);
99 ProjectList::~ProjectList() {
104 void ProjectList::setupMenu(QMenu *addMenu, QAction *defaultAction) {
105 m_addButton->setMenu(addMenu);
106 m_addButton->setDefaultAction(defaultAction);
107 m_menu = new QMenu();
108 m_menu->addActions(addMenu->actions());
111 void ProjectList::setupGeneratorMenu(QMenu *addMenu) {
112 if (!addMenu) return;
113 QMenu *menu = m_addButton->menu();
114 menu->addMenu(addMenu);
115 m_addButton->setMenu(menu);
117 m_menu->addMenu(addMenu);
118 if (addMenu->isEmpty()) addMenu->setEnabled(false);
119 m_menu->addAction(m_editAction);
120 m_menu->addAction(m_deleteAction);
121 m_menu->insertSeparator(m_deleteAction);
125 QByteArray ProjectList::headerInfo() {
126 return listView->header()->saveState();
129 void ProjectList::setHeaderInfo(const QByteArray &state) {
130 listView->header()->restoreState(state);
133 void ProjectList::slotEditClip() {
134 ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
135 if (item && !item->isGroup()) {
136 emit clipSelected(item->referencedClip());
137 emit showClipProperties(item->referencedClip());
143 void ProjectList::setRenderer(Render *projectRender) {
144 m_render = projectRender;
147 void ProjectList::slotClipSelected() {
148 if (listView->currentItem()) {
149 ProjectItem *clip = static_cast <ProjectItem*>(listView->currentItem());
150 if (!clip->isGroup()) {
151 m_selectedItem = clip;
152 emit clipSelected(clip->referencedClip());
154 m_editAction->setEnabled(true);
155 m_deleteAction->setEnabled(true);
157 emit clipSelected(NULL);
158 m_editAction->setEnabled(false);
159 m_deleteAction->setEnabled(false);
163 void ProjectList::slotPauseMonitor() {
164 if (m_render) m_render->pause();
167 void ProjectList::slotUpdateClipProperties(const QString &id, QMap <QString, QString> properties) {
168 ProjectItem *item = getItemById(id);
170 slotUpdateClipProperties(item, properties);
171 if (properties.contains("colour") || properties.contains("resource") || properties.contains("xmldata")) slotRefreshClipThumbnail(item);
172 if (properties.contains("out")) item->changeDuration(properties.value("out").toInt());
176 void ProjectList::slotUpdateClipProperties(ProjectItem *clip, QMap <QString, QString> properties) {
178 if (!clip->isGroup()) clip->setProperties(properties);
179 if (properties.contains("name")) {
180 listView->blockSignals(true);
181 clip->setText(1, properties.value("name"));
182 listView->blockSignals(false);
183 emit clipNameChanged(clip->clipId(), properties.value("name"));
185 if (properties.contains("description")) {
186 CLIPTYPE type = clip->clipType();
187 listView->blockSignals(true);
188 clip->setText(2, properties.value("description"));
189 listView->blockSignals(false);
190 if (KdenliveSettings::activate_nepomuk() && (type == AUDIO || type == VIDEO || type == AV || type == IMAGE || type == PLAYLIST)) {
191 // Use Nepomuk system to store clip description
192 Nepomuk::Resource f(clip->clipUrl().path());
194 f.setDescription(properties.value("description"));
196 KMessageBox::sorry(this, i18n("Cannot access Desktop Search info for %1.\nDisabling Desktop Search integration.", clip->clipUrl().path()));
197 KdenliveSettings::setActivate_nepomuk(false);
200 emit projectModified();
204 void ProjectList::slotItemEdited(QTreeWidgetItem *item, int column) {
205 ProjectItem *clip = static_cast <ProjectItem*>(item);
207 if (clip->referencedClip()) {
208 QMap <QString, QString> oldprops;
209 QMap <QString, QString> newprops;
210 oldprops["description"] = clip->referencedClip()->getProperty("description");
211 newprops["description"] = item->text(2);
212 slotUpdateClipProperties(clip, newprops);
213 EditClipCommand *command = new EditClipCommand(this, clip->clipId(), oldprops, newprops, false);
214 m_commandStack->push(command);
216 } else if (column == 1) {
217 if (clip->isGroup()) {
218 editFolder(item->text(1), clip->groupName(), clip->clipId());
219 clip->setGroupName(item->text(1));
220 m_doc->clipManager()->addFolder(clip->clipId(), item->text(1));
221 const int children = item->childCount();
222 for (int i = 0; i < children; i++) {
223 ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
224 child->setProperty("groupname", item->text(1));
227 if (clip->referencedClip()) {
228 QMap <QString, QString> oldprops;
229 QMap <QString, QString> newprops;
230 oldprops["name"] = clip->referencedClip()->getProperty("name");
231 newprops["name"] = item->text(1);
232 slotUpdateClipProperties(clip, newprops);
233 emit projectModified();
234 EditClipCommand *command = new EditClipCommand(this, clip->clipId(), oldprops, newprops, false);
235 m_commandStack->push(command);
241 void ProjectList::slotContextMenu(const QPoint &pos, QTreeWidgetItem *item) {
246 m_editAction->setEnabled(enable);
247 m_deleteAction->setEnabled(enable);
251 void ProjectList::slotRemoveClip() {
252 if (!listView->currentItem()) return;
254 QMap <QString, QString> folderids;
255 QList<QTreeWidgetItem *> selected = listView->selectedItems();
257 for (int i = 0; i < selected.count(); i++) {
258 item = static_cast <ProjectItem *>(selected.at(i));
259 if (item->isGroup()) folderids[item->groupName()] = item->clipId();
260 else ids << item->clipId();
261 if (item->numReferences() > 0) {
262 if (KMessageBox::questionYesNo(this, i18np("Delete clip <b>%2</b> ?<br>This will also remove the clip in timeline", "Delete clip <b>%2</b> ?<br>This will also remove its %1 clips in timeline", item->numReferences(), item->names().at(1)), i18n("Delete Clip")) != KMessageBox::Yes) return;
263 } else if (item->isGroup() && item->childCount() > 0) {
264 int children = item->childCount();
265 if (KMessageBox::questionYesNo(this, i18n("Delete folder <b>%2</b> ?<br>This will also remove the %1 clips in that folder", children, item->names().at(1)), i18n("Delete Folder")) != KMessageBox::Yes) return;
266 for (int i = 0; i < children; ++i) {
267 ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
268 ids << child->clipId();
272 if (!ids.isEmpty()) m_doc->deleteProjectClip(ids);
273 if (!folderids.isEmpty()) deleteProjectFolder(folderids);
274 if (listView->topLevelItemCount() == 0) {
275 m_editAction->setEnabled(false);
276 m_deleteAction->setEnabled(false);
280 void ProjectList::selectItemById(const QString &clipId) {
281 ProjectItem *item = getItemById(clipId);
282 if (item) listView->setCurrentItem(item);
286 void ProjectList::slotDeleteClip(const QString &clipId) {
287 ProjectItem *item = getItemById(clipId);
288 QTreeWidgetItem *p = item->parent();
290 kDebug() << "/////// DELETED CLIP HAS A PARENT... " << p->indexOfChild(item);
291 QTreeWidgetItem *clone = p->takeChild(p->indexOfChild(item));
298 void ProjectList::editFolder(const QString folderName, const QString oldfolderName, const QString &clipId) {
299 EditFolderCommand *command = new EditFolderCommand(this, folderName, oldfolderName, clipId, false);
300 m_commandStack->push(command);
301 m_doc->setModified(true);
304 void ProjectList::slotAddFolder() {
305 AddFolderCommand *command = new AddFolderCommand(this, i18n("Folder"), QString::number(m_doc->clipManager()->getFreeFolderId()), true);
306 m_commandStack->push(command);
309 void ProjectList::slotAddFolder(const QString foldername, const QString &clipId, bool remove, bool edit) {
311 ProjectItem *item = getFolderItemById(clipId);
313 m_doc->clipManager()->deleteFolder(clipId);
318 ProjectItem *item = getFolderItemById(clipId);
319 QTreeWidgetItemIterator it(listView);
321 listView->blockSignals(true);
322 item->setGroupName(foldername);
323 listView->blockSignals(false);
324 m_doc->clipManager()->addFolder(clipId, foldername);
325 const int children = item->childCount();
326 for (int i = 0; i < children; i++) {
327 ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
328 child->setProperty("groupname", foldername);
333 text << QString() << foldername;
334 listView->blockSignals(true);
335 (void) new ProjectItem(listView, text, clipId);
336 m_doc->clipManager()->addFolder(clipId, foldername);
337 listView->blockSignals(false);
344 void ProjectList::deleteProjectFolder(QMap <QString, QString> map) {
345 QMapIterator<QString, QString> i(map);
346 QUndoCommand *delCommand = new QUndoCommand();
347 delCommand->setText(i18n("Delete Folder"));
348 while (i.hasNext()) {
350 new AddFolderCommand(this, i.key(), i.value(), false, delCommand);
352 m_commandStack->push(delCommand);
353 m_doc->setModified(true);
356 void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) {
357 if (getProperties) listView->setEnabled(false);
358 listView->blockSignals(true);
359 const QString parent = clip->getProperty("groupid");
360 kDebug() << "Adding clip with groupid: " << parent;
361 ProjectItem *item = NULL;
362 if (!parent.isEmpty()) {
363 ProjectItem *parentitem = getFolderItemById(parent);
366 QString groupName = clip->getProperty("groupname");
367 //kDebug() << "Adding clip to new group: " << groupName;
368 if (groupName.isEmpty()) groupName = i18n("Folder");
369 text << QString() << groupName;
370 parentitem = new ProjectItem(listView, text, parent);
372 //kDebug() << "Adding clip to existing group: " << parentitem->groupName();
374 if (parentitem) item = new ProjectItem(parentitem, clip);
376 if (item == NULL) item = new ProjectItem(listView, clip);
378 KUrl url = clip->fileURL();
379 if (!url.isEmpty() && KdenliveSettings::activate_nepomuk()) {
380 // if file has Nepomuk comment, use it
381 Nepomuk::Resource f(url.path());
384 annotation = f.description();
386 Nepomuk::Tag tag("test");
389 KMessageBox::sorry(this, i18n("Cannot access Desktop Search info for %1.\nDisabling Desktop Search integration.", url.path()));
390 KdenliveSettings::setActivate_nepomuk(false);
392 if (!annotation.isEmpty()) item->setText(2, annotation);
394 listView->blockSignals(false);
397 void ProjectList::requestClipInfo(const QDomElement xml, const QString id) {
398 kDebug() << " PRG LISTĀ REQUEST CLP INFO: " << id;
399 m_infoQueue.insert(id, xml);
400 listView->setEnabled(false);
401 if (m_infoQueue.count() == 1) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
404 void ProjectList::slotProcessNextClipInQueue() {
405 if (m_infoQueue.isEmpty()) {
406 listView->setEnabled(true);
409 QMap<QString, QDomElement>::const_iterator i = m_infoQueue.constBegin();
410 if (i != m_infoQueue.constEnd()) {
411 const QDomElement dom = i.value();
412 const QString id = i.key();
413 m_infoQueue.remove(i.key());
414 emit getFileProperties(dom, id);
416 if (m_infoQueue.isEmpty()) listView->setEnabled(true);
419 void ProjectList::slotUpdateClip(const QString &id) {
420 ProjectItem *item = getItemById(id);
421 listView->blockSignals(true);
422 if (item) item->setData(1, UsageRole, QString::number(item->numReferences()));
423 listView->blockSignals(false);
426 void ProjectList::updateAllClips() {
427 QTreeWidgetItemIterator it(listView);
429 ProjectItem *item = static_cast <ProjectItem *>(*it);
430 if (!item->isGroup()) {
431 if (item->referencedClip()->producer() == NULL) {
432 DocClipBase *clip = item->referencedClip();
433 if (clip->clipType() == TEXT && !QFile::exists(clip->fileURL().path())) {
434 // regenerate text clip image if required
435 TitleWidget *dia_ui = new TitleWidget(KUrl(), QString(), m_render, this);
437 doc.setContent(clip->getProperty("xmldata"));
439 QImage pix = dia_ui->renderedPixmap();
440 pix.save(clip->fileURL().path());
443 requestClipInfo(clip->toXML(), clip->getId());
445 QString cachedPixmap = m_doc->projectFolder().path() + "/thumbs/" + item->getClipHash() + ".png";
446 if (QFile::exists(cachedPixmap)) {
447 //kDebug()<<"// USING CACHED PIX: "<<cachedPixmap;
448 listView->blockSignals(true);
449 item->setIcon(0, QPixmap(cachedPixmap));
450 listView->blockSignals(false);
451 } else requestClipThumbnail(item->clipId());
452 listView->blockSignals(true);
453 item->changeDuration(item->referencedClip()->producer()->get_playtime());
454 listView->blockSignals(false);
456 listView->blockSignals(true);
457 item->setData(1, UsageRole, QString::number(item->numReferences()));
458 listView->blockSignals(false);
459 qApp->processEvents();
463 QTimer::singleShot(500, this, SLOT(slotCheckForEmptyQueue()));
466 void ProjectList::slotAddClip(KUrl givenUrl, QString group) {
467 if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
469 if (givenUrl.isEmpty()) {
470 list = KFileDialog::getOpenUrls(KUrl("kfiledialog:///clipfolder"), "application/x-kdenlive video/x-flv application/vnd.rn-realmedia video/x-dv video/dv video/x-msvideo video/mpeg video/x-ms-wmv audio/mpeg audio/x-mp3 audio/x-wav application/ogg video/mp4 video/quicktime image/gif image/jpeg image/png image/x-bmp image/svg+xml image/tiff image/x-xcf-gimp image/x-vnd.adobe.photoshop image/x-pcx image/x-exr video/mlt-playlist audio/x-flac audio/mp4", this);
471 } else list.append(givenUrl);
472 if (list.isEmpty()) return;
474 QString groupId = QString();
475 if (group.isEmpty()) {
476 ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
477 if (item && !item->isGroup()) {
478 while (item->parent()) {
479 item = static_cast <ProjectItem*>(item->parent());
480 if (item->isGroup()) break;
483 if (item && item->isGroup()) {
484 group = item->groupName();
485 groupId = item->clipId();
488 m_doc->slotAddClipList(list, group, groupId);
491 void ProjectList::slotRemoveInvalidClip(const QString &id) {
492 ProjectItem *item = getItemById(id);
494 const QString path = item->referencedClip()->fileURL().path();
495 if (!path.isEmpty()) KMessageBox::sorry(this, i18n("Clip <b>%1</b><br>is invalid, will be removed from project.", path));
498 m_doc->deleteProjectClip(ids);
500 if (!m_infoQueue.isEmpty()) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
503 void ProjectList::slotAddColorClip() {
504 if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
505 QDialog *dia = new QDialog(this);
506 Ui::ColorClip_UI *dia_ui = new Ui::ColorClip_UI();
507 dia_ui->setupUi(dia);
508 dia_ui->clip_name->setText(i18n("Color Clip"));
509 dia_ui->clip_duration->setText(KdenliveSettings::color_duration());
510 if (dia->exec() == QDialog::Accepted) {
511 QString color = dia_ui->clip_color->color().name();
512 color = color.replace(0, 1, "0x") + "ff";
514 QString group = QString();
515 QString groupId = QString();
516 ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
517 if (item && !item->isGroup()) {
518 while (item->parent()) {
519 item = static_cast <ProjectItem*>(item->parent());
520 if (item->isGroup()) break;
523 if (item && item->isGroup()) {
524 group = item->groupName();
525 groupId = item->clipId();
528 m_doc->slotAddColorClipFile(dia_ui->clip_name->text(), color, dia_ui->clip_duration->text(), group, groupId);
535 void ProjectList::slotAddSlideshowClip() {
536 if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
537 SlideshowClip *dia = new SlideshowClip(this);
539 if (dia->exec() == QDialog::Accepted) {
541 QString group = QString();
542 QString groupId = QString();
543 ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
544 if (item && !item->isGroup()) {
545 while (item->parent()) {
546 item = static_cast <ProjectItem*>(item->parent());
547 if (item->isGroup()) break;
550 if (item && item->isGroup()) {
551 group = item->groupName();
552 groupId = item->clipId();
555 m_doc->slotAddSlideshowClipFile(dia->clipName(), dia->selectedPath(), dia->imageCount(), dia->clipDuration(), dia->loop(), dia->fade(), dia->lumaDuration(), dia->lumaFile(), dia->softness(), group, groupId);
560 void ProjectList::slotAddTitleClip() {
561 QString group = QString();
562 QString groupId = QString();
563 ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
564 if (item && !item->isGroup()) {
565 while (item->parent()) {
566 item = static_cast <ProjectItem*>(item->parent());
567 if (item->isGroup()) break;
570 if (item && item->isGroup()) {
571 group = item->groupName();
572 groupId = item->clipId();
575 m_doc->slotCreateTextClip(group, groupId);
578 void ProjectList::setDocument(KdenliveDoc *doc) {
579 listView->blockSignals(true);
581 m_thumbnailQueue.clear();
584 QMap <QString, QString> flist = doc->clipManager()->documentFolderList();
585 QMapIterator<QString, QString> f(flist);
586 while (f.hasNext()) {
588 (void) new ProjectItem(listView, QStringList() << QString() << f.value(), f.key());
591 QList <DocClipBase*> list = doc->clipManager()->documentClipList();
592 for (int i = 0; i < list.count(); i++) {
593 slotAddClip(list.at(i), false);
597 m_timecode = doc->timecode();
598 m_commandStack = doc->commandStack();
600 QTreeWidgetItem *first = listView->topLevelItem(0);
601 if (first) listView->setCurrentItem(first);
602 listView->blockSignals(false);
603 m_toolbar->setEnabled(true);
606 QDomElement ProjectList::producersList() {
608 QDomElement prods = doc.createElement("producerlist");
609 doc.appendChild(prods);
610 kDebug() << "//////////// PRO LISTĀ BUILD PRDSLIST ";
611 QTreeWidgetItemIterator it(listView);
613 if (!((ProjectItem *)(*it))->isGroup())
614 prods.appendChild(doc.importNode(((ProjectItem *)(*it))->toXml(), true));
620 void ProjectList::slotCheckForEmptyQueue() {
621 if (!m_refreshed && m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) {
623 emit loadingIsOver();
624 } else QTimer::singleShot(500, this, SLOT(slotCheckForEmptyQueue()));
627 void ProjectList::requestClipThumbnail(const QString &id) {
628 m_thumbnailQueue.append(id);
629 if (m_thumbnailQueue.count() == 1) QTimer::singleShot(300, this, SLOT(slotProcessNextThumbnail()));
632 void ProjectList::slotProcessNextThumbnail() {
633 if (m_thumbnailQueue.isEmpty()) {
636 slotRefreshClipThumbnail(m_thumbnailQueue.takeFirst(), false);
639 void ProjectList::slotRefreshClipThumbnail(const QString &clipId, bool update) {
640 ProjectItem *item = getItemById(clipId);
641 if (item) slotRefreshClipThumbnail(item, update);
642 else slotProcessNextThumbnail();
645 void ProjectList::slotRefreshClipThumbnail(ProjectItem *item, bool update) {
647 if (!item->referencedClip()) return;
649 int width = (int)(height * m_render->dar());
650 DocClipBase *clip = item->referencedClip();
651 if (!clip) slotProcessNextThumbnail();
653 if (clip->clipType() == AUDIO) pix = KIcon("audio-x-generic").pixmap(QSize(width, height));
654 else pix = item->referencedClip()->thumbProducer()->extractImage(item->referencedClip()->getClipThumbFrame(), width, height);
655 listView->blockSignals(true);
656 item->setIcon(0, pix);
657 listView->blockSignals(false);
658 m_doc->cachePixmap(item->getClipHash(), pix);
659 if (update) emit projectModified();
660 if (!m_thumbnailQueue.isEmpty()) QTimer::singleShot(300, this, SLOT(slotProcessNextThumbnail()));
664 void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata) {
665 ProjectItem *item = getItemById(clipId);
666 if (item && producer) {
667 listView->blockSignals(true);
668 item->setProperties(properties, metadata);
669 Q_ASSERT_X( item->referencedClip(), "void ProjectList::slotReplyGetFileProperties", QString( "Item with groupName %1 does not have a clip associated" ).arg( item->groupName() ).toLatin1() );
670 item->referencedClip()->setProducer(producer);
671 emit receivedClipDuration(clipId, item->clipMaxDuration());
672 listView->blockSignals(false);
673 } else kDebug() << "//////// COULD NOT FIND CLIP TO UPDATE PRPS...";
674 if (!m_infoQueue.isEmpty()) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
675 else listView->setEnabled(true);
678 void ProjectList::slotReplyGetImage(const QString &clipId, int pos, const QPixmap &pix, int w, int h) {
679 ProjectItem *item = getItemById(clipId);
681 listView->blockSignals(true);
682 item->setIcon(0, pix);
683 m_doc->cachePixmap(item->getClipHash(), pix);
684 listView->blockSignals(false);
688 ProjectItem *ProjectList::getItemById(const QString &id) {
690 QTreeWidgetItemIterator it(listView);
692 item = static_cast<ProjectItem *>(*it);
693 if (item->clipId() == id && item->clipType() != FOLDER)
700 ProjectItem *ProjectList::getFolderItemById(const QString &id) {
702 QTreeWidgetItemIterator it(listView);
704 item = static_cast<ProjectItem *>(*it);
705 if (item->clipId() == id && item->clipType() == FOLDER)
712 void ProjectList::slotSelectClip(const QString &ix) {
713 ProjectItem *p = getItemById(ix);
715 listView->setCurrentItem(p);
716 listView->scrollToItem(p);
717 m_editAction->setEnabled(true);
718 m_deleteAction->setEnabled(true);
722 #include "projectlist.moc"