| 348 | } |
| 349 | |
| 350 | bool 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 | |
| 386 | void AbstractFileManagerPluginPrivate::stopWatcher(ProjectFolderItem* folder) |
| 387 | { |
no test coverage detected