diff framework/MainWindowBase.cpp @ 210:143e1b56e81b templating

MainWindowBase::openAudio gets a template argument, loaded from a qt resource if exists
author Dan Stowell <dan.stowell@eecs.qmul.ac.uk>
date Fri, 15 Oct 2010 12:08:34 +0100
parents 944af6246560
children eed79c69be61
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Fri Oct 08 13:30:56 2010 +0100
+++ b/framework/MainWindowBase.cpp	Fri Oct 15 12:08:34 2010 +0100
@@ -1045,7 +1045,7 @@
 }
 
 MainWindowBase::FileOpenStatus
-MainWindowBase::openAudio(FileSource source, AudioFileOpenMode mode)
+MainWindowBase::openAudio(FileSource source, AudioFileOpenMode mode, QString templateName)
 {
 //    std::cerr << "MainWindowBase::openAudio(" << source.getLocation().toStdString() << ")" << std::endl;
 
@@ -1129,6 +1129,17 @@
         mode = ReplaceMainModel;
     }
 
+    bool loadedTemplate = false;
+    if ((mode == ReplaceMainModel) && (templateName.length() != 0)) {
+        QString tplPath = "file::templates/" + templateName + ".xml";
+        std::cerr << "SV looking for template " << tplPath.toStdString() << std::endl;
+        FileOpenStatus tplStatus = openSessionFile(tplPath);
+        if(tplStatus != FileOpenFailed) {
+            loadedTemplate = true;
+            mode = ReplaceMainModel;
+        }
+    }
+
     emit activity(tr("Import audio file \"%1\"").arg(source.getLocation()));
 
     if (mode == ReplaceMainModel) {
@@ -1144,7 +1155,7 @@
 
 	setupMenus();
 
-	if (m_sessionFile == "") {
+	if (loadedTemplate || (m_sessionFile == "")) {
             //!!! shouldn't be dealing directly with title from here -- call a method
 	    setWindowTitle(tr("%1: %2")
                            .arg(QApplication::applicationName())