Commit aa6ed8af authored by Jan Binder's avatar Jan Binder Committed by Albert Astals Cid
Browse files

Replace deprecated QMatrix by QTransform

REVIEW: 105737
parent 21fd5cfb
......@@ -849,18 +849,18 @@ void Annotation::store( QDomNode & annNode, QDomDocument & document ) const
}
}
void AnnotationPrivate::annotationTransform( const QMatrix &matrix )
void AnnotationPrivate::annotationTransform( const QTransform &matrix )
{
resetTransformation();
transform( matrix );
}
void AnnotationPrivate::transform( const QMatrix &matrix )
void AnnotationPrivate::transform( const QTransform &matrix )
{
m_transformedBoundary.transform( matrix );
}
void AnnotationPrivate::baseTransform( const QMatrix &matrix )
void AnnotationPrivate::baseTransform( const QTransform &matrix )
{
m_boundary.transform( matrix );
}
......@@ -898,8 +898,8 @@ class Okular::TextAnnotationPrivate : public Okular::AnnotationPrivate
{
}
virtual void transform( const QMatrix &matrix );
virtual void baseTransform( const QMatrix &matrix );
virtual void transform( const QTransform &matrix );
virtual void baseTransform( const QTransform &matrix );
virtual void resetTransformation();
virtual void translate( const NormalizedPoint &coord );
virtual bool openDialogAfterCreation() const;
......@@ -1130,7 +1130,7 @@ void TextAnnotation::store( QDomNode & node, QDomDocument & document ) const
}
}
void TextAnnotationPrivate::transform( const QMatrix &matrix )
void TextAnnotationPrivate::transform( const QTransform &matrix )
{
AnnotationPrivate::transform( matrix );
......@@ -1139,7 +1139,7 @@ void TextAnnotationPrivate::transform( const QMatrix &matrix )
}
}
void TextAnnotationPrivate::baseTransform( const QMatrix &matrix )
void TextAnnotationPrivate::baseTransform( const QTransform &matrix )
{
AnnotationPrivate::baseTransform( matrix );
......@@ -1190,8 +1190,8 @@ class Okular::LineAnnotationPrivate : public Okular::AnnotationPrivate
{
}
virtual void transform( const QMatrix &matrix );
virtual void baseTransform( const QMatrix &matrix );
virtual void transform( const QTransform &matrix );
virtual void baseTransform( const QTransform &matrix );
virtual void resetTransformation();
virtual void translate( const NormalizedPoint &coord );
......@@ -1434,7 +1434,7 @@ void LineAnnotation::store( QDomNode & node, QDomDocument & document ) const
}
}
void LineAnnotationPrivate::transform( const QMatrix &matrix )
void LineAnnotationPrivate::transform( const QTransform &matrix )
{
AnnotationPrivate::transform( matrix );
......@@ -1443,7 +1443,7 @@ void LineAnnotationPrivate::transform( const QMatrix &matrix )
it.next().transform( matrix );
}
void LineAnnotationPrivate::baseTransform( const QMatrix &matrix )
void LineAnnotationPrivate::baseTransform( const QTransform &matrix )
{
AnnotationPrivate::baseTransform( matrix );
......@@ -1662,7 +1662,7 @@ double HighlightAnnotation::Quad::feather() const
return d->m_feather;
}
void HighlightAnnotation::Quad::transform( const QMatrix &matrix )
void HighlightAnnotation::Quad::transform( const QTransform &matrix )
{
for ( int i = 0; i < 4; ++i ) {
d->m_transformedPoints[ i ] = d->m_points[ i ];
......@@ -1679,8 +1679,8 @@ class Okular::HighlightAnnotationPrivate : public Okular::AnnotationPrivate
{
}
virtual void transform( const QMatrix &matrix );
virtual void baseTransform( const QMatrix &matrix );
virtual void transform( const QTransform &matrix );
virtual void baseTransform( const QTransform &matrix );
HighlightAnnotation::HighlightType m_highlightType;
QList< HighlightAnnotation::Quad > m_highlightQuads;
......@@ -1725,7 +1725,7 @@ HighlightAnnotation::HighlightAnnotation( const QDomNode & node )
q.setCapEnd( qe.hasAttribute( "end" ) );
q.setFeather( qe.attribute( "feather", "0.1" ).toDouble() );
q.transform( QMatrix() );
q.transform( QTransform() );
d->m_highlightQuads.append( q );
}
......@@ -1800,7 +1800,7 @@ Annotation::SubType HighlightAnnotation::subType() const
return AHighlight;
}
void HighlightAnnotationPrivate::transform( const QMatrix &matrix )
void HighlightAnnotationPrivate::transform( const QTransform &matrix )
{
AnnotationPrivate::transform( matrix );
......@@ -1809,7 +1809,7 @@ void HighlightAnnotationPrivate::transform( const QMatrix &matrix )
it.next().transform( matrix );
}
void HighlightAnnotationPrivate::baseTransform( const QMatrix &matrix )
void HighlightAnnotationPrivate::baseTransform( const QTransform &matrix )
{
AnnotationPrivate::baseTransform( matrix );
......@@ -1904,8 +1904,8 @@ class Okular::InkAnnotationPrivate : public Okular::AnnotationPrivate
{
}
virtual void transform( const QMatrix &matrix );
virtual void baseTransform( const QMatrix &matrix );
virtual void transform( const QTransform &matrix );
virtual void baseTransform( const QTransform &matrix );
virtual void resetTransformation();
virtual void translate( const NormalizedPoint &coord );
......@@ -2029,7 +2029,7 @@ void InkAnnotation::store( QDomNode & node, QDomDocument & document ) const
}
}
void InkAnnotationPrivate::transform( const QMatrix &matrix )
void InkAnnotationPrivate::transform( const QTransform &matrix )
{
AnnotationPrivate::transform( matrix );
......@@ -2041,7 +2041,7 @@ void InkAnnotationPrivate::transform( const QMatrix &matrix )
}
}
void InkAnnotationPrivate::baseTransform( const QMatrix &matrix )
void InkAnnotationPrivate::baseTransform( const QTransform &matrix )
{
AnnotationPrivate::baseTransform( matrix );
......
......@@ -1181,7 +1181,7 @@ class OKULAR_EXPORT HighlightAnnotation : public Annotation
* Transforms the quad coordinates with the transformation defined
* by @p matrix.
*/
void transform( const QMatrix &matrix );
void transform( const QTransform &matrix );
private:
class Private;
......
......@@ -19,7 +19,7 @@
#include <QtCore/QVariant>
#include <QtGui/QColor>
class QMatrix;
class QTransform;
namespace Okular {
......@@ -36,10 +36,10 @@ class AnnotationPrivate
* Transforms the annotation coordinates with the transformation
* defined by @p matrix.
*/
void annotationTransform( const QMatrix &matrix );
void annotationTransform( const QTransform &matrix );
virtual void transform( const QMatrix &matrix );
virtual void baseTransform( const QMatrix &matrix );
virtual void transform( const QTransform &matrix );
virtual void baseTransform( const QTransform &matrix );
virtual void resetTransformation();
virtual void translate( const NormalizedPoint &coord );
virtual bool openDialogAfterCreation() const;
......
......@@ -40,7 +40,7 @@ NormalizedPoint& NormalizedPoint::operator=( const NormalizedPoint & p )
return *this;
}
void NormalizedPoint::transform( const QMatrix &matrix )
void NormalizedPoint::transform( const QTransform &matrix )
{
qreal tmp_x = (qreal)x;
qreal tmp_y = (qreal)y;
......@@ -190,7 +190,7 @@ QRect NormalizedRect::roundedGeometry( int xScale, int yScale ) const
return QRect( l, t, r - l + 1, b - t + 1 );
}
void NormalizedRect::transform( const QMatrix &matrix )
void NormalizedRect::transform( const QTransform &matrix )
{
QRectF rect( left, top, right - left, bottom - top );
rect = matrix.mapRect( rect );
......@@ -305,7 +305,7 @@ bool ObjectRect::contains( double x, double y, double, double ) const
return m_transformedPath.contains( QPointF( x, y ) );
}
void ObjectRect::transform( const QMatrix &matrix )
void ObjectRect::transform( const QTransform &matrix )
{
m_transformedPath = matrix.map( m_path );
}
......@@ -385,7 +385,7 @@ AnnotationObjectRect::~AnnotationObjectRect()
m_object = 0;
}
void AnnotationObjectRect::transform( const QMatrix &matrix )
void AnnotationObjectRect::transform( const QTransform &matrix )
{
m_annotation->d_func()->annotationTransform( matrix );
}
......
......@@ -13,6 +13,7 @@
#include <QtCore/QList>
#include <QtGui/QColor>
#include <QtGui/QPainterPath>
#include <QtGui/QTransform>
#include <kdebug.h>
#include "global.h"
......@@ -69,7 +70,7 @@ class OKULAR_EXPORT NormalizedPoint
/**
* Transforms the normalized point with the operations defined by @p matrix.
*/
void transform( const QMatrix &matrix );
void transform( const QTransform &matrix );
/**
* The normalized x coordinate.
......@@ -206,7 +207,7 @@ class OKULAR_EXPORT NormalizedRect
/**
* Transforms the normalized rectangle with the operations defined by @p matrix.
*/
void transform( const QMatrix &matrix );
void transform( const QTransform &matrix );
/**
* Returns true if the point pt is located to the bottom of the rectangle
......@@ -370,7 +371,7 @@ class OKULAR_EXPORT ObjectRect
/**
* Transforms the object rectangle with the operations defined by @p matrix.
*/
virtual void transform( const QMatrix &matrix );
virtual void transform( const QTransform &matrix );
/**
* Returns the square of the distance between the object and the point @p x, @p y
......@@ -425,7 +426,7 @@ class OKULAR_EXPORT AnnotationObjectRect : public ObjectRect
/**
* Transforms the annotation object rectangle with the operations defined by @p matrix.
*/
virtual void transform( const QMatrix &matrix );
virtual void transform( const QTransform &matrix );
private:
Annotation * m_annotation;
......@@ -576,7 +577,7 @@ template <class NormalizedShape, class Shape> class RegularArea : public QList<
/**
* Transforms the regular area with the operations defined by @p matrix.
*/
void transform( const QMatrix &matrix );
void transform( const QTransform &matrix );
};
template <class NormalizedShape, class Shape>
......@@ -808,7 +809,7 @@ QList<Shape> RegularArea<NormalizedShape, Shape>::geometry( int xScale, int ySca
}
template <class NormalizedShape, class Shape>
void RegularArea<NormalizedShape, Shape>::transform( const QMatrix &matrix )
void RegularArea<NormalizedShape, Shape>::transform( const QTransform &matrix )
{
if ( !this )
return;
......
......@@ -102,9 +102,9 @@ void PagePrivate::imageRotationDone( RotationJob * job )
}
}
QMatrix PagePrivate::rotationMatrix() const
QTransform PagePrivate::rotationMatrix() const
{
QMatrix matrix;
QTransform matrix;
matrix.rotate( (int)m_rotation * 90 );
switch ( m_rotation )
......@@ -369,7 +369,7 @@ void PagePrivate::rotateAt( Rotation orientation )
/**
* Rotate the object rects on the page.
*/
const QMatrix matrix = rotationMatrix();
const QTransform matrix = rotationMatrix();
QLinkedList< ObjectRect * >::const_iterator objectIt = m_page->m_rects.begin(), end = m_page->m_rects.end();
for ( ; objectIt != end; ++objectIt )
(*objectIt)->transform( matrix );
......@@ -519,7 +519,7 @@ void Page::setObjectRects( const QLinkedList< ObjectRect * > & rects )
/**
* Rotate the object rects of the page.
*/
const QMatrix matrix = d->rotationMatrix();
const QTransform matrix = d->rotationMatrix();
QLinkedList< ObjectRect * >::const_iterator objectIt = rects.begin(), end = rects.end();
for ( ; objectIt != end; ++objectIt )
......@@ -601,7 +601,7 @@ void Page::addAnnotation( Annotation * annotation )
AnnotationObjectRect *rect = new AnnotationObjectRect( annotation );
// Rotate the annotation on the page.
const QMatrix matrix = d->rotationMatrix();
const QTransform matrix = d->rotationMatrix();
annotation->d_ptr->baseTransform( matrix.inverted() );
annotation->d_ptr->annotationTransform( matrix );
......
......@@ -14,7 +14,7 @@
// qt/kde includes
#include <qlinkedlist.h>
#include <qmap.h>
#include <qmatrix.h>
#include <qtransform.h>
#include <qstring.h>
#include <qdom.h>
......@@ -57,7 +57,7 @@ class PagePrivate
~PagePrivate();
void imageRotationDone( RotationJob * job );
QMatrix rotationMatrix() const;
QTransform rotationMatrix() const;
/**
* Loads the local contents (e.g. annotations) of the page.
......
......@@ -9,7 +9,7 @@
#include "rotationjob_p.h"
#include <QtGui/QMatrix>
#include <QtGui/QTransform>
using namespace Okular;
......@@ -50,14 +50,14 @@ void RotationJob::run()
return;
}
QMatrix matrix = rotationMatrix( mOldRotation, mNewRotation );
QTransform matrix = rotationMatrix( mOldRotation, mNewRotation );
mRotatedImage = mImage.transformed( matrix );
}
QMatrix RotationJob::rotationMatrix( Rotation from, Rotation to )
QTransform RotationJob::rotationMatrix( Rotation from, Rotation to )
{
QMatrix matrix;
QTransform matrix;
if ( from == Rotation0 ) {
if ( to == Rotation90 )
......
......@@ -11,7 +11,7 @@
#define _OKULAR_ROTATIONJOB_P_H_
#include <QtGui/QImage>
#include <QtGui/QMatrix>
#include <QtGui/QTransform>
#include <threadweaver/Job.h>
......@@ -35,7 +35,7 @@ class RotationJob : public ThreadWeaver::Job
int id() const;
PagePrivate * page() const;
static QMatrix rotationMatrix( Rotation from, Rotation to );
static QTransform rotationMatrix( Rotation from, Rotation to );
protected:
virtual void run();
......
......@@ -174,7 +174,7 @@ class TinyTextEntity
: QString::fromRawData( d.data, length );
}
inline NormalizedRect transformedArea( const QMatrix &matrix ) const
inline NormalizedRect transformedArea( const QTransform &matrix ) const
{
NormalizedRect transformed_area = area;
transformed_area.transform( matrix );
......@@ -215,7 +215,7 @@ NormalizedRect* TextEntity::area() const
return m_area;
}
NormalizedRect TextEntity::transformedArea(const QMatrix &matrix) const
NormalizedRect TextEntity::transformedArea(const QTransform &matrix) const
{
NormalizedRect transformed_area = *m_area;
transformed_area.transform( matrix );
......@@ -359,7 +359,7 @@ RegularAreaRect * TextPage::textArea ( TextSelection * sel) const
*/
RegularAreaRect * ret= new RegularAreaRect;
const QMatrix matrix = d->m_page ? d->m_page->rotationMatrix() : QMatrix();
const QTransform matrix = d->m_page ? d->m_page->rotationMatrix() : QTransform();
#if 0
int it = -1;
int itB = -1;
......@@ -840,7 +840,7 @@ RegularAreaRect* TextPagePrivate::findTextInternalForward( int searchID, const Q
const TextList::ConstIterator &start,
const TextList::ConstIterator &end )
{
const QMatrix matrix = m_page ? m_page->rotationMatrix() : QMatrix();
const QTransform matrix = m_page ? m_page->rotationMatrix() : QTransform();
RegularAreaRect* ret=new RegularAreaRect;
......@@ -955,7 +955,7 @@ RegularAreaRect* TextPagePrivate::findTextInternalBackward( int searchID, const
const TextList::ConstIterator &start,
const TextList::ConstIterator &end )
{
const QMatrix matrix = m_page ? m_page->rotationMatrix() : QMatrix();
const QTransform matrix = m_page ? m_page->rotationMatrix() : QTransform();
RegularAreaRect* ret=new RegularAreaRect;
......
......@@ -16,7 +16,7 @@
#include "okular_export.h"
#include "global.h"
class QMatrix;
class QTransform;
namespace Okular {
......@@ -70,7 +70,7 @@ class OKULAR_EXPORT TextEntity
/**
* Returns the transformed area of the text entity.
*/
NormalizedRect transformedArea(const QMatrix &matrix) const;
NormalizedRect transformedArea(const QTransform &matrix) const;
private:
QString m_text;
......
......@@ -14,7 +14,7 @@
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QPair>
#include <QtGui/QMatrix>
#include <QtGui/QTransform>
class SearchPoint;
class TinyTextEntity;
......
......@@ -86,7 +86,7 @@ void GSRendererThread::run()
{
case Okular::Rotation90:
{
QMatrix m;
QTransform m;
m.rotate(90);
img = img.transformed( m );
break;
......@@ -94,14 +94,14 @@ void GSRendererThread::run()
case Okular::Rotation180:
{
QMatrix m;
QTransform m;
m.rotate(180);
img = img.transformed( m );
break;
}
case Okular::Rotation270:
{
QMatrix m;
QTransform m;
m.rotate(270);
img = img.transformed( m );
}
......
......@@ -393,18 +393,18 @@ static QPainterPath parseAbbreviatedPathData( const QString &data)
/**
Parse a "Matrix" attribute string
\param csv the comma separated list of values
\return the QMatrix corresponding to the affine transform
\return the QTransform corresponding to the affine transform
given in the attribute
\see XPS specification 7.4.1
*/
static QMatrix attsToMatrix( const QString &csv )
static QTransform attsToMatrix( const QString &csv )
{
QStringList values = csv.split( ',' );
if ( values.count() != 6 ) {
return QMatrix(); // that is an identity matrix - no effect
return QTransform(); // that is an identity matrix - no effect
}
return QMatrix( values.at(0).toDouble(), values.at(1).toDouble(),
return QTransform( values.at(0).toDouble(), values.at(1).toDouble(),
values.at(2).toDouble(), values.at(3).toDouble(),
values.at(4).toDouble(), values.at(5).toDouble() );
}
......@@ -440,12 +440,12 @@ static QPen parseRscRefColorForPen( const QString &data )
/**
\return Matrix specified by given data or by referenced dictionary
*/
static QMatrix parseRscRefMatrix( const QString &data )
static QTransform parseRscRefMatrix( const QString &data )
{
if (data[0] == '{') {
//TODO
kDebug(XpsDebug) << "Reference" << data;
return QMatrix();
return QTransform();
} else {
return attsToMatrix( data );
}
......@@ -878,7 +878,7 @@ void XpsHandler::processGlyph( XpsRenderNode &node )
//RenderTransform
att = node.attributes.value("RenderTransform");
if (!att.isEmpty()) {
m_painter->setWorldMatrix( parseRscRefMatrix( att ), true);
m_painter->setWorldTransform( parseRscRefMatrix( att ), true);
}
// Clip
......@@ -984,27 +984,27 @@ void XpsHandler::processImageBrush( XpsRenderNode &node )
QImage image = m_page->loadImageFromFile( node.attributes.value( "ImageSource" ) );
// Matrix which can transform [0, 0, 1, 1] rectangle to given viewbox
QMatrix viewboxMatrix = QMatrix( viewbox.width() * image.physicalDpiX() / 96, 0, 0, viewbox.height() * image.physicalDpiY() / 96, viewbox.x(), viewbox.y() );
QTransform viewboxMatrix = QTransform( viewbox.width() * image.physicalDpiX() / 96, 0, 0, viewbox.height() * image.physicalDpiY() / 96, viewbox.x(), viewbox.y() );
// Matrix which can transform [0, 0, 1, 1] rectangle to given viewport
//TODO Take ViewPort into account
QMatrix viewportMatrix;
QTransform viewportMatrix;
att = node.attributes.value( "Transform" );
if ( att.isEmpty() ) {
QVariant data = node.getChildData( "ImageBrush.Transform" );
if (data.canConvert<QMatrix>()) {
viewportMatrix = data.value<QMatrix>();
if (data.canConvert<QTransform>()) {
viewportMatrix = data.value<QTransform>();
} else {
viewportMatrix = QMatrix();
viewportMatrix = QTransform();
}
} else {
viewportMatrix = parseRscRefMatrix( att );
}
viewportMatrix = viewportMatrix * QMatrix( viewport.width(), 0, 0, viewport.height(), viewport.x(), viewport.y() );
viewportMatrix = viewportMatrix * QTransform( viewport.width(), 0, 0, viewport.height(), viewport.x(), viewport.y() );
brush = QBrush( image );
brush.setMatrix( viewboxMatrix.inverted() * viewportMatrix );
brush.setTransform( viewboxMatrix.inverted() * viewportMatrix );
node.data = qVariantFromValue( brush );
}
......@@ -1135,10 +1135,10 @@ void XpsHandler::processPath( XpsRenderNode &node )
// RenderTransform
att = node.attributes.value( "RenderTransform" );
if (! att.isEmpty() ) {
m_painter->setWorldMatrix( parseRscRefMatrix( att ), true );
m_painter->setWorldTransform( parseRscRefMatrix( att ), true );
}
if ( !pathdata->transform.isIdentity() ) {
m_painter->setWorldMatrix( pathdata->transform, true );
m_painter->setWorldTransform( pathdata->transform, true );
}
Q_FOREACH ( XpsPathFigure *figure, pathdata->paths ) {
......@@ -1292,7 +1292,7 @@ void XpsHandler::processStartElement( XpsRenderNode &node )
m_painter->save();
QString att = node.attributes.value( "RenderTransform" );
if ( !att.isEmpty() ) {
m_painter->setWorldMatrix( parseRscRefMatrix( att ), true );
m_painter->setWorldTransform( parseRscRefMatrix( att ), true );
}
att = node.attributes.value( "Opacity" );
if ( !att.isEmpty() ) {
......@@ -1316,11 +1316,11 @@ void XpsHandler::processEndElement( XpsRenderNode &node )
processPath( node );
} else if (node.name == "MatrixTransform") {
//TODO Ignoring x:key
node.data = qVariantFromValue( QMatrix( attsToMatrix( node.attributes.value( "Matrix" ) ) ) );
node.data = qVariantFromValue( QTransform( attsToMatrix( node.attributes.value( "Matrix" ) ) ) );
} else if ((node.name == "Canvas.RenderTransform") || (node.name == "Glyphs.RenderTransform") || (node.name == "Path.RenderTransform")) {
QVariant data = node.getRequiredChildData( "MatrixTransform" );
if (data.canConvert<QMatrix>()) {
m_painter->setWorldMatrix( data.value<QMatrix>(), true );
if (data.canConvert<QTransform>()) {
m_painter->setWorldTransform( data.value<QTransform>(), true );
}
} else if (node.name == "Canvas") {
m_painter->restore();
......@@ -1461,7 +1461,7 @@ bool XpsPage::renderToPainter( QPainter *painter )
{
XpsHandler handler( this );
handler.m_painter = painter;
handler.m_painter->setWorldMatrix(QMatrix().scale((qreal)painter->device()->width() / size().width(), (qreal)painter->device()->height() / size().height()));
handler.m_painter->setWorldTransform(QTransform().scale((qreal)painter->device()->width() / size().width(), (qreal)painter->device()->height() / size().height()));
QXmlSimpleReader parser;
parser.setContentHandler( &handler );
parser.setErrorHandler( &handler );
......@@ -1617,9 +1617,9 @@ Okular::TextPage* XpsPage::textPage()
QXmlStreamReader xml;
xml.addData( readFileOrDirectoryParts( pageFile ) );
QMatrix matrix = QMatrix();
QStack<QMatrix> matrices;
matrices.push( QMatrix() );
QTransform matrix = QTransform();
QStack<QTransform> matrices;
matrices.push( QTransform() );
bool useMatrix = false;
QXmlStreamAttributes glyphsAtts;
......
......@@ -76,8 +76,8 @@ struct XpsGradient