void QuaZipImageSource::extractAll() { _archive->open(QuaZip::mdUnzip); _archive->goToFirstFile(); // Keep track of the images that have not been extracted yet. auto images = QList<ImageSourceItem>(_images); auto index = 0; while (!images.isEmpty() && !_extractWatcher.isCanceled()) { // If the currently displayed image has changed and has not yet been // extracted, change the index to that image. if (_currentFileNameChanged) { auto i = std::find_if(images.begin(), images.end(), [&](ImageSourceItem a) { return a.second->relativeFilePath() == _currentFileName; }); if (i != images.end()) { index = i - images.begin(); } } // Loop through the list of images. if (index >= images.size()) { index = 0; } // Extract the image. auto file = images.at(index).second; if (!file->exists()) { _archive->setCurrentFile(file->relativeFilePath()); this->extractImage(_archive.get(), file->absoluteFilePath()); emit imageReady(file->relativeFilePath()); } // Since the image is removed, the index remains the same. images.removeAt(index); } _archive->close(); }
void LocalDiskRepo::findAllFiles(QString path, QStringList *found_files) const { QCoreApplication::processEvents(); QDir dir(path); dir.setFilter(QDir::Files | QDir::NoDotAndDotDot); dir.setSorting(QDir::Name); QStringList fileNames = dir.entryList(); QString fileName; foreach(fileName, fileNames) { // .part is the extention for a file we are still writing // we dont wanna know about these files if (!fileName.endsWith(".part")) { found_files->append(relativeFilePath(path+'/'+fileName)); } } // then recurse down into every directory dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); QStringList dirs = dir.entryList(); for (int i = 0; i < dirs.size(); ++i) { findAllFiles(path+"/"+dirs[i], found_files); } }