Commit afcfeac7 authored by Thomas Zander's avatar Thomas Zander

Constify viewConverter, and by dependency also;

- KoShape (and inheriting classes) paint, paintDecoration
- KoShapeManager paint
- KoZoomHandler

Also I fixed the group command; its wrong to use the initial bounding rect
and add to that if the initial has no objects.

svn path=/trunk/koffice/; revision=568286
parent c8af71f0
......@@ -27,6 +27,7 @@
#include "KoShapeControllerBase.h"
#include <klocale.h>
#include <kdebug.h>
KoShapeMoveCommand::KoShapeMoveCommand(const KoSelectionSet &shapes, QList<QPointF> &previousPositions, QList<QPointF> &newPositions)
: m_previousPositions(previousPositions)
......@@ -183,22 +184,55 @@ KoGroupShapesCommand::KoGroupShapesCommand() {
}
void KoGroupShapesCommand::execute () {
v v v v v v v
QList <QPointF> positions;
QRectF bound = m_container->boundingRect();
*************
QList <QPointF> positions;
bool boundingRectInitialized=true;
QRectF bound;
if(m_container->childCount() > 0)
bound = m_container->boundingRect();
else
boundingRectInitialized = false;
^ ^ ^ ^ ^ ^ ^
foreach(KoShape *shape, m_shapes) {
v v v v v v v
positions.append(shape->absolutePosition());
bound = bound.unite(shape->boundingRect());
*************
positions.append(shape->absolutePosition());
if(boundingRectInitialized)
bound = bound.unite(shape->boundingRect());
else {
bound = shape->boundingRect();
boundingRectInitialized = true;
}
^ ^ ^ ^ ^ ^ ^
m_container->addChild(shape);
v v v v v v v
^ ^ ^ ^ ^ ^ ^
}
v v v v v v v
for(int i=0; i < m_shapes.count(); i++) {
m_shapes[i]->setAbsolutePosition( positions[i] );
}
m_container->setPosition( bound.topLeft() );
m_container->resize( bound.size() );
*************
m_container->setPosition( bound.topLeft() );
m_container->resize( bound.size() );
for(int i=0; i < m_shapes.count(); i++) {
m_shapes[i]->setAbsolutePosition( positions[i] );
}
kDebug() << "after group: " << m_container->position().x() << ", " << m_container->position().y() << endl;
^ ^ ^ ^ ^ ^ ^
}
void KoGroupShapesCommand::unexecute () {
v v v v v v v
QList <QPointF> positions;
foreach(KoShape *shape, m_shapes)
positions.append(shape->absolutePosition());
......@@ -206,6 +240,7 @@ void KoGroupShapesCommand::unexecute () {
for(int i=0; i < m_shapes.count(); i++) {
m_container->removeChild(m_shapes[i]);
m_shapes[i]->setAbsolutePosition( positions[i] );
^ ^ ^ ^ ^ ^ ^
}
}
......@@ -348,34 +383,60 @@ KoShapeAlignCommand::KoShapeAlignCommand( const KoSelectionSet &shapes, Align al
QList<QPointF> previousPositions;
QList<QPointF> newPositions;
QPointF position;
v v v v v v v
QPointF delta;
^ ^ ^ ^ ^ ^ ^
QRectF bRect;
foreach( KoShape *shape, shapes ) {
if(dynamic_cast<KoShapeGroup*> (shape))
kDebug() << "Found Group\n";
else if(dynamic_cast<KoShapeContainer*> (shape))
kDebug() << "Found Container\n";
else
kDebug() << "Found shape\n";
position = shape->position();
previousPositions << position;
bRect = shape->boundingRect();
switch( align )
{
case ALIGN_HORIZONTAL_LEFT:
v v v v v v v
delta = QPointF( boundingRect.left(), bRect.y()) - bRect.topLeft();
^ ^ ^ ^ ^ ^ ^
break;
case ALIGN_HORIZONTAL_CENTER:
v v v v v v v
delta = QPointF( boundingRect.center().x() - bRect.width()/2, bRect.y()) - bRect.topLeft();
^ ^ ^ ^ ^ ^ ^
break;
case ALIGN_HORIZONTAL_RIGHT:
v v v v v v v
delta = QPointF( boundingRect.right() - bRect.width(), bRect.y()) - bRect.topLeft();
^ ^ ^ ^ ^ ^ ^
break;
case ALIGN_VERTICAL_TOP:
v v v v v v v
delta = QPointF( bRect.x(), boundingRect.top()) - bRect.topLeft();
^ ^ ^ ^ ^ ^ ^
break;
case ALIGN_VERTICAL_CENTER:
v v v v v v v
delta = QPointF( bRect.x(), boundingRect.center().y() - bRect.height()/2) - bRect.topLeft();
^ ^ ^ ^ ^ ^ ^
break;
case ALIGN_VERTICAL_BOTTOM:
v v v v v v v
delta = QPointF( bRect.x(), boundingRect.bottom() - bRect.height()) - bRect.topLeft();
^ ^ ^ ^ ^ ^ ^
break;
};
v v v v v v v
newPositions << position + delta;
*************
newPositions << position + delta;
kDebug() << "-> moving " << position.x() << "," << position.y() << " to " <<
(position + delta).x() << ", " << (position+delta).y() << endl;
^ ^ ^ ^ ^ ^ ^
}
m_command = new KoShapeMoveCommand(shapes, previousPositions, newPositions);
}
......@@ -443,7 +504,9 @@ KoShapeDistributeCommand::KoShapeDistributeCommand( const KoSelectionSet &shapes
QList<QPointF> previousPositions;
QList<QPointF> newPositions;
QPointF position;
v v v v v v v
QPointF delta;
^ ^ ^ ^ ^ ^ ^
QMapIterator<double,KoShape*> it(sortedPos);
while(it.hasNext())
{
......@@ -454,33 +517,51 @@ KoShapeDistributeCommand::KoShapeDistributeCommand( const KoSelectionSet &shapes
bRect = it.value()->boundingRect();
switch( m_distribute ) {
case DISTRIBUTE_HORIZONTAL_CENTER:
v v v v v v v
delta = QPointF( boundingRect.x() + first->boundingRect().width()/2 + pos - bRect.width()/2, bRect.y() ) - bRect.topLeft();
^ ^ ^ ^ ^ ^ ^
break;
case DISTRIBUTE_HORIZONTAL_GAP:
v v v v v v v
delta = QPointF( boundingRect.left() + pos, bRect.y() ) - bRect.topLeft();
^ ^ ^ ^ ^ ^ ^
pos += bRect.width();
break;
case DISTRIBUTE_HORIZONTAL_LEFT:
v v v v v v v
delta = QPointF( boundingRect.left() + pos, bRect.y() ) - bRect.topLeft();
^ ^ ^ ^ ^ ^ ^
break;
case DISTRIBUTE_HORIZONTAL_RIGHT:
v v v v v v v
delta = QPointF( boundingRect.left() + first->boundingRect().width() + pos - bRect.width(), bRect.y() ) - bRect.topLeft();
^ ^ ^ ^ ^ ^ ^
break;
case DISTRIBUTE_VERTICAL_CENTER:
v v v v v v v
delta = QPointF( bRect.x(), boundingRect.y() + first->boundingRect().height()/2 + pos - bRect.height()/2 ) - bRect.topLeft();
^ ^ ^ ^ ^ ^ ^
break;
case DISTRIBUTE_VERTICAL_GAP:
v v v v v v v
delta = QPointF( bRect.x(), boundingRect.top() + pos ) - bRect.topLeft();
^ ^ ^ ^ ^ ^ ^
pos += bRect.height();
break;
case DISTRIBUTE_VERTICAL_BOTTOM:
v v v v v v v
delta = QPointF( bRect.x(), boundingRect.top() + first->boundingRect().height() + pos - bRect.height() ) - bRect.topLeft();
^ ^ ^ ^ ^ ^ ^
break;
case DISTRIBUTE_VERTICAL_TOP:
v v v v v v v
delta = QPointF( bRect.x(), boundingRect.top() + pos ) - bRect.topLeft();
^ ^ ^ ^ ^ ^ ^
break;
};
v v v v v v v
newPositions << position + delta;
^ ^ ^ ^ ^ ^ ^
pos += step;
}
m_command = new KoShapeMoveCommand(sortedPos.values(), previousPositions, newPositions);
......
......@@ -264,7 +264,9 @@ class KoShapeAlignCommand : public KCommand {
public:
enum Align
{
v v v v v v v
ALIGN_HORIZONTAL_LEFT, // TODO make naming more Qt / C++ like : HorizontalLeftAlignment
^ ^ ^ ^ ^ ^ ^
ALIGN_HORIZONTAL_CENTER,
ALIGN_HORIZONTAL_RIGHT,
ALIGN_VERTICAL_BOTTOM,
......
......@@ -30,7 +30,7 @@ KoPathShape::KoPathShape()
{
}
void KoPathShape::paint( QPainter &painter, KoViewConverter &converter)
void KoPathShape::paint( QPainter &painter, const KoViewConverter &converter)
{
applyConversion(painter, converter);
painter.setBrush(background());
......
......@@ -36,7 +36,7 @@ class FLAKE_EXPORT KoPathShape : public KoShape
public:
KoPathShape();
virtual void paint( QPainter &painter, KoViewConverter &converter );
virtual void paint( QPainter &painter, const KoViewConverter &converter );
virtual void paintDecorations(QPainter &painter, KoViewConverter &converter, bool selected);
void moveTo( const QPointF &p );
......
......@@ -27,7 +27,7 @@
KoRectangleShape::KoRectangleShape() : KoShape() {
}
void KoRectangleShape::paint(QPainter &painter, KoViewConverter &converter) {
void KoRectangleShape::paint(QPainter &painter, const KoViewConverter &converter) {
painter.setBrush(background());
painter.drawRect( converter.documentToView(QRectF( 0, 0, size().width(), size().height() ) ));
}
......@@ -36,7 +36,7 @@ class FLAKE_EXPORT KoRectangleShape : public KoShape
{
public:
KoRectangleShape();
void paint(QPainter &painter, KoViewConverter &converter);
void paint(QPainter &painter, const KoViewConverter &converter);
};
#endif
......
......@@ -37,7 +37,7 @@ KoSelection::~KoSelection()
{
}
void KoSelection::paint( QPainter &painter, KoViewConverter &converter)
void KoSelection::paint( QPainter &painter, const KoViewConverter &converter)
{
/* if ( count() == 0 )
return;
......@@ -67,6 +67,7 @@ void KoSelection::selectGroupChilds( KoShapeGroup *group )
void KoSelection::select(KoShape * object)
{
kDebug() << "select " << object << endl;
Q_ASSERT(object != this);
if(m_selectedObjects.contains(object))
return;
......
......@@ -56,7 +56,7 @@ public:
KoSelection();
virtual ~KoSelection();
virtual void paint( QPainter &painter, KoViewConverter &converter );
virtual void paint( QPainter &painter, const KoViewConverter &converter );
/// add a selected object
virtual void select(KoShape * object);
......
......@@ -58,7 +58,7 @@ KoShape::~KoShape()
delete m_userData;
}
void KoShape::paintDecorations(QPainter &painter, KoViewConverter &converter, bool selected) {
void KoShape::paintDecorations(QPainter &painter, const KoViewConverter &converter, bool selected) {
if ( selected )
{
// draw connectors
......@@ -164,7 +164,7 @@ void KoShape::recalcMatrix()
updateTree();
}
QMatrix KoShape::transformationMatrix(KoViewConverter *converter) const {
QMatrix KoShape::transformationMatrix(const KoViewConverter *converter) const {
QMatrix matrix;
QRectF zoomedRect = QRectF(position(), size());
if(converter)
......
......@@ -94,7 +94,7 @@ public:
* @param converter to convert between internal and view coordinates.
* @see applyConversion()
*/
virtual void paint(QPainter &painter, KoViewConverter &converter) = 0;
virtual void paint(QPainter &painter, const KoViewConverter &converter) = 0;
/**
* Paint non-print decorations specific for this type of shape.
......@@ -104,7 +104,7 @@ public:
* @param selected true if the shape is currently selected
* @param converter to convert between internal and view coordinates.
*/
virtual void paintDecorations(QPainter &painter, KoViewConverter &converter, bool selected);
virtual void paintDecorations(QPainter &painter, const KoViewConverter &converter, bool selected);
/**
* @brief Scale the shape using the zero-point which is the top-left corner.
......@@ -463,7 +463,7 @@ public:
* @param converter if not null, this method uses the converter to mark the right
* offsets in the current view.
*/
QMatrix transformationMatrix(KoViewConverter *converter) const;
QMatrix transformationMatrix(const KoViewConverter *converter) const;
protected:
QMatrix m_invMatrix; ///< The inverted matrix; for convenience
......
......@@ -72,7 +72,7 @@ public:
* shape as its start coordinate.
* @param converter to convert between internal and view coordinates.
*/
virtual void paintBorder(KoShape *shape, QPainter &painter, KoViewConverter &converter) = 0;
virtual void paintBorder(KoShape *shape, QPainter &painter, const KoViewConverter &converter) = 0;
};
#endif
......@@ -35,22 +35,30 @@ KoShapeContainer::~KoShapeContainer() {
delete m_children;
}
v v v v v v v
void KoShapeContainer::addChild(KoShape *shape) {
Q_ASSERT(shape);
^ ^ ^ ^ ^ ^ ^
if(m_children == 0)
m_children = new ChildrenData();
v v v v v v v
m_children->add(shape);
shape->setParent(this);
childCountChanged();
^ ^ ^ ^ ^ ^ ^
}
v v v v v v v
void KoShapeContainer::removeChild(KoShape *shape) {
Q_ASSERT(shape);
^ ^ ^ ^ ^ ^ ^
if(m_children == 0)
return;
v v v v v v v
m_children->remove(shape);
shape->setParent(0);
childCountChanged();
^ ^ ^ ^ ^ ^ ^
}
int KoShapeContainer::childCount() const {
......@@ -65,7 +73,7 @@ void KoShapeContainer::setClipping(const KoShape *child, bool clipping) {
m_children->setClipping(child, clipping);
}
void KoShapeContainer::paint(QPainter &painter, KoViewConverter &converter) {
void KoShapeContainer::paint(QPainter &painter, const KoViewConverter &converter) {
painter.save();
applyConversion(painter, converter);
paintComponent(painter, converter);
......@@ -86,6 +94,28 @@ void KoShapeContainer::paint(QPainter &painter, KoViewConverter &converter) {
// QPolygon clip = (myMatrix * shapeMatrix.inverted()).mapToPolygon(clipRect.toRect());
// painter.setClipRegion(QRegion(clip));
v v v v v v v
if(! childClipped(shape) )
continue;
QRectF clipRect(QPointF(0, 0), size());
clipRect = converter.documentToView(clipRect);
QRectF clipRect(QPointF(0, 0), size());
clipRect = converter.documentToView(clipRect);
QPolygon clip = myMatrix.mapToPolygon(clipRect.toRect());
clip.translate( (position() - converter.documentToView(position())).toPoint() );
painter.setClipRegion(QRegion(clip));
*************
if(! childClipped(shape) )
continue;
QRectF clipRect(QPointF(0, 0), size());
clipRect = converter.documentToView(clipRect);
QPolygon clip = myMatrix.mapToPolygon(clipRect.toRect());
clip.translate( (position() - converter.documentToView(position())).toPoint() );
painter.setClipRegion(QRegion(clip));
*************
if(! childClipped(shape) )
continue;
QRectF clipRect(QPointF(0, 0), size());
......@@ -94,6 +124,7 @@ void KoShapeContainer::paint(QPainter &painter, KoViewConverter &converter) {
QPolygon clip = myMatrix.mapToPolygon(clipRect.toRect());
clip.translate( (position() - converter.documentToView(position())).toPoint() );
painter.setClipRegion(QRegion(clip));
^ ^ ^ ^ ^ ^ ^
//kDebug() << "rect: " << position() << endl;
//kDebug() << "polygon: " << clip.boundingRect() << endl;
//painter.drawPolygon(clip);
......
......@@ -169,7 +169,7 @@ public:
*/
bool childClipped(const KoShape *child) const;
void paint(QPainter &painter, KoViewConverter &converter);
void paint(QPainter &painter, const KoViewConverter &converter);
/**
* @brief Paint the component
......@@ -180,7 +180,7 @@ public:
* @param converter to convert between internal and view coordinates.
* @see applyConversion()
*/
virtual void paintComponent(QPainter &painter, KoViewConverter &converter) = 0;
virtual void paintComponent(QPainter &painter, const KoViewConverter &converter) = 0;
void repaint() const;
......@@ -193,6 +193,9 @@ public:
protected:
virtual void childCountChanged() { }
protected:
virtual void childCountChanged() { }
private:
/**
*/
......
......@@ -24,7 +24,7 @@ KoShapeGroup::KoShapeGroup()
{
}
void KoShapeGroup::paintComponent(QPainter &painter, KoViewConverter &converter) {
void KoShapeGroup::paintComponent(QPainter &painter, const KoViewConverter &converter) {
Q_UNUSED(painter);
Q_UNUSED(converter);
}
......@@ -66,9 +66,33 @@ bool KoShapeGroup::GroupMembers::childClipped(const KoShape *child) const {
Q_UNUSED(child);
return false;
}
v v v v v v v
void KoShapeGroup::childCountChanged() {
QRectF br = boundingRect();
setPosition( br.topLeft() );
resize( br.size() );
*************
void KoShapeGroup::childCountChanged() {
QRectF br = boundingRect();
setPosition( br.topLeft() );
resize( br.size() );
}
QRectF KoShapeGroup::boundingRect() const {
bool first=true;
QRectF boundingRect;
foreach(KoShape *shape, iterator()) {
if(first) {
boundingRect = shape->boundingRect();
first = false;
}
else
boundingRect = boundingRect.unite( shape->boundingRect() );
}
return boundingRect;
^ ^ ^ ^ ^ ^ ^
}
......@@ -44,7 +44,7 @@ public:
/// destructor
~KoShapeGroup() {};
/// This implementation is empty since a group is itself not visible.
void paintComponent(QPainter &painter, KoViewConverter &converter);
void paintComponent(QPainter &painter, const KoViewConverter &converter);
/// always returns false since the group itself can't be selected or hit
bool hitTest( const QPointF &position ) const;
......@@ -64,8 +64,10 @@ private:
private: // members
QList <KoShape *> m_groupMembers;
};
v v v v v v v
void childCountChanged();
^ ^ ^ ^ ^ ^ ^
};
#endif
......@@ -94,7 +94,7 @@ void KoShapeManager::remove( KoShape *shape )
m_shapes.removeAll(shape);
}
void KoShapeManager::paint( QPainter &painter, KoViewConverter &converter, bool forPrint)
void KoShapeManager::paint( QPainter &painter, const KoViewConverter &converter, bool forPrint)
{
updateTree();
QPen pen(Qt::NoPen); // painters by default have a black stroke, lets turn that off.
......
......@@ -89,7 +89,7 @@ public:
* @param forPrint if true, make sure only actual content is drawn and no decorations.
* @param converter to convert between document and view coordinates.
*/
virtual void paint( QPainter &painter, KoViewConverter &converter, bool forPrint );
virtual void paint( QPainter &painter, const KoViewConverter &converter, bool forPrint );
/**
* Returns the shape located at a specific point in the document.
......
......@@ -37,7 +37,7 @@ KoShapeMoveStrategy::KoShapeMoveStrategy( KoTool *tool, KoCanvasBase *canvas, co
, m_initialTopLeft(99999, 99999)
, m_start(clicked)
{
KoSelectionSet selectedShapes = canvas->shapeManager()->selection()->selectedShapes(KoFlake::StrippedSelection);
KoSelectionSet selectedShapes = canvas->shapeManager()->selection()->selectedShapes(KoFlake::TopLevelSelection);
QRectF boundingRect;
foreach(KoShape *shape, selectedShapes) {
if(shape->isLocked())
......
......@@ -39,25 +39,25 @@ public:
* Convert a coordinate in pt to pixels.
* @param documentPoint the point in the document coordinate system of a KoShape.
*/
virtual QPointF documentToView( const QPointF &documentPoint ) = 0;
virtual QPointF documentToView( const QPointF &documentPoint ) const = 0;
/**
* Convert a coordinate in pixels to pt.
* @param viewPoint the point in the coordinate system of the widget, or window.
*/
virtual QPointF viewToDocument( const QPointF &viewPoint ) = 0;
virtual QPointF viewToDocument( const QPointF &viewPoint ) const = 0;
/**
* Convert a rectangle in pt to pixels.
* @param documentRect the rect in the document coordinate system of a KoShape.
*/
virtual QRectF documentToView( const QRectF &documentRect ) = 0;
virtual QRectF documentToView( const QRectF &documentRect ) const = 0;
/**
* Convert a rectangle in pixels to pt.
* @param viewRect the rect in the coordinate system of the widget, or window.
*/
virtual QRectF viewToDocument( const QRectF &viewRect ) = 0;
virtual QRectF viewToDocument( const QRectF &viewRect ) const = 0;
/**
* set the zoom levels of the individual x and y axis to the pointer paramets.
......
#include <KoShapeGroup.h>
class MockShape : public KoShape {
void paint(QPainter &painter, KoViewConverter &converter) {
void paint(QPainter &painter, const KoViewConverter &converter) {
Q_UNUSED(painter);
Q_UNUSED(converter);
}
};
class MockContainer : public KoShapeContainer {
void paintComponent(QPainter &painter, KoViewConverter &converter) {
void paintComponent(QPainter &painter, const KoViewConverter &converter) {
Q_UNUSED(painter);
Q_UNUSED(converter);
}
};
class MockGroup : public KoShapeGroup {
void paintComponent(QPainter &painter, KoViewConverter &converter) {
void paintComponent(QPainter &painter, const KoViewConverter &converter) {
Q_UNUSED(painter);
Q_UNUSED(converter);
}
......
......@@ -53,7 +53,7 @@ public:
virtual void visit(KoCreateShapesTool *tool) = 0;
virtual QString toolTip() = 0;
void paint(QPainter &painter, KoViewConverter &converter) {
void paint(QPainter &painter, const KoViewConverter &converter) {
Q_UNUSED(converter);
painter.drawPixmap(QRect( QPoint(0,0), m_icon.size()), m_icon);
}
......@@ -246,19 +246,19 @@ bool KoShapeSelector::event(QEvent *e) {
}
// ************ DummyViewConverter **********
QPointF KoShapeSelector::DummyViewConverter::documentToView (const QPointF &documentPoint) {
QPointF KoShapeSelector::DummyViewConverter::documentToView (const QPointF &documentPoint) const {
return documentPoint;
}
QPointF KoShapeSelector::DummyViewConverter::viewToDocument (const QPointF &viewPoint) {
QPointF KoShapeSelector::DummyViewConverter::viewToDocument (const QPointF &viewPoint) const {
return viewPoint;
}
QRectF KoShapeSelector::DummyViewConverter::documentToView (const QRectF &documentRect) {
QRectF KoShapeSelector::DummyViewConverter::documentToView (const QRectF &documentRect) const {
return documentRect;
}
QRectF KoShapeSelector::DummyViewConverter::viewToDocument (const QRectF &viewRect) {
QRectF KoShapeSelector::DummyViewConverter::viewToDocument (const QRectF &viewRect) const {
return viewRect;
}
......
......@@ -60,10 +60,10 @@ private:
private:
/// \internal
class DummyViewConverter : public KoViewConverter {
QPointF documentToView (const QPointF &documentPoint);
QPointF viewToDocument (const QPointF &viewPoint);
QRectF documentToView (const QRectF &documentRect);
QRectF viewToDocument (const QRectF &viewRect);
QPointF documentToView (const QPointF &documentPoint) const;
QPointF viewToDocument (const QPointF &viewPoint) const;
QRectF documentToView (const QRectF &documentRect) const;
QRectF viewToDocument (const QRectF &viewRect) const;
void zoom (double *zoomX, double *zoomY) const;
};
......
......@@ -78,22 +78,22 @@ void KoZoomHandler::setZoom( int zoom )
setZoom(zoom / 100.0);
}
QPointF KoZoomHandler::documentToView( const QPointF &documentPoint ) {
QPointF KoZoomHandler::documentToView( const QPointF &documentPoint ) const{
return QPointF( zoomItX( documentPoint.x() ), zoomItY( documentPoint.y() ) );
}
QPointF KoZoomHandler::viewToDocument( const QPointF &viewPoint ) {
QPointF KoZoomHandler::viewToDocument( const QPointF &viewPoint ) const{
return QPointF( unzoomItX( viewPoint.x() ), unzoomItY( viewPoint.y() ) );
}
QRectF KoZoomHandler::documentToView( const QRectF &documentRect ) {
QRectF KoZoomHandler::documentToView( const QRectF &documentRect ) const{
QRectF r;
r.setCoords( zoomItX( documentRect.left() ), zoomItY( documentRect.top() ),
zoomItX( documentRect.right() ), zoomItY( documentRect.bottom() ) );
return r;
}
QRectF KoZoomHandler::viewToDocument( const QRectF &viewRect ) {
QRectF KoZoomHandler::viewToDocument( const QRectF &viewRect ) const{
QRectF r;
r.setCoords( unzoomItX( viewRect.left() ), unzoomItY( viewRect.top() ),
unzoomItX( viewRect.right() ), unzoomItY( viewRect.bottom() ) );
......
......@@ -175,25 +175,25 @@ public:
* Convert a coordinate in pt to pixels.
* @param documentPoint the point in the document coordinate system of a KoShape.
*/
QPointF documentToView( const QPointF &documentPoint );
QPointF documentToView( const QPointF &documentPoint ) const;
/**
* Convert a coordinate in pixels to pt.
* @param viewPoint the point in the coordinate system of the widget, or window.
*/
QPointF viewToDocument( const QPointF &viewPoint );
QPointF viewToDocument( const QPointF &viewPoint ) const;
/**
* Convert a rectangle in pt to pixels.
* @param documentRect the rect in the document coordinate system of a KoShape.
*/
QRectF documentToView( const QRectF &documentRect );
QRectF documentToView( const QRectF &documentRect ) const;
/**
* Convert a rectangle in pixels to pt.
* @param viewRect the rect in the coordinate system of the widget, or window.
*/
QRectF viewToDocument( const QRectF &viewRect );
QRectF viewToDocument( const QRectF &viewRect ) const;
/**
* set the zoom levels of the individual x and y axis to the pointer paramets.
......
......@@ -37,7 +37,7 @@ KoTextShape::KoTextShape()
KoTextShape::~KoTextShape() {
}
void KoTextShape::paint(QPainter &painter, KoViewConverter &converter) {
void KoTextShape::paint(QPainter &painter, const KoViewConverter &converter) {
painter.fillRect(converter.documentToView(QRectF(QPointF(0.0,0.0), size())), background());
applyConversion(painter, converter);
QAbstractTextDocumentLayout::PaintContext pc;
......
......@@ -36,7 +36,7 @@ public:
KoTextShape();
virtual ~KoTextShape();
void paint(QPainter &painter, KoViewConverter &converter);
void paint(QPainter &painter, const KoViewConverter &converter);