looqs/gui/previewgenerator.cpp

25 rader
786 B
C++
Permalänk Normal vy Historik

#include "../shared/common.h"
#include "previewgenerator.h"
2022-04-24 12:22:59 +02:00
#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)
{
PreviewGenerator *result = generators.value(info.suffix(), nullptr);
if(result == nullptr)
{
if(Common::isTextFile(info))
{
return plainTextGenerator;
}
}
return result;
2022-04-24 12:22:59 +02:00
}