Add support in the Okular core for File Attachment annotations.

(Although, they cannot be (de)serialized to XML.)

CCBUG: 155072

svn path=/trunk/KDE/kdegraphics/okular/; revision=796467
remotes/origin/KDE/4.1
Pino Toscano 18 years ago
parent f7e7386113
commit 095d8fc384
  1. 85
      core/annotations.cpp
  2. 38
      core/annotations.h

@ -15,6 +15,7 @@
#include <QtGui/QColor>
// local includes
#include "document.h"
#include "page_p.h"
using namespace Okular;
@ -2145,3 +2146,87 @@ void CaretAnnotation::store( QDomNode & node, QDomDocument & document ) const
if ( d->m_symbol != None )
caretElement.setAttribute( "symbol", caretSymbolToString( d->m_symbol ) );
}
/** FileAttachmentAnnotation [Annotation] */
class Okular::FileAttachmentAnnotationPrivate : public Okular::AnnotationPrivate
{
public:
FileAttachmentAnnotationPrivate()
: AnnotationPrivate(), icon( "PushPin" ), embfile( 0 )
{
}
~FileAttachmentAnnotationPrivate()
{
delete embfile;
}
// data fields
QString icon;
EmbeddedFile *embfile;
};
FileAttachmentAnnotation::FileAttachmentAnnotation()
: Annotation( *new FileAttachmentAnnotationPrivate() )
{
}
FileAttachmentAnnotation::FileAttachmentAnnotation( const QDomNode & node )
: Annotation( *new FileAttachmentAnnotationPrivate(), node )
{
// loop through the whole children looking for a 'fileattachment' element
QDomNode subNode = node.firstChild();
while( subNode.isElement() )
{
QDomElement e = subNode.toElement();
subNode = subNode.nextSibling();
if ( e.tagName() != "fileattachment" )
continue;
// loading complete
break;
}
}
FileAttachmentAnnotation::~FileAttachmentAnnotation()
{
}
void FileAttachmentAnnotation::store( QDomNode & node, QDomDocument & document ) const
{
// recurse to parent objects storing properties
Annotation::store( node, document );
// create [fileattachment] element
QDomElement fileAttachmentElement = document.createElement( "fileattachment" );
node.appendChild( fileAttachmentElement );
}
Annotation::SubType FileAttachmentAnnotation::subType() const
{
return AFileAttachment;
}
QString FileAttachmentAnnotation::fileIconName() const
{
Q_D( const FileAttachmentAnnotation );
return d->icon;
}
void FileAttachmentAnnotation::setFileIconName( const QString &icon )
{
Q_D( FileAttachmentAnnotation );
d->icon = icon;
}
EmbeddedFile* FileAttachmentAnnotation::embeddedFile() const
{
Q_D( const FileAttachmentAnnotation );
return d->embfile;
}
void FileAttachmentAnnotation::setEmbeddedFile( EmbeddedFile *ef )
{
Q_D( FileAttachmentAnnotation );
d->embfile = ef;
}

@ -27,6 +27,7 @@ class Annotation;
class AnnotationObjectRect;
class AnnotationPrivate;
class Document;
class EmbeddedFile;
class Page;
class PagePrivate;
class TextAnnotationPrivate;
@ -36,6 +37,7 @@ class HighlightAnnotationPrivate;
class StampAnnotationPrivate;
class InkAnnotationPrivate;
class CaretAnnotationPrivate;
class FileAttachmentAnnotationPrivate;
/**
* @short Helper class for (recursive) annotation retrieval/storage.
@ -103,6 +105,7 @@ class OKULAR_EXPORT Annotation
AStamp = 5, ///< A stamp annotation
AInk = 6, ///< An ink annotation
ACaret = 8, ///< A caret annotation
AFileAttachment = 9, ///< A file attachment annotation
A_BASE = 0 ///< The annotation base class
};
@ -1286,6 +1289,41 @@ class OKULAR_EXPORT CaretAnnotation : public Annotation
Q_DISABLE_COPY( CaretAnnotation )
};
class OKULAR_EXPORT FileAttachmentAnnotation : public Annotation
{
public:
/**
* Creates a new file attachment annotation.
*/
FileAttachmentAnnotation();
explicit FileAttachmentAnnotation( const QDomNode &node );
/**
* Destroys the file attachment annotation.
*/
virtual ~FileAttachmentAnnotation();
QString fileIconName() const;
void setFileIconName( const QString &icon );
EmbeddedFile* embeddedFile() const;
void setEmbeddedFile( EmbeddedFile *ef );
/**
* Returns the sub type of the caret annotation.
*/
SubType subType() const;
/**
* Stores the caret annotation as xml in @p document
* under the given parent @p node.
*/
void store( QDomNode &node, QDomDocument &document ) const;
private:
Q_DECLARE_PRIVATE( FileAttachmentAnnotation )
Q_DISABLE_COPY( FileAttachmentAnnotation )
};
}
#endif

Loading…
Cancel
Save