diff framework/MainWindowBase.cpp @ 230:976d43d3c67d templating

Split out openSessionTemplate with template name argument rather than FileSource
author Chris Cannam
date Tue, 17 May 2011 17:04:22 +0100
parents a6398a7400c1
children 65d75297a37e
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Wed May 11 13:49:21 2011 +0100
+++ b/framework/MainWindowBase.cpp	Tue May 17 17:04:22 2011 +0100
@@ -214,9 +214,14 @@
 
     Labeller::ValueType labellerType = Labeller::ValueFromTwoLevelCounter;
     settings.beginGroup("MainWindow");
+
     labellerType = (Labeller::ValueType)
         settings.value("labellertype", (int)labellerType).toInt();
     int cycle = settings.value("labellercycle", 4).toInt();
+
+    m_defaultSessionTemplate = settings.value("sessiontemplate", "").toString();
+    if (m_defaultSessionTemplate == "") m_defaultSessionTemplate = "default";
+
     settings.endGroup();
 
     m_labeller = new Labeller(labellerType);
@@ -1189,19 +1194,11 @@
 
     if (mode == ReplaceSession) {
 
-        if (templateName.length() != 0) {
-            // Template in the user's template directory takes
-            // priority over a bundled one; we don't unbundle, but
-            // open directly from the bundled file (where applicable)
-            ResourceFinder rf;
-            QString tfile = rf.getResourcePath("templates", templateName + ".svt");
-            if (tfile != "") {
-                std::cerr << "SV loading template file " << tfile.toStdString() << std::endl;
-                FileOpenStatus tplStatus = openSessionTemplate("file:" + tfile);
-                if (tplStatus != FileOpenFailed) {
-                    std::cerr << "Template load succeeded" << std::endl;
-                    loadedTemplate = true;
-                }
+        if (templateName != "") {
+            FileOpenStatus tplStatus = openSessionTemplate(templateName);
+            if (tplStatus != FileOpenFailed) {
+                std::cerr << "Template load succeeded" << std::endl;
+                loadedTemplate = true;
             }
         }
 
@@ -1678,6 +1675,22 @@
 }
 
 MainWindowBase::FileOpenStatus
+MainWindowBase::openSessionTemplate(QString templateName)
+{
+    // Template in the user's template directory takes
+    // priority over a bundled one; we don't unbundle, but
+    // open directly from the bundled file (where applicable)
+    ResourceFinder rf;
+    QString tfile = rf.getResourcePath("templates", templateName + ".svt");
+    if (tfile != "") {
+        std::cerr << "SV loading template file " << tfile.toStdString() << std::endl;
+        return openSessionTemplate(FileSource("file:" + tfile));
+    } else {
+        return FileOpenFailed;
+    }
+}
+
+MainWindowBase::FileOpenStatus
 MainWindowBase::openSessionTemplate(FileSource source)
 {
     std::cerr << "MainWindowBase::openSessionTemplate(" << source.getLocation().toStdString() << ")" << std::endl;