Mercurial > hg > svapp
changeset 48:c6328c8d6536
* Add Align button to main window; use it
author | Chris Cannam |
---|---|
date | Thu, 25 Oct 2007 15:45:12 +0000 |
parents | d97a7ed7aa39 |
children | 73f682a551dc |
files | framework/Document.cpp framework/Document.h |
diffstat | 2 files changed, 24 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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<RangeSummarisableTimeValueModel *>(model); if (!rm) return; + + if (rm->getAlignmentReference() == m_mainModel) return; // This involves creating three new models:
--- 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