split switcher and traverser to prepare for shuffle mode
This commit is contained in:
55
src/pathtraverser.cpp
Normal file
55
src/pathtraverser.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "pathtraverser.h"
|
||||
#include "mainwindow.h"
|
||||
#include <QDirIterator>
|
||||
#include <QTimer>
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <iostream>
|
||||
#include <stdlib.h> /* srand, rand */
|
||||
|
||||
PathTraverser::PathTraverser(const std::string path):
|
||||
path(path)
|
||||
{}
|
||||
|
||||
PathTraverser::~PathTraverser() {}
|
||||
|
||||
RecursivePathTraverser::RecursivePathTraverser(const std::string path):
|
||||
PathTraverser(path)
|
||||
{}
|
||||
|
||||
RecursivePathTraverser::~RecursivePathTraverser() {}
|
||||
|
||||
|
||||
QStringList RecursivePathTraverser::getImages() const
|
||||
{
|
||||
QDirIterator it(QString(path.c_str()), QStringList() << "*.jpg" << "*.JPG", QDir::Files, QDirIterator::Subdirectories);
|
||||
QStringList files;
|
||||
while (it.hasNext())
|
||||
{
|
||||
files.append(it.next());
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
const std::string RecursivePathTraverser::getImagePath(const std::string image) const
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
DefaultPathTraverser::DefaultPathTraverser(const std::string path):
|
||||
PathTraverser(path),
|
||||
directory(path.c_str())
|
||||
{}
|
||||
|
||||
DefaultPathTraverser::~DefaultPathTraverser() {}
|
||||
|
||||
|
||||
QStringList DefaultPathTraverser::getImages() const
|
||||
{
|
||||
return directory.entryList(QStringList() << "*.jpg" << "*.JPG", QDir::Files);
|
||||
}
|
||||
|
||||
const std::string DefaultPathTraverser::getImagePath(const std::string image) const
|
||||
{
|
||||
return directory.filePath(QString(image.c_str())).toStdString();
|
||||
}
|
||||
Reference in New Issue
Block a user