diff --git a/sdk/core/qtutils.cpp b/sdk/core/qtutils.cpp index 8714e25..fa43afd 100644 --- a/sdk/core/qtutils.cpp +++ b/sdk/core/qtutils.cpp @@ -39,7 +39,7 @@ QStringList QtUtils::getFiles(QDir dir, bool recursive) QStringList files; foreach (const QString &file, NaturalStringSort(dir.entryList(QDir::Files))) - files.append(QDir::cleanPath(dir.absoluteFilePath(file))); + files.append(dir.absoluteFilePath(file)); if (!recursive) return files; diff --git a/sdk/openbr_plugin.cpp b/sdk/openbr_plugin.cpp index 7f84972..2fed86c 100644 --- a/sdk/openbr_plugin.cpp +++ b/sdk/openbr_plugin.cpp @@ -383,6 +383,15 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) QScopedPointer i(Gallery::make(file)); TemplateList newTemplates = i->read(); newTemplates = newTemplates.mid(gallery.get("pos", 0), gallery.get("length", -1)); + + const int step = gallery.get("step", 1); + if (step > 1) { + TemplateList downsampled; downsampled.reserve(newTemplates.size()/step); + for (int i=0; i("reduce", false)) newTemplates = newTemplates.reduced(); const int crossValidate = gallery.get("crossValidate"); if (crossValidate > 0) srand(0); diff --git a/sdk/plugins/gallery.cpp b/sdk/plugins/gallery.cpp index 03f2c42..50f1be6 100644 --- a/sdk/plugins/gallery.cpp +++ b/sdk/plugins/gallery.cpp @@ -14,6 +14,7 @@ * limitations under the License. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include #ifndef BR_EMBEDDED #include #include @@ -103,9 +104,14 @@ class EmptyGallery : public Gallery // Add immediate subfolders QDir dir(file); - foreach (const QString &folder, NaturalStringSort(dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))) - foreach (const QString &file, QtUtils::getFiles(dir.absoluteFilePath(folder), true)) - templates.append(File(file, folder)); + QList< QFuture > futures; + foreach (const QString &folder, NaturalStringSort(dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))) { + const QDir subdir = dir.absoluteFilePath(folder); + if (Globals->parallelism) futures.append(QtConcurrent::run(&EmptyGallery::getTemplates, subdir)); + else templates.append(getTemplates(subdir)); + } + foreach (const QFuture &future, futures) + templates.append(future.result()); // Add root folder foreach (const QString &fileName, QtUtils::getFiles(file.name, false)) @@ -130,6 +136,15 @@ class EmptyGallery : public Gallery format->write(t); } } + + static TemplateList getTemplates(const QDir &dir) + { + const QStringList files = QtUtils::getFiles(dir, true); + TemplateList templates; templates.reserve(files.size()); + foreach (const QString &file, files) + templates.append(File(file, dir.dirName())); + return templates; + } }; BR_REGISTER(Gallery, EmptyGallery)