Changeset - 8509673ac23b
[Not reviewed]
default
0 1 0
Roeland Merks - 15 years ago 2010-11-29 14:29:29
roeland.merks@cwi.nl
Updated "saveStateXML" for consistency with snapshot() and exportData. It now suggests a default extension "xml" and produces a status message.

--
user: Roeland Merks <roeland.merks@cwi.nl>
branch 'default'
changed src/canvas.cpp
1 file changed with 16 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/canvas.cpp
Show inline comments
 
@@ -680,39 +680,54 @@ void Main::readPars()
 
void Main::saveStateXML()
 
{
 

	
 
  stopSimulation();
 
  Q3FileDialog *fd = new Q3FileDialog( this, "file dialog", TRUE );
 
  fd->setMode( Q3FileDialog::AnyFile );
 
  fd->setFilter( "LeafML files (*.xml)");
 
  fd->setDir(par.datadir);
 
  QString fileName;
 

	
 
  if ( fd->exec() == QDialog::Accepted ) {
 
    fileName = fd->selectedFile();
 

	
 
    // extract extension from filename
 
    QFileInfo fi(fileName);
 
    QString extension = fi.suffix();
 
    
 
    if (extension.isEmpty()) {
 
      extension = "xml";
 
      fileName += ".";
 
      fileName += extension;
 
    }
 
    
 
    
 
    if ( QFile::exists( fileName ) &&
 
	 QMessageBox::question(
 
			       this,
 
			       tr("Overwrite File? -- Leaf Growth"),
 
			       tr("A file called %1 already exists."
 
				  " Do you want to overwrite it?")
 
			       .arg( fileName ),
 
			       tr("&Yes"), tr("&No"),
 
			       QString::null, 1, 1 ) ) {
 
      return saveStateXML();
 

	
 
    } else {
 

	
 
      mesh.XMLSave((const char *)fileName, XMLSettingsTree());
 

	
 
      QString status_message;
 
      status_message = QString("Wrote LeafML to %1").arg(fileName);
 
      cerr << status_message.toStdString() << endl;
 
      statusBar()->showMessage(status_message);
 
    }
 
  }
 
}
 

	
 

	
 

	
 
void Main::snapshot()
 
{
 

	
 

	
 
  stopSimulation();
 
  Q3FileDialog *fd = new Q3FileDialog( this, "Save snapshot", TRUE );
0 comments (0 inline, 0 general)