X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fprojectlist.cpp;h=b2837a206950e25ffc1cd7b044bc69ccc319871e;hb=12c52e2d2e97f703714b83dfd385db2de5f03f18;hp=ff3b6acc350078275dbbd188647b3e5145277e65;hpb=aa34cd9fc976d1f442b9c38b3d9cb14ca649cc27;p=kdenlive diff --git a/src/projectlist.cpp b/src/projectlist.cpp index ff3b6acc..b2837a20 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -913,16 +913,7 @@ void ProjectList::deleteProjectFolder(QMap map) void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) { m_listView->setEnabled(false); - if (getProperties) { - m_listView->blockSignals(true); - m_refreshed = false; - // remove file_hash so that we load all properties for the clip - QDomElement e = clip->toXML().cloneNode().toElement(); - e.removeAttribute("file_hash"); - m_infoQueue.insert(clip->getId(), e); - //m_render->getFileProperties(clip->toXML(), clip->getId(), true); - } - clip->askForAudioThumbs(); + if (getProperties) m_listView->blockSignals(true); const QString parent = clip->getProperty("groupid"); ProjectItem *item = NULL; if (!parent.isEmpty()) { @@ -941,8 +932,40 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) } if (item == NULL) item = new ProjectItem(m_listView, clip); + if (item->data(0, DurationRole).isNull()) item->setData(0, DurationRole, i18n("Loading")); + if (getProperties) { + m_listView->blockSignals(true); + m_refreshed = false; + + // Proxy clips + CLIPTYPE t = clip->clipType(); + if ((t == VIDEO || t == AV || t == UNKNOWN) && KdenliveSettings::enableproxy()) { + if (clip->getProperty("proxy").isEmpty()) { + connect(clip, SIGNAL(proxyReady(const QString, bool)), this, SLOT(slotGotProxy(const QString, bool))); + item->setProxyStatus(1); + clip->generateProxy(m_doc->projectFolder()); + } + else { + // Proxy clip already created + item->setProxyStatus(2); + QDomElement e = clip->toXML().cloneNode().toElement(); + e.removeAttribute("file_hash"); + m_infoQueue.insert(clip->getId(), e); + + } + } + else { + // We don't use proxies + // remove file_hash so that we load all properties for the clip + QDomElement e = clip->toXML().cloneNode().toElement(); + e.removeAttribute("file_hash"); + m_infoQueue.insert(clip->getId(), e); + } + //m_render->getFileProperties(clip->toXML(), clip->getId(), true); + } + clip->askForAudioThumbs(); + KUrl url = clip->fileURL(); - if (getProperties == false && !clip->getClipHash().isEmpty()) { QString cachedPixmap = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "thumbs/" + clip->getClipHash() + ".png"; if (QFile::exists(cachedPixmap)) { @@ -982,10 +1005,30 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) if (getProperties) m_listView->blockSignals(false); } + if (getProperties && !m_queueTimer.isActive()) slotProcessNextClipInQueue(); } +void ProjectList::slotGotProxy(const QString id, bool success) +{ + ProjectItem *item = getItemById(id); + if (item) { + disconnect(m_listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotItemEdited(QTreeWidgetItem *, int))); + if (success) { + // Proxy clip successfully created + item->setProxyStatus(2); + QDomElement e = item->referencedClip()->toXML().cloneNode().toElement(); + e.removeAttribute("file_hash"); + m_infoQueue.insert(id, e); + if (!m_queueTimer.isActive()) slotProcessNextClipInQueue(); + } + else item->setProxyStatus(0); + connect(m_listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotItemEdited(QTreeWidgetItem *, int))); + update(); + } +} + void ProjectList::slotResetProjectList() { m_listView->clear(); @@ -1366,7 +1409,6 @@ void ProjectList::slotCheckForEmptyQueue() void ProjectList::reloadClipThumbnails() { - kDebug() << "////////////// RELOAD CLIPS THUMBNAILS!!!"; m_thumbnailQueue.clear(); QTreeWidgetItemIterator it(m_listView); while (*it) { @@ -1889,4 +1931,25 @@ void ProjectList::slotAddOrUpdateSequence(const QString frameName) } else emit displayMessage(i18n("Sequence not found"), -2); } +QMap ProjectList::getProxies() +{ + QMap list; + ProjectItem *item; + QTreeWidgetItemIterator it(m_listView); + while (*it) { + if ((*it)->type() != PROJECTCLIPTYPE) { + // subitem + ++it; + continue; + } + item = static_cast(*it); + if (item && item->referencedClip() != NULL) { + QString proxy = item->referencedClip()->getProperty("proxy"); + if (!proxy.isEmpty()) list.insert(proxy, item->clipUrl().path()); + } + ++it; + } + return list; +} + #include "projectlist.moc"