move the GUI stuff out of Generator in an own GuiInterface, and adapt the ghostscript generator to its usage; renamed also some methods to more Qt4-ish names.

svn path=/trunk/playground/graphics/okular/; revision=619044
remotes/origin/KDE/4.0
Pino Toscano 19 years ago
parent 1633d45c4a
commit d9a844d67c
  1. 30
      core/document.cpp
  2. 4
      core/document.h
  3. 13
      core/generator.cpp
  4. 7
      core/generator.h
  5. 42
      core/guiinterface.h
  6. 9
      generators/ghostview/generator_ghostview.cpp
  7. 10
      generators/ghostview/generator_ghostview.h
  8. 2
      part.cpp

@ -39,6 +39,7 @@
#include "page.h" #include "page.h"
#include "settings.h" #include "settings.h"
#include "printinterface.h" #include "printinterface.h"
#include "guiinterface.h"
using namespace Okular; using namespace Okular;
@ -313,18 +314,25 @@ bool Document::openDocument( const QString & docFile, const KUrl& url, const KMi
} }
QString Document::getXMLFile() QString Document::xmlFile()
{ {
if (generator) if ( generator )
return generator->getXMLFile(); {
Okular::GuiInterface * iface = qobject_cast< Okular::GuiInterface * >( generator );
return iface ? iface->xmlFile() : QString();
}
else
return QString(); return QString();
} }
void Document::setupGUI(KActionCollection* ac, QToolBox* tBox ) void Document::setupGui( KActionCollection *ac, QToolBox *tBox )
{ {
if (generator) if ( generator && ac && tBox )
generator->setupGUI(ac,tBox); {
Okular::GuiInterface * iface = qobject_cast< Okular::GuiInterface * >( generator );
if ( iface )
iface->setupGui( ac, tBox );
}
} }
void Document::closeDocument() void Document::closeDocument()
@ -342,8 +350,12 @@ void Document::closeDocument()
if ( d->saveBookmarksTimer ) if ( d->saveBookmarksTimer )
d->saveBookmarksTimer->stop(); d->saveBookmarksTimer->stop();
if (generator) if ( generator )
generator->freeGUI(); {
Okular::GuiInterface * iface = qobject_cast< Okular::GuiInterface * >( generator );
if ( iface )
iface->freeGui();
}
if (!m_usingCachedGenerator) if (!m_usingCachedGenerator)
{ {
// delete contents generator // delete contents generator

@ -123,8 +123,8 @@ class OKULAR_EXPORT Document : public QObject
QString pageSizeString(int page) const; QString pageSizeString(int page) const;
// gui altering stuff // gui altering stuff
QString getXMLFile(); QString xmlFile();
void setupGUI(KActionCollection * ac , QToolBox * tBox ); void setupGui( KActionCollection *ac, QToolBox *tBox );
// perform actions on document / pages // perform actions on document / pages
void setViewportPage( int page, int excludeId = -1, bool smoothMove = false ); void setViewportPage( int page, int excludeId = -1, bool smoothMove = false );

@ -75,19 +75,6 @@ bool Generator::isAllowed( int ) const
return true; return true;
} }
QString Generator::getXMLFile() const
{
return QString();
}
void Generator::setupGUI( KActionCollection*, QToolBox* )
{
}
void Generator::freeGUI()
{
}
bool Generator::supportsSearching() const bool Generator::supportsSearching() const
{ {
return false; return false;

@ -27,8 +27,6 @@
#include <kmimetype.h> #include <kmimetype.h>
class QToolBox;
class KActionCollection;
class KConfigDialog; class KConfigDialog;
class KIcon; class KIcon;
class KPrinter; class KPrinter;
@ -239,11 +237,6 @@ class OKULAR_EXPORT Generator : public QObject
*/ */
virtual bool isAllowed( int action ) const; virtual bool isAllowed( int action ) const;
// gui stuff
virtual QString getXMLFile() const;
virtual void setupGUI( KActionCollection*, QToolBox* );
virtual void freeGUI();
/** /**
* This method returns whether the generator supports searching. Default is false. * This method returns whether the generator supports searching. Default is false.
*/ */

@ -0,0 +1,42 @@
/***************************************************************************
* Copyright (C) 2007 by Pino Toscano <pino@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef _OKULAR_GUIINTERFACE_H_
#define _OKULAR_GUIINTERFACE_H_
#include "okular_export.h"
class QToolBox;
class KActionCollection;
namespace Okular {
/**
* @short Abstract interface for user interface control
*
* This interface defines an way to interact with the Okular user interface,
* eg adding actions in the menus.
*/
class OKULAR_EXPORT GuiInterface
{
public:
virtual ~GuiInterface() {}
virtual QString xmlFile() const = 0;
virtual void setupGui( KActionCollection *, QToolBox * ) = 0;
virtual void freeGui() = 0;
};
}
Q_DECLARE_INTERFACE( Okular::GuiInterface, "org.kde.okular.GuiInterface/0.1" )
#endif

@ -267,7 +267,12 @@ void GSGenerator::setPaperSize( QVector<Okular::Page*> & pagesVector, int newsiz
*/ */
} }
void GSGenerator::setupGUI(KActionCollection * ac , QToolBox * tBox ) QString GSGenerator::xmlFile() const
{
return QString();
}
void GSGenerator::setupGui( KActionCollection *ac, QToolBox *tBox )
{ {
if ( GSSettings::messages() ) if ( GSSettings::messages() )
{ {
@ -277,7 +282,7 @@ void GSGenerator::setupGUI(KActionCollection * ac , QToolBox * tBox )
m_actionCollection = ac; m_actionCollection = ac;
} }
void GSGenerator::freeGUI() void GSGenerator::freeGui()
{ {
if ( GSSettings::messages() ) if ( GSSettings::messages() )
{ {

@ -11,6 +11,7 @@
#define _OKULAR_GENERATOR_GHOSTVIEW_H_ #define _OKULAR_GENERATOR_GHOSTVIEW_H_
#include "core/generator.h" #include "core/generator.h"
#include "core/guiinterface.h"
class GSInterpreterCMD; class GSInterpreterCMD;
class GSLogWindow; class GSLogWindow;
@ -19,9 +20,11 @@ class GSInternalDocument;
class KTempFile; class KTempFile;
class KActionCollection; class KActionCollection;
class GSGenerator : public Okular::Generator class GSGenerator : public Okular::Generator, public Okular::GuiInterface
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES( Okular::GuiInterface )
public: public:
/** virtual methods to reimplement **/ /** virtual methods to reimplement **/
// load a document and fill up the pagesVector // load a document and fill up the pagesVector
@ -44,8 +47,9 @@ class GSGenerator : public Okular::Generator
QStringList paperSizes() const; QStringList paperSizes() const;
void setPaperSize( QVector<Okular::Page*> & pagesVector, int newsize ); void setPaperSize( QVector<Okular::Page*> & pagesVector, int newsize );
void setupGUI(KActionCollection * /*ac*/ , QToolBox * /* tBox */); QString xmlFile() const;
void freeGUI(); void setupGui( KActionCollection *, QToolBox * );
void freeGui();
// print document using already configured kprinter // print document using already configured kprinter
bool print( KPrinter& /*printer*/ ); bool print( KPrinter& /*printer*/ );

@ -650,7 +650,7 @@ bool Part::openFile()
} }
/* if (m_document->getXMLFile() != QString::null) /* if (m_document->getXMLFile() != QString::null)
setXMLFile(m_document->getXMLFile(),true);*/ setXMLFile(m_document->getXMLFile(),true);*/
m_document->setupGUI(actionCollection(),m_toolBox); m_document->setupGui( actionCollection(), m_toolBox );
return true; return true;
} }

Loading…
Cancel
Save