| 28 | } |
| 29 | |
| 30 | void PruneJob::start() |
| 31 | { |
| 32 | auto* output = new OutputModel(this); |
| 33 | setModel(output); |
| 34 | startOutput(); |
| 35 | |
| 36 | Path builddir = CMake::currentBuildDir( m_project ); |
| 37 | if( builddir.isEmpty() ) |
| 38 | { |
| 39 | output->appendLine(i18n("No build directory configured, cannot clear the build directory")); |
| 40 | emitResult(); |
| 41 | return; |
| 42 | } |
| 43 | else if (!builddir.isLocalFile() || QDir(builddir.toLocalFile()).exists(QStringLiteral("CMakeLists.txt"))) |
| 44 | { |
| 45 | output->appendLine(i18n("Wrong build directory, cannot clear the build directory")); |
| 46 | emitResult(); |
| 47 | return; |
| 48 | } |
| 49 | |
| 50 | QDir d( builddir.toLocalFile() ); |
| 51 | QList<QUrl> urls; |
| 52 | const auto entries = d.entryList(QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden); |
| 53 | urls.reserve(entries.size()); |
| 54 | for (const auto& entry : entries) { |
| 55 | urls << Path(builddir, entry).toUrl(); |
| 56 | } |
| 57 | output->appendLine(i18n("%1> rm -rf %2", m_project->path().pathOrUrl(), builddir.toLocalFile())); |
| 58 | m_job = KIO::del( urls ); |
| 59 | m_job->start(); |
| 60 | connect(m_job, &KJob::finished, this, &PruneJob::jobFinished); |
| 61 | } |
| 62 | |
| 63 | bool PruneJob::doKill() |
| 64 | { |
no test coverage detected