LeechCraft Monocle  0.6.70-13729-g7046a9d2a7
Modular document viewer for LeechCraft
LC::Monocle::IDocument Class Referenceabstract

Basic interface for documents. More...

#include "idocument.h"

Classes

struct  Position
 Describes a position within a document. More...
 

Public Member Functions

virtual ~IDocument ()
 Virtual destructor. More...
 
virtual QObject * GetBackendPlugin () const =0
 Returns the parent backend plugin. More...
 
virtual QObject * GetQObject ()=0
 Returns this object as a QObject. More...
 
virtual bool IsValid () const =0
 Returns whether this document is valid. More...
 
virtual DocumentInfo GetDocumentInfo () const =0
 Returns the document metadata. More...
 
virtual int GetNumPages () const =0
 Returns the number of pages in this document. More...
 
virtual QSize GetPageSize (int page) const =0
 Returns the size in pixels of the given page. More...
 
virtual QFuture< QImage > RenderPage (int page, double xScale, double yScale)=0
 Renders the given page at the given scale. More...
 
virtual QList< ILink_ptrGetPageLinks (int page)=0
 Returns the links found at the given page. More...
 
virtual QUrl GetDocURL () const =0
 Returns the URL of the document. More...
 
virtual void navigateRequested (const QString &filename, const Position &position)=0
 Emitted when navigation is requested. More...
 
virtual void printRequested (const QList< int > &pages)=0
 Emitted when printing is requested. More...
 

Detailed Description

Basic interface for documents.

This interface is the basic interface for documents returned from format backends.

Pages actions (like rendering) are also performed via this interface. Pages indexes are zero-based.

This class has some signals, and one can use the GetQObject() method to get an object of this class as a QObject and connect to those signals.

There are also other interfaces for extended functionality like documents that can be changed and saved, the documents containing annotations and so on. See the See also section for the details.

See also
IBackendPlugin::LoadDocument()
IDynamicDocument, IHaveTextContent, ISaveableDocument
ISearchableDocument, ISupportAnnotations, ISupportForms
IHaveTOC, ISupportPainting

Definition at line 101 of file idocument.h.

Constructor & Destructor Documentation

◆ ~IDocument()

virtual LC::Monocle::IDocument::~IDocument ( )
inlinevirtual

Virtual destructor.

Definition at line 106 of file idocument.h.

Member Function Documentation

◆ GetBackendPlugin()

virtual QObject* LC::Monocle::IDocument::GetBackendPlugin ( ) const
pure virtual

Returns the parent backend plugin.

This function should return the instance object of the backend plugin that created this document.

The returned value should obviously implement IBackendPlugin.

Returns
The parent backend plugin instance object.

◆ GetDocumentInfo()

virtual DocumentInfo LC::Monocle::IDocument::GetDocumentInfo ( ) const
pure virtual

Returns the document metadata.

Returns
The document metadata.

◆ GetDocURL()

virtual QUrl LC::Monocle::IDocument::GetDocURL ( ) const
pure virtual

Returns the URL of the document.

This method should return the URL of this document. URLs on the local filesystem should obviously have the file scheme.

Returns
The URL of this document.

◆ GetNumPages()

virtual int LC::Monocle::IDocument::GetNumPages ( ) const
pure virtual

Returns the number of pages in this document.

Returns
The number of pages in this document.

◆ GetPageLinks()

virtual QList<ILink_ptr> LC::Monocle::IDocument::GetPageLinks ( int  page)
pure virtual

Returns the links found at the given page.

If the format doesn't support links, an empty list should be returned.

The ownership of the returned links objects is passed to the caller.

Parameters
[in]pageThe page index to query.
See also
ILink

◆ GetPageSize()

virtual QSize LC::Monocle::IDocument::GetPageSize ( int  page) const
pure virtual

Returns the size in pixels of the given page.

This function returns the physical dimensions of the given page in pixels.

Some formats support different pages having different sizes in the same document, thus the size should be queried for each page.

Parameters
[in]pageThe index of the page to query.
Returns
The size of the given page.

◆ GetQObject()

virtual QObject* LC::Monocle::IDocument::GetQObject ( )
pure virtual

Returns this object as a QObject.

This function can be used to connect to the signals of this class.

Returns
This object as a QObject.

◆ IsValid()

virtual bool LC::Monocle::IDocument::IsValid ( ) const
pure virtual

Returns whether this document is valid.

An invalid document is basically equivalent to a null pointer, all operations on it lead to undefined behavior.

Returns
Whether this document is valid.

◆ navigateRequested()

virtual void LC::Monocle::IDocument::navigateRequested ( const QString &  filename,
const Position position 
)
pure virtual

Emitted when navigation is requested.

For example, this signal is emitted when a navigation link in a table of contents has been triggered.

If filename is empty, pageNum, x and y are all related to he current document. Otherwise filename should be loaded first.

Parameters
[out]filenameThe filename of the document to navigate to, or an empty string if the current document should be used.
[out]positionThe position within the document described by filename.
See also
Position

◆ printRequested()

virtual void LC::Monocle::IDocument::printRequested ( const QList< int > &  pages)
pure virtual

Emitted when printing is requested.

This signal is emitted when printing is requested, for example, by a link action.

Parameters
[out]pagesThe list of pages to print, or an empty list to print all pages.

◆ RenderPage()

virtual QFuture<QImage> LC::Monocle::IDocument::RenderPage ( int  page,
double  xScale,
double  yScale 
)
pure virtual

Renders the given page at the given scale.

This function should return an image with the given page rendered at the given xScale and yScale for x and y axises correspondingly. That is, the image's size should be equal to the following:

auto size = GetPageSize (page);
size.rwidth () *= xScale;
size.rheight () *= yscale;
Parameters
[in]pageThe index of the page to render.
[in]xScaleThe scale of the x axis.
[in]yScaleThe scale of the y axis.
Returns
The rendering of the given page.

The documentation for this class was generated from the following file: