Commit 26e3c709 authored by Thomas Zander's avatar Thomas Zander

Remove the private methods from KoShape.h

Also remove the friend there, which is a bit ugly and the removal
showed one bug in the API; KoShape::setCollisionDetection() was
protected while it should be public. Fixed that too.

Moved the private methods to the private object.

svn path=/trunk/koffice/; revision=1061930
parent 6e595c4d
......@@ -145,6 +145,17 @@ void KoShapePrivate::updateBorder()
inner.width() + insets.left + insets.right, insets.bottom));
}
void KoShapePrivate::addShapeManager(KoShapeManager *manager)
{
shapeManagers.insert(manager);
}
void KoShapePrivate::removeShapeManager(KoShapeManager *manager)
{
shapeManagers.remove(manager);
}
// ======== KoShape
KoShape::KoShape()
: d_ptr(new KoShapePrivate(this))
......@@ -801,18 +812,6 @@ bool KoShape::collisionDetection()
return d->detectCollision;
}
void KoShape::addShapeManager(KoShapeManager * manager)
{
Q_D(KoShape);
d->shapeManagers.insert(manager);
}
void KoShape::removeShapeManager(KoShapeManager * manager)
{
Q_D(KoShape);
d->shapeManagers.remove(manager);
}
KoShapeBorderModel *KoShape::border() const
{
Q_D(const KoShape);
......@@ -1469,3 +1468,9 @@ void KoShape::setFilterEffectStack(KoFilterEffectStack * filterEffectStack)
}
notifyChanged();
}
KoShapePrivate *KoShape::priv()
{
Q_D(KoShape);
return d;
}
......@@ -355,13 +355,13 @@ public:
* @param transparency the new shape level transparency
*/
void setTransparency(qreal transparency);
/**
* Returns the shape level transparency.
* @param recursive when true takes the parents transparency into account
*/
qreal transparency(bool recursive=false) const;
/**
* Retrieve the z-coordinate of this shape.
* The zIndex property is used to determine which shape lies on top of other objects.
......@@ -827,6 +827,26 @@ public:
/// Sets the new filter effect stack, removing the old one
void setFilterEffectStack(KoFilterEffectStack *filterEffectStack);
/**
* Set the property collision detection.
* Setting this to true will result in calls to shapeChanged() with the CollisionDetected
* parameter whenever either this or another shape is moved/rotated etc and intersects this shape.
* @param detect if true detect collisions.
*/
void setCollisionDetection(bool detect);
/**
* get the property collision detection.
* @returns true if collision detection is on.
*/
bool collisionDetection();
/**
* \internal
* Returns the private object for use withing the flake lib
*/
KoShapePrivate *priv();
protected:
/// constructor
KoShape(KoShapePrivate &);
......@@ -908,7 +928,6 @@ protected:
/* ** end loading saving */
/**
* A hook that allows inheriting classes to do something after a KoShape property changed
* This is called whenever the shape, position rotation or scale properties were altered.
......@@ -916,30 +935,12 @@ protected:
*/
virtual void shapeChanged(ChangeType type, KoShape *shape = 0);
/**
* Set the property collision detection.
* Setting this to true will result in calls to shapeChanged() with the CollisionDetected
* parameter whenever either this or another shape is moved/rotated etc and intersects this shape.
* @param detect if true detect collisions.
*/
void setCollisionDetection(bool detect);
/**
* get the property collision detection.
* @returns true if collision detection is on.
*/
bool collisionDetection();
/// return the current matrix that contains the rotation/scale/position of this shape
QMatrix matrix() const;
KoShapePrivate *d_ptr;
private:
friend class KoShapeManager;
void addShapeManager(KoShapeManager *manager);
void removeShapeManager(KoShapeManager *manager);
Q_DECLARE_PRIVATE(KoShape)
};
......
......@@ -25,6 +25,7 @@
#include "KoToolManager.h"
#include "KoPointerEvent.h"
#include "KoShape.h"
#include "KoShape_p.h"
#include "KoCanvasBase.h"
#include "KoShapeContainer.h"
#include "KoShapeBorderModel.h"
......@@ -90,7 +91,7 @@ public:
void fireSignals() {
foreach(KoShape *shape, shapesWithCollisionDetection)
shape->shapeChanged(KoShape::CollisionDetected);
shape->priv()->shapeChanged(KoShape::CollisionDetected);
}
private:
......@@ -157,10 +158,10 @@ KoShapeManager::KoShapeManager(KoCanvasBase *canvas)
KoShapeManager::~KoShapeManager()
{
foreach(KoShape *shape, d->shapes) {
shape->removeShapeManager(this);
shape->priv()->removeShapeManager(this);
}
foreach(KoShape *shape, d->additionalShapes) {
shape->removeShapeManager(this);
shape->priv()->removeShapeManager(this);
}
delete d;
}
......@@ -171,7 +172,7 @@ void KoShapeManager::setShapes(const QList<KoShape *> &shapes, Repaint repaint)
//clear selection
d->selection->deselectAll();
foreach(KoShape *shape, d->shapes) {
shape->removeShapeManager(this);
shape->priv()->removeShapeManager(this);
}
d->aggregate4update.clear();
d->tree.clear();
......@@ -185,7 +186,7 @@ void KoShapeManager::add(KoShape *shape, Repaint repaint)
{
if (d->shapes.contains(shape))
return;
shape->addShapeManager(this);
shape->priv()->addShapeManager(this);
d->shapes.append(shape);
if (! dynamic_cast<KoShapeGroup*>(shape) && ! dynamic_cast<KoShapeLayer*>(shape)) {
QRectF br(shape->boundingRect());
......@@ -215,7 +216,7 @@ void KoShapeManager::addAdditional(KoShape *shape)
if (d->additionalShapes.contains(shape)) {
return;
}
shape->addShapeManager(this);
shape->priv()->addShapeManager(this);
d->additionalShapes.append(shape);
}
}
......@@ -227,7 +228,7 @@ void KoShapeManager::remove(KoShape *shape)
detector.fireSignals();
shape->update();
shape->removeShapeManager(this);
shape->priv()->removeShapeManager(this);
d->selection->deselect(shape);
d->aggregate4update.remove(shape);
d->tree.remove(shape);
......@@ -246,7 +247,7 @@ void KoShapeManager::remove(KoShape *shape)
void KoShapeManager::removeAdditional(KoShape *shape)
{
if ( shape ) {
shape->removeShapeManager(this);
shape->priv()->removeShapeManager(this);
d->additionalShapes.removeAll(shape);
}
}
......
......@@ -32,6 +32,10 @@ public:
*/
void shapeChanged(KoShape::ChangeType type);
void addShapeManager(KoShapeManager *manager);
void removeShapeManager(KoShapeManager *manager);
/// calls update on the shape where the border is.
void updateBorder();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment