# HG changeset patch # User Chris Cannam # Date 1193311974 0 # Node ID d97a7ed7aa390bf384c2afdf29248d23af2f2fa5 # Parent 7fbe1c99d5d85bb697e025810de47db830c6ad24 * Add auto-alignment toggle to Document * Make MainWindowBase cope if there is no time ruler layer diff -r 7fbe1c99d5d8 -r d97a7ed7aa39 framework/Document.cpp --- a/framework/Document.cpp Wed Oct 24 16:43:20 2007 +0000 +++ b/framework/Document.cpp Thu Oct 25 11:32:54 2007 +0000 @@ -38,7 +38,8 @@ //!!! still need to handle command history, documentRestored/documentModified Document::Document() : - m_mainModel(0) + m_mainModel(0), + m_autoAlignment(false) { connect(this, SIGNAL(modelAboutToBeDeleted(Model *)), TransformFactory::getInstance(), @@ -370,6 +371,8 @@ m_models[model] = rec; + if (m_autoAlignment) alignModel(model); + emit modelAdded(model); } diff -r 7fbe1c99d5d8 -r d97a7ed7aa39 framework/Document.h --- a/framework/Document.h Wed Oct 24 16:43:20 2007 +0000 +++ b/framework/Document.h Thu Oct 25 11:32:54 2007 +0000 @@ -190,6 +190,9 @@ void removeLayerFromView(View *, Layer *); void toXml(QTextStream &, QString indent, QString extraAttributes) const; + + void setAutoAlignment(bool on) { m_autoAlignment = on; } + signals: void layerAdded(Layer *); void layerRemoved(Layer *); @@ -311,6 +314,8 @@ */ typedef std::set LayerSet; LayerSet m_layers; + + bool m_autoAlignment; }; #endif diff -r 7fbe1c99d5d8 -r d97a7ed7aa39 framework/MainWindowBase.cpp --- a/framework/MainWindowBase.cpp Wed Oct 24 16:43:20 2007 +0000 +++ b/framework/MainWindowBase.cpp Thu Oct 25 11:32:54 2007 +0000 @@ -897,12 +897,9 @@ Pane *pane = command->getPane(); - if (!m_timeRulerLayer) { - m_timeRulerLayer = m_document->createMainModelLayer - (LayerFactory::TimeRuler); - } - - m_document->addLayerToView(pane, m_timeRulerLayer); + if (m_timeRulerLayer) { + m_document->addLayerToView(pane, m_timeRulerLayer); + } Layer *newLayer = m_document->createImportedLayer(newModel); @@ -1865,7 +1862,7 @@ MainWindowBase::layerAboutToBeDeleted(Layer *layer) { // std::cerr << "MainWindowBase::layerAboutToBeDeleted(" << layer << ")" << std::endl; - if (layer == m_timeRulerLayer) { + if (m_timeRulerLayer && (layer == m_timeRulerLayer)) { // std::cerr << "(this is the time ruler layer)" << std::endl; m_timeRulerLayer = 0; }