| 456 | } |
| 457 | |
| 458 | ProjectFolderItem *AbstractFileManagerPlugin::import( IProject *project ) |
| 459 | { |
| 460 | Q_D(AbstractFileManagerPlugin); |
| 461 | |
| 462 | ProjectFolderItem *projectRoot = createFolderItem( project, project->path(), nullptr ); |
| 463 | emit folderAdded( projectRoot ); |
| 464 | qCDebug(FILEMANAGER) << "imported new project" << project->name() << "at" << projectRoot->path(); |
| 465 | |
| 466 | ///TODO: check if this works for remote files when something gets changed through another KDE app |
| 467 | if ( project->path().isLocalFile() ) { |
| 468 | auto watcher = new KDirWatch( project ); |
| 469 | |
| 470 | // set up the signal handling |
| 471 | // NOTE: We delay handling of the creation/deletion events here by one second to prevent |
| 472 | // useless or even outright wrong handling of events during common git workflows. |
| 473 | // I.e. sometimes we used to get a 'delete' event during a rebase which was never |
| 474 | // followed up by a 'created' signal, even though the file actually exists after |
| 475 | // the rebase. |
| 476 | // see also: https://bugs.kde.org/show_bug.cgi?id=404184 |
| 477 | connect(watcher, &KDirWatch::created, |
| 478 | this, [this] (const QString& path) { |
| 479 | QTimer::singleShot(1000, this, [this, path]() { |
| 480 | Q_D(AbstractFileManagerPlugin); |
| 481 | d->created(path); |
| 482 | }); |
| 483 | }); |
| 484 | connect(watcher, &KDirWatch::deleted, |
| 485 | this, [this] (const QString& path) { |
| 486 | QTimer::singleShot(1000, this, [this, path]() { |
| 487 | Q_D(AbstractFileManagerPlugin); |
| 488 | d->deleted(path); |
| 489 | }); |
| 490 | }); |
| 491 | watcher->addDir(project->path().toLocalFile(), KDirWatch::WatchSubDirs | KDirWatch:: WatchFiles ); |
| 492 | d->m_watchers[project] = watcher; |
| 493 | } |
| 494 | |
| 495 | d->m_filters.add(project); |
| 496 | |
| 497 | return projectRoot; |
| 498 | } |
| 499 | |
| 500 | KJob* AbstractFileManagerPlugin::createImportJob(ProjectFolderItem* item) |
| 501 | { |