Commit 90a0c98a authored by Frédéric Larue's avatar Frédéric Larue

UIMainWindow::saveProjectOptions() function modified for a correct formatting...

UIMainWindow::saveProjectOptions() function modified for a correct formatting of strings containing special characters during the XML export.
parent 4b58f567
......@@ -985,13 +985,16 @@ bool UIMainWindow::saveProjectOptions( const QString &filePath, UIProject *proje
if( !file.open( QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text ) )
return false;
// Create a stream for writing formatted text to the file.
// Create a stream for writing XML tags to the file.
QTextStream stream( &file );
QXmlStreamWriter xml( &file );
xml.setAutoFormatting(true);
xml.writeStartDocument();
// Write the opening tag of the project option XML root node.
stream << "<PROJECTOPTIONS Name=\"" << project->GetFileName() << "\">\n";
xml.writeStartElement("PROJECTOPTIONS");
xml.writeAttribute("Name", project->GetFileName());
// Save current display options for each project datum.
......@@ -1002,13 +1005,18 @@ bool UIMainWindow::saveProjectOptions( const QString &filePath, UIProject *proje
if( params.isEmpty() )
continue;
stream << " <DISPLAYOPTIONS Source=\"" << d->GetFileName() << "\">\n";
xml.writeStartElement("DISPLAYOPTIONS");
xml.writeAttribute("Source", d->GetFileName());
for( auto p : params )
{
stream << " <PARAM Id=\"" << p->Id() << "\" ";
stream << "Value=\"" << p->ValueString().replace( '\\', "\\\\" ).replace( '"', "\\\"" ) << "\"/>\n";
xml.writeStartElement("PARAM");
xml.writeAttribute("Id", p->Id());
xml.writeAttribute("Value", p->ValueString());
xml.writeEndElement(); // PARAM
}
stream << " </DISPLAYOPTIONS>\n";
xml.writeEndElement(); // DISPLAYOPTIONS
}
// Save current option values for each tool.
......@@ -1022,35 +1030,47 @@ bool UIMainWindow::saveProjectOptions( const QString &filePath, UIProject *proje
if( params.isEmpty() )
continue;
stream << " <TOOLOPTIONS Name=\"" << name << "\">\n";
xml.writeStartElement("TOOLOPTIONS");
xml.writeAttribute("Name", name);
for( auto p : params )
{
stream << " <PARAM Id=\"" << p->Id() << "\" ";
stream << "Value=\"" << p->ValueString().replace( '\\', "\\\\" ).replace( '"', "\\\"" ) << "\"/>\n";
xml.writeStartElement("PARAM");
xml.writeAttribute("Id", p->Id());
xml.writeAttribute("Value", p->ValueString());
xml.writeEndElement(); // PARAM
}
stream << " </TOOLOPTIONS>\n";
xml.writeEndElement(); // TOOLOPTIONS
}
// Save current viewer state.
// Save the list of displayed data.
stream << " <DATASTATE>\n";
xml.writeStartElement("DATASTATE");
for( auto &d : m_CurrentViewer->getDisplayables() )
stream << " <DISPLAYED Source=\"" << d.first->GetFileName() << "\"/>\n";
{
xml.writeStartElement("DISPLAYED");
xml.writeAttribute("Source", d.first->GetFileName());
xml.writeEndElement(); // DISPLAYED
}
// Save the list of selected data.
for( auto d : ui->tableCurrentProjContent->selectedData() )
stream << " <SELECTED Source=\"" << d->GetFileName() << "\"/>\n";
stream << " </DATASTATE>\n";
{
xml.writeStartElement("SELECTED");
xml.writeAttribute("Source", d->GetFileName());
xml.writeEndElement(); // SELECTED
}
xml.writeEndElement(); // DATASTATE
// Write the closing tag of the project option XML root node.
// ... rajouter dans le menu Settings une dialog box permettant de choisir ce qui doit tre sauvegard en mme temps que le projet
// ou bien le rajouter en tant qu'option lors de la sauvegarde indpendante d'un projet.
stream << "</PROJECTOPTIONS>\n";
xml.writeEndElement(); // PROJECTOPTIONS
xml.writeEndDocument();
return true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment