Generalize previews: Add PreviewResult,PreviewResultPdf, remove PdfPreview

Bu işleme şunda yer alıyor:
Albert S. 2022-01-03 22:54:22 +01:00
ebeveyn 32286cae4b
işleme 95b3d1fce2
6 değiştirilmiş dosya ile 95 ekleme ve 24 silme

Dosyayı Görüntüle

@ -1,5 +0,0 @@
#include "pdfpreview.h"
PdfPreview::PdfPreview()
{
}

Dosyayı Görüntüle

@ -1,19 +0,0 @@
#ifndef PDFPREVIEW_H
#define PDFPREVIEW_H
#include <QImage>
class PdfPreview
{
public:
PdfPreview();
QImage previewImage;
QString documentPath;
unsigned int page;
bool hasPreviewImage()
{
return !previewImage.isNull();
}
};
#endif // PDFPREVIEW_H

35
gui/previewresult.cpp Normal dosya
Dosyayı Görüntüle

@ -0,0 +1,35 @@
#include "previewresult.h"
PreviewResult::PreviewResult()
{
}
PreviewResult::~PreviewResult()
{
}
QWidget *PreviewResult::createPreviewWidget()
{
return nullptr;
}
bool PreviewResult::hasPreview()
{
return false;
}
PreviewResult::PreviewResult(QString documentPath, unsigned int page)
{
this->documentPath = documentPath;
this->page = page;
}
QString PreviewResult::getDocumentPath() const
{
return this->documentPath;
}
unsigned int PreviewResult::getPage() const
{
return this->page;
}

22
gui/previewresult.h Normal dosya
Dosyayı Görüntüle

@ -0,0 +1,22 @@
#ifndef PREVIEWRESULT_H
#define PREVIEWRESULT_H
#include "clicklabel.h"
class PreviewResult
{
protected:
QString documentPath;
unsigned int page;
public:
PreviewResult();
PreviewResult(QString documentPath, unsigned int page);
PreviewResult(const PreviewResult &o) = default;
virtual ~PreviewResult();
virtual QWidget *createPreviewWidget();
virtual bool hasPreview();
QString getDocumentPath() const;
unsigned int getPage() const;
};
#endif // PREVIEWRESULT_H

21
gui/previewresultpdf.cpp Normal dosya
Dosyayı Görüntüle

@ -0,0 +1,21 @@
#include "previewresultpdf.h"
PreviewResultPdf::PreviewResultPdf(const PreviewResult &o)
{
this->documentPath = o.getDocumentPath();
this->page = o.getPage();
}
QWidget *PreviewResultPdf::createPreviewWidget()
{
ClickLabel *label = new ClickLabel();
label->setPixmap(QPixmap::fromImage(previewImage));
label->setToolTip(getDocumentPath());
return label;
}
bool PreviewResultPdf::hasPreview()
{
bool result = !this->previewImage.isNull();
return result;
}

17
gui/previewresultpdf.h Normal dosya
Dosyayı Görüntüle

@ -0,0 +1,17 @@
#ifndef PREVIEWRESULTPDF_H
#define PREVIEWRESULTPDF_H
#include <QImage>
#include "previewresult.h"
class PreviewResultPdf : public PreviewResult
{
public:
using PreviewResult::PreviewResult;
PreviewResultPdf(const PreviewResult &o);
QImage previewImage;
QWidget *createPreviewWidget() override;
bool hasPreview() override;
};
#endif // PREVIEWRESULTPDF_H