gui: PreviewGenerator: Add get()
This commit is contained in:
bovenliggende
84e13e432b
commit
57bb5c48c8
@ -1 +1,15 @@
|
||||
#include "previewgenerator.h"
|
||||
#include "previewgeneratorpdf.h"
|
||||
#include "previewgeneratorplaintext.h"
|
||||
|
||||
static PreviewGenerator *plainTextGenerator = new PreviewGeneratorPlainText();
|
||||
|
||||
static QMap<QString, PreviewGenerator *> generators{
|
||||
{"pdf", new PreviewGeneratorPdf()}, {"txt", plainTextGenerator}, {"md", plainTextGenerator},
|
||||
{"py", plainTextGenerator}, {"java", plainTextGenerator}, {"js", plainTextGenerator},
|
||||
{"cpp", plainTextGenerator}, {"c", plainTextGenerator}, {"sql", plainTextGenerator}};
|
||||
|
||||
PreviewGenerator *PreviewGenerator::get(QFileInfo &info)
|
||||
{
|
||||
return generators.value(info.suffix(), nullptr);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define PREVIEWGENERATOR_H
|
||||
#include <QVector>
|
||||
#include <QSharedPointer>
|
||||
#include <QFileInfo>
|
||||
#include "previewresult.h"
|
||||
#include "renderconfig.h"
|
||||
|
||||
@ -12,6 +13,8 @@ class PreviewGenerator
|
||||
virtual ~PreviewGenerator()
|
||||
{
|
||||
}
|
||||
|
||||
static PreviewGenerator *get(QFileInfo &info);
|
||||
};
|
||||
|
||||
#endif // PREVIEWGENERATOR_H
|
||||
|
Laden…
Verwijs in nieuw issue
Block a user