Commit 38076c45 authored by Gerrit Erichsen's avatar Gerrit Erichsen
Browse files

Preferences as part of project xml

parent 8037c901
......@@ -992,6 +992,11 @@ bool CharLGui::saveProject()
QDomElement root = project.createElement("CharL_project");
project.appendChild(root);
root.setAttribute("version", "0.1");
// preferences --------------------------------------------------------------------------------
QDomElement preferences = project.createElement("preferences");
root.appendChild(preferences);
preferences.setAttribute("assign_data", m_preferences->assignDataFromMap());
preferences.setAttribute("assign_locations", m_preferences->assignLocationsFromMap());
// pv-modules /////////////////////////////////////////////////////////////////////////////////
QDomElement modules = project.createElement("pv_modules");
root.appendChild(modules);
......@@ -1108,8 +1113,34 @@ bool CharLGui::loadProject()
while(!node.isNull())
{
QDomElement element = node.toElement();
//preferences ---------------------------------------------------------------------
if (element.tagName() == "preferences")
{
bool assignData = static_cast<bool>(element.attribute("assign_data").toInt());
bool assignLocation = static_cast<bool>(element.attribute("assign_locations").toInt());
bool warnAboutData = (assignData != m_preferences->assignDataFromMap());
bool warnAboutLocations = (assignLocation != m_preferences->assignLocationsFromMap());
m_preferences->setAssignDataFromMap(assignData);
m_preferences->setAssignLocationsFromMap(assignLocation);
if (warnAboutData || warnAboutLocations)
{
QString text = "Changed preferences according to loaded project settings, "
"to avoid mismatches. Following settings were changed:\n";
if (warnAboutData)
{
text += "Automatically assign data from map was set to: ";
text += (assignData) ? "True" : "False\n";
}
if (warnAboutLocations)
{
text += "Automatically assign locations from map was set to: ";
text += (assignLocation) ? "True" : "False";
}
QMessageBox::information(this, "CharL - Load Project", text);
}
}
// pv-modules /////////////////////////////////////////////////////////////////////
if (element.tagName() == "pv_modules")
else if (element.tagName() == "pv_modules")
{
m_modelModulesPV->readFromXml(element);
}
......
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