mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-05 23:49:20 +00:00
Make documentInfo be Hash based instead of XML based
This commit is contained in:
parent
c5c3be9a1a
commit
e9e3d4a435
|
@ -2473,8 +2473,8 @@ void Document::closeDocument()
|
||||||
d->m_pageSize = PageSize();
|
d->m_pageSize = PageSize();
|
||||||
d->m_pageSizes.clear();
|
d->m_pageSizes.clear();
|
||||||
|
|
||||||
delete d->m_documentInfo;
|
d->m_documentInfo = DocumentInfo();
|
||||||
d->m_documentInfo = 0;
|
d->m_documentInfoAskedKeys.clear();
|
||||||
|
|
||||||
AudioPlayer::instance()->d->m_currentDocument = KUrl();
|
AudioPlayer::instance()->d->m_currentDocument = KUrl();
|
||||||
|
|
||||||
|
@ -2574,42 +2574,59 @@ bool Document::canConfigurePrinter( ) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DocumentInfo * Document::documentInfo() const
|
DocumentInfo Document::documentInfo() const
|
||||||
{
|
{
|
||||||
if ( d->m_documentInfo )
|
QSet<DocumentInfo::Key> keys;
|
||||||
return d->m_documentInfo;
|
for (Okular::DocumentInfo::Key ks = Okular::DocumentInfo::Title;
|
||||||
|
ks < Okular::DocumentInfo::Invalid;
|
||||||
if ( d->m_generator )
|
ks = Okular::DocumentInfo::Key( ks+1 ) )
|
||||||
{
|
{
|
||||||
DocumentInfo *info = new DocumentInfo();
|
keys << ks;
|
||||||
const DocumentInfo *tmp = d->m_generator->generateDocumentInfo();
|
}
|
||||||
if ( tmp )
|
|
||||||
*info = *tmp;
|
|
||||||
|
|
||||||
info->set( DocumentInfo::FilePath, currentDocument().prettyUrl() );
|
return documentInfo( keys );
|
||||||
const QString pagesSize = d->pagesSizeString();
|
}
|
||||||
if ( d->m_docSize != -1 )
|
|
||||||
|
DocumentInfo Document::documentInfo( const QSet<DocumentInfo::Key> &keys ) const
|
||||||
|
{
|
||||||
|
DocumentInfo result = d->m_documentInfo;
|
||||||
|
const QSet<DocumentInfo::Key> missingKeys = keys - d->m_documentInfoAskedKeys;
|
||||||
|
|
||||||
|
if ( d->m_generator && !missingKeys.isEmpty() )
|
||||||
|
{
|
||||||
|
DocumentInfo info = d->m_generator->generateDocumentInfo( missingKeys );
|
||||||
|
|
||||||
|
if ( missingKeys.contains( DocumentInfo::FilePath ) )
|
||||||
|
{
|
||||||
|
info.set( DocumentInfo::FilePath, currentDocument().prettyUrl() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( d->m_docSize != -1 && missingKeys.contains( DocumentInfo::DocumentSize ) )
|
||||||
{
|
{
|
||||||
const QString sizeString = KGlobal::locale()->formatByteSize( d->m_docSize );
|
const QString sizeString = KGlobal::locale()->formatByteSize( d->m_docSize );
|
||||||
info->set( DocumentInfo::DocumentSize, sizeString );
|
info.set( DocumentInfo::DocumentSize, sizeString );
|
||||||
}
|
}
|
||||||
if (!pagesSize.isEmpty())
|
if ( missingKeys.contains( DocumentInfo::PagesSize ) )
|
||||||
{
|
{
|
||||||
info->set( DocumentInfo::PagesSize, pagesSize );
|
const QString pagesSize = d->pagesSizeString();
|
||||||
|
if ( !pagesSize.isEmpty() )
|
||||||
|
{
|
||||||
|
info.set( DocumentInfo::PagesSize, pagesSize );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const DocumentInfo::Key keyPages = DocumentInfo::Pages;
|
if ( missingKeys.contains( DocumentInfo::Pages ) && info.get( DocumentInfo::Pages ).isEmpty() ) {
|
||||||
const QString keyString = DocumentInfo::getKeyString( keyPages );
|
info.set( DocumentInfo::Pages, QString::number( this->pages() ) );
|
||||||
|
|
||||||
if ( info->get( keyString ).isEmpty() ) {
|
|
||||||
info->set( keyString, QString::number( this->pages() ),
|
|
||||||
DocumentInfo::getKeyTitle( keyPages ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
d->m_documentInfo = info;
|
d->m_documentInfo.d->values.unite(info.d->values);
|
||||||
return info;
|
d->m_documentInfo.d->titles.unite(info.d->titles);
|
||||||
|
result.d->values.unite(info.d->values);
|
||||||
|
result.d->titles.unite(info.d->titles);
|
||||||
}
|
}
|
||||||
else return NULL;
|
d->m_documentInfoAskedKeys += keys;
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DocumentSynopsis * Document::documentSynopsis() const
|
const DocumentSynopsis * Document::documentSynopsis() const
|
||||||
|
@ -4641,52 +4658,51 @@ bool DocumentViewport::operator<( const DocumentViewport & vp ) const
|
||||||
|
|
||||||
/** DocumentInfo **/
|
/** DocumentInfo **/
|
||||||
|
|
||||||
DocumentInfo::DocumentInfo()
|
DocumentInfo::DocumentInfo() : d(new DocumentInfoPrivate())
|
||||||
: QDomDocument( "DocumentInformation" )
|
|
||||||
{
|
{
|
||||||
QDomElement docElement = createElement( "DocumentInfo" );
|
|
||||||
appendChild( docElement );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentInfo::set( const QString &key, const QString &value,
|
DocumentInfo::DocumentInfo(const DocumentInfo &info) : d(new DocumentInfoPrivate())
|
||||||
const QString &title )
|
|
||||||
{
|
{
|
||||||
QDomElement docElement = documentElement();
|
*this = info;
|
||||||
QDomElement element;
|
}
|
||||||
|
|
||||||
// check whether key already exists
|
DocumentInfo& DocumentInfo::operator=(const DocumentInfo &info)
|
||||||
QDomNodeList list = docElement.elementsByTagName( key );
|
{
|
||||||
if ( list.count() > 0 )
|
d->values = info.d->values;
|
||||||
element = list.item( 0 ).toElement();
|
d->titles = info.d->titles;
|
||||||
else
|
return *this;
|
||||||
element = createElement( key );
|
}
|
||||||
|
|
||||||
element.setAttribute( "value", value );
|
DocumentInfo::~DocumentInfo()
|
||||||
element.setAttribute( "title", title );
|
{
|
||||||
|
delete d;
|
||||||
|
}
|
||||||
|
|
||||||
if ( list.count() == 0 )
|
void DocumentInfo::set( const QString &key, const QString &value, const QString &title )
|
||||||
docElement.appendChild( element );
|
{
|
||||||
|
d->values[ key ] = value;
|
||||||
|
d->titles[ key ] = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentInfo::set( Key key, const QString &value )
|
void DocumentInfo::set( Key key, const QString &value )
|
||||||
{
|
{
|
||||||
const QString keyString = getKeyString( key );
|
d->values[ getKeyString( key ) ] = value;
|
||||||
if ( !keyString.isEmpty() )
|
}
|
||||||
set( keyString, value, getKeyTitle( key ) );
|
|
||||||
else
|
QStringList DocumentInfo::keys() const
|
||||||
kWarning(OkularDebug) << "Invalid key passed";
|
{
|
||||||
|
return d->values.keys();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DocumentInfo::get( Key key ) const
|
||||||
|
{
|
||||||
|
return get( getKeyString( key ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DocumentInfo::get( const QString &key ) const
|
QString DocumentInfo::get( const QString &key ) const
|
||||||
{
|
{
|
||||||
const QDomElement docElement = documentElement();
|
return d->values[ key ];
|
||||||
|
|
||||||
// check whether key already exists
|
|
||||||
const QDomNodeList list = docElement.elementsByTagName( key );
|
|
||||||
if ( list.count() > 0 )
|
|
||||||
return list.item( 0 ).toElement().attribute( "value" );
|
|
||||||
else
|
|
||||||
return QString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DocumentInfo::getKeyString( Key key ) //const
|
QString DocumentInfo::getKeyString( Key key ) //const
|
||||||
|
@ -4741,11 +4757,33 @@ QString DocumentInfo::getKeyString( Key key ) //const
|
||||||
return "pageSize";
|
return "pageSize";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
kWarning() << "Unknown" << key;
|
||||||
return QString();
|
return QString();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DocumentInfo::Key DocumentInfo::getKeyFromString( const QString &key ) //const
|
||||||
|
{
|
||||||
|
if (key == "title") return Title;
|
||||||
|
else if (key == "subject") return Subject;
|
||||||
|
else if (key == "description") return Description;
|
||||||
|
else if (key == "author") return Author;
|
||||||
|
else if (key == "creator") return Creator;
|
||||||
|
else if (key == "producer") return Producer;
|
||||||
|
else if (key == "copyright") return Copyright;
|
||||||
|
else if (key == "pages") return Pages;
|
||||||
|
else if (key == "creationDate") return CreationDate;
|
||||||
|
else if (key == "modificationDate") return ModificationDate;
|
||||||
|
else if (key == "mimeType") return MimeType;
|
||||||
|
else if (key == "category") return Category;
|
||||||
|
else if (key == "keywords") return Keywords;
|
||||||
|
else if (key == "filePath") return FilePath;
|
||||||
|
else if (key == "documentSize") return DocumentSize;
|
||||||
|
else if (key == "pageSize") return PagesSize;
|
||||||
|
else return Invalid;
|
||||||
|
}
|
||||||
|
|
||||||
QString DocumentInfo::getKeyTitle( Key key ) //const
|
QString DocumentInfo::getKeyTitle( Key key ) //const
|
||||||
{
|
{
|
||||||
switch ( key ) {
|
switch ( key ) {
|
||||||
|
@ -4803,6 +4841,15 @@ QString DocumentInfo::getKeyTitle( Key key ) //const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString DocumentInfo::getKeyTitle( const QString &key ) const
|
||||||
|
{
|
||||||
|
QString title = getKeyTitle ( getKeyFromString( key ) );
|
||||||
|
if ( title.isEmpty() )
|
||||||
|
title = d->titles[ key ];
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** DocumentSynopsis **/
|
/** DocumentSynopsis **/
|
||||||
|
|
||||||
|
|
186
core/document.h
186
core/document.h
|
@ -36,7 +36,7 @@ namespace Okular {
|
||||||
|
|
||||||
class Annotation;
|
class Annotation;
|
||||||
class BookmarkManager;
|
class BookmarkManager;
|
||||||
class DocumentInfo;
|
class DocumentInfoPrivate;
|
||||||
class DocumentObserver;
|
class DocumentObserver;
|
||||||
class DocumentPrivate;
|
class DocumentPrivate;
|
||||||
class DocumentSynopsis;
|
class DocumentSynopsis;
|
||||||
|
@ -63,6 +63,110 @@ class VisiblePageRect;
|
||||||
#define SW_SEARCH_ID 3
|
#define SW_SEARCH_ID 3
|
||||||
#define PRESENTATION_SEARCH_ID 4
|
#define PRESENTATION_SEARCH_ID 4
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The DocumentInfo structure can be filled in by generators to display
|
||||||
|
* metadata about the currently opened file.
|
||||||
|
*/
|
||||||
|
class OKULAR_EXPORT DocumentInfo
|
||||||
|
{
|
||||||
|
friend class Document;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* The list of predefined keys.
|
||||||
|
*/
|
||||||
|
enum Key {
|
||||||
|
Title, ///< The title of the document
|
||||||
|
Subject, ///< The subject of the document
|
||||||
|
Description, ///< The description of the document
|
||||||
|
Author, ///< The author of the document
|
||||||
|
Creator, ///< The creator of the document (this can be different from the author)
|
||||||
|
Producer, ///< The producer of the document (e.g. some software)
|
||||||
|
Copyright, ///< The copyright of the document
|
||||||
|
Pages, ///< The number of pages of the document
|
||||||
|
CreationDate, ///< The date of creation of the document
|
||||||
|
ModificationDate, ///< The date of last modification of the document
|
||||||
|
MimeType, ///< The mime type of the document
|
||||||
|
Category, ///< The category of the document
|
||||||
|
Keywords, ///< The keywords which describe the content of the document
|
||||||
|
FilePath, ///< The path of the file @since 0.10 (KDE 4.4)
|
||||||
|
DocumentSize, ///< The size of the document @since 0.10 (KDE 4.4)
|
||||||
|
PagesSize, ///< The size of the pages (if all pages have the same size) @since 0.10 (KDE 4.4)
|
||||||
|
CustomKeys, ///< All the custom keys the generator supports @since 0.21
|
||||||
|
Invalid ///< An invalid key @since 0.21. It will always be the last element in the enum
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new document info.
|
||||||
|
*/
|
||||||
|
DocumentInfo();
|
||||||
|
DocumentInfo(const DocumentInfo &info);
|
||||||
|
DocumentInfo& operator=( const DocumentInfo& );
|
||||||
|
|
||||||
|
~DocumentInfo();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all the keys present in this DocumentInfo
|
||||||
|
*
|
||||||
|
* @since 0.21
|
||||||
|
*/
|
||||||
|
QStringList keys() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value for a given key or an null string when the
|
||||||
|
* key doesn't exist.
|
||||||
|
*/
|
||||||
|
QString get( Key key ) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value for a given key or an null string when the
|
||||||
|
* key doesn't exist.
|
||||||
|
*/
|
||||||
|
QString get( const QString &key ) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a value for a custom key. The title should be an i18n'ed
|
||||||
|
* string, since it's used in the document information dialog.
|
||||||
|
*/
|
||||||
|
void set( const QString &key, const QString &value,
|
||||||
|
const QString &title = QString() );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a value for a special key. The title should be an i18n'ed
|
||||||
|
* string, since it's used in the document information dialog.
|
||||||
|
*/
|
||||||
|
void set( Key key, const QString &value );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the user visible string for the given key
|
||||||
|
* Takes into account keys added by the set() that takes a QString
|
||||||
|
*
|
||||||
|
* @since 0.21
|
||||||
|
*/
|
||||||
|
QString getKeyTitle( const QString &key ) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the internal string for the given key
|
||||||
|
* @since 0.10 (KDE 4.4)
|
||||||
|
*/
|
||||||
|
static QString getKeyString( Key key );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the user visible string for the given key
|
||||||
|
* @since 0.10 (KDE 4.4)
|
||||||
|
*/
|
||||||
|
static QString getKeyTitle( Key key );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Key from a string key
|
||||||
|
* @since 0.21
|
||||||
|
*/
|
||||||
|
static Key getKeyFromString( const QString &key );
|
||||||
|
|
||||||
|
private:
|
||||||
|
DocumentInfoPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @short The Document. Heart of everything. Actions take place here.
|
* @short The Document. Heart of everything. Actions take place here.
|
||||||
|
@ -139,10 +243,15 @@ class OKULAR_EXPORT Document : public QObject
|
||||||
bool isOpened() const;
|
bool isOpened() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the meta data of the document or 0 if no meta data
|
* Returns the meta data of the document.
|
||||||
* are available.
|
|
||||||
*/
|
*/
|
||||||
const DocumentInfo * documentInfo() const;
|
DocumentInfo documentInfo() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the asked set of meta data of the document. The result may contain more
|
||||||
|
* metadata than the one asked for.
|
||||||
|
*/
|
||||||
|
DocumentInfo documentInfo( const QSet<DocumentInfo::Key> &keys ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the table of content of the document or 0 if no
|
* Returns the table of content of the document or 0 if no
|
||||||
|
@ -1077,75 +1186,6 @@ class OKULAR_EXPORT DocumentViewport
|
||||||
} autoFit;
|
} autoFit;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @short A DOM tree containing information about the document.
|
|
||||||
*
|
|
||||||
* The DocumentInfo structure can be filled in by generators to display
|
|
||||||
* metadata about the currently opened file.
|
|
||||||
*/
|
|
||||||
class OKULAR_EXPORT DocumentInfo : public QDomDocument
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* The list of predefined keys.
|
|
||||||
*/
|
|
||||||
enum Key {
|
|
||||||
Title, ///< The title of the document
|
|
||||||
Subject, ///< The subject of the document
|
|
||||||
Description, ///< The description of the document
|
|
||||||
Author, ///< The author of the document
|
|
||||||
Creator, ///< The creator of the document (this can be different from the author)
|
|
||||||
Producer, ///< The producer of the document (e.g. some software)
|
|
||||||
Copyright, ///< The copyright of the document
|
|
||||||
Pages, ///< The number of pages of the document
|
|
||||||
CreationDate, ///< The date of creation of the document
|
|
||||||
ModificationDate, ///< The date of last modification of the document
|
|
||||||
MimeType, ///< The mime type of the document
|
|
||||||
Category, ///< The category of the document
|
|
||||||
Keywords, ///< The keywords which describe the content of the document
|
|
||||||
FilePath, ///< The path of the file @since 0.10 (KDE 4.4)
|
|
||||||
DocumentSize, ///< The size of the document @since 0.10 (KDE 4.4)
|
|
||||||
PagesSize ///< The size of the pages (if all pages have the same size) @since 0.10 (KDE 4.4)
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new document info.
|
|
||||||
*/
|
|
||||||
DocumentInfo();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a value for a special key. The title should be an i18n'ed
|
|
||||||
* string, since it's used in the document information dialog.
|
|
||||||
*/
|
|
||||||
void set( const QString &key, const QString &value,
|
|
||||||
const QString &title = QString() );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the value for a predefined key. You should use this method
|
|
||||||
* whenever a predefined key exists for your value.
|
|
||||||
*/
|
|
||||||
void set( Key key, const QString &value );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the value for a given key or an empty string when the
|
|
||||||
* key doesn't exist.
|
|
||||||
*/
|
|
||||||
QString get( const QString &key ) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the internal string for the given key
|
|
||||||
* @since 0.10 (KDE 4.4)
|
|
||||||
*/
|
|
||||||
static QString getKeyString( Key key );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the user visible string for the given key
|
|
||||||
* @since 0.10 (KDE 4.4)
|
|
||||||
*/
|
|
||||||
static QString getKeyTitle( Key key );
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @short A DOM tree that describes the Table of Contents.
|
* @short A DOM tree that describes the Table of Contents.
|
||||||
*
|
*
|
||||||
|
|
|
@ -96,7 +96,6 @@ class DocumentPrivate
|
||||||
m_scripter( 0 ),
|
m_scripter( 0 ),
|
||||||
m_archiveData( 0 ),
|
m_archiveData( 0 ),
|
||||||
m_fontsCached( false ),
|
m_fontsCached( false ),
|
||||||
m_documentInfo( 0 ),
|
|
||||||
m_annotationEditingEnabled ( true ),
|
m_annotationEditingEnabled ( true ),
|
||||||
m_annotationBeingMoved( false )
|
m_annotationBeingMoved( false )
|
||||||
{
|
{
|
||||||
|
@ -258,7 +257,8 @@ class DocumentPrivate
|
||||||
|
|
||||||
QPointer< FontExtractionThread > m_fontThread;
|
QPointer< FontExtractionThread > m_fontThread;
|
||||||
bool m_fontsCached;
|
bool m_fontsCached;
|
||||||
DocumentInfo *m_documentInfo;
|
QSet<DocumentInfo::Key> m_documentInfoAskedKeys;
|
||||||
|
DocumentInfo m_documentInfo;
|
||||||
FontInfo::List m_fontsCache;
|
FontInfo::List m_fontsCache;
|
||||||
|
|
||||||
QSet< View * > m_views;
|
QSet< View * > m_views;
|
||||||
|
@ -272,6 +272,13 @@ class DocumentPrivate
|
||||||
QDomNode m_prevPropsOfAnnotBeingModified;
|
QDomNode m_prevPropsOfAnnotBeingModified;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DocumentInfoPrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QMap<QString, QString> values; // key -> value
|
||||||
|
QMap<QString, QString> titles; // key -> title For the custom keys
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -290,9 +290,9 @@ TextPage* Generator::textPage( Page* )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DocumentInfo * Generator::generateDocumentInfo()
|
DocumentInfo Generator::generateDocumentInfo(const QSet<DocumentInfo::Key> &keys) const
|
||||||
{
|
{
|
||||||
return 0;
|
return DocumentInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
const DocumentSynopsis * Generator::generateDocumentSynopsis()
|
const DocumentSynopsis * Generator::generateDocumentSynopsis()
|
||||||
|
|
|
@ -308,10 +308,9 @@ class OKULAR_EXPORT Generator : public QObject
|
||||||
virtual void generateTextPage( Page * page );
|
virtual void generateTextPage( Page * page );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the general information object of the document or 0 if
|
* Returns the general information object of the document.
|
||||||
* no information are available.
|
|
||||||
*/
|
*/
|
||||||
virtual const DocumentInfo * generateDocumentInfo();
|
virtual DocumentInfo generateDocumentInfo( const QSet<DocumentInfo::Key> &keys ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the 'table of content' object of the document or 0 if
|
* Returns the 'table of content' object of the document or 0 if
|
||||||
|
|
|
@ -135,12 +135,17 @@ static KJSObject docGetInfo( KJSContext *ctx, void *object )
|
||||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
|
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
|
||||||
|
|
||||||
KJSObject obj;
|
KJSObject obj;
|
||||||
const DocumentInfo *docinfo = doc->m_generator->generateDocumentInfo();
|
QSet<DocumentInfo::Key> keys;
|
||||||
if ( docinfo )
|
keys << DocumentInfo::Title
|
||||||
{
|
<< DocumentInfo::Author
|
||||||
|
<< DocumentInfo::Subject
|
||||||
|
<< DocumentInfo::Keywords
|
||||||
|
<< DocumentInfo::Creator
|
||||||
|
<< DocumentInfo::Producer;
|
||||||
|
const DocumentInfo docinfo = doc->m_parent->documentInfo( keys );
|
||||||
#define KEY_GET( key, property ) \
|
#define KEY_GET( key, property ) \
|
||||||
do { \
|
do { \
|
||||||
const QString data = docinfo->get( key ); \
|
const QString data = docinfo.get( key ); \
|
||||||
if ( !data.isEmpty() ) \
|
if ( !data.isEmpty() ) \
|
||||||
{ \
|
{ \
|
||||||
const KJSString newval( data ); \
|
const KJSString newval( data ); \
|
||||||
|
@ -148,14 +153,13 @@ do { \
|
||||||
obj.setProperty( ctx, QString( property ).toLower(), newval ); \
|
obj.setProperty( ctx, QString( property ).toLower(), newval ); \
|
||||||
} \
|
} \
|
||||||
} while ( 0 );
|
} while ( 0 );
|
||||||
KEY_GET( "title", "Title" );
|
KEY_GET( DocumentInfo::Title, "Title" );
|
||||||
KEY_GET( "author", "Author" );
|
KEY_GET( DocumentInfo::Author, "Author" );
|
||||||
KEY_GET( "subject", "Subject" );
|
KEY_GET( DocumentInfo::Subject, "Subject" );
|
||||||
KEY_GET( "keywords", "Keywords" );
|
KEY_GET( DocumentInfo::Keywords, "Keywords" );
|
||||||
KEY_GET( "creator", "Creator" );
|
KEY_GET( DocumentInfo::Creator, "Creator" );
|
||||||
KEY_GET( "producer", "Producer" );
|
KEY_GET( DocumentInfo::Producer, "Producer" );
|
||||||
#undef KEY_GET
|
#undef KEY_GET
|
||||||
}
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,16 +167,16 @@ do { \
|
||||||
static KJSObject docGet ## name( KJSContext *, void *object ) \
|
static KJSObject docGet ## name( KJSContext *, void *object ) \
|
||||||
{ \
|
{ \
|
||||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object ); \
|
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object ); \
|
||||||
const DocumentInfo *docinfo = doc->m_generator->generateDocumentInfo(); \
|
const DocumentInfo docinfo = doc->m_parent->documentInfo(QSet<DocumentInfo::Key>() << key ); \
|
||||||
return KJSString( docinfo->get( key ) ); \
|
return KJSString( docinfo.get( key ) ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
DOCINFO_GET_METHOD( "author", Author )
|
DOCINFO_GET_METHOD( DocumentInfo::Author, Author )
|
||||||
DOCINFO_GET_METHOD( "creator", Creator )
|
DOCINFO_GET_METHOD( DocumentInfo::Creator, Creator )
|
||||||
DOCINFO_GET_METHOD( "keywords", Keywords )
|
DOCINFO_GET_METHOD( DocumentInfo::Keywords, Keywords )
|
||||||
DOCINFO_GET_METHOD( "producer", Producer )
|
DOCINFO_GET_METHOD( DocumentInfo::Producer, Producer )
|
||||||
DOCINFO_GET_METHOD( "title", Title )
|
DOCINFO_GET_METHOD( DocumentInfo::Title, Title )
|
||||||
DOCINFO_GET_METHOD( "subject", Subject )
|
DOCINFO_GET_METHOD( DocumentInfo::Subject, Subject )
|
||||||
|
|
||||||
#undef DOCINFO_GET_METHOD
|
#undef DOCINFO_GET_METHOD
|
||||||
|
|
||||||
|
|
|
@ -453,10 +453,10 @@ bool TextDocumentGenerator::print( QPrinter& printer )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentInfo* TextDocumentGenerator::generateDocumentInfo()
|
Okular::DocumentInfo TextDocumentGenerator::generateDocumentInfo( const QSet<DocumentInfo::Key> & /*keys*/ ) const
|
||||||
{
|
{
|
||||||
Q_D( TextDocumentGenerator );
|
Q_D( const TextDocumentGenerator );
|
||||||
return &d->mDocumentInfo;
|
return d->mDocumentInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentSynopsis* TextDocumentGenerator::generateDocumentSynopsis()
|
const Okular::DocumentSynopsis* TextDocumentGenerator::generateDocumentSynopsis()
|
||||||
|
@ -473,7 +473,7 @@ QVariant TextDocumentGeneratorPrivate::metaData( const QString &key, const QVari
|
||||||
Q_UNUSED( option )
|
Q_UNUSED( option )
|
||||||
if ( key == "DocumentTitle" )
|
if ( key == "DocumentTitle" )
|
||||||
{
|
{
|
||||||
return mDocumentInfo.get( "title" );
|
return mDocumentInfo.get( DocumentInfo::Title );
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@ class OKULAR_EXPORT TextDocumentGenerator : public Generator, public Okular::Con
|
||||||
*/
|
*/
|
||||||
TextDocumentSettings* generalSettings();
|
TextDocumentSettings* generalSettings();
|
||||||
|
|
||||||
const Okular::DocumentInfo* generateDocumentInfo();
|
Okular::DocumentInfo generateDocumentInfo( const QSet<DocumentInfo::Key> &keys ) const;
|
||||||
const Okular::DocumentSynopsis* generateDocumentSynopsis();
|
const Okular::DocumentSynopsis* generateDocumentSynopsis();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -71,7 +71,6 @@ CHMGenerator::CHMGenerator( QObject *parent, const QVariantList &args )
|
||||||
|
|
||||||
m_syncGen=0;
|
m_syncGen=0;
|
||||||
m_file=0;
|
m_file=0;
|
||||||
m_docInfo=0;
|
|
||||||
m_pixmapRequestZoom=1;
|
m_pixmapRequestZoom=1;
|
||||||
m_request = 0;
|
m_request = 0;
|
||||||
}
|
}
|
||||||
|
@ -163,8 +162,6 @@ bool CHMGenerator::loadDocument( const QString & fileName, QVector< Okular::Page
|
||||||
bool CHMGenerator::doCloseDocument()
|
bool CHMGenerator::doCloseDocument()
|
||||||
{
|
{
|
||||||
// delete the document information of the old document
|
// delete the document information of the old document
|
||||||
delete m_docInfo;
|
|
||||||
m_docInfo=0;
|
|
||||||
delete m_file;
|
delete m_file;
|
||||||
m_file=0;
|
m_file=0;
|
||||||
m_textpageAddedList.clear();
|
m_textpageAddedList.clear();
|
||||||
|
@ -234,16 +231,14 @@ void CHMGenerator::slotCompleted()
|
||||||
signalPixmapRequestDone( req );
|
signalPixmapRequestDone( req );
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentInfo * CHMGenerator::generateDocumentInfo()
|
Okular::DocumentInfo CHMGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
|
||||||
{
|
{
|
||||||
if (!m_docInfo)
|
Okular::DocumentInfo docInfo;
|
||||||
{
|
if ( keys.contains( Okular::DocumentInfo::MimeType ) )
|
||||||
m_docInfo=new Okular::DocumentInfo();
|
docInfo.set( Okular::DocumentInfo::MimeType, "application/x-chm" );
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::Title ) )
|
||||||
m_docInfo->set( Okular::DocumentInfo::MimeType, "application/x-chm" );
|
docInfo.set( Okular::DocumentInfo::Title, m_file->title() );
|
||||||
m_docInfo->set( Okular::DocumentInfo::Title, m_file->title() );
|
return docInfo;
|
||||||
}
|
|
||||||
return m_docInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentSynopsis * CHMGenerator::generateDocumentSynopsis()
|
const Okular::DocumentSynopsis * CHMGenerator::generateDocumentSynopsis()
|
||||||
|
|
|
@ -36,7 +36,7 @@ class CHMGenerator : public Okular::Generator
|
||||||
~CHMGenerator();
|
~CHMGenerator();
|
||||||
bool loadDocument( const QString & fileName, QVector< Okular::Page * > & pagesVector );
|
bool loadDocument( const QString & fileName, QVector< Okular::Page * > & pagesVector );
|
||||||
|
|
||||||
const Okular::DocumentInfo * generateDocumentInfo();
|
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
|
||||||
const Okular::DocumentSynopsis * generateDocumentSynopsis();
|
const Okular::DocumentSynopsis * generateDocumentSynopsis();
|
||||||
|
|
||||||
bool canGeneratePixmap() const;
|
bool canGeneratePixmap() const;
|
||||||
|
@ -64,7 +64,6 @@ class CHMGenerator : public Okular::Generator
|
||||||
QString m_chmUrl;
|
QString m_chmUrl;
|
||||||
Okular::PixmapRequest* m_request;
|
Okular::PixmapRequest* m_request;
|
||||||
int m_pixmapRequestZoom;
|
int m_pixmapRequestZoom;
|
||||||
Okular::DocumentInfo* m_docInfo;
|
|
||||||
QBitArray m_textpageAddedList;
|
QBitArray m_textpageAddedList;
|
||||||
QBitArray m_rectsGenerated;
|
QBitArray m_rectsGenerated;
|
||||||
};
|
};
|
||||||
|
|
|
@ -84,7 +84,7 @@ static KAboutData createAboutData()
|
||||||
OKULAR_EXPORT_PLUGIN( DjVuGenerator, createAboutData() )
|
OKULAR_EXPORT_PLUGIN( DjVuGenerator, createAboutData() )
|
||||||
|
|
||||||
DjVuGenerator::DjVuGenerator( QObject *parent, const QVariantList &args )
|
DjVuGenerator::DjVuGenerator( QObject *parent, const QVariantList &args )
|
||||||
: Okular::Generator( parent, args ), m_docInfo( 0 ), m_docSyn( 0 )
|
: Okular::Generator( parent, args ), m_docSyn( 0 )
|
||||||
{
|
{
|
||||||
setFeature( TextExtraction );
|
setFeature( TextExtraction );
|
||||||
setFeature( Threaded );
|
setFeature( Threaded );
|
||||||
|
@ -120,8 +120,6 @@ bool DjVuGenerator::doCloseDocument()
|
||||||
m_djvu->closeFile();
|
m_djvu->closeFile();
|
||||||
userMutex()->unlock();
|
userMutex()->unlock();
|
||||||
|
|
||||||
delete m_docInfo;
|
|
||||||
m_docInfo = 0;
|
|
||||||
delete m_docSyn;
|
delete m_docSyn;
|
||||||
m_docSyn = 0;
|
m_docSyn = 0;
|
||||||
|
|
||||||
|
@ -136,48 +134,34 @@ QImage DjVuGenerator::image( Okular::PixmapRequest *request )
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentInfo * DjVuGenerator::generateDocumentInfo()
|
Okular::DocumentInfo DjVuGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
|
||||||
{
|
{
|
||||||
if ( m_docInfo )
|
Okular::DocumentInfo docInfo;
|
||||||
return m_docInfo;
|
|
||||||
|
|
||||||
m_docInfo = new Okular::DocumentInfo();
|
if ( keys.contains( Okular::DocumentInfo::MimeType ) )
|
||||||
|
docInfo.set( Okular::DocumentInfo::MimeType, "image/vnd.djvu" );
|
||||||
m_docInfo->set( Okular::DocumentInfo::MimeType, "image/vnd.djvu" );
|
|
||||||
|
|
||||||
if ( m_djvu )
|
if ( m_djvu )
|
||||||
{
|
{
|
||||||
// compile internal structure reading properties from KDjVu
|
// compile internal structure reading properties from KDjVu
|
||||||
QString title = m_djvu->metaData( "title" ).toString();
|
if ( keys.contains( Okular::DocumentInfo::Author ) )
|
||||||
m_docInfo->set( Okular::DocumentInfo::Title, title.isEmpty() ? i18nc( "Unknown title", "Unknown" ) : title );
|
docInfo.set( Okular::DocumentInfo::Title, m_djvu->metaData( "title" ).toString() );
|
||||||
QString author = m_djvu->metaData( "author" ).toString();
|
if ( keys.contains( Okular::DocumentInfo::Author ) )
|
||||||
m_docInfo->set( Okular::DocumentInfo::Author, author.isEmpty() ? i18nc( "Unknown author", "Unknown" ) : author );
|
docInfo.set( Okular::DocumentInfo::Author, m_djvu->metaData( "author" ).toString() );
|
||||||
QString editor = m_djvu->metaData( "editor" ).toString();
|
if ( keys.contains( Okular::DocumentInfo::CreationDate ) )
|
||||||
m_docInfo->set( "editor", editor.isEmpty() ? i18nc( "Unknown editor", "Unknown" ) : editor, i18n( "Editor" ) );
|
docInfo.set( Okular::DocumentInfo::CreationDate, m_djvu->metaData( "year" ).toString() );
|
||||||
QString publisher = m_djvu->metaData( "publisher" ).toString();
|
if ( keys.contains( Okular::DocumentInfo::CustomKeys ) )
|
||||||
m_docInfo->set( "publisher", publisher.isEmpty() ? i18nc( "Unknown publisher", "Unknown" ) : publisher, i18n( "Publisher" ) );
|
{
|
||||||
QString year = m_djvu->metaData( "year" ).toString();
|
docInfo.set( "editor", m_djvu->metaData( "editor" ).toString(), i18n( "Editor" ) );
|
||||||
m_docInfo->set( Okular::DocumentInfo::CreationDate, year.isEmpty() ? i18nc( "Unknown creation date", "Unknown" ) : year );
|
docInfo.set( "publisher", m_djvu->metaData( "publisher" ).toString(), i18n( "Publisher" ) );
|
||||||
QString volume = m_djvu->metaData( "volume" ).toString();
|
docInfo.set( "volume", m_djvu->metaData( "volume" ).toString(), i18n( "Volume" ) );
|
||||||
m_docInfo->set( "volume", volume.isEmpty() ? i18nc( "Unknown volume information", "Unknown" ) : volume, i18n( "Volume" ) );
|
docInfo.set( "documentType", m_djvu->metaData( "documentType" ).toString(), i18n( "Type of document" ) );
|
||||||
QString doctype = m_djvu->metaData( "documentType" ).toString();
|
QVariant numcomponents = m_djvu->metaData( "componentFile" );
|
||||||
m_docInfo->set( "documentType", doctype.isEmpty() ? i18nc( "Unknown type of document", "Unknown" ) : doctype, i18n( "Type of document" ) );
|
docInfo.set( "componentFile", numcomponents.type() != QVariant::Int ? i18nc( "Unknown number of component files", "Unknown" ) : numcomponents.toString(), i18n( "Component Files" ) );
|
||||||
QVariant numcomponents = m_djvu->metaData( "componentFile" );
|
}
|
||||||
m_docInfo->set( "componentFile", numcomponents.type() != QVariant::Int ? i18nc( "Unknown number of component files", "Unknown" ) : numcomponents.toString(), i18n( "Component Files" ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_docInfo->set( Okular::DocumentInfo::Title, i18nc( "Unknown title", "Unknown" ) );
|
|
||||||
m_docInfo->set( Okular::DocumentInfo::Author, i18nc( "Unknown author", "Unknown" ) );
|
|
||||||
m_docInfo->set( "editor", i18nc( "Unknown editor", "Unknown" ), i18n( "Editor" ) );
|
|
||||||
m_docInfo->set( "publisher", i18nc( "Unknown publisher", "Unknown" ), i18n( "Publisher" ) );
|
|
||||||
m_docInfo->set( Okular::DocumentInfo::CreationDate, i18nc( "Unknown creation date", "Unknown" ) );
|
|
||||||
m_docInfo->set( "volume", i18nc( "Unknown volume information", "Unknown" ), i18n( "Volume" ) );
|
|
||||||
m_docInfo->set( "documentType", i18nc( "Unknown type of document", "Unknown" ), i18n( "Type of document" ) );
|
|
||||||
m_docInfo->set( "componentFile", i18nc( "Unknown number of component files", "Unknown" ), i18n( "Component Files" ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_docInfo;
|
return docInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentSynopsis * DjVuGenerator::generateDocumentSynopsis()
|
const Okular::DocumentSynopsis * DjVuGenerator::generateDocumentSynopsis()
|
||||||
|
|
|
@ -30,7 +30,7 @@ class DjVuGenerator : public Okular::Generator
|
||||||
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
|
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
|
||||||
|
|
||||||
// document information
|
// document information
|
||||||
const Okular::DocumentInfo * generateDocumentInfo();
|
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
|
||||||
const Okular::DocumentSynopsis * generateDocumentSynopsis();
|
const Okular::DocumentSynopsis * generateDocumentSynopsis();
|
||||||
|
|
||||||
// printing
|
// printing
|
||||||
|
@ -51,7 +51,6 @@ class DjVuGenerator : public Okular::Generator
|
||||||
|
|
||||||
KDjVu *m_djvu;
|
KDjVu *m_djvu;
|
||||||
|
|
||||||
Okular::DocumentInfo *m_docInfo;
|
|
||||||
Okular::DocumentSynopsis *m_docSyn;
|
Okular::DocumentSynopsis *m_docSyn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ static KAboutData createAboutData()
|
||||||
OKULAR_EXPORT_PLUGIN( DviGenerator, createAboutData() )
|
OKULAR_EXPORT_PLUGIN( DviGenerator, createAboutData() )
|
||||||
|
|
||||||
DviGenerator::DviGenerator( QObject *parent, const QVariantList &args ) : Okular::Generator( parent, args ),
|
DviGenerator::DviGenerator( QObject *parent, const QVariantList &args ) : Okular::Generator( parent, args ),
|
||||||
m_fontExtracted( false ), m_docInfo( 0 ), m_docSynopsis( 0 ), m_dviRenderer( 0 )
|
m_fontExtracted( false ), m_docSynopsis( 0 ), m_dviRenderer( 0 )
|
||||||
{
|
{
|
||||||
setFeature( Threaded );
|
setFeature( Threaded );
|
||||||
setFeature( TextExtraction );
|
setFeature( TextExtraction );
|
||||||
|
@ -130,8 +130,6 @@ bool DviGenerator::loadDocument( const QString & fileName, QVector< Okular::Page
|
||||||
|
|
||||||
bool DviGenerator::doCloseDocument()
|
bool DviGenerator::doCloseDocument()
|
||||||
{
|
{
|
||||||
delete m_docInfo;
|
|
||||||
m_docInfo = 0;
|
|
||||||
delete m_docSynopsis;
|
delete m_docSynopsis;
|
||||||
m_docSynopsis = 0;
|
m_docSynopsis = 0;
|
||||||
delete m_dviRenderer;
|
delete m_dviRenderer;
|
||||||
|
@ -335,14 +333,12 @@ Okular::TextPage *DviGenerator::extractTextFromPage( dviPageInfo *pageInfo )
|
||||||
return ktp;
|
return ktp;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentInfo *DviGenerator::generateDocumentInfo()
|
Okular::DocumentInfo DviGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
|
||||||
{
|
{
|
||||||
if ( m_docInfo )
|
Okular::DocumentInfo docInfo;
|
||||||
return m_docInfo;
|
|
||||||
|
|
||||||
m_docInfo = new Okular::DocumentInfo();
|
if ( keys.contains( Okular::DocumentInfo::MimeType ) )
|
||||||
|
docInfo.set( Okular::DocumentInfo::MimeType, "application/x-dvi" );
|
||||||
m_docInfo->set( Okular::DocumentInfo::MimeType, "application/x-dvi" );
|
|
||||||
|
|
||||||
QMutexLocker lock( userMutex() );
|
QMutexLocker lock( userMutex() );
|
||||||
|
|
||||||
|
@ -351,12 +347,13 @@ const Okular::DocumentInfo *DviGenerator::generateDocumentInfo()
|
||||||
dvifile *dvif = m_dviRenderer->dviFile;
|
dvifile *dvif = m_dviRenderer->dviFile;
|
||||||
|
|
||||||
// read properties from dvif
|
// read properties from dvif
|
||||||
//m_docInfo->set( "filename", dvif->filename, i18n("Filename") );
|
//docInfo.set( "filename", dvif->filename, i18n("Filename") );
|
||||||
m_docInfo->set( "generatorDate", dvif->generatorString,
|
if ( keys.contains( Okular::DocumentInfo::CustomKeys ) )
|
||||||
i18n("Generator/Date") );
|
docInfo.set( "generatorDate", dvif->generatorString, i18n("Generator/Date") );
|
||||||
m_docInfo->set( Okular::DocumentInfo::Pages, QString::number( dvif->total_pages ) );
|
if ( keys.contains( Okular::DocumentInfo::Pages ) )
|
||||||
|
docInfo.set( Okular::DocumentInfo::Pages, QString::number( dvif->total_pages ) );
|
||||||
}
|
}
|
||||||
return m_docInfo;
|
return docInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentSynopsis *DviGenerator::generateDocumentSynopsis()
|
const Okular::DocumentSynopsis *DviGenerator::generateDocumentSynopsis()
|
||||||
|
|
|
@ -31,7 +31,7 @@ class DviGenerator : public Okular::Generator
|
||||||
bool loadDocument( const QString & fileName, QVector< Okular::Page * > & pagesVector );
|
bool loadDocument( const QString & fileName, QVector< Okular::Page * > & pagesVector );
|
||||||
|
|
||||||
// document information
|
// document information
|
||||||
const Okular::DocumentInfo *generateDocumentInfo();
|
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
|
||||||
|
|
||||||
// table of contents
|
// table of contents
|
||||||
const Okular::DocumentSynopsis *generateDocumentSynopsis();
|
const Okular::DocumentSynopsis *generateDocumentSynopsis();
|
||||||
|
@ -52,7 +52,6 @@ class DviGenerator : public Okular::Generator
|
||||||
double m_resolution;
|
double m_resolution;
|
||||||
bool m_fontExtracted;
|
bool m_fontExtracted;
|
||||||
|
|
||||||
Okular::DocumentInfo *m_docInfo;
|
|
||||||
Okular::DocumentSynopsis *m_docSynopsis;
|
Okular::DocumentSynopsis *m_docSynopsis;
|
||||||
|
|
||||||
dviRenderer *m_dviRenderer;
|
dviRenderer *m_dviRenderer;
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
|
|
||||||
#include "generator_fax.h"
|
#include "generator_fax.h"
|
||||||
|
|
||||||
#include "faxdocument.h"
|
|
||||||
|
|
||||||
#include <QtGui/QPainter>
|
#include <QtGui/QPainter>
|
||||||
#include <QtGui/QPrinter>
|
#include <QtGui/QPrinter>
|
||||||
|
|
||||||
|
@ -52,13 +50,12 @@ FaxGenerator::~FaxGenerator()
|
||||||
|
|
||||||
bool FaxGenerator::loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector )
|
bool FaxGenerator::loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector )
|
||||||
{
|
{
|
||||||
FaxDocument::DocumentType type;
|
|
||||||
if ( fileName.toLower().endsWith( ".g3" ) )
|
if ( fileName.toLower().endsWith( ".g3" ) )
|
||||||
type = FaxDocument::G3;
|
m_type = FaxDocument::G3;
|
||||||
else
|
else
|
||||||
type = FaxDocument::G4;
|
m_type = FaxDocument::G4;
|
||||||
|
|
||||||
FaxDocument faxDocument( fileName, type );
|
FaxDocument faxDocument( fileName, m_type );
|
||||||
|
|
||||||
if ( !faxDocument.load() )
|
if ( !faxDocument.load() )
|
||||||
{
|
{
|
||||||
|
@ -73,20 +70,12 @@ bool FaxGenerator::loadDocument( const QString & fileName, QVector<Okular::Page*
|
||||||
Okular::Page * page = new Okular::Page( 0, m_img.width(), m_img.height(), Okular::Rotation0 );
|
Okular::Page * page = new Okular::Page( 0, m_img.width(), m_img.height(), Okular::Rotation0 );
|
||||||
pagesVector[0] = page;
|
pagesVector[0] = page;
|
||||||
|
|
||||||
m_docInfo = new Okular::DocumentInfo();
|
|
||||||
if ( type == FaxDocument::G3 )
|
|
||||||
m_docInfo->set( Okular::DocumentInfo::MimeType, "image/fax-g3" );
|
|
||||||
else
|
|
||||||
m_docInfo->set( Okular::DocumentInfo::MimeType, "image/fax-g4" );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FaxGenerator::doCloseDocument()
|
bool FaxGenerator::doCloseDocument()
|
||||||
{
|
{
|
||||||
m_img = QImage();
|
m_img = QImage();
|
||||||
delete m_docInfo;
|
|
||||||
m_docInfo = 0;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -102,9 +91,17 @@ QImage FaxGenerator::image( Okular::PixmapRequest * request )
|
||||||
return m_img.scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
|
return m_img.scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentInfo * FaxGenerator::generateDocumentInfo()
|
Okular::DocumentInfo FaxGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
|
||||||
{
|
{
|
||||||
return m_docInfo;
|
Okular::DocumentInfo docInfo;
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::MimeType ) )
|
||||||
|
{
|
||||||
|
if ( m_type == FaxDocument::G3 )
|
||||||
|
docInfo.set( Okular::DocumentInfo::MimeType, "image/fax-g3" );
|
||||||
|
else
|
||||||
|
docInfo.set( Okular::DocumentInfo::MimeType, "image/fax-g4" );
|
||||||
|
}
|
||||||
|
return docInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FaxGenerator::print( QPrinter& printer )
|
bool FaxGenerator::print( QPrinter& printer )
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
#include <QtGui/QImage>
|
#include <QtGui/QImage>
|
||||||
|
|
||||||
|
#include "faxdocument.h"
|
||||||
|
|
||||||
class FaxGenerator : public Okular::Generator
|
class FaxGenerator : public Okular::Generator
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -24,7 +26,7 @@ class FaxGenerator : public Okular::Generator
|
||||||
|
|
||||||
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
|
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
|
||||||
|
|
||||||
const Okular::DocumentInfo * generateDocumentInfo();
|
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
|
||||||
|
|
||||||
bool print( QPrinter& printer );
|
bool print( QPrinter& printer );
|
||||||
|
|
||||||
|
@ -34,7 +36,7 @@ class FaxGenerator : public Okular::Generator
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QImage m_img;
|
QImage m_img;
|
||||||
Okular::DocumentInfo *m_docInfo;
|
FaxDocument::DocumentType m_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -186,9 +186,9 @@ void KIMGIOGenerator::slotTest()
|
||||||
kDebug() << "Test";
|
kDebug() << "Test";
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentInfo * KIMGIOGenerator::generateDocumentInfo()
|
Okular::DocumentInfo KIMGIOGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
|
||||||
{
|
{
|
||||||
return &docInfo;
|
return docInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "generator_kimgio.moc"
|
#include "generator_kimgio.moc"
|
||||||
|
|
|
@ -30,7 +30,7 @@ class KIMGIOGenerator : public Okular::Generator
|
||||||
bool print( QPrinter& printer );
|
bool print( QPrinter& printer );
|
||||||
|
|
||||||
// [INHERITED] document information
|
// [INHERITED] document information
|
||||||
const Okular::DocumentInfo * generateDocumentInfo();
|
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool doCloseDocument();
|
bool doCloseDocument();
|
||||||
|
|
|
@ -126,9 +126,9 @@ bool PluckerGenerator::doCloseDocument()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentInfo* PluckerGenerator::generateDocumentInfo()
|
Okular::DocumentInfo PluckerGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> & /*keys*/ ) const
|
||||||
{
|
{
|
||||||
return &mDocumentInfo;
|
return mDocumentInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage PluckerGenerator::image( Okular::PixmapRequest *request )
|
QImage PluckerGenerator::image( Okular::PixmapRequest *request )
|
||||||
|
|
|
@ -31,7 +31,7 @@ class PluckerGenerator : public Okular::Generator
|
||||||
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
|
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
|
||||||
|
|
||||||
// [INHERITED] document information
|
// [INHERITED] document information
|
||||||
const Okular::DocumentInfo * generateDocumentInfo();
|
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
|
||||||
|
|
||||||
// [INHERITED] perform actions on document / pages
|
// [INHERITED] perform actions on document / pages
|
||||||
QImage image( Okular::PixmapRequest *request );
|
QImage image( Okular::PixmapRequest *request );
|
||||||
|
|
|
@ -421,7 +421,7 @@ static void PDFGeneratorPopplerDebugFunction(const QString &message, const QVari
|
||||||
|
|
||||||
PDFGenerator::PDFGenerator( QObject *parent, const QVariantList &args )
|
PDFGenerator::PDFGenerator( QObject *parent, const QVariantList &args )
|
||||||
: Generator( parent, args ), pdfdoc( 0 ),
|
: Generator( parent, args ), pdfdoc( 0 ),
|
||||||
docInfoDirty( true ), docSynopsisDirty( true ),
|
docSynopsisDirty( true ),
|
||||||
docEmbeddedFilesDirty( true ), nextFontPage( 0 ),
|
docEmbeddedFilesDirty( true ), nextFontPage( 0 ),
|
||||||
annotProxy( 0 ), synctex_scanner( 0 )
|
annotProxy( 0 ), synctex_scanner( 0 )
|
||||||
{
|
{
|
||||||
|
@ -539,7 +539,6 @@ bool PDFGenerator::doCloseDocument()
|
||||||
delete pdfdoc;
|
delete pdfdoc;
|
||||||
pdfdoc = 0;
|
pdfdoc = 0;
|
||||||
userMutex()->unlock();
|
userMutex()->unlock();
|
||||||
docInfoDirty = true;
|
|
||||||
docSynopsisDirty = true;
|
docSynopsisDirty = true;
|
||||||
docSyn.clear();
|
docSyn.clear();
|
||||||
docEmbeddedFilesDirty = true;
|
docEmbeddedFilesDirty = true;
|
||||||
|
@ -619,64 +618,47 @@ void PDFGenerator::loadPages(QVector<Okular::Page*> &pagesVector, int rotation,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentInfo * PDFGenerator::generateDocumentInfo()
|
Okular::DocumentInfo PDFGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
|
||||||
{
|
{
|
||||||
if ( docInfoDirty )
|
Okular::DocumentInfo docInfo;
|
||||||
|
docInfo.set( Okular::DocumentInfo::MimeType, "application/pdf" );
|
||||||
|
|
||||||
|
userMutex()->lock();
|
||||||
|
|
||||||
|
|
||||||
|
if ( pdfdoc )
|
||||||
{
|
{
|
||||||
userMutex()->lock();
|
// compile internal structure reading properties from PDFDoc
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::Title ) )
|
||||||
docInfo.set( Okular::DocumentInfo::MimeType, "application/pdf" );
|
|
||||||
|
|
||||||
if ( pdfdoc )
|
|
||||||
{
|
|
||||||
// compile internal structure reading properties from PDFDoc
|
|
||||||
docInfo.set( Okular::DocumentInfo::Title, pdfdoc->info("Title") );
|
docInfo.set( Okular::DocumentInfo::Title, pdfdoc->info("Title") );
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::Subject ) )
|
||||||
docInfo.set( Okular::DocumentInfo::Subject, pdfdoc->info("Subject") );
|
docInfo.set( Okular::DocumentInfo::Subject, pdfdoc->info("Subject") );
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::Author ) )
|
||||||
docInfo.set( Okular::DocumentInfo::Author, pdfdoc->info("Author") );
|
docInfo.set( Okular::DocumentInfo::Author, pdfdoc->info("Author") );
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::Keywords ) )
|
||||||
docInfo.set( Okular::DocumentInfo::Keywords, pdfdoc->info("Keywords") );
|
docInfo.set( Okular::DocumentInfo::Keywords, pdfdoc->info("Keywords") );
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::Creator ) )
|
||||||
docInfo.set( Okular::DocumentInfo::Creator, pdfdoc->info("Creator") );
|
docInfo.set( Okular::DocumentInfo::Creator, pdfdoc->info("Creator") );
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::Producer ) )
|
||||||
docInfo.set( Okular::DocumentInfo::Producer, pdfdoc->info("Producer") );
|
docInfo.set( Okular::DocumentInfo::Producer, pdfdoc->info("Producer") );
|
||||||
docInfo.set( Okular::DocumentInfo::CreationDate,
|
if ( keys.contains( Okular::DocumentInfo::CreationDate ) )
|
||||||
KGlobal::locale()->formatDateTime( pdfdoc->date("CreationDate"), KLocale::LongDate, true ) );
|
docInfo.set( Okular::DocumentInfo::CreationDate, KGlobal::locale()->formatDateTime( pdfdoc->date("CreationDate"), KLocale::LongDate, true ) );
|
||||||
docInfo.set( Okular::DocumentInfo::ModificationDate,
|
if ( keys.contains( Okular::DocumentInfo::ModificationDate ) )
|
||||||
KGlobal::locale()->formatDateTime( pdfdoc->date("ModDate"), KLocale::LongDate, true ) );
|
docInfo.set( Okular::DocumentInfo::ModificationDate, KGlobal::locale()->formatDateTime( pdfdoc->date("ModDate"), KLocale::LongDate, true ) );
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::CustomKeys ) )
|
||||||
|
{
|
||||||
int major, minor;
|
int major, minor;
|
||||||
pdfdoc->getPdfVersion(&major, &minor);
|
pdfdoc->getPdfVersion(&major, &minor);
|
||||||
docInfo.set( "format", i18nc( "PDF v. <version>", "PDF v. %1.%2",
|
docInfo.set( "format", i18nc( "PDF v. <version>", "PDF v. %1.%2", major, minor ), i18n( "Format" ) );
|
||||||
major, minor ), i18n( "Format" ) );
|
docInfo.set( "encryption", pdfdoc->isEncrypted() ? i18n( "Encrypted" ) : i18n( "Unencrypted" ), i18n("Security") );
|
||||||
docInfo.set( "encryption", pdfdoc->isEncrypted() ? i18n( "Encrypted" ) : i18n( "Unencrypted" ),
|
docInfo.set( "optimization", pdfdoc->isLinearized() ? i18n( "Yes" ) : i18n( "No" ), i18n("Optimized") );
|
||||||
i18n("Security") );
|
|
||||||
docInfo.set( "optimization", pdfdoc->isLinearized() ? i18n( "Yes" ) : i18n( "No" ),
|
|
||||||
i18n("Optimized") );
|
|
||||||
|
|
||||||
docInfo.set( Okular::DocumentInfo::Pages, QString::number( pdfdoc->numPages() ) );
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO not sure one can reach here, check and if it is not possible, remove the code
|
|
||||||
docInfo.set( Okular::DocumentInfo::Title, i18n("Unknown") );
|
|
||||||
docInfo.set( Okular::DocumentInfo::Subject, i18n("Unknown") );
|
|
||||||
docInfo.set( Okular::DocumentInfo::Author, i18n("Unknown") );
|
|
||||||
docInfo.set( Okular::DocumentInfo::Keywords, i18n("Unknown") );
|
|
||||||
docInfo.set( Okular::DocumentInfo::Creator, i18n("Unknown") );
|
|
||||||
docInfo.set( Okular::DocumentInfo::Producer, i18n("Unknown") );
|
|
||||||
docInfo.set( Okular::DocumentInfo::CreationDate, i18n("Unknown Date") );
|
|
||||||
docInfo.set( Okular::DocumentInfo::ModificationDate, i18n("Unknown Date") );
|
|
||||||
|
|
||||||
docInfo.set( "format", "PDF", i18n( "Format" ) );
|
docInfo.set( Okular::DocumentInfo::Pages, QString::number( pdfdoc->numPages() ) );
|
||||||
docInfo.set( "encryption", i18n( "Unknown Encryption" ), i18n( "Security" ) );
|
|
||||||
docInfo.set( "optimization", i18n( "Unknown Optimization" ), i18n( "Optimized" ) );
|
|
||||||
|
|
||||||
docInfo.set( Okular::DocumentInfo::Pages, i18n("Unknown") );
|
|
||||||
}
|
|
||||||
userMutex()->unlock();
|
|
||||||
|
|
||||||
// if pdfdoc is valid then we cached good info -> don't cache them again
|
|
||||||
if ( pdfdoc )
|
|
||||||
docInfoDirty = false;
|
|
||||||
}
|
}
|
||||||
return &docInfo;
|
userMutex()->unlock();
|
||||||
|
|
||||||
|
return docInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentSynopsis * PDFGenerator::generateDocumentSynopsis()
|
const Okular::DocumentSynopsis * PDFGenerator::generateDocumentSynopsis()
|
||||||
|
|
|
@ -64,7 +64,7 @@ class PDFGenerator : public Okular::Generator, public Okular::ConfigInterface, p
|
||||||
Okular::Document::OpenResult loadDocumentFromDataWithPassword( const QByteArray & fileData, QVector<Okular::Page*> & pagesVector, const QString & password );
|
Okular::Document::OpenResult loadDocumentFromDataWithPassword( const QByteArray & fileData, QVector<Okular::Page*> & pagesVector, const QString & password );
|
||||||
void loadPages(QVector<Okular::Page*> &pagesVector, int rotation=-1, bool clear=false);
|
void loadPages(QVector<Okular::Page*> &pagesVector, int rotation=-1, bool clear=false);
|
||||||
// [INHERITED] document information
|
// [INHERITED] document information
|
||||||
const Okular::DocumentInfo * generateDocumentInfo();
|
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
|
||||||
const Okular::DocumentSynopsis * generateDocumentSynopsis();
|
const Okular::DocumentSynopsis * generateDocumentSynopsis();
|
||||||
Okular::FontInfo::List fontsForPage( int page );
|
Okular::FontInfo::List fontsForPage( int page );
|
||||||
const QList<Okular::EmbeddedFile*> * embeddedFiles() const;
|
const QList<Okular::EmbeddedFile*> * embeddedFiles() const;
|
||||||
|
@ -137,8 +137,6 @@ class PDFGenerator : public Okular::Generator, public Okular::ConfigInterface, p
|
||||||
|
|
||||||
|
|
||||||
// misc variables for document info and synopsis caching
|
// misc variables for document info and synopsis caching
|
||||||
bool docInfoDirty;
|
|
||||||
Okular::DocumentInfo docInfo;
|
|
||||||
bool docSynopsisDirty;
|
bool docSynopsisDirty;
|
||||||
Okular::DocumentSynopsis docSyn;
|
Okular::DocumentSynopsis docSyn;
|
||||||
mutable bool docEmbeddedFilesDirty;
|
mutable bool docEmbeddedFilesDirty;
|
||||||
|
|
|
@ -54,7 +54,6 @@ OKULAR_EXPORT_PLUGIN(GSGenerator, createAboutData())
|
||||||
GSGenerator::GSGenerator( QObject *parent, const QVariantList &args ) :
|
GSGenerator::GSGenerator( QObject *parent, const QVariantList &args ) :
|
||||||
Okular::Generator( parent, args ),
|
Okular::Generator( parent, args ),
|
||||||
m_internalDocument(0),
|
m_internalDocument(0),
|
||||||
m_docInfo(0),
|
|
||||||
m_request(0)
|
m_request(0)
|
||||||
{
|
{
|
||||||
setFeature( PrintPostscript );
|
setFeature( PrintPostscript );
|
||||||
|
@ -182,9 +181,6 @@ bool GSGenerator::doCloseDocument()
|
||||||
spectre_document_free(m_internalDocument);
|
spectre_document_free(m_internalDocument);
|
||||||
m_internalDocument = 0;
|
m_internalDocument = 0;
|
||||||
|
|
||||||
delete m_docInfo;
|
|
||||||
m_docInfo = 0;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,28 +261,34 @@ bool GSGenerator::canGeneratePixmap() const
|
||||||
return !m_request;
|
return !m_request;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentInfo * GSGenerator::generateDocumentInfo()
|
Okular::DocumentInfo GSGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
|
||||||
{
|
{
|
||||||
if (!m_docInfo)
|
Okular::DocumentInfo docInfo;
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::Title ) )
|
||||||
|
docInfo.set( Okular::DocumentInfo::Title, spectre_document_get_title(m_internalDocument) );
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::Author ) )
|
||||||
|
docInfo.set( Okular::DocumentInfo::Author, spectre_document_get_for(m_internalDocument) );
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::Creator ) )
|
||||||
|
docInfo.set( Okular::DocumentInfo::Creator, spectre_document_get_creator(m_internalDocument) );
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::CreationDate ) )
|
||||||
|
docInfo.set( Okular::DocumentInfo::CreationDate, spectre_document_get_creation_date(m_internalDocument) );
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::CustomKeys ) )
|
||||||
|
docInfo.set( "dscversion", spectre_document_get_format(m_internalDocument), i18n("Document version") );
|
||||||
|
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::MimeType ) )
|
||||||
{
|
{
|
||||||
m_docInfo = new Okular::DocumentInfo();
|
|
||||||
|
|
||||||
m_docInfo->set( Okular::DocumentInfo::Title, spectre_document_get_title(m_internalDocument) );
|
|
||||||
m_docInfo->set( Okular::DocumentInfo::Author, spectre_document_get_for(m_internalDocument) );
|
|
||||||
m_docInfo->set( Okular::DocumentInfo::Creator, spectre_document_get_creator(m_internalDocument) );
|
|
||||||
m_docInfo->set( Okular::DocumentInfo::CreationDate, spectre_document_get_creation_date(m_internalDocument) );
|
|
||||||
m_docInfo->set( "dscversion", spectre_document_get_format(m_internalDocument), i18n("Document version") );
|
|
||||||
|
|
||||||
int languageLevel = spectre_document_get_language_level(m_internalDocument);
|
int languageLevel = spectre_document_get_language_level(m_internalDocument);
|
||||||
if (languageLevel > 0) m_docInfo->set( "langlevel", QString::number(languageLevel), i18n("Language Level") );
|
if (languageLevel > 0) docInfo.set( "langlevel", QString::number(languageLevel), i18n("Language Level") );
|
||||||
if (spectre_document_is_eps(m_internalDocument))
|
if (spectre_document_is_eps(m_internalDocument))
|
||||||
m_docInfo->set( Okular::DocumentInfo::MimeType, "image/x-eps" );
|
docInfo.set( Okular::DocumentInfo::MimeType, "image/x-eps" );
|
||||||
else
|
else
|
||||||
m_docInfo->set( Okular::DocumentInfo::MimeType, "application/postscript" );
|
docInfo.set( Okular::DocumentInfo::MimeType, "application/postscript" );
|
||||||
|
|
||||||
m_docInfo->set( Okular::DocumentInfo::Pages, QString::number(spectre_document_get_n_pages(m_internalDocument)) );
|
|
||||||
}
|
}
|
||||||
return m_docInfo;
|
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::Pages ) )
|
||||||
|
docInfo.set( Okular::DocumentInfo::Pages, QString::number(spectre_document_get_n_pages(m_internalDocument)) );
|
||||||
|
|
||||||
|
return docInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
Okular::Rotation GSGenerator::orientation(SpectreOrientation pageOrientation) const
|
Okular::Rotation GSGenerator::orientation(SpectreOrientation pageOrientation) const
|
||||||
|
|
|
@ -26,7 +26,7 @@ class GSGenerator : public Okular::Generator, public Okular::ConfigInterface
|
||||||
bool loadDocument( const QString & fileName, QVector< Okular::Page * > & pagesVector );
|
bool loadDocument( const QString & fileName, QVector< Okular::Page * > & pagesVector );
|
||||||
|
|
||||||
// Document description and Table of contents
|
// Document description and Table of contents
|
||||||
const Okular::DocumentInfo * generateDocumentInfo();
|
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
|
||||||
const Okular::DocumentSynopsis * generateDocumentSynopsis() { return 0L; }
|
const Okular::DocumentSynopsis * generateDocumentSynopsis() { return 0L; }
|
||||||
const Okular::DocumentFonts * generateDocumentFonts() { return 0L; }
|
const Okular::DocumentFonts * generateDocumentFonts() { return 0L; }
|
||||||
|
|
||||||
|
@ -59,7 +59,6 @@ class GSGenerator : public Okular::Generator, public Okular::ConfigInterface
|
||||||
|
|
||||||
// backendish stuff
|
// backendish stuff
|
||||||
SpectreDocument *m_internalDocument;
|
SpectreDocument *m_internalDocument;
|
||||||
Okular::DocumentInfo *m_docInfo;
|
|
||||||
|
|
||||||
Okular::PixmapRequest *m_request;
|
Okular::PixmapRequest *m_request;
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ OKULAR_EXPORT_PLUGIN( TIFFGenerator, createAboutData() )
|
||||||
|
|
||||||
TIFFGenerator::TIFFGenerator( QObject *parent, const QVariantList &args )
|
TIFFGenerator::TIFFGenerator( QObject *parent, const QVariantList &args )
|
||||||
: Okular::Generator( parent, args ),
|
: Okular::Generator( parent, args ),
|
||||||
d( new Private ), m_docInfo( 0 )
|
d( new Private )
|
||||||
{
|
{
|
||||||
setFeature( Threaded );
|
setFeature( Threaded );
|
||||||
setFeature( PrintNative );
|
setFeature( PrintNative );
|
||||||
|
@ -194,7 +194,6 @@ TIFFGenerator::~TIFFGenerator()
|
||||||
d->tiff = 0;
|
d->tiff = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete m_docInfo;
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,8 +244,6 @@ bool TIFFGenerator::doCloseDocument()
|
||||||
delete d->dev;
|
delete d->dev;
|
||||||
d->dev = 0;
|
d->dev = 0;
|
||||||
d->data.clear();
|
d->data.clear();
|
||||||
delete m_docInfo;
|
|
||||||
m_docInfo = 0;
|
|
||||||
m_pageMapping.clear();
|
m_pageMapping.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,40 +301,52 @@ QImage TIFFGenerator::image( Okular::PixmapRequest * request )
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentInfo * TIFFGenerator::generateDocumentInfo()
|
Okular::DocumentInfo TIFFGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
|
||||||
{
|
{
|
||||||
if ( !d->tiff )
|
Okular::DocumentInfo docInfo;
|
||||||
return 0;
|
if ( d->tiff )
|
||||||
|
{
|
||||||
|
if ( keys.contains( Okular::DocumentInfo::MimeType ) )
|
||||||
|
docInfo.set( Okular::DocumentInfo::MimeType, "image/tiff" );
|
||||||
|
|
||||||
if ( m_docInfo )
|
if ( keys.contains( Okular::DocumentInfo::Description ) )
|
||||||
return m_docInfo;
|
{
|
||||||
|
char* buffer = 0;
|
||||||
|
TIFFGetField( d->tiff, TIFFTAG_IMAGEDESCRIPTION, &buffer );
|
||||||
|
docInfo.set( Okular::DocumentInfo::Description, buffer ? QString::fromLatin1( buffer ) : QString() );
|
||||||
|
}
|
||||||
|
|
||||||
m_docInfo = new Okular::DocumentInfo();
|
if ( keys.contains( Okular::DocumentInfo::Producer ) )
|
||||||
|
{
|
||||||
|
char* buffer = 0;
|
||||||
|
TIFFGetField( d->tiff, TIFFTAG_SOFTWARE, &buffer );
|
||||||
|
docInfo.set( Okular::DocumentInfo::Producer, buffer ? QString::fromLatin1( buffer ) : QString() );
|
||||||
|
}
|
||||||
|
|
||||||
m_docInfo->set( Okular::DocumentInfo::MimeType, "image/tiff" );
|
if ( keys.contains( Okular::DocumentInfo::Copyright ) )
|
||||||
|
{
|
||||||
|
char* buffer = 0;
|
||||||
|
TIFFGetField( d->tiff, TIFFTAG_COPYRIGHT, &buffer );
|
||||||
|
docInfo.set( Okular::DocumentInfo::Copyright, buffer ? QString::fromLatin1( buffer ) : QString() );
|
||||||
|
}
|
||||||
|
|
||||||
char* buffer = 0;
|
if ( keys.contains( Okular::DocumentInfo::Author ) )
|
||||||
TIFFGetField( d->tiff, TIFFTAG_IMAGEDESCRIPTION, &buffer );
|
{
|
||||||
m_docInfo->set( Okular::DocumentInfo::Description, buffer ? QString::fromLatin1( buffer ) : i18nc( "Unknown description", "Unknown" ) );
|
char* buffer = 0;
|
||||||
|
TIFFGetField( d->tiff, TIFFTAG_ARTIST, &buffer );
|
||||||
|
docInfo.set( Okular::DocumentInfo::Author, buffer ? QString::fromLatin1( buffer ) : QString() );
|
||||||
|
}
|
||||||
|
|
||||||
buffer = 0;
|
if ( keys.contains( Okular::DocumentInfo::CreationDate ) )
|
||||||
TIFFGetField( d->tiff, TIFFTAG_SOFTWARE, &buffer );
|
{
|
||||||
m_docInfo->set( Okular::DocumentInfo::Producer, buffer ? QString::fromLatin1( buffer ) : i18nc( "Unknown producer", "Unknown" ) );
|
char* buffer = 0;
|
||||||
|
TIFFGetField( d->tiff, TIFFTAG_DATETIME, &buffer );
|
||||||
|
QDateTime date = convertTIFFDateTime( buffer );
|
||||||
|
docInfo.set( Okular::DocumentInfo::CreationDate, date.isValid() ? KGlobal::locale()->formatDateTime( date, KLocale::LongDate, true ) : QString() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buffer = 0;
|
return docInfo;
|
||||||
TIFFGetField( d->tiff, TIFFTAG_COPYRIGHT, &buffer );
|
|
||||||
m_docInfo->set( Okular::DocumentInfo::Copyright, buffer ? QString::fromLatin1( buffer ) : i18nc( "Unknown copyright statement", "Unknown" ) );
|
|
||||||
|
|
||||||
buffer = 0;
|
|
||||||
TIFFGetField( d->tiff, TIFFTAG_ARTIST, &buffer );
|
|
||||||
m_docInfo->set( Okular::DocumentInfo::Author, buffer ? QString::fromLatin1( buffer ) : i18nc( "Unknown author", "Unknown" ) );
|
|
||||||
|
|
||||||
buffer = 0;
|
|
||||||
TIFFGetField( d->tiff, TIFFTAG_DATETIME, &buffer );
|
|
||||||
QDateTime date = convertTIFFDateTime( buffer );
|
|
||||||
m_docInfo->set( Okular::DocumentInfo::CreationDate, date.isValid() ? KGlobal::locale()->formatDateTime( date, KLocale::LongDate, true ) : i18nc( "Unknown creation date", "Unknown" ) );
|
|
||||||
|
|
||||||
return m_docInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TIFFGenerator::loadPages( QVector<Okular::Page*> & pagesVector )
|
void TIFFGenerator::loadPages( QVector<Okular::Page*> & pagesVector )
|
||||||
|
|
|
@ -24,7 +24,7 @@ class TIFFGenerator : public Okular::Generator
|
||||||
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
|
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
|
||||||
bool loadDocumentFromData( const QByteArray & fileData, QVector< Okular::Page * > & pagesVector );
|
bool loadDocumentFromData( const QByteArray & fileData, QVector< Okular::Page * > & pagesVector );
|
||||||
|
|
||||||
const Okular::DocumentInfo * generateDocumentInfo();
|
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
|
||||||
|
|
||||||
bool print( QPrinter& printer );
|
bool print( QPrinter& printer );
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@ class TIFFGenerator : public Okular::Generator
|
||||||
void loadPages( QVector<Okular::Page*> & pagesVector );
|
void loadPages( QVector<Okular::Page*> & pagesVector );
|
||||||
int mapPage( int page ) const;
|
int mapPage( int page ) const;
|
||||||
|
|
||||||
Okular::DocumentInfo * m_docInfo;
|
|
||||||
QHash< int, int > m_pageMapping;
|
QHash< int, int > m_pageMapping;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1892,7 +1892,7 @@ XpsPage* XpsDocument::page(int pageNum) const
|
||||||
return m_pages.at(pageNum);
|
return m_pages.at(pageNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
XpsFile::XpsFile() : m_docInfo( 0 )
|
XpsFile::XpsFile()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1996,14 +1996,11 @@ bool XpsFile::loadDocument(const QString &filename)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentInfo * XpsFile::generateDocumentInfo()
|
Okular::DocumentInfo XpsFile::generateDocumentInfo() const
|
||||||
{
|
{
|
||||||
if ( m_docInfo )
|
Okular::DocumentInfo docInfo;
|
||||||
return m_docInfo;
|
|
||||||
|
|
||||||
m_docInfo = new Okular::DocumentInfo();
|
docInfo.set( Okular::DocumentInfo::MimeType, "application/oxps" );
|
||||||
|
|
||||||
m_docInfo->set( Okular::DocumentInfo::MimeType, "application/oxps" );
|
|
||||||
|
|
||||||
if ( ! m_corePropertiesFileName.isEmpty() ) {
|
if ( ! m_corePropertiesFileName.isEmpty() ) {
|
||||||
const KZipFileEntry* corepropsFile = static_cast<const KZipFileEntry *>(m_xpsArchive->directory()->entry(m_corePropertiesFileName));
|
const KZipFileEntry* corepropsFile = static_cast<const KZipFileEntry *>(m_xpsArchive->directory()->entry(m_corePropertiesFileName));
|
||||||
|
@ -2018,25 +2015,25 @@ const Okular::DocumentInfo * XpsFile::generateDocumentInfo()
|
||||||
if ( xml.isStartElement() )
|
if ( xml.isStartElement() )
|
||||||
{
|
{
|
||||||
if (xml.name() == "title") {
|
if (xml.name() == "title") {
|
||||||
m_docInfo->set( Okular::DocumentInfo::Title, xml.readElementText() );
|
docInfo.set( Okular::DocumentInfo::Title, xml.readElementText() );
|
||||||
} else if (xml.name() == "subject") {
|
} else if (xml.name() == "subject") {
|
||||||
m_docInfo->set( Okular::DocumentInfo::Subject, xml.readElementText() );
|
docInfo.set( Okular::DocumentInfo::Subject, xml.readElementText() );
|
||||||
} else if (xml.name() == "description") {
|
} else if (xml.name() == "description") {
|
||||||
m_docInfo->set( Okular::DocumentInfo::Description, xml.readElementText() );
|
docInfo.set( Okular::DocumentInfo::Description, xml.readElementText() );
|
||||||
} else if (xml.name() == "creator") {
|
} else if (xml.name() == "creator") {
|
||||||
m_docInfo->set( Okular::DocumentInfo::Creator, xml.readElementText() );
|
docInfo.set( Okular::DocumentInfo::Creator, xml.readElementText() );
|
||||||
} else if (xml.name() == "category") {
|
} else if (xml.name() == "category") {
|
||||||
m_docInfo->set( Okular::DocumentInfo::Category, xml.readElementText() );
|
docInfo.set( Okular::DocumentInfo::Category, xml.readElementText() );
|
||||||
} else if (xml.name() == "created") {
|
} else if (xml.name() == "created") {
|
||||||
QDateTime createdDate = QDateTime::fromString( xml.readElementText(), "yyyy-MM-ddThh:mm:ssZ" );
|
QDateTime createdDate = QDateTime::fromString( xml.readElementText(), "yyyy-MM-ddThh:mm:ssZ" );
|
||||||
m_docInfo->set( Okular::DocumentInfo::CreationDate, KGlobal::locale()->formatDateTime( createdDate, KLocale::LongDate, true ) );
|
docInfo.set( Okular::DocumentInfo::CreationDate, KGlobal::locale()->formatDateTime( createdDate, KLocale::LongDate, true ) );
|
||||||
} else if (xml.name() == "modified") {
|
} else if (xml.name() == "modified") {
|
||||||
QDateTime modifiedDate = QDateTime::fromString( xml.readElementText(), "yyyy-MM-ddThh:mm:ssZ" );
|
QDateTime modifiedDate = QDateTime::fromString( xml.readElementText(), "yyyy-MM-ddThh:mm:ssZ" );
|
||||||
m_docInfo->set( Okular::DocumentInfo::ModificationDate, KGlobal::locale()->formatDateTime( modifiedDate, KLocale::LongDate, true ) );
|
docInfo.set( Okular::DocumentInfo::ModificationDate, KGlobal::locale()->formatDateTime( modifiedDate, KLocale::LongDate, true ) );
|
||||||
} else if (xml.name() == "keywords") {
|
} else if (xml.name() == "keywords") {
|
||||||
m_docInfo->set( Okular::DocumentInfo::Keywords, xml.readElementText() );
|
docInfo.set( Okular::DocumentInfo::Keywords, xml.readElementText() );
|
||||||
} else if (xml.name() == "revision") {
|
} else if (xml.name() == "revision") {
|
||||||
m_docInfo->set( "revision", xml.readElementText(), i18n( "Revision" ) );
|
docInfo.set( "revision", xml.readElementText(), i18n( "Revision" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2048,19 +2045,13 @@ const Okular::DocumentInfo * XpsFile::generateDocumentInfo()
|
||||||
kDebug(XpsDebug) << "No core properties filename";
|
kDebug(XpsDebug) << "No core properties filename";
|
||||||
}
|
}
|
||||||
|
|
||||||
m_docInfo->set( Okular::DocumentInfo::Pages, QString::number(numPages()) );
|
docInfo.set( Okular::DocumentInfo::Pages, QString::number(numPages()) );
|
||||||
|
|
||||||
return m_docInfo;
|
return docInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XpsFile::closeDocument()
|
bool XpsFile::closeDocument()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( m_docInfo )
|
|
||||||
delete m_docInfo;
|
|
||||||
|
|
||||||
m_docInfo = 0;
|
|
||||||
|
|
||||||
qDeleteAll( m_documents );
|
qDeleteAll( m_documents );
|
||||||
m_documents.clear();
|
m_documents.clear();
|
||||||
|
|
||||||
|
@ -2159,7 +2150,7 @@ Okular::TextPage* XpsGenerator::textPage( Okular::Page * page )
|
||||||
return xpsPage->textPage();
|
return xpsPage->textPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Okular::DocumentInfo * XpsGenerator::generateDocumentInfo()
|
Okular::DocumentInfo XpsGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
|
||||||
{
|
{
|
||||||
kDebug(XpsDebug) << "generating document metadata";
|
kDebug(XpsDebug) << "generating document metadata";
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,7 @@ public:
|
||||||
bool loadDocument( const QString & fileName );
|
bool loadDocument( const QString & fileName );
|
||||||
bool closeDocument();
|
bool closeDocument();
|
||||||
|
|
||||||
const Okular::DocumentInfo * generateDocumentInfo();
|
Okular::DocumentInfo generateDocumentInfo() const;
|
||||||
|
|
||||||
QImage thumbnail();
|
QImage thumbnail();
|
||||||
|
|
||||||
|
@ -287,7 +287,6 @@ private:
|
||||||
bool m_thumbnailIsLoaded;
|
bool m_thumbnailIsLoaded;
|
||||||
|
|
||||||
QString m_corePropertiesFileName;
|
QString m_corePropertiesFileName;
|
||||||
Okular::DocumentInfo * m_docInfo;
|
|
||||||
|
|
||||||
QString m_signatureOrigin;
|
QString m_signatureOrigin;
|
||||||
|
|
||||||
|
@ -307,7 +306,7 @@ class XpsGenerator : public Okular::Generator
|
||||||
|
|
||||||
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
|
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
|
||||||
|
|
||||||
const Okular::DocumentInfo * generateDocumentInfo();
|
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
|
||||||
const Okular::DocumentSynopsis * generateDocumentSynopsis();
|
const Okular::DocumentSynopsis * generateDocumentSynopsis();
|
||||||
|
|
||||||
Okular::ExportFormat::List exportFormats() const;
|
Okular::ExportFormat::List exportFormats() const;
|
||||||
|
|
27
part.cpp
27
part.cpp
|
@ -1160,19 +1160,8 @@ QString Part::currentDocument()
|
||||||
|
|
||||||
QString Part::documentMetaData( const QString &metaData ) const
|
QString Part::documentMetaData( const QString &metaData ) const
|
||||||
{
|
{
|
||||||
const Okular::DocumentInfo * info = m_document->documentInfo();
|
const Okular::DocumentInfo info = m_document->documentInfo();
|
||||||
if ( info )
|
return info.get( metaData );
|
||||||
{
|
|
||||||
QDomElement docElement = info->documentElement();
|
|
||||||
for ( QDomNode node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() )
|
|
||||||
{
|
|
||||||
const QDomElement element = node.toElement();
|
|
||||||
if ( metaData.compare( element.tagName(), Qt::CaseInsensitive ) == 0 )
|
|
||||||
return element.attribute( "value" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return QString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2537,14 +2526,12 @@ void Part::slotAboutBackend()
|
||||||
|
|
||||||
if ( aboutData.programIconName().isEmpty() || aboutData.programIconName() == aboutData.appName() )
|
if ( aboutData.programIconName().isEmpty() || aboutData.programIconName() == aboutData.appName() )
|
||||||
{
|
{
|
||||||
if ( const Okular::DocumentInfo *documentInfo = m_document->documentInfo() )
|
const Okular::DocumentInfo documentInfo = m_document->documentInfo(QSet<DocumentInfo::Key>() << DocumentInfo::MimeType);
|
||||||
|
const QString mimeTypeName = documentInfo.get(DocumentInfo::MimeType);
|
||||||
|
if ( !mimeTypeName.isEmpty() )
|
||||||
{
|
{
|
||||||
const QString mimeTypeName = documentInfo->get("mimeType");
|
if ( KMimeType::Ptr type = KMimeType::mimeType( mimeTypeName ) )
|
||||||
if ( !mimeTypeName.isEmpty() )
|
aboutData.setProgramIconName( type->iconName() );
|
||||||
{
|
|
||||||
if ( KMimeType::Ptr type = KMimeType::mimeType( mimeTypeName ) )
|
|
||||||
aboutData.setProgramIconName( type->iconName() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -353,14 +353,11 @@ void PresentationWidget::notifySetup( const QVector< Okular::Page * > & pageSet,
|
||||||
|
|
||||||
// get metadata from the document
|
// get metadata from the document
|
||||||
m_metaStrings.clear();
|
m_metaStrings.clear();
|
||||||
const Okular::DocumentInfo * info = m_document->documentInfo();
|
const Okular::DocumentInfo info = m_document->documentInfo( QSet<Okular::DocumentInfo::Key>() << Okular::DocumentInfo::Title << Okular::DocumentInfo::Author );
|
||||||
if ( info )
|
if ( !info.get( Okular::DocumentInfo::Title ).isNull() )
|
||||||
{
|
m_metaStrings += i18n( "Title: %1", info.get( Okular::DocumentInfo::Title ) );
|
||||||
if ( !info->get( "title" ).isNull() )
|
if ( !info.get( Okular::DocumentInfo::Author ).isNull() )
|
||||||
m_metaStrings += i18n( "Title: %1", info->get( "title" ) );
|
m_metaStrings += i18n( "Author: %1", info.get( Okular::DocumentInfo::Author ) );
|
||||||
if ( !info->get( "author" ).isNull() )
|
|
||||||
m_metaStrings += i18n( "Author: %1", info->get( "author" ) );
|
|
||||||
}
|
|
||||||
m_metaStrings += i18n( "Pages: %1", m_document->pages() );
|
m_metaStrings += i18n( "Pages: %1", m_document->pages() );
|
||||||
m_metaStrings += i18n( "Click to begin" );
|
m_metaStrings += i18n( "Click to begin" );
|
||||||
|
|
||||||
|
|
|
@ -41,71 +41,55 @@ PropertiesDialog::PropertiesDialog(QWidget *parent, Okular::Document *doc)
|
||||||
m_fontModel( 0 ), m_fontInfo( 0 ), m_fontProgressBar( 0 ),
|
m_fontModel( 0 ), m_fontInfo( 0 ), m_fontProgressBar( 0 ),
|
||||||
m_fontScanStarted( false )
|
m_fontScanStarted( false )
|
||||||
{
|
{
|
||||||
setFaceType( Tabbed );
|
setFaceType( Tabbed );
|
||||||
setCaption( i18n( "Unknown File" ) );
|
setCaption( i18n( "Unknown File" ) );
|
||||||
setButtons( Ok );
|
setButtons( Ok );
|
||||||
|
|
||||||
// PROPERTIES
|
// PROPERTIES
|
||||||
QFrame *page = new QFrame();
|
QFrame *page = new QFrame();
|
||||||
KPageWidgetItem *item = addPage( page, i18n( "&Properties" ) );
|
KPageWidgetItem *item = addPage( page, i18n( "&Properties" ) );
|
||||||
item->setIcon( KIcon( "document-properties" ) );
|
item->setIcon( KIcon( "document-properties" ) );
|
||||||
|
|
||||||
// get document info, if not present display blank data and a warning
|
// get document info
|
||||||
const Okular::DocumentInfo * info = doc->documentInfo();
|
const Okular::DocumentInfo info = doc->documentInfo();
|
||||||
if ( !info ) {
|
QFormLayout *layout = new QFormLayout( page );
|
||||||
QVBoxLayout *layout = new QVBoxLayout( page );
|
|
||||||
layout->addWidget( new QLabel( i18n( "No document opened." ), page ) );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFormLayout *layout = new QFormLayout( page );
|
// mime name based on mimetype id
|
||||||
|
QString mimeName = info.get( Okular::DocumentInfo::MimeType ).section( '/', -1 ).toUpper();
|
||||||
|
setCaption( i18n( "%1 Properties", mimeName ) );
|
||||||
|
|
||||||
// mime name based on mimetype id
|
int valMaxWidth = 100;
|
||||||
QString mimeName = info->get( "mimeType" ).section( '/', -1 ).toUpper();
|
|
||||||
setCaption( i18n( "%1 Properties", mimeName ) );
|
|
||||||
|
|
||||||
QDomElement docElement = info->documentElement();
|
/* obtains the properties list, conveniently ordered */
|
||||||
|
QStringList orderedProperties;
|
||||||
int valMaxWidth = 100;
|
orderedProperties << Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::FilePath )
|
||||||
|
<< Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::PagesSize )
|
||||||
/* obtains the properties list, conveniently ordered */
|
<< Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::DocumentSize );
|
||||||
QStringList orderedProperties;
|
for (Okular::DocumentInfo::Key ks = Okular::DocumentInfo::Title;
|
||||||
orderedProperties << Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::FilePath )
|
ks <= Okular::DocumentInfo::Keywords;
|
||||||
<< Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::PagesSize )
|
ks = Okular::DocumentInfo::Key( ks+1 ) )
|
||||||
<< Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::DocumentSize );
|
{
|
||||||
for (Okular::DocumentInfo::Key ks = Okular::DocumentInfo::Title;
|
orderedProperties << Okular::DocumentInfo::getKeyString( ks );
|
||||||
ks <= Okular::DocumentInfo::Keywords;
|
}
|
||||||
ks = Okular::DocumentInfo::Key( ks+1 ) ) {
|
foreach( const QString &ks, info.keys()) {
|
||||||
orderedProperties << Okular::DocumentInfo::getKeyString( ks );
|
if ( !orderedProperties.contains( ks ) ) {
|
||||||
}
|
orderedProperties << ks;
|
||||||
for ( QDomNode node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
|
}
|
||||||
const QDomElement element = node.toElement();
|
|
||||||
|
|
||||||
const QString titleString = element.attribute( "title" );
|
|
||||||
const QString valueString = element.attribute( "value" );
|
|
||||||
if ( titleString.isEmpty() || valueString.isEmpty() )
|
|
||||||
continue;
|
|
||||||
if ( !orderedProperties.contains( element.tagName() ) ) {
|
|
||||||
orderedProperties << element.tagName();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
QDomNodeList list;
|
for ( QStringList::Iterator it = orderedProperties.begin();
|
||||||
|
it != orderedProperties.end();
|
||||||
for ( QStringList::Iterator it = orderedProperties.begin();
|
++it )
|
||||||
it != orderedProperties.end(); ++it ) {
|
{
|
||||||
list = docElement.elementsByTagName( (*it) );
|
const QString key = *it;
|
||||||
if ( list.count() == 1 ) {
|
const QString titleString = info.getKeyTitle( key );
|
||||||
|
const QString valueString = info.get( key );
|
||||||
QDomElement element = list.at(0).toElement();
|
if ( titleString.isNull() || valueString.isNull() )
|
||||||
const QString titleString = element.attribute( "title" );
|
|
||||||
const QString valueString = element.attribute( "value" );
|
|
||||||
if ( titleString.isEmpty() || valueString.isEmpty() )
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// create labels and layout them
|
// create labels and layout them
|
||||||
QWidget *value = NULL;
|
QWidget *value = NULL;
|
||||||
if ( element.tagName() == Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::MimeType ) ) {
|
if ( key == Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::MimeType ) ) {
|
||||||
/// for mime type fields, show icon as well
|
/// for mime type fields, show icon as well
|
||||||
value = new QWidget( page );
|
value = new QWidget( page );
|
||||||
/// place icon left of mime type's name
|
/// place icon left of mime type's name
|
||||||
|
@ -138,53 +122,52 @@ PropertiesDialog::PropertiesDialog(QWidget *parent, Okular::Document *doc)
|
||||||
// refine maximum width of 'value' labels
|
// refine maximum width of 'value' labels
|
||||||
valMaxWidth = qMax( valMaxWidth, fontMetrics().width( valueString ) );
|
valMaxWidth = qMax( valMaxWidth, fontMetrics().width( valueString ) );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// FONTS
|
// FONTS
|
||||||
QVBoxLayout *page2Layout = 0;
|
QVBoxLayout *page2Layout = 0;
|
||||||
if ( doc->canProvideFontInformation() ) {
|
if ( doc->canProvideFontInformation() ) {
|
||||||
// create fonts tab and layout it
|
// create fonts tab and layout it
|
||||||
QFrame *page2 = new QFrame();
|
QFrame *page2 = new QFrame();
|
||||||
m_fontPage = addPage(page2, i18n("&Fonts"));
|
m_fontPage = addPage(page2, i18n("&Fonts"));
|
||||||
m_fontPage->setIcon( KIcon( "preferences-desktop-font" ) );
|
m_fontPage->setIcon( KIcon( "preferences-desktop-font" ) );
|
||||||
page2Layout = new QVBoxLayout(page2);
|
page2Layout = new QVBoxLayout(page2);
|
||||||
page2Layout->setMargin(marginHint());
|
page2Layout->setMargin(marginHint());
|
||||||
page2Layout->setSpacing(spacingHint());
|
page2Layout->setSpacing(spacingHint());
|
||||||
// add a tree view
|
// add a tree view
|
||||||
QTreeView *view = new QTreeView(page2);
|
QTreeView *view = new QTreeView(page2);
|
||||||
view->setContextMenuPolicy(Qt::CustomContextMenu);
|
view->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showFontsMenu(QPoint)));
|
connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showFontsMenu(QPoint)));
|
||||||
page2Layout->addWidget(view);
|
page2Layout->addWidget(view);
|
||||||
view->setRootIsDecorated(false);
|
view->setRootIsDecorated(false);
|
||||||
view->setAlternatingRowColors(true);
|
view->setAlternatingRowColors(true);
|
||||||
view->setSortingEnabled( true );
|
view->setSortingEnabled( true );
|
||||||
// creating a proxy model so we can sort the data
|
// creating a proxy model so we can sort the data
|
||||||
QSortFilterProxyModel *proxymodel = new QSortFilterProxyModel(view);
|
QSortFilterProxyModel *proxymodel = new QSortFilterProxyModel(view);
|
||||||
proxymodel->setDynamicSortFilter( true );
|
proxymodel->setDynamicSortFilter( true );
|
||||||
proxymodel->setSortCaseSensitivity( Qt::CaseInsensitive );
|
proxymodel->setSortCaseSensitivity( Qt::CaseInsensitive );
|
||||||
m_fontModel = new FontsListModel(view);
|
m_fontModel = new FontsListModel(view);
|
||||||
proxymodel->setSourceModel(m_fontModel);
|
proxymodel->setSourceModel(m_fontModel);
|
||||||
view->setModel(proxymodel);
|
view->setModel(proxymodel);
|
||||||
view->sortByColumn( 0, Qt::AscendingOrder );
|
view->sortByColumn( 0, Qt::AscendingOrder );
|
||||||
m_fontInfo = new QLabel( this );
|
m_fontInfo = new QLabel( this );
|
||||||
page2Layout->addWidget( m_fontInfo );
|
page2Layout->addWidget( m_fontInfo );
|
||||||
m_fontInfo->setText( i18n( "Reading font information..." ) );
|
m_fontInfo->setText( i18n( "Reading font information..." ) );
|
||||||
m_fontInfo->hide();
|
m_fontInfo->hide();
|
||||||
m_fontProgressBar = new QProgressBar( this );
|
m_fontProgressBar = new QProgressBar( this );
|
||||||
page2Layout->addWidget( m_fontProgressBar );
|
page2Layout->addWidget( m_fontProgressBar );
|
||||||
m_fontProgressBar->setRange( 0, 100 );
|
m_fontProgressBar->setRange( 0, 100 );
|
||||||
m_fontProgressBar->setValue( 0 );
|
m_fontProgressBar->setValue( 0 );
|
||||||
m_fontProgressBar->hide();
|
m_fontProgressBar->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
// current width: left columnt + right column + dialog borders
|
// current width: left columnt + right column + dialog borders
|
||||||
int width = layout->minimumSize().width() + valMaxWidth + 2 * marginHint() + spacingHint() + 30;
|
int width = layout->minimumSize().width() + valMaxWidth + 2 * marginHint() + spacingHint() + 30;
|
||||||
if ( page2Layout )
|
if ( page2Layout )
|
||||||
width = qMax( width, page2Layout->sizeHint().width() + marginHint() + spacingHint() + 31 );
|
width = qMax( width, page2Layout->sizeHint().width() + marginHint() + spacingHint() + 31 );
|
||||||
// stay inside the 2/3 of the screen width
|
// stay inside the 2/3 of the screen width
|
||||||
QRect screenContainer = KGlobalSettings::desktopGeometry( this );
|
QRect screenContainer = KGlobalSettings::desktopGeometry( this );
|
||||||
width = qMin( width, 2*screenContainer.width()/3 );
|
width = qMin( width, 2*screenContainer.width()/3 );
|
||||||
resize(width, 1);
|
resize(width, 1);
|
||||||
|
|
||||||
connect( pageWidget(), SIGNAL(currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)),
|
connect( pageWidget(), SIGNAL(currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)),
|
||||||
this, SLOT(pageChanged(KPageWidgetItem*,KPageWidgetItem*)) );
|
this, SLOT(pageChanged(KPageWidgetItem*,KPageWidgetItem*)) );
|
||||||
|
|
Loading…
Reference in a new issue