DRY image formats
This commit is contained in:
@@ -13,6 +13,14 @@ PathTraverser::PathTraverser(const std::string path):
|
|||||||
|
|
||||||
PathTraverser::~PathTraverser() {}
|
PathTraverser::~PathTraverser() {}
|
||||||
|
|
||||||
|
QStringList PathTraverser::getImageFormats() const {
|
||||||
|
QStringList imageFormats;
|
||||||
|
imageFormats << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG";
|
||||||
|
imageFormats << "*.PNG" << "*.png";
|
||||||
|
imageFormats << "*.tiff" << "*.TIFF" << "*.tif" << "*.TIF";
|
||||||
|
return imageFormats;
|
||||||
|
}
|
||||||
|
|
||||||
RecursivePathTraverser::RecursivePathTraverser(const std::string path):
|
RecursivePathTraverser::RecursivePathTraverser(const std::string path):
|
||||||
PathTraverser(path)
|
PathTraverser(path)
|
||||||
{}
|
{}
|
||||||
@@ -22,8 +30,7 @@ RecursivePathTraverser::~RecursivePathTraverser() {}
|
|||||||
|
|
||||||
QStringList RecursivePathTraverser::getImages() const
|
QStringList RecursivePathTraverser::getImages() const
|
||||||
{
|
{
|
||||||
QDirIterator it(QString(path.c_str()),
|
QDirIterator it(QString(path.c_str()), getImageFormats(),
|
||||||
QStringList() << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG" << "*.PNG" << "*.png" << "*.tiff" << "*.TIFF" << "*.tif" << "*.TIF",
|
|
||||||
QDir::Files, QDirIterator::Subdirectories);
|
QDir::Files, QDirIterator::Subdirectories);
|
||||||
QStringList files;
|
QStringList files;
|
||||||
while (it.hasNext())
|
while (it.hasNext())
|
||||||
@@ -48,8 +55,7 @@ DefaultPathTraverser::~DefaultPathTraverser() {}
|
|||||||
|
|
||||||
QStringList DefaultPathTraverser::getImages() const
|
QStringList DefaultPathTraverser::getImages() const
|
||||||
{
|
{
|
||||||
return directory.entryList(QStringList() << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG" << "*.PNG" << "*.png"<< "*.tiff" << "*.TIFF"<< "*.tif" << "*.TIF",
|
return directory.entryList(getImageFormats(), QDir::Files);
|
||||||
QDir::Files);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string DefaultPathTraverser::getImagePath(const std::string image) const
|
const std::string DefaultPathTraverser::getImagePath(const std::string image) const
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class PathTraverser
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
const std::string path;
|
const std::string path;
|
||||||
|
QStringList getImageFormats() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RecursivePathTraverser : public PathTraverser
|
class RecursivePathTraverser : public PathTraverser
|
||||||
|
|||||||
Reference in New Issue
Block a user