# HG changeset patch # User Chris Cannam # Date 1193327112 0 # Node ID c6328c8d6536edd104d2ece010d0788271ca0a57 # Parent d97a7ed7aa390bf384c2afdf29248d23af2f2fa5 * Add Align button to main window; use it diff -r d97a7ed7aa39 -r c6328c8d6536 framework/Document.cpp --- a/framework/Document.cpp Thu Oct 25 11:32:54 2007 +0000 +++ b/framework/Document.cpp Thu Oct 25 15:45:12 2007 +0000 @@ -319,6 +319,12 @@ deleteLayer(obsoleteLayers[k], true); } + for (ModelMap::iterator i = m_models.begin(); i != m_models.end(); ++i) { + if (i->first->getAlignmentReference() == oldMainModel) { + alignModel(i->first); + } + } + emit mainModelChanged(m_mainModel); // we already emitted modelAboutToBeDeleted for this @@ -672,6 +678,8 @@ RangeSummarisableTimeValueModel *rm = dynamic_cast(model); if (!rm) return; + + if (rm->getAlignmentReference() == m_mainModel) return; // This involves creating three new models: diff -r d97a7ed7aa39 -r c6328c8d6536 framework/Document.h --- a/framework/Document.h Thu Oct 25 11:32:54 2007 +0000 +++ b/framework/Document.h Thu Oct 25 15:45:12 2007 +0000 @@ -189,10 +189,21 @@ */ void removeLayerFromView(View *, Layer *); + /** + * Specify whether models added via addImportedModel should be + * automatically aligned against the main model if appropriate. + */ + void setAutoAlignment(bool on) { m_autoAlignment = on; } + + /** + * Generate alignments for all appropriate models against the main + * model. Existing alignments will not be re-calculated unless + * the main model has changed since they were calculated. + */ + void alignModels(); + void toXml(QTextStream &, QString indent, QString extraAttributes) const; - void setAutoAlignment(bool on) { m_autoAlignment = on; } - signals: void layerAdded(Layer *); void layerRemoved(Layer *); @@ -222,15 +233,12 @@ /** * If model is suitable for alignment, align it against the main - * model and store the alignment in the model. + * model and store the alignment in the model. (If the model has + * an alignment already for the current main model, leave it + * unchanged.) */ void alignModel(Model *); - /** - * Realign all models if the main model has changed. Is this wise? - */ - void alignModels(); - /* * Every model that is in use by a layer in the document must be * found in either m_mainModel or m_models. We own and control