Mercurial > hg > easaier-soundaccess
changeset 254:8bdd4752c2b2
remove/add layer without command. patch for bug: impossibility to re-load a layer as it was only set to dormant in the command
not very clean but it works.
author | lbajardsilogic |
---|---|
date | Thu, 12 Jun 2008 14:40:15 +0000 |
parents | 82d17c4d4b39 |
children | 1f26f21febd9 |
files | data/fileio/ModelReader.cpp sv/document/Document.cpp sv/document/Document.h sv/main/MainWindow.cpp |
diffstat | 4 files changed, 39 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/data/fileio/ModelReader.cpp Thu Jun 12 13:36:37 2008 +0000 +++ b/data/fileio/ModelReader.cpp Thu Jun 12 14:40:15 2008 +0000 @@ -240,7 +240,7 @@ } if (m_pane && m_layer) { - m_document->addLayerToView(m_pane, m_layer); + m_document->addLayerToViewWithoutCommand(m_pane, m_layer); } }
--- a/sv/document/Document.cpp Thu Jun 12 13:36:37 2008 +0000 +++ b/sv/document/Document.cpp Thu Jun 12 14:40:15 2008 +0000 @@ -585,6 +585,31 @@ } void +Document::addLayerToViewWithoutCommand(View *view, Layer *layer) +{ + Model *model = layer->getModel(); + if (!model) { +// std::cerr << "Document::addLayerToView: Layer (\"" +// << layer->objectName().toStdString() +// << "\") with no model being added to view: " +// << "normally you want to set the model first" << std::endl; + } else { + if (model != m_mainModel && + m_models.find(model) == m_models.end()) { + std::cerr << "ERROR: Document::addLayerToView: Layer " << layer + << " has unregistered model " << model + << " -- register the layer's model before adding the layer!" << std::endl; + return; + } + } + + view->addLayer(layer); + layer->setLayerDormant(view, false); + + addToLayerViewMap(layer, view); +} + +void Document::removeLayerFromView(View *view, Layer *layer) { CommandHistory::getInstance()->addCommand @@ -592,6 +617,14 @@ } void +Document::removeLayerFromViewWithoutCommand(View *view, Layer *layer) +{ + view->removeLayer(layer); + removeFromLayerViewMap(layer, view); + deleteLayer(layer); +} + +void Document::addToLayerViewMap(Layer *layer, View *view) { bool firstView = (m_layerViewMap.find(layer) == m_layerViewMap.end() ||
--- a/sv/document/Document.h Thu Jun 12 13:36:37 2008 +0000 +++ b/sv/document/Document.h Thu Jun 12 14:40:15 2008 +0000 @@ -194,10 +194,13 @@ */ void addLayerToView(View *, Layer *); - /** + void addLayerToViewWithoutCommand(View *, Layer *); + + /** * Remove the given layer from the given view. */ void removeLayerFromView(View *, Layer *); + void removeLayerFromViewWithoutCommand(View *, Layer *); inline std::set<Layer *>& getLayers(){return m_layers;}
--- a/sv/main/MainWindow.cpp Thu Jun 12 13:36:37 2008 +0000 +++ b/sv/main/MainWindow.cpp Thu Jun 12 14:40:15 2008 +0000 @@ -4086,7 +4086,7 @@ if (pane) { Layer *layer = pane->getSelectedLayer(); if (layer) { - m_document->/*deleteLayer(layer);*/removeLayerFromView(pane, layer); + m_document->removeLayerFromViewWithoutCommand(pane, layer); } } updateMenuStates();