# HG changeset patch # User Chris Cannam # Date 1305113035 -3600 # Node ID 2c827ac7c8e72e5a3c867297594bc54fa8426b90 # Parent 9d50c42d7ca09fa3fe6b582276fb119151c6e49c When saving a session as a template, use the silent.wav placeholder instead of the main model diff -r 9d50c42d7ca0 -r 2c827ac7c8e7 framework/Document.cpp --- a/framework/Document.cpp Tue May 10 19:37:45 2011 +0100 +++ b/framework/Document.cpp Wed May 11 12:23:55 2011 +0100 @@ -1072,12 +1072,29 @@ void Document::toXml(QTextStream &out, QString indent, QString extraAttributes) const { + toXml(out, indent, extraAttributes, false); +} + +void +Document::toXmlAsTemplate(QTextStream &out, QString indent, QString extraAttributes) const +{ + toXml(out, indent, extraAttributes, true); +} + +void +Document::toXml(QTextStream &out, QString indent, QString extraAttributes, + bool asTemplate) const +{ out << indent + QString("\n") .arg(extraAttributes == "" ? "" : " ").arg(extraAttributes); if (m_mainModel) { - m_mainModel->toXml(out, indent + " ", "mainModel=\"true\""); + if (asTemplate) { + writePlaceholderMainModel(out, indent + " "); + } else { + m_mainModel->toXml(out, indent + " ", "mainModel=\"true\""); + } PlayParameters *playParameters = PlayParameterRepository::getInstance()->getPlayParameters(m_mainModel); @@ -1189,6 +1206,15 @@ } void +Document::writePlaceholderMainModel(QTextStream &out, QString indent) const +{ + out << indent; + out << QString("\n") + .arg(getObjectExportId(m_mainModel)) + .arg(m_mainModel->getSampleRate()); +} + +void Document::writeBackwardCompatibleDerivation(QTextStream &out, QString indent, Model *targetModel, const ModelRecord &rec) const diff -r 9d50c42d7ca0 -r 2c827ac7c8e7 framework/Document.h --- a/framework/Document.h Tue May 10 19:37:45 2011 +0100 +++ b/framework/Document.h Wed May 11 12:23:55 2011 +0100 @@ -214,6 +214,7 @@ void alignModels(); void toXml(QTextStream &, QString indent, QString extraAttributes) const; + void toXmlAsTemplate(QTextStream &, QString indent, QString extraAttributes) const; signals: void layerAdded(Layer *); @@ -334,6 +335,9 @@ static TransformId getAlignmentTransformName(); + void toXml(QTextStream &, QString, QString, bool asTemplate) const; + void writePlaceholderMainModel(QTextStream &, QString) const; + /** * And these are the layers. We also control the lifespans of * these (usually through the commands used to add and remove them). diff -r 9d50c42d7ca0 -r 2c827ac7c8e7 framework/MainWindowBase.cpp --- a/framework/MainWindowBase.cpp Tue May 10 19:37:45 2011 +0100 +++ b/framework/MainWindowBase.cpp Wed May 11 12:23:55 2011 +0100 @@ -1961,7 +1961,7 @@ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QTextStream out(&bzFile); - toXml(out); + toXml(out, false); out.flush(); QApplication::restoreOverrideCursor(); @@ -2006,7 +2006,7 @@ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QTextStream out(&file); - toXml(out); + toXml(out, true); out.flush(); QApplication::restoreOverrideCursor(); @@ -2025,7 +2025,7 @@ } void -MainWindowBase::toXml(QTextStream &out) +MainWindowBase::toXml(QTextStream &out, bool asTemplate) { QString indent(" "); @@ -2033,7 +2033,11 @@ out << "\n"; out << "\n"; - m_document->toXml(out, "", ""); + if (asTemplate) { + m_document->toXmlAsTemplate(out, "", ""); + } else { + m_document->toXml(out, "", ""); + } out << "\n"; diff -r 9d50c42d7ca0 -r 2c827ac7c8e7 framework/MainWindowBase.h --- a/framework/MainWindowBase.h Tue May 10 19:37:45 2011 +0100 +++ b/framework/MainWindowBase.h Wed May 11 12:23:55 2011 +0100 @@ -411,7 +411,7 @@ virtual void connectLayerEditDialog(ModelDataTableDialog *dialog); - virtual void toXml(QTextStream &stream); + virtual void toXml(QTextStream &stream, bool asTemplate); };