changeset 47:d97a7ed7aa39

* Add auto-alignment toggle to Document * Make MainWindowBase cope if there is no time ruler layer
author Chris Cannam
date Thu, 25 Oct 2007 11:32:54 +0000
parents 7fbe1c99d5d8
children c6328c8d6536
files framework/Document.cpp framework/Document.h framework/MainWindowBase.cpp
diffstat 3 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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);
 }
 
--- 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<Layer *> LayerSet;
     LayerSet m_layers;
+
+    bool m_autoAlignment;
 };
 
 #endif
--- 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;
     }