Merge window.text, contents and inplaceText annotation properties

BUG: 319442
REVIEW: 110391
remotes/origin/epub-qtextdoc
Jon Mease 13 years ago committed by Fabio D'Urso
parent 460502d124
commit 2ae9e58bb4
  1. 56
      core/annotations.cpp
  2. 20
      core/annotations.h
  3. 10
      core/document.cpp
  4. 2
      generators/djvu/generator_djvu.cpp
  5. 2
      generators/poppler/annots.cpp
  6. 2
      ui/pagepainter.cpp
  7. 5
      ui/pageviewannotator.cpp

@ -269,7 +269,6 @@ class Annotation::Window::Private
int m_height; int m_height;
QString m_title; QString m_title;
QString m_summary; QString m_summary;
QString m_text;
}; };
Annotation::Window::Window() Annotation::Window::Window()
@ -356,17 +355,6 @@ QString Annotation::Window::summary() const
return d->m_summary; return d->m_summary;
} }
void Annotation::Window::setText( const QString &text )
{
d->m_text = text;
}
QString Annotation::Window::text() const
{
return d->m_text;
}
class Annotation::Revision::Private class Annotation::Revision::Private
{ {
public: public:
@ -711,7 +699,7 @@ void Annotation::store( QDomNode & annNode, QDomDocument & document ) const
// Sub-Node-4 - window // Sub-Node-4 - window
if ( d->m_window.flags() != -1 || !d->m_window.title().isEmpty() || if ( d->m_window.flags() != -1 || !d->m_window.title().isEmpty() ||
!d->m_window.summary().isEmpty() || !d->m_window.text().isEmpty() ) !d->m_window.summary().isEmpty() )
{ {
QDomElement wE = document.createElement( "window" ); QDomElement wE = document.createElement( "window" );
e.appendChild( wE ); e.appendChild( wE );
@ -722,14 +710,6 @@ void Annotation::store( QDomNode & annNode, QDomDocument & document ) const
wE.setAttribute( "height", d->m_window.height() ); wE.setAttribute( "height", d->m_window.height() );
wE.setAttribute( "title", d->m_window.title() ); wE.setAttribute( "title", d->m_window.title() );
wE.setAttribute( "summary", d->m_window.summary() ); wE.setAttribute( "summary", d->m_window.summary() );
// store window.text as a subnode, because we need escaped data
if ( !d->m_window.text().isEmpty() )
{
QDomElement escapedText = document.createElement( "text" );
wE.appendChild( escapedText );
QDomCDATASection textCData = document.createCDATASection( d->m_window.text() );
escapedText.appendChild( textCData );
}
} }
// create [revision] element of the annotation node (if any) // create [revision] element of the annotation node (if any)
@ -890,14 +870,6 @@ void AnnotationPrivate::setAnnotationProperties( const QDomNode& node )
m_window.setHeight( ee.attribute( "height" ).toInt() ); m_window.setHeight( ee.attribute( "height" ).toInt() );
m_window.setTitle( ee.attribute( "title" ) ); m_window.setTitle( ee.attribute( "title" ) );
m_window.setSummary( ee.attribute( "summary" ) ); m_window.setSummary( ee.attribute( "summary" ) );
// parse window subnodes
QDomNode winNode = ee.firstChild();
for ( ; winNode.isElement(); winNode = winNode.nextSibling() )
{
QDomElement winElement = winNode.toElement();
if ( winElement.tagName() == "text" )
m_window.setText( winElement.firstChild().toCDATASection().data() );
}
} }
} }
@ -950,7 +922,6 @@ class Okular::TextAnnotationPrivate : public Okular::AnnotationPrivate
QString m_textIcon; QString m_textIcon;
QFont m_textFont; QFont m_textFont;
int m_inplaceAlign; int m_inplaceAlign;
QString m_inplaceText;
NormalizedPoint m_inplaceCallout[3]; NormalizedPoint m_inplaceCallout[3];
NormalizedPoint m_transformedInplaceCallout[3]; NormalizedPoint m_transformedInplaceCallout[3];
TextAnnotation::InplaceIntent m_inplaceIntent; TextAnnotation::InplaceIntent m_inplaceIntent;
@ -1021,18 +992,6 @@ int TextAnnotation::inplaceAlignment() const
return d->m_inplaceAlign; return d->m_inplaceAlign;
} }
void TextAnnotation::setInplaceText( const QString &text )
{
Q_D( TextAnnotation );
d->m_inplaceText = text;
}
QString TextAnnotation::inplaceText() const
{
Q_D( const TextAnnotation );
return d->m_inplaceText;
}
void TextAnnotation::setInplaceCallout( const NormalizedPoint &point, int index ) void TextAnnotation::setInplaceCallout( const NormalizedPoint &point, int index )
{ {
if ( index < 0 || index > 2 ) if ( index < 0 || index > 2 )
@ -1099,16 +1058,7 @@ void TextAnnotation::store( QDomNode & node, QDomDocument & document ) const
if ( d->m_inplaceIntent != Unknown ) if ( d->m_inplaceIntent != Unknown )
textElement.setAttribute( "intent", (int)d->m_inplaceIntent ); textElement.setAttribute( "intent", (int)d->m_inplaceIntent );
// Sub-Node-1 - escapedText // Sub-Node - callout
if ( !d->m_inplaceText.isEmpty() )
{
QDomElement escapedText = document.createElement( "escapedText" );
textElement.appendChild( escapedText );
QDomCDATASection textCData = document.createCDATASection( d->m_inplaceText );
escapedText.appendChild( textCData );
}
// Sub-Node-2 - callout
if ( d->m_inplaceCallout[0].x != 0.0 ) if ( d->m_inplaceCallout[0].x != 0.0 )
{ {
QDomElement calloutElement = document.createElement( "callout" ); QDomElement calloutElement = document.createElement( "callout" );
@ -1203,7 +1153,7 @@ void TextAnnotationPrivate::setAnnotationProperties( const QDomNode& node )
if ( ee.tagName() == "escapedText" ) if ( ee.tagName() == "escapedText" )
{ {
m_inplaceText = ee.firstChild().toCDATASection().data(); m_contents = ee.firstChild().toCDATASection().data();
} }
else if ( ee.tagName() == "callout" ) else if ( ee.tagName() == "callout" )
{ {

@ -512,16 +512,6 @@ class OKULAR_EXPORT Annotation
*/ */
QString summary() const; QString summary() const;
/**
* Sets the @p text of the window.
*/
void setText( const QString &text );
/**
* Returns the text of the window.
*/
QString text() const;
private: private:
class Private; class Private;
Private* const d; Private* const d;
@ -815,16 +805,6 @@ class OKULAR_EXPORT TextAnnotation : public Annotation
*/ */
int inplaceAlignment() const; int inplaceAlignment() const;
/**
* Sets the inplace @p text of the text annotation.
*/
void setInplaceText( const QString &text );
/**
* Returns the inplace text of the text annotation.
*/
QString inplaceText() const;
/** /**
* Sets the inplace callout @p point at @p index. * Sets the inplace callout @p point at @p index.
* *

@ -1151,14 +1151,7 @@ void DocumentPrivate::performSetAnnotationContents( const QString & newContents,
{ {
bool appearanceChanged = false; bool appearanceChanged = false;
// Set window text // Check if appearanceChanged should be true
if ( !annot->window().text().isEmpty() )
{
annot->window().setText( newContents );
return;
}
// Handle special cases
switch ( annot->subType() ) switch ( annot->subType() )
{ {
// If it's an in-place TextAnnotation, set the inplace text // If it's an in-place TextAnnotation, set the inplace text
@ -1167,7 +1160,6 @@ void DocumentPrivate::performSetAnnotationContents( const QString & newContents,
Okular::TextAnnotation * txtann = static_cast< Okular::TextAnnotation * >( annot ); Okular::TextAnnotation * txtann = static_cast< Okular::TextAnnotation * >( annot );
if ( txtann->textType() == Okular::TextAnnotation::InPlace ) if ( txtann->textType() == Okular::TextAnnotation::InPlace )
{ {
txtann->setInplaceText( newContents );
appearanceChanged = true; appearanceChanged = true;
} }
break; break;

@ -424,7 +424,7 @@ Okular::Annotation* DjVuGenerator::convertKDjVuAnnotation( int w, int h, KDjVu::
newtxtann->setTextType( txtann->inlineText() ? Okular::TextAnnotation::InPlace : Okular::TextAnnotation::Linked ); newtxtann->setTextType( txtann->inlineText() ? Okular::TextAnnotation::InPlace : Okular::TextAnnotation::Linked );
newtxtann->style().setOpacity( txtann->color().alphaF() ); newtxtann->style().setOpacity( txtann->color().alphaF() );
// FIXME remove once the annotation text handling is fixed // FIXME remove once the annotation text handling is fixed
newtxtann->setInplaceText( ann->comment() ); newtxtann->setContents( ann->comment() );
newann = newtxtann; newann = newtxtann;
break; break;
} }

@ -176,8 +176,6 @@ void PopplerAnnotationProxy::notifyModification( const Okular::Annotation *okl_a
ppl_txtann->setTextIcon( okl_txtann->textIcon() ); ppl_txtann->setTextIcon( okl_txtann->textIcon() );
ppl_txtann->setTextFont( okl_txtann->textFont() ); ppl_txtann->setTextFont( okl_txtann->textFont() );
ppl_txtann->setInplaceAlign( okl_txtann->inplaceAlignment() ); ppl_txtann->setInplaceAlign( okl_txtann->inplaceAlignment() );
if ( okl_txtann->textType() == Okular::TextAnnotation::InPlace )
ppl_txtann->setContents( okl_txtann->inplaceText() ); // overrides contents
ppl_txtann->setCalloutPoints( QVector<QPointF>() ); ppl_txtann->setCalloutPoints( QVector<QPointF>() );
ppl_txtann->setInplaceIntent( (Poppler::TextAnnotation::InplaceIntent)okl_txtann->inplaceIntent() ); ppl_txtann->setInplaceIntent( (Poppler::TextAnnotation::InplaceIntent)okl_txtann->inplaceIntent() );
break; break;

@ -696,7 +696,7 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
painter.scale( 1.0 * scaledWidth / page->width(), 1.0 * scaledHeight / page->height() ); painter.scale( 1.0 * scaledWidth / page->width(), 1.0 * scaledHeight / page->height() );
painter.drawText( 2, 2, image.width() - 2, image.height() - 2, painter.drawText( 2, 2, image.width() - 2, image.height() - 2,
Qt::AlignTop | halign | Qt::TextWordWrap, Qt::AlignTop | halign | Qt::TextWordWrap,
text->inplaceText() ); text->contents() );
painter.resetTransform(); painter.resetTransform();
painter.drawRect( 0, 0, image.width() - 1, image.height() - 1 ); painter.drawRect( 0, 0, image.width() - 1, image.height() - 1 );
painter.end(); painter.end();

@ -164,7 +164,7 @@ class PickPointEngine : public AnnotatorEngine
//add note //add note
Okular::TextAnnotation * ta = new Okular::TextAnnotation(); Okular::TextAnnotation * ta = new Okular::TextAnnotation();
ann = ta; ann = ta;
ta->setInplaceText( note ); ta->setContents( note );
ta->setTextType( Okular::TextAnnotation::InPlace ); ta->setTextType( Okular::TextAnnotation::InPlace );
//set boundary //set boundary
rect.left = qMin(startpoint.x,point.x); rect.left = qMin(startpoint.x,point.x);
@ -175,7 +175,7 @@ class PickPointEngine : public AnnotatorEngine
static int padding = 2; static int padding = 2;
const QFontMetricsF mf(ta->textFont()); const QFontMetricsF mf(ta->textFont());
const QRectF rcf = mf.boundingRect( Okular::NormalizedRect( rect.left, rect.top, 1.0, 1.0 ).geometry( (int)pagewidth, (int)pageheight ).adjusted( padding, padding, -padding, -padding ), const QRectF rcf = mf.boundingRect( Okular::NormalizedRect( rect.left, rect.top, 1.0, 1.0 ).geometry( (int)pagewidth, (int)pageheight ).adjusted( padding, padding, -padding, -padding ),
Qt::AlignTop | Qt::AlignLeft | Qt::TextWordWrap, ta->inplaceText() ); Qt::AlignTop | Qt::AlignLeft | Qt::TextWordWrap, ta->contents() );
rect.right = qMax(rect.right, rect.left+(rcf.width()+padding*2)/pagewidth); rect.right = qMax(rect.right, rect.left+(rcf.width()+padding*2)/pagewidth);
rect.bottom = qMax(rect.bottom, rect.top+(rcf.height()+padding*2)/pageheight); rect.bottom = qMax(rect.bottom, rect.top+(rcf.height()+padding*2)/pageheight);
ta->window().setSummary( i18n( "Inline Note" ) ); ta->window().setSummary( i18n( "Inline Note" ) );
@ -187,7 +187,6 @@ class PickPointEngine : public AnnotatorEngine
ann = ta; ann = ta;
ta->setTextType( Okular::TextAnnotation::Linked ); ta->setTextType( Okular::TextAnnotation::Linked );
ta->setTextIcon( "Note" ); ta->setTextIcon( "Note" );
ta->window().setText( QString() );
//ta->window.flags &= ~(Okular::Annotation::Hidden); //ta->window.flags &= ~(Okular::Annotation::Hidden);
const double iconhei=0.03; const double iconhei=0.03;
rect.left = point.x; rect.left = point.x;

Loading…
Cancel
Save