Add a basic version (just the internal class, not the visualisation) of Caret annotation.

svn path=/trunk/KDE/kdegraphics/okular/; revision=793884
remotes/origin/KDE/4.1
Pino Toscano 18 years ago
parent 3a05c50287
commit ba9042c2e0
  1. 79
      core/annotations.cpp
  2. 46
      core/annotations.h

@ -49,6 +49,9 @@ Annotation * AnnotationUtils::createAnnotation( const QDomElement & annElement )
case Annotation::AInk:
annotation = new InkAnnotation( annElement );
break;
case Annotation::ACaret:
annotation = new CaretAnnotation( annElement );
break;
}
// return created annotation
@ -2027,3 +2030,79 @@ void InkAnnotationPrivate::translate( const NormalizedPoint &coord )
}
}
}
/** CaretAnnotation [Annotation] */
class Okular::CaretAnnotationPrivate : public Okular::AnnotationPrivate
{
public:
CaretAnnotationPrivate()
: AnnotationPrivate(), m_symbol( "None" )
{
}
QString m_symbol;
};
CaretAnnotation::CaretAnnotation()
: Annotation( *new CaretAnnotationPrivate() )
{
}
CaretAnnotation::CaretAnnotation( const QDomNode & node )
: Annotation( *new CaretAnnotationPrivate(), node )
{
Q_D( CaretAnnotation );
// loop through the whole children looking for a 'caret' element
QDomNode subNode = node.firstChild();
while( subNode.isElement() )
{
QDomElement e = subNode.toElement();
subNode = subNode.nextSibling();
if ( e.tagName() != "caret" )
continue;
// parse the attributes
if ( e.hasAttribute( "symbol" ) )
d->m_symbol = e.attribute( "symbol" );
// loading complete
break;
}
}
CaretAnnotation::~CaretAnnotation()
{
}
void CaretAnnotation::setCaretSymbol( const QString &symbol )
{
Q_D( CaretAnnotation );
d->m_symbol = symbol;
}
QString CaretAnnotation::caretSymbol() const
{
Q_D( const CaretAnnotation );
return d->m_symbol;
}
Annotation::SubType CaretAnnotation::subType() const
{
return ACaret;
}
void CaretAnnotation::store( QDomNode & node, QDomDocument & document ) const
{
Q_D( const CaretAnnotation );
// recurse to parent objects storing properties
Annotation::store( node, document );
// create [caret] element
QDomElement caretElement = document.createElement( "caret" );
node.appendChild( caretElement );
// append the optional attributes
if ( d->m_symbol != "None" )
caretElement.setAttribute( "symbol", d->m_symbol );
}

@ -35,6 +35,7 @@ class GeomAnnotationPrivate;
class HighlightAnnotationPrivate;
class StampAnnotationPrivate;
class InkAnnotationPrivate;
class CaretAnnotationPrivate;
/**
* @short Helper class for (recursive) annotation retrieval/storage.
@ -101,6 +102,7 @@ class OKULAR_EXPORT Annotation
AHighlight = 4, ///< A highlight annotation
AStamp = 5, ///< A stamp annotation
AInk = 6, ///< An ink annotation
ACaret = 8, ///< A caret annotation
A_BASE = 0 ///< The annotation base class
};
@ -1191,6 +1193,50 @@ class OKULAR_EXPORT InkAnnotation : public Annotation
Q_DISABLE_COPY( InkAnnotation )
};
class OKULAR_EXPORT CaretAnnotation : public Annotation
{
public:
/**
* Creates a new caret annotation.
*/
CaretAnnotation();
/**
* Creates a new caret annotation from the xml @p description
*/
explicit CaretAnnotation( const QDomNode &description );
/**
* Destroys the caret annotation.
*/
~CaretAnnotation();
/**
* Sets the @p symbol for the caret annotation.
*/
void setCaretSymbol( const QString &symbol );
/**
* Returns the symbol of the annotation.
*/
QString caretSymbol() const;
/**
* 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( CaretAnnotation )
Q_DISABLE_COPY( CaretAnnotation )
};
}
#endif

Loading…
Cancel
Save