gui: PreviewGenerator: Add get()

This commit is contained in:
Albert S. 2022-04-24 12:22:59 +02:00
父節點 84e13e432b
當前提交 57bb5c48c8
共有 2 個檔案被更改,包括 17 行新增0 行删除

查看文件

@ -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