From a7d2563d3131368f9d08d5ccfc3e14fcebf3b41c Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sun, 2 Dec 2007 22:48:31 +0000 Subject: [PATCH] update a bit with the recent API changes (still missing the kdeprint removal, though) svn path=/trunk/KDE/kdegraphics/okular/; revision=744193 --- Mainpage.dox | 69 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/Mainpage.dox b/Mainpage.dox index 7ba96524f..f45479062 100644 --- a/Mainpage.dox +++ b/Mainpage.dox @@ -174,15 +174,17 @@ The API of the Generator looks like the following: class MagicGenerator : public Okular::Generator { public: - MagicGenerator(); + MagicGenerator( QObject *parent, const QVariantList &args ); ~MagicGenerator(); bool loadDocument( const QString &fileName, QVector &pages ); - bool closeDocument(); bool canGeneratePixmap() const; void generatePixmap( Okular::PixmapRequest *request ); + protected: + bool doCloseDocument(); + private: MagicDocument mMagicDocument; }; @@ -195,10 +197,17 @@ The implementation of the Generator looks like this: #include "magicgenerator.h" -OKULAR_EXPORT_PLUGIN(MagicGenerator) +static KAboutData createAboutData() +{ + KAboutData aboutData(...); + // fill the about data + return aboutData; +} -MagicGenerator::MagicGenerator() - : Okular::Generator() +OKULAR_EXPORT_PLUGIN(MagicGenerator, createAboutData()) + +MagicGenerator::MagicGenerator( QObject *parent, const QVariantList &args ) + : Okular::Generator( parent, args ) { } @@ -225,7 +234,7 @@ bool MagicGenerator::loadDocument( const QString &fileName, QVector &pages ); - bool closeDocument(); bool canGeneratePixmap() const; void generatePixmap( Okular::PixmapRequest *request ); @@ -457,6 +463,9 @@ class MagicGenerator : public Okular::Generator virtual bool canGenerateTextPage() const; virtual void generateTextPage( Okular::Page *page, enum Okular::GenerationType type = Okular::Synchronous ); + protected: + bool doCloseDocument(); + private: MagicDocument mMagicDocument; }; @@ -478,7 +487,8 @@ Let us take a look at the implementation of these methods in our MagicGenerator: ... -MagicGenerator::MagicGenerator() +MagicGenerator::MagicGenerator( QObject *parent, const QVariantList &args ) + : Okular::Generator( parent, args ) { setFeature( TextExtraction ); } @@ -558,13 +568,14 @@ The new MagicGenerator API looks like the following: class MagicGenerator : public Okular::Generator { public: - MagicGenerator(); + MagicGenerator( QObject *parent, const QVariantList &args ); ~MagicGenerator(); bool loadDocument( const QString &fileName, QVector &pages ); - bool closeDocument(); - proteced: + protected: + bool doCloseDocument(); + virtual QImage image( Okular::PixmapRequest *request ); virtual Okular::TextPage* textPage( Okular::Page *page ); @@ -581,7 +592,8 @@ Before explaining why, we'll take a look at the implementation: \code -MagicGenerator::MagicGenerator() +MagicGenerator::MagicGenerator( QObject *parent, const QVariantList &args ) + : Okular::Generator( parent, args ) { setFeature( TextExtraction ); setFeature( Threaded ); @@ -644,11 +656,10 @@ The API of our HTMLGenerator looks like the following: class HTMLGenerator : public Okular::Generator { public: - HTMLGenerator(); + HTMLGenerator( QObject *parent, const QVariantList &args ); ~HTMLGenerator(); bool loadDocument( const QString &fileName, QVector &pages ); - bool closeDocument(); bool canGeneratePixmap() const; void generatePixmap( Okular::PixmapRequest *request ); @@ -663,6 +674,9 @@ class HTMLGenerator : public Okular::Generator virtual bool exportTo( const QString &fileName, const Okular::ExportFormat &format ); + protected: + bool doCloseDocument(); + private: QTextDocument *mTextDocument; Okular::DocumentInfo mDocumentInfo; @@ -696,10 +710,17 @@ Now that you know what the methods are supposed to do, let's take a look at the #include "htmlgenerator.h" -OKULAR_EXPORT_PLUGIN(HTMLGenerator) +static KAboutData createAboutData() +{ + KAboutData aboutData(...); + // fill the about data + return aboutData; +} -HTMLGenerator::HTMLGenerator() - : Okular::Generator(), +OKULAR_EXPORT_PLUGIN(HTMLGenerator, createAboutData()) + +HTMLGenerator::HTMLGenerator( QObject *parent, const QVariantList &args ) + : Okular::Generator( parent, args ), mTextDocument( 0 ) { } @@ -750,7 +771,7 @@ bool HTMLGenerator::loadDocument( const QString &fileName, QVector