| 562 | } |
| 563 | |
| 564 | void ProjectManagerViewPlugin::removeItems(const QList< ProjectBaseItem* >& items) |
| 565 | { |
| 566 | if (items.isEmpty()) { |
| 567 | return; |
| 568 | } |
| 569 | |
| 570 | //copy the list of selected items and sort it to guarantee parents will come before children |
| 571 | QList<KDevelop::ProjectBaseItem*> sortedItems = items; |
| 572 | std::sort(sortedItems.begin(), sortedItems.end(), ProjectBaseItem::pathLessThan); |
| 573 | |
| 574 | Path lastFolder; |
| 575 | QHash< IProjectFileManager*, QList<KDevelop::ProjectBaseItem*> > filteredItems; |
| 576 | QStringList itemPaths; |
| 577 | for (KDevelop::ProjectBaseItem* item : std::as_const(sortedItems)) { |
| 578 | if (item->isProjectRoot()) { |
| 579 | continue; |
| 580 | } else if (item->folder() || item->file()) { |
| 581 | //make sure no children of folders that will be deleted are listed |
| 582 | if (lastFolder.isParentOf(item->path())) { |
| 583 | continue; |
| 584 | } else if (item->folder()) { |
| 585 | lastFolder = item->path(); |
| 586 | } |
| 587 | |
| 588 | IProjectFileManager* manager = item->project()->projectFileManager(); |
| 589 | if (manager) { |
| 590 | filteredItems[manager] << item; |
| 591 | itemPaths << item->path().pathOrUrl(); |
| 592 | } |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | if (filteredItems.isEmpty()) { |
| 597 | return; |
| 598 | } |
| 599 | |
| 600 | if (KMessageBox::warningTwoActionsList(QApplication::activeWindow(), |
| 601 | i18np("Do you really want to delete this item?", |
| 602 | "Do you really want to delete these %1 items?", itemPaths.size()), |
| 603 | itemPaths, i18nc("@title:window", "Delete Files"), KStandardGuiItem::del(), |
| 604 | KStandardGuiItem::cancel()) |
| 605 | == KMessageBox::SecondaryAction) { |
| 606 | return; |
| 607 | } |
| 608 | |
| 609 | //Go though projectmanagers, have them remove the files and folders that they own |
| 610 | QHash< IProjectFileManager*, QList<KDevelop::ProjectBaseItem*> >::iterator it; |
| 611 | for (it = filteredItems.begin(); it != filteredItems.end(); ++it) |
| 612 | { |
| 613 | Q_ASSERT(it.key()); |
| 614 | it.key()->removeFilesAndFolders(it.value()); |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | void ProjectManagerViewPlugin::removeTargetFilesFromContextMenu() |
| 619 | { |
nothing calls this directly
no test coverage detected