* @brief Walks the read roots, collecting files to search within the scan cap. */
| 497 | * @brief Walks the read roots, collecting files to search within the scan cap. |
| 498 | */ |
| 499 | static QStringList gatherSearchFiles(const QStringList& roots, int cap) |
| 500 | { |
| 501 | QStringList files; |
| 502 | for (const auto& root : roots) { |
| 503 | const QFileInfo rootInfo(root); |
| 504 | if (rootInfo.isFile()) { |
| 505 | files.append(root); |
| 506 | continue; |
| 507 | } |
| 508 | |
| 509 | QDirIterator it(root, |
| 510 | QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden | QDir::NoSymLinks, |
| 511 | QDirIterator::Subdirectories); |
| 512 | while (it.hasNext() && files.size() < cap) |
| 513 | files.append(it.next()); |
| 514 | |
| 515 | if (files.size() >= cap) |
| 516 | break; |
| 517 | } |
| 518 | |
| 519 | return files; |
| 520 | } |
| 521 | |
| 522 | /** |
| 523 | * @brief Grep-like content search across the read roots; literal or regex. |