QStringList getListFilesFind(const QString &pathr, QStringList filters){ QStack<QString> dirs; QString path; QStringList listFiles; if(pathr.isEmpty()) path = QDir::currentPath(); else path = pathr; dirs.push(path); while (!dirs.isEmpty()) { path = dirs.pop(); QDir dir(path); if(!dir.exists()) continue; foreach (QString file, dir.entryList(filters)) listFiles << QFileInfo(dir, file).absoluteFilePath(); foreach (QString subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)){ dirs.push(path + QDir::separator() + subDir); } } return listFiles;}
C++ (Qt) m_countFiles+= dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot).count(); foreach (QString file, dir.entryList(filters)) { m_currentNumberFile ++; emit progress(m_currentNumberFile *100 / m_countFiles); listFiles << QFileInfo(dir, file).absoluteFilePath(); }
C++ (Qt)m_countFiles += dir.entryList(filters).count();
QStringList getListFilesFind(const QString &pathr, QStringList filters){ QStack<QString> dirs; QString path; QStringList listFiles; qint32 countFiles = 1; qint32 currentNumberFile = 0; qint32 progress = 0; qint32 progressOld = 0; if(pathr.isEmpty()) path = QDir::currentPath(); else path = pathr; dirs.push(path); while (!dirs.isEmpty()) { path = dirs.pop(); QDir dir(path); countFiles += dir.entryList(QDir::NoDotAndDotDot).count(); ++currentNumberFile; if(!dir.exists()) continue; foreach (QString file, dir.entryList(filters)) { ++currentNumberFile; listFiles << QFileInfo(dir, file).absoluteFilePath(); progress = currentNumberFile * 100 / countFiles; if (progressOld != progress) { progressOld = progress; emit progress(progress); } } foreach (QString subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)){ dirs.push(path + QDir::separator() + subDir); } } return listFiles;}
countFiles += dir.entryList(QDir::NoDotAndDotDot).count();
countFiles += dir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot).count();
QStringList getListFilesFind(const QString &pathr, QStringList filters){ QStack<QString> dirs; QString path; QStringList listFiles; qint32 countFiles = 1; qint32 currentNumberFile = 0; qint32 progress = 0; qint32 progressOld = 0; if(pathr.isEmpty()) path = QDir::currentPath(); else path = pathr; dirs.push(path); while (!dirs.isEmpty()) { path = dirs.pop(); QDir dir(path); countFiles += dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot).count(); ++currentNumberFile; progress = currentNumberFile * 100 / countFiles; if (progressOld != progress) { progressOld = progress; emit progress(progress); } if(!dir.exists()) continue; foreach (QString file, dir.entryList(filters)) { listFiles << QFileInfo(dir, file).absoluteFilePath(); } foreach (QString subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)){ dirs.push(path + QDir::separator() + subDir); } } return listFiles;}