comparison 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
comparison
equal deleted inserted replaced
225:9d50c42d7ca0 226:2c827ac7c8e7
1070 } 1070 }
1071 1071
1072 void 1072 void
1073 Document::toXml(QTextStream &out, QString indent, QString extraAttributes) const 1073 Document::toXml(QTextStream &out, QString indent, QString extraAttributes) const
1074 { 1074 {
1075 toXml(out, indent, extraAttributes, false);
1076 }
1077
1078 void
1079 Document::toXmlAsTemplate(QTextStream &out, QString indent, QString extraAttributes) const
1080 {
1081 toXml(out, indent, extraAttributes, true);
1082 }
1083
1084 void
1085 Document::toXml(QTextStream &out, QString indent, QString extraAttributes,
1086 bool asTemplate) const
1087 {
1075 out << indent + QString("<data%1%2>\n") 1088 out << indent + QString("<data%1%2>\n")
1076 .arg(extraAttributes == "" ? "" : " ").arg(extraAttributes); 1089 .arg(extraAttributes == "" ? "" : " ").arg(extraAttributes);
1077 1090
1078 if (m_mainModel) { 1091 if (m_mainModel) {
1079 1092
1080 m_mainModel->toXml(out, indent + " ", "mainModel=\"true\""); 1093 if (asTemplate) {
1094 writePlaceholderMainModel(out, indent + " ");
1095 } else {
1096 m_mainModel->toXml(out, indent + " ", "mainModel=\"true\"");
1097 }
1081 1098
1082 PlayParameters *playParameters = 1099 PlayParameters *playParameters =
1083 PlayParameterRepository::getInstance()->getPlayParameters(m_mainModel); 1100 PlayParameterRepository::getInstance()->getPlayParameters(m_mainModel);
1084 if (playParameters) { 1101 if (playParameters) {
1085 playParameters->toXml 1102 playParameters->toXml
1184 1201
1185 (*i)->toXml(out, indent + " "); 1202 (*i)->toXml(out, indent + " ");
1186 } 1203 }
1187 1204
1188 out << indent + "</data>\n"; 1205 out << indent + "</data>\n";
1206 }
1207
1208 void
1209 Document::writePlaceholderMainModel(QTextStream &out, QString indent) const
1210 {
1211 out << indent;
1212 out << QString("<model id=\"%1\" name=\"placeholder\" sampleRate=\"%2\" type=\"wavefile\" file=\":samples/silent.wav\" mainModel=\"true\"/>\n")
1213 .arg(getObjectExportId(m_mainModel))
1214 .arg(m_mainModel->getSampleRate());
1189 } 1215 }
1190 1216
1191 void 1217 void
1192 Document::writeBackwardCompatibleDerivation(QTextStream &out, QString indent, 1218 Document::writeBackwardCompatibleDerivation(QTextStream &out, QString indent,
1193 Model *targetModel, 1219 Model *targetModel,