change the metaData() function of the Generator to use QVariant as type for the returned value and for the 'option' parameter, this gives more flexibility

svn path=/trunk/playground/graphics/okular/; revision=599847
remotes/origin/KDE/4.0
Pino Toscano 20 years ago
parent 9a2b938431
commit 8def2109ec
  1. 4
      core/document.cpp
  2. 2
      core/document.h
  3. 4
      core/generator.cpp
  4. 3
      core/generator.h
  5. 10
      generators/chm/generator_chm.cpp
  6. 2
      generators/chm/generator_chm.h
  7. 12
      generators/poppler/generator_pdf.cpp
  8. 2
      generators/poppler/generator_pdf.h
  9. 6
      part.cpp
  10. 2
      ui/presentationwidget.cpp
  11. 2
      ui/toc.cpp

@ -641,9 +641,9 @@ bool Document::historyAtEnd() const
return d->viewportIterator == --(d->viewportHistory.end());
}
QString Document::getMetaData( const QString & key, const QString & option ) const
QVariant Document::getMetaData( const QString & key, const QVariant & option ) const
{
return generator ? generator->metaData( key, option ) : QString();
return generator ? generator->metaData( key, option ) : QVariant();
}
int Document::rotation() const

@ -115,7 +115,7 @@ class OKULAR_EXPORT Document : public QObject
bool exportTo( const QString& fileName, const ExportFormat& format ) const;
bool historyAtBegin() const;
bool historyAtEnd() const;
QString getMetaData( const QString & key, const QString & option = QString() ) const;
QVariant getMetaData( const QString & key, const QVariant & option = QVariant() ) const;
int rotation() const;
QSizeF allPagesSize() const;
QString pageSizeString(int page) const;

@ -125,9 +125,9 @@ bool Generator::print( KPrinter& )
return false;
}
QString Generator::metaData( const QString&, const QString& ) const
QVariant Generator::metaData( const QString&, const QVariant& ) const
{
return QString();
return QVariant();
}
bool Generator::reparseConfig()

