Commit 9b6e5c9097b2bcf384a1ec8a449fa7e867e3e99d
1 parent
baa5927d
Removed natural sort, made FilesWithLabel a br typedef
Showing
3 changed files
with
8 additions
and
8 deletions
openbr/core/utility.cpp
| @@ -19,18 +19,18 @@ QStringList br::getFiles(QDir dir, bool recursive) | @@ -19,18 +19,18 @@ QStringList br::getFiles(QDir dir, bool recursive) | ||
| 19 | return files; | 19 | return files; |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | -QList<QPair<QString,QStringList> > br::getFilesWithLabels(QDir dir) | 22 | +QList<br::FilesWithLabel> br::getFilesWithLabels(QDir dir) |
| 23 | { | 23 | { |
| 24 | dir = QDir(dir.canonicalPath()); | 24 | dir = QDir(dir.canonicalPath()); |
| 25 | 25 | ||
| 26 | QStringList files; | 26 | QStringList files; |
| 27 | - foreach (const QString &file, QtUtils::naturalSort(dir.entryList(QDir::Files))) | 27 | + foreach (const QString &file, dir.entryList(QDir::Files)) |
| 28 | files.append(dir.absoluteFilePath(file)); | 28 | files.append(dir.absoluteFilePath(file)); |
| 29 | 29 | ||
| 30 | - QList<QPair<QString,QStringList> > filesWithLabels; | ||
| 31 | - filesWithLabels.append(QPair<QString,QStringList>(dir.dirName(),files)); | 30 | + QList<br::FilesWithLabel> filesWithLabels; |
| 31 | + filesWithLabels.append(br::FilesWithLabel(dir.dirName(),files)); | ||
| 32 | 32 | ||
| 33 | - foreach (const QString &folder, QtUtils::naturalSort(dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))) { | 33 | + foreach (const QString &folder, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { |
| 34 | QDir subdir(dir); | 34 | QDir subdir(dir); |
| 35 | bool success = subdir.cd(folder); if (!success) qFatal("cd failure."); | 35 | bool success = subdir.cd(folder); if (!success) qFatal("cd failure."); |
| 36 | filesWithLabels.append(getFilesWithLabels(subdir)); | 36 | filesWithLabels.append(getFilesWithLabels(subdir)); |
openbr/core/utility.h
| @@ -10,6 +10,8 @@ | @@ -10,6 +10,8 @@ | ||
| 10 | namespace br | 10 | namespace br |
| 11 | { | 11 | { |
| 12 | 12 | ||
| 13 | +typedef QPair<QString,QStringList> FilesWithLabel; | ||
| 14 | + | ||
| 13 | BR_EXPORT QStringList getFiles(QDir dir, bool recursive); | 15 | BR_EXPORT QStringList getFiles(QDir dir, bool recursive); |
| 14 | BR_EXPORT QList<QPair<QString,QStringList> > getFilesWithLabels(QDir dir); | 16 | BR_EXPORT QList<QPair<QString,QStringList> > getFilesWithLabels(QDir dir); |
| 15 | BR_EXPORT QStringList getFiles(const QString ®exp); | 17 | BR_EXPORT QStringList getFiles(const QString ®exp); |
openbr/plugins/gallery/empty.cpp
| @@ -20,8 +20,6 @@ | @@ -20,8 +20,6 @@ | ||
| 20 | #include <openbr/core/qtutils.h> | 20 | #include <openbr/core/qtutils.h> |
| 21 | #include <openbr/core/utility.h> | 21 | #include <openbr/core/utility.h> |
| 22 | 22 | ||
| 23 | -typedef QPair<QString,QStringList> FilesWithLabel; | ||
| 24 | - | ||
| 25 | namespace br | 23 | namespace br |
| 26 | { | 24 | { |
| 27 | 25 | ||
| @@ -116,7 +114,7 @@ class EmptyGallery : public Gallery | @@ -116,7 +114,7 @@ class EmptyGallery : public Gallery | ||
| 116 | static TemplateList getTemplates(const QDir &dir) | 114 | static TemplateList getTemplates(const QDir &dir) |
| 117 | { | 115 | { |
| 118 | const QList<FilesWithLabel> filesWithLabels = getFilesWithLabels(dir); | 116 | const QList<FilesWithLabel> filesWithLabels = getFilesWithLabels(dir); |
| 119 | - TemplateList templates; templates.reserve(filesWithLabels.size()); | 117 | + TemplateList templates; |
| 120 | foreach (const FilesWithLabel &filesWithLabel, filesWithLabels) | 118 | foreach (const FilesWithLabel &filesWithLabel, filesWithLabels) |
| 121 | foreach (const QString &file, filesWithLabel.second) | 119 | foreach (const QString &file, filesWithLabel.second) |
| 122 | templates.append(File(file, filesWithLabel.first)); | 120 | templates.append(File(file, filesWithLabel.first)); |