diff --git a/openbr/core/utility.cpp b/openbr/core/utility.cpp new file mode 100644 index 0000000..e6f2508 --- /dev/null +++ b/openbr/core/utility.cpp @@ -0,0 +1,34 @@ +#include +#include "utility.h" + +QStringList br::getFiles(QDir dir, bool recursive) +{ + dir = QDir(dir.canonicalPath()); + + QStringList files; + foreach (const QString &file, QtUtils::naturalSort(dir.entryList(QDir::Files))) + files.append(dir.absoluteFilePath(file)); + + if (!recursive) return files; + + foreach (const QString &folder, QtUtils::naturalSort(dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))) { + QDir subdir(dir); + bool success = subdir.cd(folder); if (!success) qFatal("cd failure."); + files.append(getFiles(subdir, true)); + } + return files; +} + +QStringList br::getFiles(const QString ®exp) +{ + QFileInfo fileInfo(regexp); + QDir dir(fileInfo.dir()); + QRegExp re(fileInfo.fileName()); + re.setPatternSyntax(QRegExp::Wildcard); + + QStringList files; + foreach (const QString &fileName, dir.entryList(QDir::Files)) + if (re.exactMatch(fileName)) + files.append(dir.filePath(fileName)); + return files; +} diff --git a/openbr/core/utility.h b/openbr/core/utility.h new file mode 100644 index 0000000..b6b1d1e --- /dev/null +++ b/openbr/core/utility.h @@ -0,0 +1,18 @@ +#ifndef BR_CORE_UTILITY_H +#define BR_CORE_UTILITY_H + +#include +#include + +#include +#include + +namespace br +{ + +BR_EXPORT QStringList getFiles(QDir dir, bool recursive); +BR_EXPORT QStringList getFiles(const QString ®exp); + +} // namespace br + +#endif // BR_CORE_UTILITY_H diff --git a/openbr/gui/utility.cpp b/openbr/gui/utility.cpp index 4a509ea..013ece0 100644 --- a/openbr/gui/utility.cpp +++ b/openbr/gui/utility.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include "utility.h" using namespace cv; @@ -46,35 +45,3 @@ QImage br::toQImage(const Mat &mat) return QImage(mat8uc3.data, mat8uc3.cols, mat8uc3.rows, 3*mat8uc3.cols, QImage::Format_RGB888).copy(); } - -QStringList br::getFiles(QDir dir, bool recursive) -{ - dir = QDir(dir.canonicalPath()); - - QStringList files; - foreach (const QString &file, QtUtils::naturalSort(dir.entryList(QDir::Files))) - files.append(dir.absoluteFilePath(file)); - - if (!recursive) return files; - - foreach (const QString &folder, QtUtils::naturalSort(dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))) { - QDir subdir(dir); - bool success = subdir.cd(folder); if (!success) qFatal("cd failure."); - files.append(getFiles(subdir, true)); - } - return files; -} - -QStringList br::getFiles(const QString ®exp) -{ - QFileInfo fileInfo(regexp); - QDir dir(fileInfo.dir()); - QRegExp re(fileInfo.fileName()); - re.setPatternSyntax(QRegExp::Wildcard); - - QStringList files; - foreach (const QString &fileName, dir.entryList(QDir::Files)) - if (re.exactMatch(fileName)) - files.append(dir.filePath(fileName)); - return files; -} diff --git a/openbr/gui/utility.h b/openbr/gui/utility.h index 4552215..80b1ccb 100644 --- a/openbr/gui/utility.h +++ b/openbr/gui/utility.h @@ -1,5 +1,5 @@ -#ifndef BR_UTILITY_H -#define BR_UTILITY_H +#ifndef BR_GUI_UTILITY_H +#define BR_GUI_UTILITY_H #include #include @@ -12,9 +12,7 @@ namespace br { BR_EXPORT QImage toQImage(const cv::Mat &mat); -BR_EXPORT QStringList getFiles(QDir dir, bool recursive); -BR_EXPORT QStringList getFiles(const QString ®exp); } // namespace br -#endif // BR_UTILITY_H +#endif // BR_GUI_UTILITY_H diff --git a/openbr/plugins/cmake/db.cmake b/openbr/plugins/cmake/db.cmake new file mode 100644 index 0000000..fed0d80 --- /dev/null +++ b/openbr/plugins/cmake/db.cmake @@ -0,0 +1,3 @@ +if(${BR_EMBEDDED}) + set(BR_EXCLUDED_PLUGINS ${BR_EXCLUDED_PLUGINS} plugins/gallery/db.cpp) +endif() diff --git a/openbr/plugins/cmake/xml.cmake b/openbr/plugins/cmake/xml.cmake new file mode 100644 index 0000000..0d8ad73 --- /dev/null +++ b/openbr/plugins/cmake/xml.cmake @@ -0,0 +1,3 @@ +if(${BR_EMBEDDED}) + set(BR_EXCLUDED_PLUGINS ${BR_EXCLUDED_PLUGINS} plugins/gallery/xml.cpp) +endif() diff --git a/openbr/plugins/gallery/db.cpp b/openbr/plugins/gallery/db.cpp index 9b7d5b5..05fd774 100644 --- a/openbr/plugins/gallery/db.cpp +++ b/openbr/plugins/gallery/db.cpp @@ -38,7 +38,6 @@ class dbGallery : public Gallery QString query = file.get("query"); QString subset = file.get("subset", ""); -#ifndef BR_EMBEDDED QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(file); if (!db.open()) qFatal("Failed to open SQLite database %s.", qPrintable(file.name)); @@ -167,7 +166,6 @@ class dbGallery : public Gallery } db.close(); -#endif // BR_EMBEDDED *done = true; return templates; diff --git a/openbr/plugins/gallery/empty.cpp b/openbr/plugins/gallery/empty.cpp index 698efc4..c73aaae 100644 --- a/openbr/plugins/gallery/empty.cpp +++ b/openbr/plugins/gallery/empty.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include namespace br {