@ -22,6 +22,7 @@
#include <QtCore/QList>
#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtCore/QVariant>
#include <QtCore/QVector>
#include <kmimetype.h>
@ -283,7 +284,7 @@ class OKULAR_EXPORT Generator : public QObject
* This method returns the meta data of the given @p key with the given @p option
* of the document.
*/
virtual QString metaData( const QString &key, const QString &option ) const;
virtual QVariant metaData( const QString &key, const QVariant &option ) const;
/**
* This method is called to tell the generator to re-parse its configuration.

@ -306,7 +306,7 @@ void CHMGenerator::additionalRequestData()
}
else
{
Okular::DocumentViewport viewport(metaData( "NamedViewport", '/' + url ));
Okular::DocumentViewport viewport( metaData( "NamedViewport", '/' + url ).toString() );
objRects.push_back(
new Okular::ObjectRect ( Okular::NormalizedRect(r,xScale,yScale),
false,
@ -371,12 +371,12 @@ bool CHMGenerator::supportsSearching() const
return true;
}
QString CHMGenerator::metaData( const QString &key, const QString &option ) const
QVariant CHMGenerator::metaData( const QString &key, const QVariant &option ) const
{
if ( key == "NamedViewport" && !option.isEmpty() )
if ( key == "NamedViewport" && !option.toString().isEmpty() )
{
Okular::DocumentViewport viewport;
viewport.pageNumber = m_file->getPageNum( option ) -1;
viewport.pageNumber = m_file->getPageNum( option.toString() ) -1;
if ( viewport.pageNumber >= 0 )
return viewport.toString();
}
@ -384,7 +384,7 @@ QString CHMGenerator::metaData( const QString &key, const QString &option ) cons
{
return m_file->Title();
}
return QString();
return QVariant();
}
/*

@ -45,7 +45,7 @@ class CHMGenerator : public Okular::Generator
bool supportsSearching() const;
QString metaData( const QString & key, const QString & option ) const;
QVariant metaData( const QString & key, const QVariant & option ) const;
public slots:
void slotCompleted();

@ -687,21 +687,21 @@ bool PDFGenerator::print( KPrinter& printer )
return false;
}
QString PDFGenerator::metaData( const QString & key, const QString & option ) const
QVariant PDFGenerator::metaData( const QString & key, const QVariant & option ) const
{
if ( key == "StartFullScreen" )
{
// asking for the 'start in fullscreen mode' (pdf property)
if ( pdfdoc->pageMode() == Poppler::Document::FullScreen )
return "yes";
return true;
}
else if ( key == "NamedViewport" && !option.isEmpty() )
else if ( key == "NamedViewport" && !option.toString().isEmpty() )
{
// asking for the page related to a 'named link destination'. the
// option is the link name. @see addSynopsisChildren.
Okular::DocumentViewport viewport;
docLock.lock();
Poppler::LinkDestination *ld = pdfdoc->linkDestination( option );
Poppler::LinkDestination *ld = pdfdoc->linkDestination( option.toString() );
docLock.unlock();
if ( ld )
{
@ -721,9 +721,9 @@ QString PDFGenerator::metaData( const QString & key, const QString & option ) co
else if ( key == "OpenTOC" )
{
if ( pdfdoc->pageMode() == Poppler::Document::UseOutlines )
return "yes";
return true;
}
return QString();
return QVariant();
}
bool PDFGenerator::reparseConfig()

@ -78,7 +78,7 @@ class PDFGenerator : public Okular::Generator
bool print( KPrinter& printer );
// [INHERITED] reply to some metadata requests
QString metaData( const QString & key, const QString & option ) const;
QVariant metaData( const QString & key, const QVariant & option ) const;
// [INHERITED] reparse configuration
bool reparseConfig();

@ -623,12 +623,12 @@ bool Part::openFile()
m_watcher->addFile(m_file);
// if the 'OpenTOC' flag is set, start presentation
if ( m_document->getMetaData( "OpenTOC" ) == "yes" && m_toolBox->isItemEnabled( 0 ) )
if ( m_document->getMetaData( "OpenTOC" ).toBool() && m_toolBox->isItemEnabled( 0 ) )
{
m_toolBox->setCurrentIndex( 0 );
}
// if the 'StartFullScreen' flag is set, start presentation
if ( m_document->getMetaData( "StartFullScreen" ) == "yes" )
if ( m_document->getMetaData( "StartFullScreen" ).toBool() )
{
KMessageBox::information( m_presentationWidget, i18n("The document is going to be launched on presentation mode because the file requested it."), QString::null, "autoPresentationWarning" );
slotShowPresentation();
@ -653,7 +653,7 @@ bool Part::openUrl(const KUrl &url)
m_viewportDirty.pageNumber = -1;
// if the document have a 'DocumentTitle' flag set (and it is not empty), set it as title
QString title = m_document->getMetaData( "DocumentTitle" );
QString title = m_document->getMetaData( "DocumentTitle" ).toString();
if ( !title.isEmpty() && !title.trimmed().isEmpty() )
{
emit setWindowCaption( title );

@ -65,7 +65,7 @@ PresentationWidget::PresentationWidget( QWidget * parent, Okular::Document * doc
setAttribute( Qt::WA_DeleteOnClose );
setAttribute( Qt::WA_OpaquePaintEvent );
setObjectName( "presentationWidget" );
QString caption = doc->getMetaData( "DocumentTitle" );
QString caption = doc->getMetaData( "DocumentTitle" ).toString();
if ( caption.trimmed().isEmpty() )
caption = doc->currentDocument().fileName();
setWindowTitle( KInstance::makeStdCaption( caption ) );

@ -213,7 +213,7 @@ Okular::DocumentViewport TOC::getViewport( const QDomElement &e ) const
{
// if the node references a viewport, get the reference and set it
const QString & page = e.attribute( "ViewportName" );
const QString & viewport = m_document->getMetaData( "NamedViewport", page );
QString viewport = m_document->getMetaData( "NamedViewport", page ).toString();
if ( !viewport.isNull() )
return Okular::DocumentViewport( viewport );
}

Loading…
Cancel
Save