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/gallery/db.cpp b/openbr/plugins/gallery/db.cpp index 9b7d5b5..a529440 100644 --- a/openbr/plugins/gallery/db.cpp +++ b/openbr/plugins/gallery/db.cpp @@ -14,7 +14,9 @@ * limitations under the License. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#ifndef BR_EMBEDDED #include +#endif // BR_EMBEDDED #include #include 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 { diff --git a/openbr/plugins/gallery/xml.cpp b/openbr/plugins/gallery/xml.cpp index 4df2e00..7965c15 100644 --- a/openbr/plugins/gallery/xml.cpp +++ b/openbr/plugins/gallery/xml.cpp @@ -14,7 +14,9 @@ * limitations under the License. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#ifndef BR_EMBEDDED #include +#endif // BR_EMBEDDED #include #include @@ -36,10 +38,12 @@ class xmlGallery : public FileGallery BR_PROPERTY(bool, skipMissing, false) FileList files; +#ifndef BR_EMBEDDED QXmlStreamReader reader; + bool signatureActive; +#endif // BR_EMBEDDED QString currentSignatureName; - bool signatureActive; ~xmlGallery() { @@ -50,15 +54,17 @@ class xmlGallery : public FileGallery TemplateList readBlock(bool *done) { + TemplateList templates; + +#ifndef BR_EMBEDDED + qint64 count = 0; + if (readOpen()) reader.setDevice(&f); if (reader.atEnd()) f.seek(0); - TemplateList templates; - qint64 count = 0; - while (!reader.atEnd()) { // if an identity is active we try to read presentations @@ -169,8 +175,9 @@ class xmlGallery : public FileGallery } } } - *done = true; +#endif // BR_EMBEDDED + *done = true; return templates; }