Fixed material attribute writing to XML and removed commented out lines

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-08-21 11:48:51 +02:00
parent ff6d3c7155
commit b4ced822e0
3 changed files with 17 additions and 4 deletions

View File

@ -129,7 +129,6 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge
<< QApplication::translate("Detail", "Interfacing", 0) << QApplication::translate("Detail", "Interfacing", 0)
<< QApplication::translate("Detail", "Interlining", 0); << QApplication::translate("Detail", "Interlining", 0);
//ui.comboBoxMaterial->addItems(m_qslMaterials);
for (int i = 0; i < m_qslMaterials.count(); ++i) for (int i = 0; i < m_qslMaterials.count(); ++i)
{ {
ui.comboBoxMaterial->addItem(m_qslMaterials[i], i); ui.comboBoxMaterial->addItem(m_qslMaterials[i], i);
@ -253,7 +252,8 @@ void DialogDetail::AddUpdate()
QStringList qslUserMaterials = qApp->Settings()->GetUserDefinedMaterials(); QStringList qslUserMaterials = qApp->Settings()->GetUserDefinedMaterials();
int i = ui.comboBoxMaterial->currentData().toInt(); int i = ui.comboBoxMaterial->currentData().toInt();
if (i < m_qslMaterials.count() && mcp.m_qsMaterialUserDef == m_qslMaterials[i]) QString qsMat = ui.comboBoxMaterial->currentText();
if (i < m_qslMaterials.count() && qsMat == m_qslMaterials[i])
{ {
mcp.m_eMaterial = MaterialType(i); mcp.m_eMaterial = MaterialType(i);
mcp.m_qsMaterialUserDef.clear(); mcp.m_qsMaterialUserDef.clear();
@ -261,7 +261,7 @@ void DialogDetail::AddUpdate()
else else
{ {
mcp.m_eMaterial = MaterialType::mtUserDefined; mcp.m_eMaterial = MaterialType::mtUserDefined;
mcp.m_qsMaterialUserDef = ui.comboBoxMaterial->currentText(); mcp.m_qsMaterialUserDef = qsMat;
// check if we have new user defined material // check if we have new user defined material
bool bFound = false; bool bFound = false;
for (int i = 0; i < qslUserMaterials.count() && bFound == false; ++i) for (int i = 0; i < qslUserMaterials.count() && bFound == false; ++i)
@ -832,7 +832,6 @@ void DialogDetail::SetEditMode()
} }
else else
{ {
//ui.comboBoxMaterial->setCurrentText(m_qslMaterials[int(mcp.m_eMaterial)]);
ui.comboBoxMaterial->setCurrentIndex(int(mcp.m_eMaterial)); ui.comboBoxMaterial->setCurrentIndex(int(mcp.m_eMaterial));
} }
ui.spinBoxCutNumber->setValue(mcp.m_iCutNumber); ui.spinBoxCutNumber->setValue(mcp.m_iCutNumber);

View File

@ -452,6 +452,10 @@ void VToolDetail::AddToFile()
{ {
doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef); doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef);
} }
else
{
domMCP.removeAttribute(VAbstractPattern::AttrUserDefined);
}
doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber); doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber);
doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement)); doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement));
domData.appendChild(domMCP); domData.appendChild(domMCP);
@ -514,6 +518,10 @@ void VToolDetail::RefreshDataInFile()
{ {
doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef); doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef);
} }
else
{
domMCP.removeAttribute(VAbstractPattern::AttrUserDefined);
}
doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber); doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber);
doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement)); doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement));
domData.appendChild(domMCP); domData.appendChild(domMCP);

View File

@ -163,8 +163,14 @@ void SaveDetailOptions::SavePatternPieceData(QDomElement &domElement, const VDet
doc->SetAttribute(domMCP, VAbstractPattern::AttrMaterial, int(mcp.m_eMaterial)); doc->SetAttribute(domMCP, VAbstractPattern::AttrMaterial, int(mcp.m_eMaterial));
if (mcp.m_eMaterial == MaterialType::mtUserDefined) if (mcp.m_eMaterial == MaterialType::mtUserDefined)
{ {
qDebug() << "USER DEFINED MATERIAL";
doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef); doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef);
} }
else
{
qDebug() << "PREDEFINED MATERIAL";
domMCP.removeAttribute(VAbstractPattern::AttrUserDefined);
}
doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber); doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber);
doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement)); doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement));
domData.appendChild(domMCP); domData.appendChild(domMCP);