comparison framework/MainWindowBase.cpp @ 224:46213a34900f templating

Add saveSessionTemplate method
author Chris Cannam
date Tue, 10 May 2011 13:58:08 +0100
parents e8ae978e1a3d
children 9d50c42d7ca0
comparison
equal deleted inserted replaced
223:e8ae978e1a3d 224:46213a34900f
1979 .arg(path).arg(f.what())); 1979 .arg(path).arg(f.what()));
1980 return false; 1980 return false;
1981 } 1981 }
1982 } 1982 }
1983 1983
1984 bool
1985 MainWindowBase::saveSessionTemplate(QString path)
1986 {
1987 try {
1988
1989 TempWriteFile temp(path);
1990
1991 QFile file(temp.getTemporaryFilename());
1992 if (!file.open(QIODevice::WriteOnly)) {
1993 std::cerr << "Failed to open session template file \""
1994 << temp.getTemporaryFilename().toStdString()
1995 << "\" for writing: "
1996 << file.errorString().toStdString() << std::endl;
1997 return false;
1998 }
1999
2000 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2001
2002 QTextStream out(&file);
2003 toXml(out);
2004 out.flush();
2005
2006 QApplication::restoreOverrideCursor();
2007
2008 file.close();
2009 temp.moveToTarget();
2010 return true;
2011
2012 } catch (FileOperationFailed &f) {
2013
2014 QMessageBox::critical(this, tr("Failed to write file"),
2015 tr("<b>Save failed</b><p>Failed to write to file \"%1\": %2")
2016 .arg(path).arg(f.what()));
2017 return false;
2018 }
2019 }
2020
1984 void 2021 void
1985 MainWindowBase::toXml(QTextStream &out) 2022 MainWindowBase::toXml(QTextStream &out)
1986 { 2023 {
1987 QString indent(" "); 2024 QString indent(" ");
1988 2025