Commit da8e7ed0 authored by Thomas Zander's avatar Thomas Zander

Refactor isEditable() to only live on the KoShape and not as a static helper

method in the interaction classes anymore.

svn path=/trunk/koffice/; revision=743768
parent 6489fa60
......@@ -72,24 +72,3 @@ QPointF KoInteractionStrategy::snapToGrid( const QPointF &point, Qt::KeyboardMod
return p;
}
// static
bool KoInteractionStrategy::isEditable( const KoShape * shape ) {
Q_ASSERT(shape);
if( !shape || !shape->isVisible() || shape->isLocked() )
return false;
KoShapeContainer * parent = shape->parent();
if(parent && parent->isChildLocked(shape))
return false;
while( parent )
{
if( ! parent->isVisible() )
return false;
parent = parent->parent();
}
return true;
}
......@@ -97,10 +97,6 @@ protected:
*/
QPointF snapToGrid( const QPointF &point, Qt::KeyboardModifiers modifiers );
friend class KoInteractionTool;
/// checks recursively if the shape or one of its parents is not visible or locked
static bool isEditable( const KoShape * shape );
protected: // members
KoTool *m_parent; ///< the KoTool instance that controls this strategy.
QList<KoShape*> m_selectedShapes; ///< the objects this strategy will act on.
......
......@@ -115,8 +115,4 @@ void KoInteractionTool::keyReleaseEvent(QKeyEvent *event) {
}
}
bool KoInteractionTool::shapeIsEditable( const KoShape * shape ) {
return KoInteractionStrategy::isEditable(shape);
}
#include "KoInteractionTool.moc"
......@@ -83,9 +83,6 @@ protected:
*/
virtual KoInteractionStrategy *createStrategy(KoPointerEvent *event) = 0;
/// checks recursively if the shape or one of its parents is not visible or locked
static bool shapeIsEditable( const KoShape * shape );
private:
KoInteractionTool(const KoInteractionTool&);
KoInteractionTool& operator=(const KoInteractionTool&);
......
......@@ -297,7 +297,7 @@ void DefaultTool::updateCursor() {
if(koSelection()->count() > 0) { // has a selection
bool editable=false;
foreach(KoShape *shape, koSelection()->selectedShapes(KoFlake::StrippedSelection)) {
if(!shape->isLocked())
if(editable || !shape->isEditable())
editable = true;
}
......@@ -767,7 +767,7 @@ KoInteractionStrategy *DefaultTool::createStrategy(KoPointerEvent *event) {
KoFlake::SelectionHandle handle = handleAt(event->point, &insideSelection);
foreach (KoShape* shape, select->selectedShapes()) {
if( shapeIsEditable( shape ) ) {
if( shape->isEditable() ) {
editableShape = true;
break;
}
......
......@@ -37,7 +37,7 @@ ShapeMoveStrategy::ShapeMoveStrategy( KoTool *tool, KoCanvasBase *canvas, const
QList<KoShape*> selectedShapes = canvas->shapeManager()->selection()->selectedShapes(KoFlake::TopLevelSelection);
QRectF boundingRect;
foreach(KoShape *shape, selectedShapes) {
if( ! isEditable( shape ) )
if( ! shape->isEditable() )
continue;
m_selectedShapes << shape;
m_previousPositions << shape->position();
......
......@@ -37,7 +37,7 @@ ShapeResizeStrategy::ShapeResizeStrategy( KoTool *tool, KoCanvasBase *canvas,
Q_ASSERT( canvas->shapeManager()->selection()->count() > 0);
QList<KoShape*> selectedShapes = canvas->shapeManager()->selection()->selectedShapes(KoFlake::StrippedSelection);
foreach(KoShape *shape, selectedShapes) {
if( ! isEditable( shape ) )
if( ! shape->isEditable() )
continue;
m_selectedShapes << shape;
m_startPositions << shape->position();
......
......@@ -39,7 +39,7 @@ ShapeRotateStrategy::ShapeRotateStrategy( KoTool *tool, KoCanvasBase *canvas, co
{
QList<KoShape*> selectedShapes = canvas->shapeManager()->selection()->selectedShapes(KoFlake::StrippedSelection);
foreach(KoShape *shape, selectedShapes) {
if( ! isEditable( shape ) )
if( ! shape->isEditable() )
continue;
m_selectedShapes << shape;
if( m_selectedShapes.count() == 1 )
......
......@@ -44,7 +44,7 @@ ShapeShearStrategy::ShapeShearStrategy( KoTool *tool, KoCanvasBase *canvas, cons
KoSelection * sel = canvas->shapeManager()->selection();
QList<KoShape*> selectedShapes = sel->selectedShapes(KoFlake::StrippedSelection);
foreach(KoShape *shape, selectedShapes) {
if( ! isEditable( shape ) )
if( ! shape->isEditable() )
continue;
m_selectedShapes << shape;
m_oldTransforms << shape->transformation();
......
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