Commit a47a0091 authored by Thomas Zander's avatar Thomas Zander

Make sure a hidden shape is never selected (by user interaction)

Add a 'isSelectable' boolean to every shape to allow certain objects
 in the flake hierarchy to be unselectable. Probably usefull for things
like a shape that is a page in KPresenter. Or a shape that is a layer in
Krita.

svn path=/trunk/koffice/; revision=604246
parent 1db415a2
...@@ -86,7 +86,7 @@ KoInteractionStrategy* KoInteractionStrategy::createStrategy(KoPointerEvent *eve ...@@ -86,7 +86,7 @@ KoInteractionStrategy* KoInteractionStrategy::createStrategy(KoPointerEvent *eve
return new KoShapeMoveStrategy(parent, canvas, event->point); return new KoShapeMoveStrategy(parent, canvas, event->point);
} }
KoShape * object( shapeManager->shapeAt( event->point ) ); KoShape * object( shapeManager->shapeAt( event->point, (event->modifiers() & Qt::ShiftButton) ? KoFlake::NextUnselected : KoFlake::ShapeOnTop, true ) );
if( !object && handle == KoFlake::NoHandle) { if( !object && handle == KoFlake::NoHandle) {
if ( ( event->modifiers() & Qt::ControlModifier ) == 0 ) if ( ( event->modifiers() & Qt::ControlModifier ) == 0 )
{ {
......
...@@ -68,6 +68,8 @@ void KoSelection::select(KoShape * object) ...@@ -68,6 +68,8 @@ void KoSelection::select(KoShape * object)
{ {
Q_ASSERT(object != this); Q_ASSERT(object != this);
Q_ASSERT(object); Q_ASSERT(object);
if(! object->isSelectable())
return;
if(!m_selectedObjects.contains(object)) if(!m_selectedObjects.contains(object))
m_selectedObjects << object; m_selectedObjects << object;
......
...@@ -48,6 +48,7 @@ KoShape::KoShape() ...@@ -48,6 +48,7 @@ KoShape::KoShape()
, m_visible( true ) , m_visible( true )
, m_locked( false ) , m_locked( false )
, m_keepAspect( false ) , m_keepAspect( false )
, m_selectable( true )
, m_userData(0) , m_userData(0)
{ {
recalcMatrix(); recalcMatrix();
......
...@@ -292,6 +292,18 @@ public: ...@@ -292,6 +292,18 @@ public:
*/ */
bool isVisible() const { return m_visible; } bool isVisible() const { return m_visible; }
/**
* Makes it possible for the user to select this shape.
* This parameter defaults to true.
* @param locked when true; set the shape to be selectable.
*/
void setSelectable(bool selectable) { m_selectable = selectable; }
/**
* Returns wheather this shape can be selected by the user.
* @return true only when the object is selectable.
*/
bool isSelectable() const { return m_selectable; }
/** /**
* Changes the Shape to be locked in place. * Changes the Shape to be locked in place.
* Being locked means the shape can no longer change shape or position. * Being locked means the shape can no longer change shape or position.
...@@ -527,7 +539,7 @@ private: ...@@ -527,7 +539,7 @@ private:
int m_zIndex; int m_zIndex;
KoShapeContainer *m_parent; KoShapeContainer *m_parent;
bool m_visible, m_locked, m_keepAspect; bool m_visible, m_locked, m_keepAspect, m_selectable;
QSet<KoShapeManager *> m_shapeManagers; QSet<KoShapeManager *> m_shapeManagers;
......
...@@ -103,6 +103,8 @@ void KoShapeRubberSelectStrategy::finishInteraction( Qt::KeyboardModifiers modif ...@@ -103,6 +103,8 @@ void KoShapeRubberSelectStrategy::finishInteraction( Qt::KeyboardModifiers modif
QList<KoShape *> shapes( m_canvas->shapeManager()->shapesAt( m_selectRect ) ); QList<KoShape *> shapes( m_canvas->shapeManager()->shapesAt( m_selectRect ) );
foreach ( KoShape * shape, shapes ) foreach ( KoShape * shape, shapes )
{ {
if(! (shape->isSelectable() && shape->isVisible()))
continue;
selection->select( shape ); selection->select( shape );
} }
m_parent->repaintDecorations(); m_parent->repaintDecorations();
......
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