| 85 | } |
| 86 | |
| 87 | void FileManagerListJob::startNextJob() |
| 88 | { |
| 89 | if (m_listQueue.empty() || isCanceled()) { |
| 90 | return; |
| 91 | } |
| 92 | |
| 93 | #ifdef TIME_IMPORT_JOB |
| 94 | m_subTimer.start(); |
| 95 | #endif |
| 96 | |
| 97 | m_item = m_listQueue.dequeue(); |
| 98 | if (m_item->path().isLocalFile()) { |
| 99 | // optimized version for local projects using QDir directly |
| 100 | m_localFolderFuture = QtConcurrent::run([this] (const Path& path) { |
| 101 | if (isCanceled()) { |
| 102 | return; |
| 103 | } |
| 104 | QDir dir(path.toLocalFile()); |
| 105 | const auto entries = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden); |
| 106 | if (isCanceled()) { |
| 107 | return; |
| 108 | } |
| 109 | KIO::UDSEntryList results; |
| 110 | std::transform(entries.begin(), entries.end(), std::back_inserter(results), [] (const QFileInfo& info) -> KIO::UDSEntry { |
| 111 | KIO::UDSEntry entry; |
| 112 | entry.fastInsert(KIO::UDSEntry::UDS_NAME, info.fileName()); |
| 113 | if (info.isDir()) { |
| 114 | entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, QT_STAT_DIR); |
| 115 | } |
| 116 | if (info.isSymLink()) { |
| 117 | entry.fastInsert(KIO::UDSEntry::UDS_LINK_DEST, info.symLinkTarget()); |
| 118 | } |
| 119 | return entry; |
| 120 | }); |
| 121 | QMetaObject::invokeMethod(this, "handleResults", Q_ARG(KIO::UDSEntryList, results)); |
| 122 | }, m_item->path()); |
| 123 | } else { |
| 124 | KIO::ListJob* job = KIO::listDir( m_item->path().toUrl(), KIO::HideProgressInfo ); |
| 125 | job->addMetaData(QStringLiteral("details"), QStringLiteral("0")); |
| 126 | connect(job, &KIO::ListJob::entries, this, &FileManagerListJob::remoteFolderSubjobEntriesFound); |
| 127 | connect(job, &KJob::finished, this, &FileManagerListJob::remoteFolderSubjobFinished); |
| 128 | |
| 129 | m_remoteFolderSubjob = job; |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | void FileManagerListJob::remoteFolderSubjobFinished(KJob* job) |
| 134 | { |