gui: PreviewGeneratorMapFunctor: Use PreviewGenerator::get()

This commit is contained in:
Albert S. 2022-04-24 12:27:06 +02:00
parent 57bb5c48c8
commit 1536781bda
2 changed files with 2 additions and 25 deletions

View File

@ -3,26 +3,6 @@
PreviewGeneratorMapFunctor::PreviewGeneratorMapFunctor() PreviewGeneratorMapFunctor::PreviewGeneratorMapFunctor()
{ {
generator[GeneratorIndex::PDF] = new PreviewGeneratorPdf();
}
PreviewGenerator *PreviewGeneratorMapFunctor::getGenerator(QString filePath)
{
/* Dirty, but that's all we have at this point */
if(filePath.endsWith(".pdf"))
{
return generator[GeneratorIndex::PDF];
}
return nullptr;
}
PreviewGeneratorMapFunctor::~PreviewGeneratorMapFunctor()
{
for(int i = GeneratorIndex::PDF; i < GeneratorIndex::LAST_DUMMY; i++)
{
// delete generator[i];
generator[i] = nullptr;
}
} }
void PreviewGeneratorMapFunctor::setRenderConfig(RenderConfig config) void PreviewGeneratorMapFunctor::setRenderConfig(RenderConfig config)
@ -32,7 +12,8 @@ void PreviewGeneratorMapFunctor::setRenderConfig(RenderConfig config)
QSharedPointer<PreviewResult> PreviewGeneratorMapFunctor::operator()(const QSharedPointer<PreviewResult> &renderResult) QSharedPointer<PreviewResult> PreviewGeneratorMapFunctor::operator()(const QSharedPointer<PreviewResult> &renderResult)
{ {
PreviewGenerator *previewGenerator = getGenerator(renderResult->getDocumentPath()); QFileInfo info{renderResult->getDocumentPath()};
PreviewGenerator *previewGenerator = PreviewGenerator::get(info);
if(previewGenerator == nullptr) if(previewGenerator == nullptr)
{ {
return QSharedPointer<PreviewResult>(); return QSharedPointer<PreviewResult>();

View File

@ -14,16 +14,12 @@ class PreviewGeneratorMapFunctor
LAST_DUMMY LAST_DUMMY
}; };
RenderConfig renderConfig; RenderConfig renderConfig;
PreviewGenerator *generator[LAST_DUMMY];
PreviewGenerator *getGenerator(QString filePath);
public: public:
typedef QSharedPointer<PreviewResult> result_type; typedef QSharedPointer<PreviewResult> result_type;
PreviewGeneratorMapFunctor(); PreviewGeneratorMapFunctor();
~PreviewGeneratorMapFunctor();
void setRenderConfig(RenderConfig config); void setRenderConfig(RenderConfig config);
QSharedPointer<PreviewResult> operator()(const QSharedPointer<PreviewResult> &renderResult); QSharedPointer<PreviewResult> operator()(const QSharedPointer<PreviewResult> &renderResult);