changeset 224:46213a34900f templating

Add saveSessionTemplate method
author Chris Cannam
date Tue, 10 May 2011 13:58:08 +0100
parents e8ae978e1a3d
children 9d50c42d7ca0
files framework/MainWindowBase.cpp framework/MainWindowBase.h
diffstat 2 files changed, 38 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Mon May 09 16:55:47 2011 +0100
+++ b/framework/MainWindowBase.cpp	Tue May 10 13:58:08 2011 +0100
@@ -1981,6 +1981,43 @@
     }
 }
 
+bool
+MainWindowBase::saveSessionTemplate(QString path)
+{
+    try {
+
+        TempWriteFile temp(path);
+
+        QFile file(temp.getTemporaryFilename());
+        if (!file.open(QIODevice::WriteOnly)) {
+            std::cerr << "Failed to open session template file \""
+                      << temp.getTemporaryFilename().toStdString()
+                      << "\" for writing: "
+                      << file.errorString().toStdString() << std::endl;
+            return false;
+        }
+        
+        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+
+        QTextStream out(&file);
+        toXml(out);
+        out.flush();
+
+        QApplication::restoreOverrideCursor();
+
+        file.close();
+        temp.moveToTarget();
+        return true;
+
+    } catch (FileOperationFailed &f) {
+        
+        QMessageBox::critical(this, tr("Failed to write file"),
+                              tr("<b>Save failed</b><p>Failed to write to file \"%1\": %2")
+                              .arg(path).arg(f.what()));
+        return false;
+    }
+}
+
 void
 MainWindowBase::toXml(QTextStream &out)
 {
--- a/framework/MainWindowBase.h	Mon May 09 16:55:47 2011 +0100
+++ b/framework/MainWindowBase.h	Tue May 10 13:58:08 2011 +0100
@@ -105,6 +105,7 @@
     virtual FileOpenStatus openSession(FileSource source);
 
     virtual bool saveSessionFile(QString path);
+    virtual bool saveSessionTemplate(QString path);
 
     /// Implementation of FrameTimer interface method
     virtual unsigned long getFrame() const;