gui: PreviewGenerator: Add get()
This commit is contained in:
parent
84e13e432b
commit
57bb5c48c8
@ -1 +1,15 @@
|
|||||||
#include "previewgenerator.h"
|
#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
|
#define PREVIEWGENERATOR_H
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
|
#include <QFileInfo>
|
||||||
#include "previewresult.h"
|
#include "previewresult.h"
|
||||||
#include "renderconfig.h"
|
#include "renderconfig.h"
|
||||||
|
|
||||||
@ -12,6 +13,8 @@ class PreviewGenerator
|
|||||||
virtual ~PreviewGenerator()
|
virtual ~PreviewGenerator()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PreviewGenerator *get(QFileInfo &info);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PREVIEWGENERATOR_H
|
#endif // PREVIEWGENERATOR_H
|
||||||
|
Loading…
Reference in New Issue
Block a user