X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fprojectlist.cpp;h=10be0cd1b18876cfe88390ac11e063eca09f99be;hb=8bcc799b522e6e5ae0299973b4d296bef831a17f;hp=2bd11bd1cc1f893cf800f87c687aaa48f77f962c;hpb=3c7759acbcc7b2e48d1c6e03d7279f9e6101e7bc;p=kdenlive diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 2bd11bd1..10be0cd1 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -19,7 +19,6 @@ #include "projectlist.h" #include "projectitem.h" -#include "subprojectitem.h" #include "addfoldercommand.h" #include "kdenlivesettings.h" #include "slideshowclip.h" @@ -33,6 +32,7 @@ #include "kthumb.h" #include "projectlistview.h" #include "editclipcommand.h" +#include "editclipcutcommand.h" #include "editfoldercommand.h" #include "addclipcutcommand.h" @@ -46,10 +46,11 @@ #include #include #include - +#ifdef NEPOMUK #include #include //#include +#endif #include #include @@ -113,7 +114,7 @@ ProjectList::ProjectList(QWidget *parent) : m_listViewDelegate = new ItemDelegate(m_listView); m_listView->setItemDelegate(m_listViewDelegate); - +#ifdef NEPOMUK if (KdenliveSettings::activate_nepomuk()) { Nepomuk::ResourceManager::instance()->init(); if (!Nepomuk::ResourceManager::instance()->initialized()) { @@ -121,6 +122,7 @@ ProjectList::ProjectList(QWidget *parent) : KdenliveSettings::setActivate_nepomuk(false); } } +#endif } ProjectList::~ProjectList() @@ -308,7 +310,7 @@ void ProjectList::slotReloadClip(const QString &id) } //requestClipInfo(item->toXml(), item->clipId(), true); // Clear the file_hash value, which will cause a complete reload of the clip - emit getFileProperties(item->toXml(), item->clipId(), true); + emit getFileProperties(item->toXml(), item->clipId(), m_listView->iconSize().height(), true); } } } @@ -316,44 +318,43 @@ void ProjectList::slotReloadClip(const QString &id) void ProjectList::setRenderer(Render *projectRender) { m_render = projectRender; - m_listView->setIconSize(QSize(43 * m_render->dar(), 43)); + m_listView->setIconSize(QSize((ProjectItem::itemDefaultHeight() - 2) * m_render->dar(), ProjectItem::itemDefaultHeight() - 2)); } void ProjectList::slotClipSelected() { if (m_listView->currentItem()) { - if (m_listView->currentItem()->type() == PROJECTFOLDERTYPE) { - emit clipSelected(NULL); - m_editAction->setEnabled(false); - m_deleteAction->setEnabled(true); - m_openAction->setEnabled(false); - m_reloadAction->setEnabled(false); - m_transcodeAction->setEnabled(false); - } - else { - ProjectItem *clip; - if (m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE) { - // this is a sub item, use base clip - clip = static_cast (m_listView->currentItem()->parent()); - if (clip == NULL) kDebug() << "-----------ERROR"; - SubProjectItem *sub = static_cast (m_listView->currentItem()); - emit clipSelected(clip->referencedClip(), sub->zone()); - return; - } - clip = static_cast (m_listView->currentItem()); - emit clipSelected(clip->referencedClip()); - m_editAction->setEnabled(true); - m_deleteAction->setEnabled(true); - m_reloadAction->setEnabled(true); - m_transcodeAction->setEnabled(true); - if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) { - m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp())); - m_openAction->setEnabled(true); - } else if (clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) { - m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp())); - m_openAction->setEnabled(true); - } else m_openAction->setEnabled(false); - } + if (m_listView->currentItem()->type() == PROJECTFOLDERTYPE) { + emit clipSelected(NULL); + m_editAction->setEnabled(false); + m_deleteAction->setEnabled(true); + m_openAction->setEnabled(false); + m_reloadAction->setEnabled(false); + m_transcodeAction->setEnabled(false); + } else { + ProjectItem *clip; + if (m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE) { + // this is a sub item, use base clip + clip = static_cast (m_listView->currentItem()->parent()); + if (clip == NULL) kDebug() << "-----------ERROR"; + SubProjectItem *sub = static_cast (m_listView->currentItem()); + emit clipSelected(clip->referencedClip(), sub->zone()); + return; + } + clip = static_cast (m_listView->currentItem()); + emit clipSelected(clip->referencedClip()); + m_editAction->setEnabled(true); + m_deleteAction->setEnabled(true); + m_reloadAction->setEnabled(true); + m_transcodeAction->setEnabled(true); + if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) { + m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp())); + m_openAction->setEnabled(true); + } else if (clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) { + m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp())); + m_openAction->setEnabled(true); + } else m_openAction->setEnabled(false); + } } else { emit clipSelected(NULL); m_editAction->setEnabled(false); @@ -398,11 +399,13 @@ void ProjectList::slotUpdateClipProperties(ProjectItem *clip, QMap blockSignals(true); clip->setText(1, properties.value("description")); m_listView->blockSignals(false); +#ifdef NEPOMUK if (KdenliveSettings::activate_nepomuk() && (type == AUDIO || type == VIDEO || type == AV || type == IMAGE || type == PLAYLIST)) { // Use Nepomuk system to store clip description Nepomuk::Resource f(clip->clipUrl().path()); f.setDescription(properties.value("description")); } +#endif emit projectModified(); } } @@ -411,6 +414,14 @@ void ProjectList::slotItemEdited(QTreeWidgetItem *item, int column) { if (item->type() == PROJECTSUBCLIPTYPE) { // this is a sub-item + if (column == 1) { + // user edited description + SubProjectItem *sub = static_cast (item); + ProjectItem *item = static_cast (sub->parent()); + EditClipCutCommand *command = new EditClipCutCommand(this, item->clipId(), sub->zone(), sub->zone(), sub->description(), sub->text(1), true); + m_commandStack->push(command); + //slotUpdateCutClipProperties(sub->clipId(), sub->zone(), sub->text(1), sub->text(1)); + } return; } if (item->type() == PROJECTFOLDERTYPE) { @@ -501,11 +512,8 @@ void ProjectList::slotRemoveClip() // subitem SubProjectItem *sub = static_cast (selected.at(i)); ProjectItem *item = static_cast (sub->parent()); - new AddClipCutCommand(this, item->clipId(), sub->zone().x(), sub->zone().y(), true, delCommand); - continue; - } - - if (selected.at(i)->type() == PROJECTFOLDERTYPE) { + new AddClipCutCommand(this, item->clipId(), sub->zone().x(), sub->zone().y(), sub->description(), true, delCommand); + } else if (selected.at(i)->type() == PROJECTFOLDERTYPE) { // folder FolderProjectItem *folder = static_cast (selected.at(i)); folderids[folder->groupName()] = folder->clipId(); @@ -516,15 +524,15 @@ void ProjectList::slotRemoveClip() ProjectItem *child = static_cast (folder->child(i)); ids << child->clipId(); } - continue; - } - - ProjectItem *item = static_cast (selected.at(i)); - ids << item->clipId(); - if (item->numReferences() > 0) { - if (KMessageBox::questionYesNo(this, i18np("Delete clip %2?
This will also remove the clip in timeline", "Delete clip %2?
This will also remove its %1 clips in timeline", item->numReferences(), item->names().at(1)), i18n("Delete Clip")) != KMessageBox::Yes) return; + } else { + ProjectItem *item = static_cast (selected.at(i)); + ids << item->clipId(); + if (item->numReferences() > 0) { + if (KMessageBox::questionYesNo(this, i18np("Delete clip %2?
This will also remove the clip in timeline", "Delete clip %2?
This will also remove its %1 clips in timeline", item->numReferences(), item->names().at(1)), i18n("Delete Clip")) != KMessageBox::Yes) return; + } } } + if (delCommand->childCount() == 0) delete delCommand; else m_commandStack->push(delCommand); if (!ids.isEmpty()) m_doc->deleteProjectClip(ids); @@ -655,10 +663,10 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) if (getProperties == false && !clip->getClipHash().isEmpty()) { QString cachedPixmap = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "thumbs/" + clip->getClipHash() + ".png"; if (QFile::exists(cachedPixmap)) { - item->setIcon(0, QPixmap(cachedPixmap)); + item->setData(0, Qt::DecorationRole, QPixmap(cachedPixmap)); } } - +#ifdef NEPOMUK if (!url.isEmpty() && KdenliveSettings::activate_nepomuk()) { // if file has Nepomuk comment, use it Nepomuk::Resource f(url.path()); @@ -666,16 +674,16 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) if (!annotation.isEmpty()) item->setText(1, annotation); item->setText(2, QString::number(f.rating())); } - +#endif // Add cut zones - QList cuts = clip->cutZones(); + QList cuts = clip->cutZones(); if (!cuts.isEmpty()) { for (int i = 0; i < cuts.count(); i++) { - SubProjectItem *sub = new SubProjectItem(item, cuts.at(i).x(), cuts.at(i).y()); + SubProjectItem *sub = new SubProjectItem(item, cuts.at(i).zone.x(), cuts.at(i).zone.y(), cuts.at(i).description); if (!clip->getClipHash().isEmpty()) { - QString cachedPixmap = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "thumbs/" + clip->getClipHash() + '#' + QString::number(cuts.at(i).x()) + ".png"; + QString cachedPixmap = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "thumbs/" + clip->getClipHash() + '#' + QString::number(cuts.at(i).zone.x()) + ".png"; if (QFile::exists(cachedPixmap)) { - sub->setIcon(0, QPixmap(cachedPixmap)); + sub->setData(0, Qt::DecorationRole, QPixmap(cachedPixmap)); } } } @@ -713,7 +721,7 @@ void ProjectList::slotProcessNextClipInQueue() const QDomElement dom = j.value(); const QString id = j.key(); m_infoQueue.remove(j.key()); - emit getFileProperties(dom, id, false); + emit getFileProperties(dom, id, m_listView->iconSize().height(), false); } } @@ -737,7 +745,7 @@ void ProjectList::updateAllClips() if ((*it)->type() == PROJECTSUBCLIPTYPE) { // subitem SubProjectItem *sub = static_cast (*it); - if (sub->icon(0).isNull()) { + if (sub->data(0, Qt::DecorationRole).isNull()) { item = static_cast ((*it)->parent()); requestClipThumbnail(item->clipId() + '#' + QString::number(sub->zone().x())); } @@ -755,7 +763,7 @@ void ProjectList::updateAllClips() requestClipInfo(clip->toXML(), clip->getId()); } else item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); } else { - if (item->icon(0).isNull()) { + if (item->data(0, Qt::DecorationRole).isNull()) { requestClipThumbnail(clip->getId()); } if (item->data(0, DurationRole).toString().isEmpty()) { @@ -799,6 +807,16 @@ void ProjectList::slotAddClip(const QList givenList, const QString &group for (int i = 0; i < givenList.count(); i++) list << givenList.at(i); } + + foreach(const KUrl &file, list) { + // Check there is no folder here + KMimeType::Ptr type = KMimeType::findByUrl(file); + if (type->is("inode/directory")) { + // user dropped a folder + list.removeAll(file); + } + } + if (list.isEmpty()) return; if (givenList.isEmpty()) { @@ -1051,7 +1069,7 @@ void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update) return; } QPixmap pix; - int height = it->sizeHint(0).height(); + int height = m_listView->iconSize().height(); int width = (int)(height * m_render->dar()); if (clip->clipType() == AUDIO) pix = KIcon("audio-x-generic").pixmap(QSize(width, height)); else if (clip->clipType() == IMAGE) pix = QPixmap::fromImage(KThumb::getFrame(item->referencedClip()->producer(), 0, width, height)); @@ -1059,7 +1077,7 @@ void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update) if (!pix.isNull()) { m_listView->blockSignals(true); - it->setIcon(0, pix); + it->setData(0, Qt::DecorationRole, pix); if (m_listView->isEnabled()) m_listView->blockSignals(false); if (!isSubItem) m_doc->cachePixmap(item->getClipHash(), pix); else m_doc->cachePixmap(item->getClipHash() + '#' + QString::number(frame), pix); @@ -1089,9 +1107,9 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce delete producer; }*/ if (m_listView->isEnabled()) m_listView->blockSignals(false); - if (item->icon(0).isNull()) { + /*if (item->icon(0).isNull()) { requestClipThumbnail(clipId); - } + }*/ } else kDebug() << "//////// COULD NOT FIND CLIP TO UPDATE PRPS..."; int max = m_doc->clipManager()->clipsCount(); emit displayMessage(i18n("Loading clips"), (int)(100 *(max - m_infoQueue.count()) / max)); @@ -1108,7 +1126,7 @@ void ProjectList::slotReplyGetImage(const QString &clipId, const QPixmap &pix) ProjectItem *item = getItemById(clipId); if (item && !pix.isNull()) { m_listView->blockSignals(true); - item->setIcon(0, pix); + item->setData(0, Qt::DecorationRole, pix); m_doc->cachePixmap(item->getClipHash(), pix); if (m_listView->isEnabled()) m_listView->blockSignals(false); } @@ -1173,7 +1191,7 @@ FolderProjectItem *ProjectList::getFolderItemById(const QString &id) while (*it) { if ((*it)->type() == PROJECTFOLDERTYPE) { item = static_cast(*it); - return item; + if (item->clipId() == id) return item; } ++it; } @@ -1253,24 +1271,24 @@ void ProjectList::slotAddClipCut(const QString &id, int in, int out) ProjectItem *clip = getItemById(id); if (clip == NULL) return; if (clip->referencedClip()->hasCutZone(QPoint(in, out))) return; - AddClipCutCommand *command = new AddClipCutCommand(this, id, in, out, false); + AddClipCutCommand *command = new AddClipCutCommand(this, id, in, out, QString(), false); m_commandStack->push(command); } -void ProjectList::addClipCut(const QString &id, int in, int out) +void ProjectList::addClipCut(const QString &id, int in, int out, const QString desc) { ProjectItem *clip = getItemById(id); if (clip) { DocClipBase *base = clip->referencedClip(); base->addCutZone(in, out); m_listView->blockSignals(true); - SubProjectItem *sub = new SubProjectItem(clip, in, out); - + SubProjectItem *sub = new SubProjectItem(clip, in, out, desc); QPixmap p = clip->referencedClip()->thumbProducer()->extractImage(in, (int)(sub->sizeHint(0).height() * m_render->dar()), sub->sizeHint(0).height() - 2); - sub->setIcon(0, p); + sub->setData(0, Qt::DecorationRole, p); m_doc->cachePixmap(clip->getClipHash() + '#' + QString::number(in), p); m_listView->blockSignals(false); } + emit projectModified(); } void ProjectList::removeClipCut(const QString &id, int in, int out) @@ -1279,18 +1297,53 @@ void ProjectList::removeClipCut(const QString &id, int in, int out) if (clip) { DocClipBase *base = clip->referencedClip(); base->removeCutZone(in, out); + SubProjectItem *sub = getSubItem(clip, QPoint(in, out)); + if (sub) { + m_listView->blockSignals(true); + delete sub; + m_listView->blockSignals(false); + } + } + emit projectModified(); +} + +SubProjectItem *ProjectList::getSubItem(ProjectItem *clip, QPoint zone) +{ + SubProjectItem *sub = NULL; + if (clip) { for (int i = 0; i < clip->childCount(); i++) { QTreeWidgetItem *it = clip->child(i); - if (it->type() != PROJECTSUBCLIPTYPE) continue; - SubProjectItem *sub = static_cast (it); - if (sub->zone() == QPoint(in, out)) { - m_listView->blockSignals(true); - delete it; - m_listView->blockSignals(false); - break; + if (it->type() == PROJECTSUBCLIPTYPE) { + sub = static_cast (it); + if (sub->zone() == zone) break; + else sub = NULL; } } } + return sub; +} + +void ProjectList::slotUpdateClipCut(QPoint p) +{ + if (!m_listView->currentItem() || m_listView->currentItem()->type() != PROJECTSUBCLIPTYPE) return; + SubProjectItem *sub = static_cast (m_listView->currentItem()); + ProjectItem *item = static_cast (sub->parent()); + EditClipCutCommand *command = new EditClipCutCommand(this, item->clipId(), sub->zone(), p, sub->text(1), sub->text(1), true); + m_commandStack->push(command); +} + +void ProjectList::doUpdateClipCut(const QString &id, const QPoint oldzone, const QPoint zone, const QString &comment) +{ + ProjectItem *clip = getItemById(id); + SubProjectItem *sub = getSubItem(clip, oldzone); + if (sub == NULL || clip == NULL) return; + DocClipBase *base = clip->referencedClip(); + base->updateCutZone(oldzone.x(), oldzone.y(), zone.x(), zone.y(), comment); + m_listView->blockSignals(true); + sub->setZone(zone); + sub->setDescription(comment); + m_listView->blockSignals(false); + emit projectModified(); } #include "projectlist.moc"