Commit b1fdff45 authored by Thomas Zander's avatar Thomas Zander

I'm sure many people that compile koffice regularly got quite annoyed that

many changes in flake lead to a big recompile of the whole of koffice.
So, lets do this at one go; convert most public classes to use a d-pointer
which will result is much less changes in the header files.

svn path=/trunk/koffice/; revision=636203
parent 0a8568d6
/* This file is part of the KDE project
*
* Copyright (C) 2006 Thomas Zander <zander@kde.org>
* Copyright (C) 2006-2007 Thomas Zander <zander@kde.org>
* Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org>
*
* This library is free software; you can redistribute it and/or
......@@ -28,8 +28,17 @@
#include <kcommand.h>
class KoCreateShapesTool::Private {
public:
Private() : newShapeProperties(0) {}
QString shapeId;
KoProperties *newShapeProperties;
};
KoCreateShapesTool::KoCreateShapesTool(KoCanvasBase *canvas)
: KoInteractionTool( canvas )
: KoInteractionTool( canvas ),
d(new Private())
{
}
......@@ -42,3 +51,19 @@ void KoCreateShapesTool::mouseReleaseEvent( KoPointerEvent *event ) {
KoInteractionTool::mouseReleaseEvent(event);
emit KoTool::sigDone();
}
void KoCreateShapesTool::setShapeId( const QString &id ) {
d->shapeId = id;
}
const QString &KoCreateShapesTool::shapeId() const {
return d->shapeId;
}
void KoCreateShapesTool::setShapeProperties( KoProperties *properties ) {
d->newShapeProperties = properties;
}
KoProperties const * KoCreateShapesTool::shapeProperties() {
return d->newShapeProperties;
}
/* This file is part of the KDE project
*
* Copyright (C) 2006 Thomas Zander <zander@kde.org>
* Copyright (C) 2006-2007 Thomas Zander <zander@kde.org>
* Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org>
*
* This library is free software; you can redistribute it and/or
......@@ -56,30 +56,30 @@ public:
* create the new shape.
* @param id the SHAPEID of the to be generated shape
*/
void setShapeId( const QString &id ) { m_shapeId = id; }
void setShapeId( const QString &id );
/**
* return the shape Id that is to be created.
* @return the shape Id that is to be created.
*/
const QString &shapeId() const { return m_shapeId; }
const QString &shapeId() const;
/**
* Set the shape properties that the create controller will use for the next shape it will
* create.
* @param properties the properties or 0 if the default shape should be created.
*/
void setShapeProperties( KoProperties *properties ) { m_newShapeProperties = properties; }
void setShapeProperties( KoProperties *properties );
/**
* return the properties to be used for creating the next shape
* @return the properties to be used for creating the next shape
*/
KoProperties const * shapeProperties() { return m_newShapeProperties; }
KoProperties const * shapeProperties();
private:
private:
friend class KoCreateShapeStrategy;
QString m_shapeId;
KoProperties *m_newShapeProperties;
class Private;
Private * const d;
};
#endif
This diff is collapsed.
/* This file is part of the KDE project
Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org>
Copyright (C) 2006 Thomas Zander <zander@kde.org>
Copyright (C) 2006-2007 Thomas Zander <zander@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -107,19 +107,9 @@ private:
// convenience method;
KoSelection * koSelection();
KoFlake::SelectionHandle m_lastHandle;
bool m_mouseWasInsideHandles;
QPointF m_selectionBox[8];
QPolygonF m_selectionOutline;
QPointF m_lastPoint;
KoShapeMoveCommand *m_moveCommand;
QTime m_lastUsedMoveCommand;
// TODO alter these 3 arrays to be static const instead
QCursor m_sizeCursors[8];
QCursor m_rotateCursors[8];
QCursor m_shearCursors[8];
double m_angle;
class Private;
Private * const d;
};
/**
......
/* This file is part of the KDE project
* Copyright (C) 2006 Thomas Zander <zander@kde.org>
* Copyright (C) 2006-2007 Thomas Zander <zander@kde.org>
* Copyright (C) 2006 Jan Hambrecht <jaham@gmx.net>
* Copyright (C) 2007 Thorsten Zachmann <zachmann@kde.org>
*
......@@ -27,17 +27,28 @@
#include <KoGenStyle.h>
class KoLineBorder::Private {
public:
QColor color;
QPen pen;
};
KoLineBorder::KoLineBorder()
: m_color(Qt::black)
: d(new Private())
{
m_pen.setWidthF( 0.0 );
d->color = QColor(Qt::black);
d->pen.setWidthF( 0.0 );
}
KoLineBorder::KoLineBorder(double lineWidth, QColor color)
: m_color(color)
: d(new Private())
{
m_pen.setWidthF( qMax(0.0,lineWidth) );
m_pen.setJoinStyle(Qt::MiterJoin);
d->pen.setWidthF( qMax(0.0,lineWidth) );
d->pen.setJoinStyle(Qt::MiterJoin);
}
KoLineBorder::~KoLineBorder() {
delete d;
}
void KoLineBorder::fillStyle( KoGenStyle &style, KoShapeSavingContext &context )
......@@ -51,7 +62,7 @@ void KoLineBorder::fillStyle( KoGenStyle &style, KoShapeSavingContext &context )
KoInsets* KoLineBorder::borderInsets(const KoShape *shape, KoInsets &insets) {
Q_UNUSED(shape);
double lineWidth = m_pen.widthF();
double lineWidth = d->pen.widthF();
if(lineWidth < 0)
lineWidth = 1;
lineWidth /= 2; // since we draw a line half inside, and half outside the object.
......@@ -63,54 +74,54 @@ KoInsets* KoLineBorder::borderInsets(const KoShape *shape, KoInsets &insets) {
}
bool KoLineBorder::hasTransparency() {
return m_color.alpha() > 0;
return d->color.alpha() > 0;
}
void KoLineBorder::paintBorder(KoShape *shape, QPainter &painter, const KoViewConverter &converter) {
KoShape::applyConversion( painter, converter );
m_pen.setColor(m_color);
painter.strokePath( shape->outline(), m_pen );
d->pen.setColor(d->color);
painter.strokePath( shape->outline(), d->pen );
}
void KoLineBorder::setCapStyle( Qt::PenCapStyle style ) {
m_pen.setCapStyle( style );
d->pen.setCapStyle( style );
}
Qt::PenCapStyle KoLineBorder::capStyle() const {
return m_pen.capStyle();
return d->pen.capStyle();
}
void KoLineBorder::setJoinStyle( Qt::PenJoinStyle style ) {
m_pen.setJoinStyle( style );
d->pen.setJoinStyle( style );
}
Qt::PenJoinStyle KoLineBorder::joinStyle() const {
return m_pen.joinStyle();
return d->pen.joinStyle();
}
void KoLineBorder::setLineWidth( double lineWidth ) {
m_pen.setWidthF( qMax(0.0,lineWidth) );
d->pen.setWidthF( qMax(0.0,lineWidth) );
}
double KoLineBorder::lineWidth() const {
return m_pen.widthF();
return d->pen.widthF();
}
void KoLineBorder::setMiterLimit( double miterLimit ) {
m_pen.setMiterLimit( miterLimit );
d->pen.setMiterLimit( miterLimit );
}
double KoLineBorder::miterLimit() const {
return m_pen.miterLimit();
return d->pen.miterLimit();
}
const QColor & KoLineBorder::color() const
{
return m_color;
return d->color;
}
void KoLineBorder::setColor( const QColor & color )
{
m_color = color;
d->color = color;
}
/* This file is part of the KDE project
* Copyright (C) 2006 Thomas Zander <zander@kde.org>
* Copyright (C) 2006-2007 Thomas Zander <zander@kde.org>
* Copyright (C) 2006 Jan Hambrecht <jaham@gmx.net>
* Copyright (C) 2007 Thorsten Zachmann <zachmann@kde.org>
*
......@@ -46,7 +46,7 @@ public:
* @param color the color we draw the outline in.
*/
explicit KoLineBorder(double lineWidth, QColor color = Qt::black);
virtual ~KoLineBorder() {};
virtual ~KoLineBorder();
/// Sets the lines cap style
void setCapStyle( Qt::PenCapStyle style );
......@@ -76,8 +76,8 @@ public:
virtual void paintBorder(KoShape *shape, QPainter &painter, const KoViewConverter &converter);
private:
QColor m_color;
QPen m_pen;
class Private;
Private * const d;
};
#endif
/* This file is part of the KDE project
Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org>
Copyright (C) 2007 Thomas Zander <zander@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -22,8 +23,14 @@
#include <QDebug>
#include <QPainter>
class KoParameterShape::Private {
public:
Private() : modified(false) {}
bool modified;
};
KoParameterShape::KoParameterShape()
: m_modified( false )
: d(new Private())
{
}
......@@ -132,3 +139,10 @@ QPointF KoParameterShape::normalize()
return offset;
}
bool KoParameterShape::isParametricShape() const {
return !d->modified;
}
void KoParameterShape::setModified( bool modified ) {
d->modified = modified;
}
/* This file is part of the KDE project
Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org>
Copyright (C) 2007 Thomas Zander <zander@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -101,7 +102,7 @@ public:
*
* @return true if it is a parametic shape, false otherwise
*/
bool isParametricShape() const { return !m_modified; }
bool isParametricShape() const;
/**
* @brief Set the modified status.
......@@ -111,7 +112,7 @@ public:
*
* @param modified the modification state
*/
void setModified( bool modified ) { m_modified = modified; }
void setModified( bool modified );
virtual QPointF normalize();
......@@ -138,7 +139,8 @@ protected:
QList<QPointF> m_handles;
private:
bool m_modified;
class Private;
Private * const d;
};
#endif /* KOPARAMETERSHAPE_H */
This diff is collapsed.
/* This file is part of the KDE project
Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org>
Copyright (C) 2007 Thomas Zander <zander@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -86,6 +87,7 @@ public:
class FLAKE_EXPORT KoPathPoint
{
public:
/// property enum
enum KoPointProperty
{
Normal = 0, ///< it has no control points
......@@ -110,12 +112,7 @@ public:
Q_DECLARE_FLAGS( KoPointTypes, KoPointType )
/// Default constructor
KoPathPoint()
: m_shape( 0 )
, m_point( 0.0, 0.0 )
, m_properties( Normal )
, m_pointGroup( 0 )
{}
KoPathPoint();
/**
* @brief Constructor
......@@ -124,12 +121,7 @@ public:
* @param point the position relative to the shape origin
* @param properties describing the point
*/
KoPathPoint( KoPathShape * path, const QPointF & point, KoPointProperties properties = Normal )
: m_shape( path )
, m_point( point )
, m_properties( properties )
, m_pointGroup( 0 )
{}
KoPathPoint( KoPathShape * path, const QPointF & point, KoPointProperties properties = Normal );
/**
* @brief Copy Constructor
......@@ -144,14 +136,14 @@ public:
/**
* @brief Destructor
*/
~KoPathPoint() {}
~KoPathPoint();
/**
* @brief return the position relative to the shape origin
*
* @return point
*/
QPointF point() const { return m_point; }
QPointF point() const;
/**
* @brief get the control point 1
......@@ -160,7 +152,7 @@ public:
*
* @return control point 1 of this point
*/
QPointF controlPoint1() const { return m_controlPoint1; }
QPointF controlPoint1() const;
/**
* @brief get the second control point
......@@ -169,7 +161,7 @@ public:
*
* @return control point 2 of this point
*/
QPointF controlPoint2() const { return m_controlPoint2; }
QPointF controlPoint2() const;
/**
* @brief alter the point
......@@ -200,7 +192,7 @@ public:
*
* @return properties of the point
*/
KoPointProperties properties() const { return m_properties; }
KoPointProperties properties() const;
/**
* @brief Set the properties of a point
......@@ -268,7 +260,7 @@ public:
* @brief Get the path shape the point belongs to
* @return the path shape the point belongs to
*/
KoPathShape * parent() const { return m_shape; }
KoPathShape * parent() const;
/**
* @brief Get the bounding rect of the point.
......@@ -295,14 +287,10 @@ protected:
friend class KoPathShape;
void removeFromGroup();
void addToGroup( KoPointGroup *pointGroup );
KoPointGroup * group() { return m_pointGroup; }
KoPointGroup * group();
private:
KoPathShape * m_shape;
QPointF m_point;
QPointF m_controlPoint1;
QPointF m_controlPoint2;
KoPointProperties m_properties;
KoPointGroup * m_pointGroup;
class Private;
Private * const d;
};
/**
......@@ -759,6 +747,10 @@ protected:
friend class KoParameterToPathCommand;
KoSubpathList m_subpaths;
private:
class Private;
Private * const d;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( KoPathPoint::KoPointProperties )
......
......@@ -3,6 +3,7 @@
Copyright (C) 2006 Boudewijn Rempt <boud@valdyas.org>
Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org>
Copyright (C) 2006 Jan Hambrecht <jaham@gmx.net>
Copyright (C) 2006-2007 Thomas Zander <zander@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -28,13 +29,25 @@
#include <QPainter>
#include <QTimer>
class KoSelection::Private {
public:
Private() : eventTriggered(false), activeLayer(0) {}
QList<KoShape*> selectedShapes;
bool eventTriggered;
KoShapeLayer *activeLayer;
};
KoSelection::KoSelection()
: m_eventTriggered( false ), m_activeLayer( 0 )
: d(new Private())
{
}
KoSelection::~KoSelection()
{
delete d;
}
void KoSelection::paint( QPainter &painter, const KoViewConverter &converter)
......@@ -49,9 +62,9 @@ void KoSelection::selectGroupChilds( KoShapeGroup *group )
return;
foreach(KoShape *shape, group->iterator()) {
if( m_selectedShapes.contains(shape))
if( d->selectedShapes.contains(shape))
continue;
m_selectedShapes << shape;
d->selectedShapes << shape;
KoShapeGroup* childGroup = dynamic_cast<KoShapeGroup*>( shape );
if( childGroup )
......@@ -65,8 +78,8 @@ void KoSelection::select(KoShape * object)
Q_ASSERT(object);
if(! object->isSelectable())
return;
if(!m_selectedShapes.contains(object))
m_selectedShapes << object;
if(!d->selectedShapes.contains(object))
d->selectedShapes << object;
KoShapeGroup* group = dynamic_cast<KoShapeGroup*>(object);
if( group )
......@@ -76,14 +89,14 @@ void KoSelection::select(KoShape * object)
while( parent ) {
KoShapeGroup *parentGroup = dynamic_cast<KoShapeGroup*>(parent);
if( ! parentGroup ) break;
if( ! m_selectedShapes.contains(parentGroup) ) {
m_selectedShapes << parentGroup;
if( ! d->selectedShapes.contains(parentGroup) ) {
d->selectedShapes << parentGroup;
selectGroupChilds( parentGroup );
}
parent = parentGroup->parent();
}
if(m_selectedShapes.count() == 1)
if(d->selectedShapes.count() == 1)
{
rotate(object->rotation());
shear(object->shearX(), object->shearY());
......@@ -98,18 +111,18 @@ void KoSelection::select(KoShape * object)
void KoSelection::deselect(KoShape * object)
{
if(! m_selectedShapes.contains(object))
if(! d->selectedShapes.contains(object))
return;
KoShapeGroup *group = dynamic_cast<KoShapeGroup*>(object->parent());
if(group) {
m_selectedShapes.removeAll(group);
d->selectedShapes.removeAll(group);
foreach(KoShape *shape, group->iterator())
m_selectedShapes.removeAll(shape);
d->selectedShapes.removeAll(shape);
}
else
m_selectedShapes.removeAll( object );
d->selectedShapes.removeAll( object );
if(m_selectedShapes.count() == 1)
if(d->selectedShapes.count() == 1)
{
rotate(firstSelectedShape()->rotation());
shear(firstSelectedShape()->shearX(), firstSelectedShape()->shearY());
......@@ -119,21 +132,21 @@ void KoSelection::deselect(KoShape * object)
void KoSelection::deselectAll()
{
if(m_selectedShapes.isEmpty())
if(d->selectedShapes.isEmpty())
return;
m_selectedShapes.clear();
d->selectedShapes.clear();
requestSelectionChangedEvent();
}
void KoSelection::requestSelectionChangedEvent() {
if(m_eventTriggered)
if(d->eventTriggered)
return;
m_eventTriggered = true;
d->eventTriggered = true;
QTimer::singleShot(0, this, SLOT(selectionChangedEvent()));
}
void KoSelection::selectionChangedEvent() {
m_eventTriggered = false;
d->eventTriggered = false;
scale(1,1);
boundingRect(); //has the side effect of updating the size and position
emit selectionChanged();
......@@ -141,7 +154,7 @@ void KoSelection::selectionChangedEvent() {
int KoSelection::count() const
{
return m_selectedShapes.count();
return d->selectedShapes.count();
}
bool KoSelection::hitTest( const QPointF &position ) const
......@@ -152,7 +165,7 @@ bool KoSelection::hitTest( const QPointF &position ) const
return bb.contains( position );
}
else if ( count() == 1 )
return ( *m_selectedShapes.begin() )->hitTest( position );
return ( *d->selectedShapes.begin() )->hitTest( position );
else // count == 0
return false;
}
......@@ -165,10 +178,10 @@ QRectF KoSelection::boundingRect() const
QMatrix tmat = transformationMatrix(0);
QMatrix itmat = tmat.inverted();
if ( !m_selectedShapes.isEmpty() )
if ( !d->selectedShapes.isEmpty() )
{
QList<KoShape*>::const_iterator it = m_selectedShapes.begin();
for ( ; it != m_selectedShapes.end(); ++it ) {
QList<KoShape*>::const_iterator it = d->selectedShapes.begin();
for ( ; it != d->selectedShapes.end(); ++it ) {
if( dynamic_cast<KoShapeGroup*>( *it ))
continue;
if(first) {
......@@ -193,7 +206,7 @@ const QList<KoShape*> KoSelection::selectedShapes(KoFlake::SelectionType strip)
QList<KoShape*> answer;
// strip the child objects when there is also a parent included.
bool doStripping = strip == KoFlake::StrippedSelection;
foreach (KoShape *shape, m_selectedShapes) {
foreach (KoShape *shape, d->selectedShapes) {
KoShapeContainer *container = shape->parent();
if(strip != KoFlake::TopLevelSelection && dynamic_cast<KoShapeGroup*>(shape))
// since a KoShapeGroup
......@@ -202,11 +215,11 @@ const QList<KoShape*> KoSelection::selectedShapes(KoFlake::SelectionType strip)
continue;
bool add = true;
while(doStripping && add && container) {
if(dynamic_cast<KoShapeGroup*>(container) == 0 && m_selectedShapes.contains(container))
if(dynamic_cast<KoShapeGroup*>(container) == 0 && d->selectedShapes.contains(container))
add = false;
container = container->parent();
}
if(strip == KoFlake::TopLevelSelection && container && m_selectedShapes.contains(container))
if(strip == KoFlake::TopLevelSelection && container && d->selectedShapes.contains(container))
add = false;
if(add)
answer << shape;
......@@ -218,7 +231,7 @@ bool KoSelection::isSelected(const KoShape *object) const {
if(object == this)
return true;
foreach(KoShape *shape, m_selectedShapes)
foreach(KoShape *shape, d->selectedShapes)
if(shape == object)
return true;
......@@ -233,11 +246,11 @@ KoShape *KoSelection::firstSelectedShape(KoFlake::SelectionType strip) const {
}
void KoSelection::setActiveLayer( KoShapeLayer* layer ) {
m_activeLayer = layer;
d->activeLayer = layer;
}
KoShapeLayer* KoSelection::activeLayer() const {
return m_activeLayer;