#include "kdenlivesettings.h"
#include "slideshowclip.h"
#include "ui_colorclip_ui.h"
+#include "titlewidget.h"
#include "definitions.h"
void ProjectList::slotEditClip() {
ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
- if (item && !item->isGroup()) emit clipSelected(item->referencedClip());
- emit showClipProperties(item->referencedClip());
+ if (item && !item->isGroup()) {
+ emit clipSelected(item->referencedClip());
+ emit showClipProperties(item->referencedClip());
+ }
}
}
void ProjectList::slotClipSelected() {
- ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
- if (item && !item->isGroup()) {
- m_selectedItem = item;
- emit clipSelected(item->referencedClip());
+ if (listView->currentItem()) {
+ ProjectItem *clip = static_cast <ProjectItem*>(listView->currentItem());
+ if (!clip->isGroup()) {
+ m_selectedItem = clip;
+ emit clipSelected(clip->referencedClip());
+ }
+ m_editAction->setEnabled(true);
+ m_deleteAction->setEnabled(true);
+ } else {
+ m_editAction->setEnabled(false);
+ m_deleteAction->setEnabled(false);
}
}
void ProjectList::slotUpdateClipProperties(ProjectItem *clip, QMap <QString, QString> properties) {
if (!clip) return;
- clip->setProperties(properties);
+ if (!clip->isGroup()) clip->setProperties(properties);
if (properties.contains("description")) {
CLIPTYPE type = clip->clipType();
clip->setText(2, properties.value("description"));
QMap <QString, QString> props;
props["description"] = item->text(2);
slotUpdateClipProperties(clip, props);
- } else if (column == 1 && clip->clipType() == FOLDER) {
+ } else if (column == 1 && clip->isGroup()) {
m_doc->slotEditFolder(item->text(1), clip->groupName(), clip->clipId());
+ clip->setGroupName(item->text(1));
+ const int children = item->childCount();
+ for (int i = 0; i < children; i++) {
+ ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
+ child->setProperty("groupname", item->text(1));
+ }
}
}
}
m_editAction->setEnabled(enable);
m_deleteAction->setEnabled(enable);
-
m_menu->popup(pos);
}
void ProjectList::slotRemoveClip() {
if (!listView->currentItem()) return;
- ProjectItem *item = static_cast <ProjectItem *>(listView->currentItem());
QList <QString> ids;
QMap <QString, QString> folderids;
- if (item->clipType() == FOLDER) folderids[item->groupName()] = item->clipId();
- else ids << item->clipId();
- if (item->numReferences() > 0) {
- 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;
- } else if (item->clipType() == FOLDER && item->childCount() > 0) {
- int children = item->childCount();
- 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;
- for (int i = 0; i < children; ++i) {
- ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
- ids << child->clipId();
+ QList<QTreeWidgetItem *> selected = listView->selectedItems();
+ ProjectItem *item;
+ for (int i = 0; i < selected.count(); i++) {
+ item = static_cast <ProjectItem *>(selected.at(i));
+ if (item->isGroup()) folderids[item->groupName()] = item->clipId();
+ else ids << item->clipId();
+ if (item->numReferences() > 0) {
+ 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;
+ } else if (item->isGroup() && item->childCount() > 0) {
+ int children = item->childCount();
+ 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;
+ for (int i = 0; i < children; ++i) {
+ ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
+ ids << child->clipId();
+ }
}
}
if (!ids.isEmpty()) m_doc->deleteProjectClip(ids);
if (!folderids.isEmpty()) m_doc->deleteProjectFolder(folderids);
+ if (listView->topLevelItemCount() == 0) {
+ m_editAction->setEnabled(false);
+ m_deleteAction->setEnabled(false);
+ }
}
void ProjectList::selectItemById(const QString &clipId) {
QTreeWidgetItemIterator it(listView);
while (*it) {
item = static_cast <ProjectItem *>(*it);
- if (item->clipType() == FOLDER && item->clipId() == clipId) {
+ if (item->isGroup() && item->clipId() == clipId) {
delete item;
break;
}
}
} else {
if (edit) {
- disconnect(listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotUpdateItemDescription(QTreeWidgetItem *, int)));
+ listView->blockSignals(true);
ProjectItem *item;
QTreeWidgetItemIterator it(listView);
while (*it) {
item = static_cast <ProjectItem *>(*it);
- if (item->clipType() == FOLDER && item->clipId() == clipId) {
- item->setText(1, foldername);
+ if (item->isGroup() && item->clipId() == clipId) {
+ item->setGroupName(foldername);
+ const int children = item->childCount();
+ for (int i = 0; i < children; i++) {
+ ProjectItem *child = static_cast <ProjectItem *>(item->child(i));
+ child->setProperty("groupname", foldername);
+ }
break;
}
++it;
}
- connect(listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotUpdateItemDescription(QTreeWidgetItem *, int)));
+ listView->blockSignals(false);
} else {
QStringList text;
text << QString() << foldername;
}
void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) {
- const QString parent = clip->toXML().attribute("groupid");
+ const QString parent = clip->getProperty("groupid");
ProjectItem *item = NULL;
- if (parent != 0) {
+ if (!parent.isEmpty()) {
ProjectItem *parentitem = getItemById(parent);
+ if (!parentitem) {
+ QStringList text;
+ QString groupName = clip->getProperty("groupname");
+ if (groupName.isEmpty()) groupName = i18n("Folder");
+ text << QString() << groupName;
+ listView->blockSignals(true);
+ parentitem = new ProjectItem(listView, text, parent);
+ listView->blockSignals(false);
+ }
if (parentitem) item = new ProjectItem(parentitem, clip);
}
if (item == NULL) item = new ProjectItem(listView, clip);
while (*it) {
ProjectItem *item = static_cast <ProjectItem *>(*it);
if (!item->isGroup()) {
- if (item->referencedClip()->producer() == NULL) emit getFileProperties(item->referencedClip()->toXML(), item->referencedClip()->getId());
- else {
+ if (item->referencedClip()->producer() == NULL) {
+ DocClipBase *clip = item->referencedClip();
+ if (clip->clipType() == TEXT && !QFile::exists(clip->fileURL().path())) {
+ // regenerate text clip image if required
+ TitleWidget *dia_ui = new TitleWidget(KUrl(), QString(), m_render, this);
+ QDomDocument doc;
+ doc.setContent(clip->getProperty("xmldata"));
+ dia_ui->setXml(doc);
+ QPixmap pix = dia_ui->renderedPixmap();
+ pix.save(clip->fileURL().path());
+ delete dia_ui;
+ }
+ emit getFileProperties(clip->toXML(), clip->getId());
+ } else {
slotRefreshClipThumbnail(item, false);
item->changeDuration(item->referencedClip()->producer()->get_playtime());
}
if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
KUrl::List list;
if (givenUrl.isEmpty()) {
- list = KFileDialog::getOpenUrls(KUrl("kfiledialog:///clipfolder"), "application/vnd.kde.kdenlive application/vnd.westley.scenelist application/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", this);
+ list = KFileDialog::getOpenUrls(KUrl("kfiledialog:///clipfolder"), "application/x-kdenlive application/x-flash-video 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);
} else list.append(givenUrl);
if (list.isEmpty()) return;
QString groupId = QString();
if (group.isEmpty()) {
ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
- if (item && item->clipType() != FOLDER) {
+ if (item && !item->isGroup()) {
while (item->parent()) {
item = static_cast <ProjectItem*>(item->parent());
- if (item->clipType() == FOLDER) break;
+ if (item->isGroup()) break;
}
}
- if (item && item->clipType() == FOLDER) {
+ if (item && item->isGroup()) {
group = item->groupName();
groupId = item->clipId();
}
QString group = QString();
QString groupId = QString();
ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
- if (item && item->clipType() != FOLDER) {
+ if (item && !item->isGroup()) {
while (item->parent()) {
item = static_cast <ProjectItem*>(item->parent());
- if (item->clipType() == FOLDER) break;
+ if (item->isGroup()) break;
}
}
- if (item && item->clipType() == FOLDER) {
+ if (item && item->isGroup()) {
group = item->groupName();
groupId = item->clipId();
}
QString group = QString();
QString groupId = QString();
ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
- if (item && item->clipType() != FOLDER) {
+ if (item && !item->isGroup()) {
while (item->parent()) {
item = static_cast <ProjectItem*>(item->parent());
- if (item->clipType() == FOLDER) break;
+ if (item->isGroup()) break;
}
}
- if (item && item->clipType() == FOLDER) {
+ if (item && item->isGroup()) {
group = item->groupName();
groupId = item->clipId();
}
QString group = QString();
QString groupId = QString();
ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
- if (item && item->clipType() != FOLDER) {
+ if (item && !item->isGroup()) {
while (item->parent()) {
item = static_cast <ProjectItem*>(item->parent());
- if (item->clipType() == FOLDER) break;
+ if (item->isGroup()) break;
}
}
- if (item && item->clipType() == FOLDER) {
+ if (item && item->isGroup()) {
group = item->groupName();
groupId = item->clipId();
}
if (p) {
listView->setCurrentItem(p);
listView->scrollToItem(p);
+ m_editAction->setEnabled(true);
+ m_deleteAction->setEnabled(true);
}
}