Mercurial > hg > svapp
diff framework/Document.cpp @ 226:2c827ac7c8e7 templating
When saving a session as a template, use the silent.wav placeholder instead of the main model
author | Chris Cannam |
---|---|
date | Wed, 11 May 2011 12:23:55 +0100 |
parents | fe83e6e68683 |
children | dd14baa45847 |
line wrap: on
line diff
--- 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("<data%1%2>\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("<model id=\"%1\" name=\"placeholder\" sampleRate=\"%2\" type=\"wavefile\" file=\":samples/silent.wav\" mainModel=\"true\"/>\n") + .arg(getObjectExportId(m_mainModel)) + .arg(m_mainModel->getSampleRate()); +} + +void Document::writeBackwardCompatibleDerivation(QTextStream &out, QString indent, Model *targetModel, const ModelRecord &rec) const