fileseacher.cpp 827 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "fileseacher.h"
  2. FileSeacher::FileSeacher(QObject* parent)
  3. : QObject(parent)
  4. {
  5. }
  6. void FileSeacher::startSearch(QString rootPath)
  7. {
  8. this->rootPath = rootPath;
  9. searchDir(rootPath);
  10. }
  11. void FileSeacher::searchDir(QString path)
  12. {
  13. QDir dir(path);
  14. QFileInfo fileInfo;
  15. QFileInfoList fileList = dir.entryInfoList();
  16. for (int i = 0; i < fileList.count(); i++) {
  17. fileInfo = fileList.at(i);
  18. QString fileName = fileList.at(i).fileName().trimmed();
  19. if ((fileName == ".") || (fileName == "..")) {
  20. continue;
  21. }
  22. emit findFileInfo(rootPath, fileInfo);
  23. if (fileInfo.isDir()) {
  24. searchDir(fileInfo.filePath());
  25. }
  26. }
  27. }
  28. int FileSeacher::pid() const
  29. {
  30. return m_pid;
  31. }
  32. void FileSeacher::setPid(int pid)
  33. {
  34. m_pid = pid;
  35. }