Commit 422cac8b authored by Emanuele Tamponi's avatar Emanuele Tamponi

Fixed some functions.

svn path=/trunk/koffice/; revision=659223
parent fa520c45
......@@ -198,10 +198,11 @@ void KisCanvas2::addCommand(QUndoCommand *command)
KoShapeManager* KisCanvas2::shapeManager() const
{
KisShapeController *controller = dynamic_cast<KisShapeController*>(m_d->view->document()->shapeController());
Q_ASSERT(controller);
if (controller->activeLayerShape()->shapeId() == KIS_SHAPE_LAYER_ID)
KoShape *shape = controller->activeLayerShape();
if (shape && shape->shapeId() == KIS_SHAPE_LAYER_ID)
return dynamic_cast<KisShapeLayer*>(controller->activeLayerShape())->shapeManager();
return m_d->shapeManager;
}
......
......@@ -49,6 +49,7 @@ public:
KisLayerMap layerShapes; // maps from krita/image layers to shapes
KisDoc2 * doc;
KisNameServer * nameServer;
bool ignoreActiveLayer;
};
KisShapeController::KisShapeController( KisDoc2 * doc, KisNameServer *nameServer )
......@@ -58,6 +59,7 @@ KisShapeController::KisShapeController( KisDoc2 * doc, KisNameServer *nameServer
m_d->doc = doc;
m_d->nameServer = nameServer;
m_d->image = 0;
m_d->ignoreActiveLayer = false;
}
......@@ -130,10 +132,18 @@ void KisShapeController::removeShape( KoShape* shape )
}
}
foreach( KoView *view, m_d->doc->views() ) {
KisCanvas2 *canvas = ((KisView2*)view)->canvasBase();
canvas->shapeManager()->remove(shape);
canvas->canvasWidget()->update();
if ( shape->shapeId() == KIS_LAYER_SHAPE_ID
|| shape->shapeId() == KIS_SHAPE_LAYER_ID
|| shape->shapeId() == KIS_LAYER_CONTAINER_ID
|| shape->shapeId() == KIS_MASK_SHAPE_ID )
{
m_d->ignoreActiveLayer = true;
foreach( KoView *view, m_d->doc->views() ) {
KisCanvas2 *canvas = ((KisView2*)view)->canvasBase();
canvas->shapeManager()->remove(shape);
canvas->canvasWidget()->update();
}
m_d->ignoreActiveLayer = false;
}
m_d->doc->setModified( true );
......@@ -141,8 +151,6 @@ void KisShapeController::removeShape( KoShape* shape )
void KisShapeController::addShape( KoShape* shape )
{
kDebug(41007) << ">>>>> KisShapeController::addShape: " << shape->shapeId() << ", active layer: " << activeLayerShape() << endl;
......@@ -268,11 +276,13 @@ void KisShapeController::slotLayerAdded( KisLayerSP layer )
m_d->layerShapes[layer] = shape;
m_d->ignoreActiveLayer = true;
foreach( KoView *view, m_d->doc->views() ) {
KisCanvas2 *canvas = ((KisView2*)view)->canvasBase();
canvas->shapeManager()->add(shape);
canvas->canvasWidget()->update();
}
m_d->ignoreActiveLayer = false;
}
......@@ -325,6 +335,9 @@ void KisShapeController::slotLayerActivated( KisLayerSP layer )
KoShape * KisShapeController::activeLayerShape()
{
if (m_d->ignoreActiveLayer)
return 0;
if ( !m_d->image ) {
kDebug(41007) << "activeLayerShape() current image = " << m_d->image << endl;
return 0;
......
......@@ -85,13 +85,19 @@ void KisShapeLayer::paintComponent(QPainter &painter, const KoViewConverter &con
void KisShapeLayer::addChild(KoShape *object)
{
kDebug(41001) << "KisShapeLayer::addChild {" << endl;
kDebug(41001) << "KisShapeLayer::addChild" << endl;
KoShapeLayer::addChild( object );
m_d->canvas->shapeManager()->add( object );
setDirty(m_d->converter->documentToView(object->boundingRect()).toRect());
}
void KisShapeLayer::removeChild(KoShape *object)
{
m_d->canvas->shapeManager()->remove( object );
KoShapeLayer::removeChild( object );
}
QIcon KisShapeLayer::icon() const
{
return KIcon("gear");
......
......@@ -65,6 +65,7 @@ public:
// KoShapeContainer overrides
void addChild(KoShape *object);
void removeChild(KoShape *object);
// KisExternalLayer implementation
QIcon icon() const;
......
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