[calligra/layer_box_cleaning_kazakov] krita: Fixes and cleaning for KisLayerBox
Dmitry Kazakov
dimula73 at gmail.com
Sat Mar 19 21:24:36 CET 2011
Git commit 10016f1b023d4c77f8e17055e4786d0f5d57d9ea by Dmitry Kazakov.
Committed on 19/03/2011 at 21:07.
Pushed by dkazakov into branch 'layer_box_cleaning_kazakov'.
Fixes and cleaning for KisLayerBox
This patch fixes:
1) Drag-and-drop (it has been broken recently)
2) KisNodeManager::activeNode() is now set properly, when a node
is deleted (caused a crash).
3) Controls of KisLayerBox are enabled/disabled properly again
(has been broken as well as 1) )
Does *not* fix:
1) Crash when adding a transparency mask with a precreated
selection (bug 266687)
CCMAIL:kimageshop at kde.org
M +54 -49 krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp
M +1 -1 krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.h
M +1 -13 krita/ui/kis_doc2.cc
M +0 -7 krita/ui/kis_doc2.h
M +61 -54 krita/ui/kis_node_manager.cpp
M +21 -2 krita/ui/kis_node_manager.h
M +17 -21 krita/ui/kis_node_model.cpp
M +0 -2 krita/ui/kis_node_model.h
M +0 -6 krita/ui/kis_view2.cpp
http://commits.kde.org/calligra/10016f1b023d4c77f8e17055e4786d0f5d57d9ea
diff --git a/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp b/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp
index fdaeecc..b66cb18 100644
--- a/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp
+++ b/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp
@@ -92,7 +92,6 @@ KisLayerBox::KisLayerBox()
connect(m_wdgLayerBox->listLayers, SIGNAL(contextMenuRequested(const QPoint&, const QModelIndex&)),
this, SLOT(slotContextMenuRequested(const QPoint&, const QModelIndex&)));
- connect(m_wdgLayerBox->listLayers, SIGNAL(clicked(const QModelIndex&)), SLOT(slotNodeActivated(const QModelIndex&)));
m_viewModeMenu = new KMenu(this);
QActionGroup *group = new QActionGroup(this);
@@ -130,10 +129,27 @@ KisLayerBox::KisLayerBox()
m_wdgLayerBox->bnDuplicate->setIcon(SmallIcon("edit-copy"));
+
+ connect(m_wdgLayerBox->bnAdd, SIGNAL(clicked()), SLOT(slotNewPaintLayer()));
+ connect(m_wdgLayerBox->bnDelete, SIGNAL(clicked()), SLOT(slotRmClicked()));
+ // NOTE: this is _not_ a mistake. The layerbox shows the layers in the reverse order
+ connect(m_wdgLayerBox->bnRaise, SIGNAL(clicked()), SLOT(slotLowerClicked()));
+ connect(m_wdgLayerBox->bnLower, SIGNAL(clicked()), SLOT(slotRaiseClicked()));
+ // END NOTE
+
+ connect(m_wdgLayerBox->bnProperties, SIGNAL(clicked()), SLOT(slotPropertiesClicked()));
+ connect(m_wdgLayerBox->bnDuplicate, SIGNAL(clicked()), SLOT(slotDuplicateClicked()));
+
+ connect(m_wdgLayerBox->doubleOpacity, SIGNAL(valueChanged(qreal)), SLOT(slotOpacitySliderMoved(qreal)));
+ connect(&m_delayTimer, SIGNAL(timeout()), SLOT(slotOpacityChanged()));
+
+ connect(m_wdgLayerBox->cmbComposite, SIGNAL(activated(const QString&)), SLOT(slotCompositeOpChanged(const QString&)));
+
+
m_newLayerMenu = new KMenu(this);
m_wdgLayerBox->bnAdd->setMenu(m_newLayerMenu);
m_wdgLayerBox->bnAdd->setPopupMode(QToolButton::MenuButtonPopup);
- connect(m_wdgLayerBox->bnAdd, SIGNAL(clicked()), SLOT(slotNewPaintLayer()));
+
m_newLayerMenu->addAction(KIcon("document-new"), i18n("&Paint Layer"), this, SLOT(slotNewPaintLayer()));
m_newLayerMenu->addAction(KIcon("folder-new"), i18n("&Group Layer"), this, SLOT(slotNewGroupLayer()));
m_newLayerMenu->addAction(KIcon("edit-copy"), i18n("&Clone Layer"), this, SLOT(slotNewCloneLayer()));
@@ -147,24 +163,17 @@ KisLayerBox::KisLayerBox()
m_newLayerMenu->addAction(KIcon("view-filter"), i18n("&Transformation Mask..."), this, SLOT(slotNewTransformationMask()));
#endif
m_newLayerMenu->addAction(KIcon("edit-paste"), i18n("&Local Selection"), this, SLOT(slotNewSelectionMask()));
- connect(m_wdgLayerBox->bnDelete, SIGNAL(clicked()), SLOT(slotRmClicked()));
-
- // NOTE: this is _not_ a mistake. The layerbox shows the layers in the reverse order
- connect(m_wdgLayerBox->bnRaise, SIGNAL(clicked()), SLOT(slotLowerClicked()));
- connect(m_wdgLayerBox->bnLower, SIGNAL(clicked()), SLOT(slotRaiseClicked()));
- // END NOTE
- connect(m_wdgLayerBox->bnProperties, SIGNAL(clicked()), SLOT(slotPropertiesClicked()));
- connect(m_wdgLayerBox->bnDuplicate, SIGNAL(clicked()), SLOT(slotDuplicateClicked()));
- connect(m_wdgLayerBox->doubleOpacity, SIGNAL(valueChanged(qreal)), SLOT(slotOpacitySliderMoved(qreal)));
- connect(&m_delayTimer, SIGNAL(timeout()), SLOT(slotOpacityChanged()));
- connect(m_wdgLayerBox->cmbComposite, SIGNAL(activated(const QString&)), SLOT(slotCompositeOpChanged(const QString&)));
m_nodeModel = new KisNodeModel(this);
- connect(m_nodeModel, SIGNAL(nodeActivated(KisNodeSP)), this, SLOT(updateUI()));
- connect(m_nodeModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(updateUI()));
- connect(m_nodeModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(updateUI()));
- connect(m_nodeModel, SIGNAL(modelReset()), this, SLOT(updateUI()));
+
+ // connect model updateUI() to enable/disable controls
+ connect(m_nodeModel, SIGNAL(nodeActivated(KisNodeSP)), SLOT(updateUI()));
+ connect(m_nodeModel, SIGNAL(rowsInserted(const QModelIndex&, int, int)), SLOT(updateUI()));
+ connect(m_nodeModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), SLOT(updateUI()));
+ connect(m_nodeModel, SIGNAL(rowsMoved(const QModelIndex&, int, int, const QModelIndex&, int)), SLOT(updateUI()));
+ connect(m_nodeModel, SIGNAL(modelReset()), SLOT(updateUI()));
+
m_wdgLayerBox->listLayers->setModel(m_nodeModel);
}
@@ -175,7 +184,10 @@ KisLayerBox::~KisLayerBox()
void KisLayerBox::setCanvas(KoCanvasBase * canvas)
{
- disconnect();
+ if(m_canvas) {
+ disconnect(m_canvas);
+ }
+
m_canvas = dynamic_cast<KisCanvas2*>(canvas);
connect(m_canvas, SIGNAL(imageChanged(KisImageWSP)), SLOT(setImage(KisImageWSP)));
setImage(m_canvas->view()->image());
@@ -183,42 +195,42 @@ void KisLayerBox::setCanvas(KoCanvasBase * canvas)
void KisLayerBox::setImage(KisImageWSP image)
{
- if (!image) return;
m_image = image;
- if (m_canvas && m_canvas->view()) {
- KisView2* view = m_canvas->view();
- if (!m_nodeManager.isNull()) {
- m_nodeManager->disconnect(this);
- }
- m_nodeManager = view->nodeManager();
- connect(m_nodeManager, SIGNAL(sigNodeActivated(KisNodeSP)), this, SLOT(setCurrentNode(KisNodeSP)));
+ if (m_image && m_canvas && m_canvas->view()) {
- if (!m_nodeModel.isNull()) {
- m_nodeModel->disconnect(this);
- }
- m_nodeModel->setImage(image);
-
- if (m_nodeManager->activeNode()) {
- setCurrentNode(m_nodeManager->activeNode());
+ if (m_nodeManager) {
+ m_nodeManager->disconnect(this);
}
+ m_nodeManager = m_canvas->view()->nodeManager();
- m_image = view->image();
+ connect(m_image, SIGNAL(sigAboutToBeDeleted()), SLOT(notifyImageDeleted()));
- updateUI();
+ // cold start
+ setCurrentNode(m_nodeManager->activeNode());
+ connect(m_nodeManager, SIGNAL(sigUiNeedChangeActiveNode(KisNodeSP)), this, SLOT(setCurrentNode(KisNodeSP)));
+ connect(m_nodeModel, SIGNAL(nodeActivated(KisNodeSP)), m_nodeManager, SLOT(slotUiActivatedNode(KisNodeSP)));
- m_wdgLayerBox->listLayers->expandAll();
- m_wdgLayerBox->listLayers->scrollToBottom();
+ connect(m_nodeModel, SIGNAL(requestAddNode(KisNodeSP, KisNodeSP)), m_nodeManager, SLOT(addNode(KisNodeSP, KisNodeSP)));
+ connect(m_nodeModel, SIGNAL(requestAddNode(KisNodeSP, KisNodeSP, int)), m_nodeManager, SLOT(insertNode(KisNodeSP, KisNodeSP, int)));
+ connect(m_nodeModel, SIGNAL(requestMoveNode(KisNodeSP, KisNodeSP)), m_nodeManager, SLOT(moveNode(KisNodeSP, KisNodeSP)));
+ connect(m_nodeModel, SIGNAL(requestMoveNode(KisNodeSP, KisNodeSP, int)), m_nodeManager, SLOT(moveNodeAt(KisNodeSP, KisNodeSP, int)));
}
+
+ m_nodeModel->setImage(m_image);
+ m_wdgLayerBox->listLayers->expandAll();
+ m_wdgLayerBox->listLayers->scrollToBottom();
}
+void KisLayerBox::notifyImageDeleted()
+{
+ setImage(0);
+}
void KisLayerBox::updateUI()
{
- Q_ASSERT(! m_image.isNull());
+ KisNodeSP active = m_image ? m_nodeManager->activeNode() : 0;
- KisNodeSP active = m_nodeManager->activeNode();
-
m_wdgLayerBox->bnDelete->setEnabled(active);
m_wdgLayerBox->bnRaise->setEnabled(active && (active->nextSibling()
|| (active->parent() && active->parent() != m_image->root())));
@@ -250,11 +262,10 @@ void KisLayerBox::updateUI()
void KisLayerBox::setCurrentNode(KisNodeSP node)
{
- if (node && m_nodeModel) {
+ if (node) {
m_wdgLayerBox->listLayers->setCurrentIndex(m_nodeModel->indexFromNode(node));
updateUI();
}
-
}
void KisLayerBox::slotSetCompositeOp(const KoCompositeOp* compositeOp)
@@ -418,15 +429,9 @@ void KisLayerBox::slotPropertiesClicked()
void KisLayerBox::slotDuplicateClicked()
{
- m_nodeManager->duplicateActiveNode();
-}
-
-void KisLayerBox::slotNodeActivated(const QModelIndex & node)
-{
- m_nodeManager->activateNode(m_nodeModel->nodeFromIndex(node));
+ m_nodeManager->duplicateActiveNode();
}
-
void KisLayerBox::slotCompositeOpChanged(const QString& _compositeOp)
{
m_nodeManager->nodeCompositeOpChanged(m_nodeManager->activeColorSpace()->compositeOp(_compositeOp));
diff --git a/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.h b/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.h
index 95ef13d..a9e3e7b 100644
--- a/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.h
+++ b/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.h
@@ -69,6 +69,7 @@ public:
private slots:
void setImage(KisImageWSP image);
+ void notifyImageDeleted();
void slotContextMenuRequested(const QPoint &pos, const QModelIndex &index);
@@ -104,7 +105,6 @@ private slots:
void slotCompositeOpChanged(const QString&);
void slotOpacityChanged();
void slotOpacitySliderMoved(qreal opacity);
- void slotNodeActivated(const QModelIndex &);
private:
diff --git a/krita/ui/kis_doc2.cc b/krita/ui/kis_doc2.cc
index 9d3903c..caaeaaf 100644
--- a/krita/ui/kis_doc2.cc
+++ b/krita/ui/kis_doc2.cc
@@ -89,7 +89,6 @@
#include "canvas/kis_canvas2.h"
#include "kis_undo_adapter.h"
#include "flake/kis_shape_controller.h"
-#include "kis_node_model.h"
#include "kra/kis_kra_loader.h"
#include "kra/kis_kra_saver.h"
#include "kis_statusbar.h"
@@ -123,7 +122,7 @@ public:
}
~KisDocPrivate() {
- // Don't delete m_d->shapeController or m_d->nodeModel because it's in a QObject hierarchy.
+ // Don't delete m_d->shapeController because it's in a QObject hierarchy.
delete undoAdapter;
delete nserver;
}
@@ -136,7 +135,6 @@ public:
KisImageSP image;
KisShapeController* shapeController;
- KisNodeModel* nodeModel;
KisKraLoader* kraLoader;
KisKraSaver* kraSaver;
@@ -164,7 +162,6 @@ KisDoc2::~KisDoc2()
{
// Despite being QObject they needs to be deleted before the image
delete m_d->shapeController;
- delete m_d->nodeModel;
if (m_d->image) {
m_d->image->notifyAboutToBeDeleted();
@@ -219,7 +216,6 @@ bool KisDoc2::init()
Q_CHECK_PTR(m_d->nserver);
m_d->shapeController = new KisShapeController(this, m_d->nserver);
- m_d->nodeModel = new KisNodeModel(this);
m_d->kraSaver = 0;
m_d->kraLoader = 0;
@@ -261,7 +257,6 @@ bool KisDoc2::loadXML(const KoXmlDocument& doc, KoStore *)
{
if (m_d->image) {
m_d->shapeController->setImage(0);
- m_d->nodeModel->setImage(0);
m_d->image = 0;
}
@@ -334,7 +329,6 @@ bool KisDoc2::completeLoading(KoStore *store)
setModified(false);
m_d->image->setUndoAdapter(m_d->undoAdapter);
m_d->shapeController->setImage(m_d->image);
- m_d->nodeModel->setImage(m_d->image);
connect(m_d->image.data(), SIGNAL(sigImageModified()), this, SLOT(setModified()));
@@ -525,11 +519,6 @@ KoShape * KisDoc2::addShape(const KisNodeSP node)
return m_d->shapeController->shapeForNode(node);
}
-KisNodeModel * KisDoc2::nodeModel() const
-{
- return m_d->nodeModel;
-}
-
void KisDoc2::prepareForImport()
{
if (m_d->nserver == 0)
@@ -551,7 +540,6 @@ void KisDoc2::setCurrentImage(KisImageWSP image)
m_d->image = image;
m_d->image->setUndoAdapter(m_d->undoAdapter);
m_d->shapeController->setImage(image);
- m_d->nodeModel->setImage(image);
setModified(false);
diff --git a/krita/ui/kis_doc2.h b/krita/ui/kis_doc2.h
index dac0952..c563d6b 100644
--- a/krita/ui/kis_doc2.h
+++ b/krita/ui/kis_doc2.h
@@ -40,7 +40,6 @@ class KoShapeControllerBase;
class KisView2;
class KisChildDoc;
class KisUndoAdapter;
-class KisNodeModel;
/**
* The class that represents a Krita document containing content and
settings.
@@ -144,12 +143,6 @@ public:
*/
KoShape * addShape(const KisNodeSP node);
- /**
- * The layer model provides a light-weight Qt model-view
- * compatible model on the internal Krita image layer hierarchy.
- */
- KisNodeModel * nodeModel() const;
-
signals:
void sigLoadingFinished();
diff --git a/krita/ui/kis_node_manager.cpp b/krita/ui/kis_node_manager.cpp
index 703ad2a..4ed6a9b 100644
--- a/krita/ui/kis_node_manager.cpp
+++ b/krita/ui/kis_node_manager.cpp
@@ -61,6 +61,7 @@ struct KisNodeManager::Private {
KisNodeSP activeNodeBeforeMove;
void slotLayersChanged(KisGroupLayerSP);
+ bool activateNodeImpl(KisNodeSP node);
};
void KisNodeManager::Private::slotLayersChanged(KisGroupLayerSP layer)
@@ -68,6 +69,57 @@ void KisNodeManager::Private::slotLayersChanged(KisGroupLayerSP layer)
self->activateNode(layer->at(0));
}
+bool KisNodeManager::Private::activateNodeImpl(KisNodeSP node)
+{
+ Q_ASSERT(view);
+ Q_ASSERT(view->canvasBase());
+ Q_ASSERT(view->canvasBase()->globalShapeManager());
+
+ if (node && node == activeNode) {
+ return false;
+ }
+
+ // Set the selection on the shape manager to the active layer
+ // and set call KoSelection::setActiveLayer( KoShapeLayer* layer )
+ // with the parent of the active layer.
+ KoSelection * selection = view->canvasBase()->globalShapeManager()->selection();
+ Q_ASSERT(selection);
+ selection->deselectAll();
+
+ if (!node) {
+ selection->setActiveLayer(0);
+ activeNode = 0;
+ maskManager->activateMask(0);
+ layerManager->activateLayer(0);
+ } else {
+ KoShape * shape = view->document()->shapeForNode(node);
+ if (!shape) {
+ shape = view->document()->addShape(node);
+ }
+
+ selection->select(shape);
+ KoShapeLayer * shapeLayer = dynamic_cast<KoShapeLayer*>(shape);
+
+ Q_ASSERT(shapeLayer);
+ shapeLayer->setGeometryProtected(node->userLocked());
+ shapeLayer->setVisible(node->visible());
+ selection->setActiveLayer(shapeLayer);
+
+
+ activeNode = node;
+ if (KisLayerSP layer = dynamic_cast<KisLayer*>(node.data())) {
+ maskManager->activateMask(0);
+ layerManager->activateLayer(layer);
+ } else if (KisMaskSP mask = dynamic_cast<KisMask*>(node.data())) {
+ maskManager->activateMask(mask);
+ // XXX_NODE: for now, masks cannot be nested.
+ layerManager->activateLayer(static_cast<KisLayer*>(node->parent().data()));
+ }
+
+ }
+ return true;
+}
+
KisNodeManager::KisNodeManager(KisView2 * view, KisDoc2 * doc)
: m_d(new Private())
{
@@ -232,7 +284,6 @@ void KisNodeManager::moveNodeAt(KisNodeSP node, KisNodeSP parent, int index)
}
}
-
void KisNodeManager::createNode(const QString & nodeType)
{
@@ -270,63 +321,19 @@ void KisNodeManager::createNode(const QString & nodeType)
void KisNodeManager::activateNode(KisNodeSP node)
{
- Q_ASSERT(m_d->view);
- Q_ASSERT(m_d->view->canvasBase());
- Q_ASSERT(m_d->view->canvasBase()->globalShapeManager());
-
- if (node && m_d->activeNode) {
- if (node == m_d->activeNode) {
- return;
- }
+ if(m_d->activateNodeImpl(node)) {
+ emit sigUiNeedChangeActiveNode(node);
+ emit sigNodeActivated(node);
+ nodesUpdated();
}
+}
- // Set the selection on the shape manager to the active layer
- // and set call KoSelection::setActiveLayer( KoShapeLayer* layer )
- // with the parent of the active layer.
- KoSelection * selection = m_d->view->canvasBase()->globalShapeManager()->selection();
- Q_ASSERT(selection);
- selection->deselectAll();
-
- if (! node) {
- selection->setActiveLayer(0);
- emit sigNodeActivated(0);
- m_d->activeNode = 0;
- m_d->maskManager->activateMask(0);
- m_d->layerManager->activateLayer(0);
- } else {
- KoShape * shape = m_d->view->document()->shapeForNode(node);
- if (!shape) {
- shape = m_d->view->document()->addShape(node);
- }
-#if 0
- KoShape * parentShape = shape->parent();
- if (!parentShape) {
- parentShape = m_d->view->document()->addShape(node->parent());
- }
-#endif
-
- selection->select(shape);
- KoShapeLayer * shapeLayer = dynamic_cast<KoShapeLayer*>(shape);
- Q_ASSERT(shapeLayer);
- if (shapeLayer) {
- shapeLayer->setGeometryProtected(node->userLocked());
- shapeLayer->setVisible(node->visible());
- selection->setActiveLayer(shapeLayer);
- }
-
- m_d->activeNode = node;
- if (KisLayerSP layer = dynamic_cast<KisLayer*>(node.data())) {
- m_d->maskManager->activateMask(0);
- m_d->layerManager->activateLayer(layer);
- } else if (KisMaskSP mask = dynamic_cast<KisMask*>(node.data())) {
- m_d->maskManager->activateMask(mask);
- // XXX_NODE: for now, masks cannot be nested.
- m_d->layerManager->activateLayer(static_cast<KisLayer*>(node->parent().data()));
- }
+void KisNodeManager::slotUiActivatedNode(KisNodeSP node)
+{
+ if(m_d->activateNodeImpl(node)) {
emit sigNodeActivated(node);
-
+ nodesUpdated();
}
- nodesUpdated();
}
void KisNodeManager::nodesUpdated()
diff --git a/krita/ui/kis_node_manager.h b/krita/ui/kis_node_manager.h
index 7ed9bba..92ee062 100644
--- a/krita/ui/kis_node_manager.h
+++ b/krita/ui/kis_node_manager.h
@@ -79,6 +79,16 @@ public:
*/
void setNodeCompositeOp(KisNodeSP node, const KoCompositeOp* compositeOp);
+ /**
+ * Explicitly activates \p node
+ * The UI will be noticed that active node has been changed.
+ *
+ * Both sigNodeActivated and sigUiNeedChangeActiveNode are emitted.
+ *
+ * \see slotUiActivatedNode for comparison
+ */
+ void activateNode(KisNodeSP node);
+
/// Get the class that manages the layer user interface
KisLayerManager * layerManager();
@@ -87,16 +97,25 @@ public:
signals:
- void sigNodeActivated(KisNodeSP layer);
+ void sigNodeActivated(KisNodeSP node);
+ void sigUiNeedChangeActiveNode(KisNodeSP node);
public slots:
+ /**
+ * Activates \p node.
+ * All non-ui listeners are notified with sigNodeActivated,
+ * sigUiNeedChangeActiveNode is *not* emitted.
+ *
+ * \see activateNode
+ */
+ void slotUiActivatedNode(KisNodeSP node);
+
void addNode(KisNodeSP node, KisNodeSP activeNode);
void insertNode(KisNodeSP node, KisNodeSP parent, int index);
void moveNode(KisNodeSP node, KisNodeSP activeNode);
void moveNodeAt(KisNodeSP node, KisNodeSP parent, int index);
void createNode(const QString & node);
- void activateNode(KisNodeSP layer);
void nodesUpdated();
void nodeProperties(KisNodeSP node);
void nodeOpacityChanged(qreal opacity, bool finalChange);
diff --git a/krita/ui/kis_node_model.cpp b/krita/ui/kis_node_model.cpp
index 1dcb6d6..9adc817 100644
--- a/krita/ui/kis_node_model.cpp
+++ b/krita/ui/kis_node_model.cpp
@@ -69,21 +69,24 @@ void KisNodeModel::setImage(KisImageWSP image)
if (m_d->image) {
m_d->image->disconnect(this);
}
+
m_d->image = image;
- connect(m_d->image, SIGNAL(sigPostLayersChanged(KisGroupLayerSP)), SLOT(layersChanged()));
-
- connect(m_d->image, SIGNAL(sigAboutToAddANode(KisNode*, int)),
- SLOT(beginInsertNodes(KisNode*, int)));
- connect(m_d->image, SIGNAL(sigNodeHasBeenAdded(KisNode*, int)),
- SLOT(endInsertNodes(KisNode*, int)));
- connect(m_d->image, SIGNAL(sigAboutToRemoveANode(KisNode*, int)),
- SLOT(beginRemoveNodes(KisNode*, int)));
- connect(m_d->image, SIGNAL(sigNodeHasBeenRemoved(KisNode*, int)),
- SLOT(endRemoveNodes(KisNode*, int)));
- connect(m_d->image, SIGNAL(sigNodeChanged(KisNode*)),
- SLOT(nodeChanged(KisNode*)));
- connect(m_d->image, SIGNAL(sigAboutToBeDeleted()),
- SLOT(imageDeleted()));
+
+ if(m_d->image) {
+ connect(m_d->image, SIGNAL(sigPostLayersChanged(KisGroupLayerSP)),
+ SLOT(layersChanged()));
+ connect(m_d->image, SIGNAL(sigAboutToAddANode(KisNode*, int)),
+ SLOT(beginInsertNodes(KisNode*, int)));
+ connect(m_d->image, SIGNAL(sigNodeHasBeenAdded(KisNode*, int)),
+ SLOT(endInsertNodes(KisNode*, int)));
+ connect(m_d->image, SIGNAL(sigAboutToRemoveANode(KisNode*, int)),
+ SLOT(beginRemoveNodes(KisNode*, int)));
+ connect(m_d->image, SIGNAL(sigNodeHasBeenRemoved(KisNode*, int)),
+ SLOT(endRemoveNodes(KisNode*, int)));
+ connect(m_d->image, SIGNAL(sigNodeChanged(KisNode*)),
+ SLOT(nodeChanged(KisNode*)));
+ }
+ reset();
}
KisNodeSP KisNodeModel::nodeFromIndex(const QModelIndex &index)
@@ -201,7 +204,6 @@ QModelIndex KisNodeModel::index(int row, int column, const QModelIndex &parent)
QModelIndex KisNodeModel::parent(const QModelIndex &index) const
{
//dbgUI <<"KisNodeModel::parent " << index;
- kDebug() << "image " << m_d->image;
if (!m_d->image || !index.isValid())
return QModelIndex();
@@ -514,10 +516,4 @@ void KisNodeModel::updateNodes()
m_d->updateQueue.clear();
}
-void KisNodeModel::imageDeleted()
-{
- m_d->image = 0;
- reset();
-}
-
#include "kis_node_model.moc"
diff --git a/krita/ui/kis_node_model.h b/krita/ui/kis_node_model.h
index cb5085d..16155d5 100644
--- a/krita/ui/kis_node_model.h
+++ b/krita/ui/kis_node_model.h
@@ -81,8 +81,6 @@ private slots:
void nodeChanged(KisNode * node);
void updateNodes();
- void imageDeleted();
-
private:
class Private;
diff --git a/krita/ui/kis_view2.cpp b/krita/ui/kis_view2.cpp
index 31d6d8f..bd0d82f 100644
--- a/krita/ui/kis_view2.cpp
+++ b/krita/ui/kis_view2.cpp
@@ -97,7 +97,6 @@
#include "kis_group_layer.h"
#include "kis_custom_palette.h"
#include "kis_resource_server_provider.h"
-#include "kis_node_model.h"
#include "kis_projection.h"
#include "kis_node.h"
#include "kis_node_manager.h"
@@ -624,11 +623,6 @@ void KisView2::createManagers()
m_d->nodeManager = new KisNodeManager(this, m_d->doc);
m_d->nodeManager->setup(actionCollection());
- connect(m_d->doc->nodeModel(), SIGNAL(requestAddNode(KisNodeSP, KisNodeSP)), m_d->nodeManager, SLOT(addNode(KisNodeSP, KisNodeSP)));
- connect(m_d->doc->nodeModel(), SIGNAL(requestAddNode(KisNodeSP, KisNodeSP, int)), m_d->nodeManager, SLOT(insertNode(KisNodeSP, KisNodeSP, int)));
- connect(m_d->doc->nodeModel(), SIGNAL(requestMoveNode(KisNodeSP, KisNodeSP)), m_d->nodeManager, SLOT(moveNode(KisNodeSP, KisNodeSP)));
- connect(m_d->doc->nodeModel(), SIGNAL(requestMoveNode(KisNodeSP, KisNodeSP, int)), m_d->nodeManager, SLOT(moveNodeAt(KisNodeSP, KisNodeSP, int)));
-
// the following cast is not really safe, but better here than in the zoomManager
// best place would be outside kisview too
More information about the kimageshop
mailing list