gui: PreviewGeneratorMapFunctor: Use PreviewGenerator::get()

Αυτή η υποβολή περιλαμβάνεται σε:
Albert S. 2022-04-24 12:27:06 +02:00
γονέας 57bb5c48c8
υποβολή 1536781bda
2 αρχεία άλλαξαν με 2 προσθήκες και 25 διαγραφές

@ -3,26 +3,6 @@
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)
@ -32,7 +12,8 @@ void PreviewGeneratorMapFunctor::setRenderConfig(RenderConfig config)
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)
{
return QSharedPointer<PreviewResult>();

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