From 1b526f545f359b9650e8ab3d692471c007906c2c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Mon, 13 Oct 2008 08:27:35 +0000 Subject: [PATCH] Fix "delete" key not working in project tree, allow deletion of several clips at once svn path=/branches/KDE4/; revision=2456 --- src/mainwindow.cpp | 3 ++- src/projectlist.cpp | 26 +++++++++++++++----------- src/projectlist.h | 2 +- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 93b4de4d..90a4d7cb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1321,7 +1321,8 @@ void MainWindow::slotSwitchSnap() { void MainWindow::slotDeleteTimelineClip() { - if (m_activeTimeline) { + if (projectListDock->isActiveWindow()) m_projectList->slotRemoveClip(); + else if (m_activeTimeline) { m_activeTimeline->projectView()->deleteSelectedClips(); } } diff --git a/src/projectlist.cpp b/src/projectlist.cpp index af83769a..4b2c345b 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -203,19 +203,23 @@ void ProjectList::slotContextMenu(const QPoint &pos, QTreeWidgetItem *item) { void ProjectList::slotRemoveClip() { if (!listView->currentItem()) return; - ProjectItem *item = static_cast (listView->currentItem()); QList ids; QMap 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 %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 if (item->clipType() == FOLDER && item->childCount() > 0) { - int children = item->childCount(); - if (KMessageBox::questionYesNo(this, i18n("Delete folder %2 ?
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 (item->child(i)); - ids << child->clipId(); + QList selected = listView->selectedItems(); + ProjectItem *item; + for (int i = 0; i < selected.count(); i++) { + item = static_cast (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 %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 if (item->clipType() == FOLDER && item->childCount() > 0) { + int children = item->childCount(); + if (KMessageBox::questionYesNo(this, i18n("Delete folder %2 ?
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 (item->child(i)); + ids << child->clipId(); + } } } if (!ids.isEmpty()) m_doc->deleteProjectClip(ids); diff --git a/src/projectlist.h b/src/projectlist.h index 7a63cd9c..20b812ec 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -121,6 +121,7 @@ public slots: void slotRefreshClipThumbnail(ProjectItem *item, bool update = true); void slotRemoveInvalidClip(const QString &id); void slotSelectClip(const QString &ix); + void slotRemoveClip(); private: ProjectListView *listView; @@ -142,7 +143,6 @@ private: private slots: void slotAddClip(QUrl givenUrl = QUrl(), QString group = QString()); - void slotRemoveClip(); void slotEditClip(); void slotClipSelected(); void slotAddColorClip(); -- 2.39.2