Commit b7b2a760 authored by Thomas Zander's avatar Thomas Zander

The interaction strategies now refer to the container a shape is in in order

to ask if that shape can be moved / rotated.
This has the effect that the layer can return false when the layer is locked,
while the other containers just return the locked bool on the shape.

Fixes moving of inline objects in KWord to work again.

svn path=/trunk/koffice/; revision=664968
parent 308f97de
......@@ -126,14 +126,17 @@ void KoInteractionStrategy::applyGrid(QPointF &point) {
point.setY( static_cast<int>( point.y() / gridY + 1e-10 ) * gridY );
}
// static
bool KoInteractionStrategy::isEditable( KoShape * shape ) {
if( ! shape->isVisible() || shape->isLocked() )
return false;
KoShapeContainer * parent = shape->parent();
if(parent->isChildLocked(shape))
return false;
while( parent )
{
if( ! parent->isVisible() || parent->isLocked() )
if( ! parent->isVisible() )
return false;
parent = parent->parent();
}
......
......@@ -74,6 +74,10 @@ public:
return answer;
}
bool isChildLocked(const KoShape *child) const {
return child->isLocked();
}
void containerChanged(KoShapeContainer *) { }
void childChanged(KoShape *, KoShape::ChangeType ) { }
......@@ -158,6 +162,12 @@ int KoShapeContainer::childCount() const {
return d->children->count();
}
bool KoShapeContainer::isChildLocked(const KoShape *child) const {
if(d->children == 0)
return false;
return d->children->isChildLocked(child);
}
void KoShapeContainer::setClipping(const KoShape *child, bool clipping) {
if(d->children == 0)
return;
......
......@@ -118,7 +118,15 @@ public:
*/
bool childClipped(const KoShape *child) const;
void paint(QPainter &painter, const KoViewConverter &converter);
/**
* Return wheather the child has the effective state of being locked for user modifications.
* This method is deferred to the model, which should call the KoShape::isLocked() on the child.
* @param child the shape that the user wants to move.
*/
bool isChildLocked(const KoShape *child) const;
/// reimplemented
virtual void paint(QPainter &painter, const KoViewConverter &converter);
/**
* @brief Paint the component
......@@ -131,7 +139,8 @@ public:
*/
virtual void paintComponent(QPainter &painter, const KoViewConverter &converter) = 0;
void repaint() const;
/// reimplemented
virtual void repaint() const;
/**
* Create and return an iterator over all child shapes.
......
......@@ -72,6 +72,14 @@ public:
*/
virtual bool childClipped(const KoShape *child) const = 0;
/**
* Return wheather the child has the effective state of being locked for user modifications.
* The model has to call KoShape::isLocked() and base its return value upon that, it can
* additionally find rules on wheather the child is locked based on the container state.
* @param child the shape that the user wants to move.
*/
virtual bool isChildLocked(const KoShape *child) const = 0;
/**
* Return the current number of children registered.
* @return the current number of children registered.
......
......@@ -44,6 +44,10 @@ public:
}
void containerChanged(KoShapeContainer *) { }
void childChanged(KoShape *, KoShape::ChangeType ) { }
bool isChildLocked(const KoShape *child) const {
Q_ASSERT(child->parent());
return child->isLocked() || child->parent()->isLocked();
}
private: // members
QList <KoShape *> m_members;
......
......@@ -179,3 +179,7 @@ void KoTextShapeContainerModel::proposeMove(KoShape *child, QPointF &move) {
move.setX(0); // let the text layout move it.
move.setY(0);
}
bool KoTextShapeContainerModel::isChildLocked(const KoShape *child) const {
return child->isLocked();
}
......@@ -54,6 +54,8 @@ public:
virtual void proposeMove(KoShape *child, QPointF &move);
/// reimplemented from KoShapeContainerModel
virtual void childChanged(KoShape *child, KoShape::ChangeType type);
/// reimplemented from KoShapeContainerModel
virtual bool isChildLocked(const KoShape *child) const;
/// each child that is added due to being anchored in the text has an anchor; register it for rules based placement.
void addAnchor(KoTextAnchor *anchor);
......
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