Commit 0eb2bd26 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Warn before deleting used clips

parent e513a722
...@@ -794,6 +794,7 @@ void Bin::slotDeleteClip() ...@@ -794,6 +794,7 @@ void Bin::slotDeleteClip()
ProjectSubClip *sub; ProjectSubClip *sub;
QString subId; QString subId;
QPoint zone; QPoint zone;
bool usedFolder = false;
// check folders, remove child folders if there is any // check folders, remove child folders if there is any
QList <ProjectFolder*> topFolders; QList <ProjectFolder*> topFolders;
foreach (const QModelIndex &ix, indexes) { foreach (const QModelIndex &ix, indexes) {
...@@ -810,6 +811,9 @@ void Bin::slotDeleteClip() ...@@ -810,6 +811,9 @@ void Bin::slotDeleteClip()
} }
if (item->itemType() != AbstractProjectItem::FolderItem) continue; if (item->itemType() != AbstractProjectItem::FolderItem) continue;
ProjectFolder *current = static_cast<ProjectFolder*>(item); ProjectFolder *current = static_cast<ProjectFolder*>(item);
if (!usedFolder && !current->isEmpty()) {
usedFolder = true;
}
if (topFolders.isEmpty()) { if (topFolders.isEmpty()) {
topFolders << current; topFolders << current;
continue; continue;
...@@ -842,7 +846,7 @@ void Bin::slotDeleteClip() ...@@ -842,7 +846,7 @@ void Bin::slotDeleteClip()
foreach (const ProjectFolder *f, topFolders) { foreach (const ProjectFolder *f, topFolders) {
foldersIds << f->clipId(); foldersIds << f->clipId();
} }
bool usedClips = false;
QList <ProjectFolder*> topClips; QList <ProjectFolder*> topClips;
// Check if clips are in already selected folders // Check if clips are in already selected folders
foreach (const QModelIndex &ix, indexes) { foreach (const QModelIndex &ix, indexes) {
...@@ -857,7 +861,18 @@ void Bin::slotDeleteClip() ...@@ -857,7 +861,18 @@ void Bin::slotDeleteClip()
break; break;
} }
} }
if (!isChild) clipIds << current->clipId(); if (!isChild) {
if (!usedClips && current->refCount() > 0) {
usedClips = true;
}
clipIds << current->clipId();
}
}
if (usedClips && (KMessageBox::warningContinueCancel(this, i18n("This will delete all selected clips from timeline")) != KMessageBox::Continue)) {
return;
} else if (usedFolder && (KMessageBox::warningContinueCancel(this, i18n("This will delete all folder content")) != KMessageBox::Continue)) {
return;
} }
m_doc->clipManager()->deleteProjectItems(clipIds, foldersIds, subClipIds); m_doc->clipManager()->deleteProjectItems(clipIds, foldersIds, subClipIds);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment