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

Method rename

kdevplatform/project/abstractfilemanagerplugin.cpp:350–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348}
349
350bool AbstractFileManagerPluginPrivate::rename(ProjectBaseItem* item, const Path& newPath)
351{
352 if ( !q->isValid(newPath, true, item->project()) ) {
353 int cancel = KMessageBox::warningContinueCancel( qApp->activeWindow(),
354 i18n("You tried to rename '%1' to '%2', but the latter is filtered and will be hidden.\n"
355 "Do you want to continue?", item->text(), newPath.lastPathSegment()),
356 QString(), KStandardGuiItem::cont(), KStandardGuiItem::cancel(), QStringLiteral("GenericManagerRenameToFiltered")
357 );
358 if ( cancel == KMessageBox::Cancel ) {
359 return false;
360 }
361 }
362 const auto parentItems = item->project()->foldersForPath(IndexedString(newPath.parent().pathOrUrl()));
363 for (ProjectFolderItem* parent : parentItems) {
364 if ( parent->folder() ) {
365 stopWatcher(parent);
366 const Path source = item->path();
367 bool success = renameUrl( item->project(), source.toUrl(), newPath.toUrl() );
368 if ( success ) {
369 item->setPath( newPath );
370 item->parent()->takeRow( item->row() );
371 parent->appendRow( item );
372 if (item->file()) {
373 emit q->fileRenamed(source, item->file());
374 } else {
375 Q_ASSERT(item->folder());
376 emit q->folderRenamed(source, item->folder());
377 }
378 }
379 continueWatcher(parent);
380 return success;
381 }
382 }
383 return false;
384}
385
386void AbstractFileManagerPluginPrivate::stopWatcher(ProjectFolderItem* folder)
387{

Callers 2

renameFolderMethod · 0.45
renameFileMethod · 0.45

Calls 15

lastPathSegmentMethod · 0.80
foldersForPathMethod · 0.80
pathOrUrlMethod · 0.80
folderMethod · 0.80
takeRowMethod · 0.80
appendRowMethod · 0.80
IndexedStringClass · 0.70
QStringClass · 0.50
isValidMethod · 0.45
projectMethod · 0.45
textMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected