changeset 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 70b2681665a7
children eed79c69be61 0b1886cee2cf
files framework/MainWindowBase.cpp framework/MainWindowBase.h
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
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())
--- a/framework/MainWindowBase.h	Fri Oct 08 13:30:56 2010 +0100
+++ b/framework/MainWindowBase.h	Fri Oct 15 12:08:34 2010 +0100
@@ -95,7 +95,7 @@
     virtual FileOpenStatus open(QString fileOrUrl, AudioFileOpenMode = AskUser);
     virtual FileOpenStatus open(FileSource source, AudioFileOpenMode = AskUser);
     
-    virtual FileOpenStatus openAudio(FileSource source, AudioFileOpenMode = AskUser);
+    virtual FileOpenStatus openAudio(FileSource source, AudioFileOpenMode = AskUser, QString templateName = "");
     virtual FileOpenStatus openPlaylist(FileSource source, AudioFileOpenMode = AskUser);
     virtual FileOpenStatus openLayer(FileSource source);
     virtual FileOpenStatus openImage(FileSource source);