MCPcopy Create free account
hub / github.com/KDE/kdevelop / removeItems

Method removeItems

plugins/projectmanagerview/projectmanagerviewplugin.cpp:564–616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

562}
563
564void 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
618void ProjectManagerViewPlugin::removeTargetFilesFromContextMenu()
619{

Callers

nothing calls this directly

Calls 15

sortFunction · 0.85
isProjectRootMethod · 0.80
folderMethod · 0.80
isParentOfMethod · 0.80
projectFileManagerMethod · 0.80
pathOrUrlMethod · 0.80
isEmptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
fileMethod · 0.45
pathMethod · 0.45
projectMethod · 0.45

Tested by

no test coverage detected