mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-14 20:03:38 +00:00
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
This commit is contained in:
parent
e82ba7082a
commit
e182f47cba
|
@ -428,7 +428,7 @@ Annotation::RevisionType Annotation::Revision::type() const
|
|||
|
||||
|
||||
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 )
|
|||
|
||||
Annotation::~Annotation()
|
||||
{
|
||||
if ( d_ptr->m_disposeFunc )
|
||||
d_ptr->m_disposeFunc( this );
|
||||
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
|
@ -699,6 +702,24 @@ const QLinkedList< Annotation::Revision > & Annotation::revisions() const
|
|||
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
|
||||
{
|
||||
Q_D( const Annotation );
|
||||
|
|
|
@ -166,6 +166,16 @@ class OKULAR_EXPORT Annotation
|
|||
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.
|
||||
*/
|
||||
|
@ -567,6 +577,36 @@ class OKULAR_EXPORT Annotation
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
// qt/kde includes
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtGui/QColor>
|
||||
|
||||
class QMatrix;
|
||||
|
@ -57,6 +58,9 @@ class AnnotationPrivate
|
|||
Okular::Annotation::Style m_style;
|
||||
Okular::Annotation::Window m_window;
|
||||
QLinkedList< Okular::Annotation::Revision > m_revisions;
|
||||
|
||||
Annotation::DisposeDataFunction m_disposeFunc;
|
||||
QVariant m_nativeId;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue