Commit e182f47c authored by Pino Toscano's avatar Pino Toscano

Add the possibility to store in an Annotation a "native id" of the annotation itself.

What it represents is totally in the hands of the various generators.

Add a function hook to cleanup the annotation data (the "native id", basically).

svn path=/trunk/KDE/kdegraphics/okular/; revision=796378
parent e82ba708
...@@ -428,7 +428,7 @@ Annotation::RevisionType Annotation::Revision::type() const ...@@ -428,7 +428,7 @@ Annotation::RevisionType Annotation::Revision::type() const
AnnotationPrivate::AnnotationPrivate() AnnotationPrivate::AnnotationPrivate()
: m_page( 0 ), m_flags( 0 ) : m_page( 0 ), m_flags( 0 ), m_disposeFunc( 0 )
{ {
} }
...@@ -554,6 +554,9 @@ Annotation::Annotation( AnnotationPrivate &dd, const QDomNode & annNode ) ...@@ -554,6 +554,9 @@ Annotation::Annotation( AnnotationPrivate &dd, const QDomNode & annNode )
Annotation::~Annotation() Annotation::~Annotation()
{ {
if ( d_ptr->m_disposeFunc )
d_ptr->m_disposeFunc( this );
delete d_ptr; delete d_ptr;
} }
...@@ -699,6 +702,24 @@ const QLinkedList< Annotation::Revision > & Annotation::revisions() const ...@@ -699,6 +702,24 @@ const QLinkedList< Annotation::Revision > & Annotation::revisions() const
return d->m_revisions; return d->m_revisions;
} }
void Annotation::setNativeId( const QVariant &id )
{
Q_D( Annotation );
d->m_nativeId = id;
}
QVariant Annotation::nativeId() const
{
Q_D( const Annotation );
return d->m_nativeId;
}
void Annotation::setDisposeDataFunction( DisposeDataFunction func )
{
Q_D( Annotation );
d->m_disposeFunc = func;
}
void Annotation::store( QDomNode & annNode, QDomDocument & document ) const void Annotation::store( QDomNode & annNode, QDomDocument & document ) const
{ {
Q_D( const Annotation ); Q_D( const Annotation );
......
...@@ -166,6 +166,16 @@ class OKULAR_EXPORT Annotation ...@@ -166,6 +166,16 @@ class OKULAR_EXPORT Annotation
Completed = 64 ///< Has been completed Completed = 64 ///< Has been completed
}; };
/**
* A function to be called when the annotation is destroyed.
*
* @warning the function must *not* call any virtual function,
* nor subcast.
*
* @since 0.7 (KDE 4.1)
*/
typedef void ( * DisposeDataFunction )( const Okular::Annotation * );
/** /**
* Destroys the annotation. * Destroys the annotation.
*/ */
...@@ -567,6 +577,36 @@ class OKULAR_EXPORT Annotation ...@@ -567,6 +577,36 @@ class OKULAR_EXPORT Annotation
*/ */
const QLinkedList< Revision > & revisions() const; const QLinkedList< Revision > & revisions() const;
/**
* Sets the "native" @p id of the annotation.
*
* This is for use of the Generator, that can optionally store an
* handle (a pointer, an identifier, etc) of the "native" annotation
* object, if any.
*
* @note Okular makes no use of this
*
* @since 0.7 (KDE 4.1)
*/
void setNativeId( const QVariant &id );
/**
* Returns the "native" id of the annotation.
*
* @since 0.7 (KDE 4.1)
*/
QVariant nativeId() const;
/**
* Sets a function to be called when the annotation is destroyed.
*
* @warning the function must *not* call any virtual function,
* nor subcast.
*
* @since 0.7 (KDE 4.1)
*/
void setDisposeDataFunction( DisposeDataFunction func );
/** /**
* Returns the sub type of the annotation. * Returns the sub type of the annotation.
*/ */
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// qt/kde includes // qt/kde includes
#include <QtCore/QDateTime> #include <QtCore/QDateTime>
#include <QtCore/QString> #include <QtCore/QString>
#include <QtCore/QVariant>
#include <QtGui/QColor> #include <QtGui/QColor>
class QMatrix; class QMatrix;
...@@ -57,6 +58,9 @@ class AnnotationPrivate ...@@ -57,6 +58,9 @@ class AnnotationPrivate
Okular::Annotation::Style m_style; Okular::Annotation::Style m_style;
Okular::Annotation::Window m_window; Okular::Annotation::Window m_window;
QLinkedList< Okular::Annotation::Revision > m_revisions; QLinkedList< Okular::Annotation::Revision > m_revisions;
Annotation::DisposeDataFunction m_disposeFunc;
QVariant m_nativeId;
}; };
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment