Text layouts for every page

This commit is contained in:
Jakub Melka
2019-12-31 17:39:31 +01:00
parent c803317b6b
commit c832c4ecef
11 changed files with 509 additions and 125 deletions

View File

@ -20,6 +20,7 @@
#include "pdfrenderer.h"
#include "pdfpainter.h"
#include "pdftextlayout.h"
#include <QCache>
#include <QFuture>
@ -72,6 +73,11 @@ public:
/// \param compile Compile the page, if it is not found in the cache
const PDFPrecompiledPage* getCompiledPage(PDFInteger pageIndex, bool compile);
/// Returns text layout of the page. If page index is invalid,
/// then empty text layout is returned.
/// \param pageIndex Page index
PDFTextLayout getTextLayout(PDFInteger pageIndex);
signals:
void pageImageChanged(bool all, const std::vector<PDFInteger>& pages);
void renderingError(PDFInteger pageIndex, const QList<PDFRenderError>& errors);
@ -79,6 +85,9 @@ signals:
private:
void onPageCompiled();
/// Returns text layouts for all pages
PDFTextLayoutStorage getTextLayoutsImpl();
struct CompileTask
{
QFuture<PDFPrecompiledPage> taskFuture;
@ -89,6 +98,7 @@ private:
State m_state = State::Inactive;
QCache<PDFInteger, PDFPrecompiledPage> m_cache;
std::map<PDFInteger, CompileTask> m_tasks;
PDFCachedItem<PDFTextLayoutStorage> m_textLayouts;
};
} // namespace pdf