| 1 | #include "FileDialogFilterHelper.h" |
| 2 | #include <QImageReader> |
| 3 | #include <QImageWriter> |
| 4 | |
| 5 | const QString &FileDialogFilterHelper::ImageFilesImport() |
| 6 | { |
| 7 | const static QString importfilter(FileDialogFilterHelper::ImageFiles(true)); |
| 8 | return importfilter; |
| 9 | } |
| 10 | const QString &FileDialogFilterHelper::ImageFilesExport() |
| 11 | { |
| 12 | const static QString exportfilter(FileDialogFilterHelper::ImageFiles(false)); |
| 13 | return exportfilter; |
| 14 | } |
| 15 | const QString &FileDialogFilterHelper::AllFiles() |
| 16 | { |
| 17 | const static QString allfiles_str(QLatin1String("(*)")); |
| 18 | return allfiles_str; |
| 19 | } |
| 20 | |
| 21 | QString FileDialogFilterHelper::ImageFiles(bool import) |
| 22 | { |
| 23 | QList<QByteArray> supported_formats = import ? QImageReader::supportedImageFormats() : QImageWriter::supportedImageFormats(); |
| 24 | QString filter_str(QLatin1String("(")); |
| 25 | |
| 26 | for (int i = 0; i < supported_formats.count(); i++) { |
| 27 | filter_str.append(((i == 0) ? "*." : " *.") + QString(supported_formats.at(i))); |
| 28 | } |
| 29 | filter_str.append(");;"); |
| 30 | return filter_str; |
| 31 | } |