Fixed the SaveDetailOption::undo method and few code style issues
--HG-- branch : feature
This commit is contained in:
parent
553f8dc2d2
commit
b14a3c9551
|
@ -47,7 +47,7 @@
|
||||||
#include "../vgeometry/vcubicbezierpath.h"
|
#include "../vgeometry/vcubicbezierpath.h"
|
||||||
#include "../core/vapplication.h"
|
#include "../core/vapplication.h"
|
||||||
#include "../vpatterndb/calculator.h"
|
#include "../vpatterndb/calculator.h"
|
||||||
#include "vpatternpiecedata.h"
|
#include "../vpatterndb/vpatternpiecedata.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
|
|
|
@ -69,7 +69,7 @@ const MaterialCutPlacement& VPatternPieceData::GetMCP(int i) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(i >= 0);
|
Q_ASSERT(i >= 0);
|
||||||
Q_ASSERT(i < GetMCPCount());
|
Q_ASSERT(i < GetMCPCount());
|
||||||
return m_conMCP[i];
|
return m_conMCP.at(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -83,8 +83,8 @@ void VPatternPieceData::RemoveMCP(int i)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPatternPieceData::Clear()
|
void VPatternPieceData::Clear()
|
||||||
{
|
{
|
||||||
m_qsLetter = "";
|
m_qsLetter.clear();
|
||||||
m_qsName = "";
|
m_qsName.clear();
|
||||||
m_conMCP.clear();
|
m_conMCP.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
#include "../../../vgeometry/vsplinepath.h"
|
#include "../../../vgeometry/vsplinepath.h"
|
||||||
#include "../../../vpatterndb/vcontainer.h"
|
#include "../../../vpatterndb/vcontainer.h"
|
||||||
#include "../../../ifc/xml/vdomdocument.h"
|
#include "../../../ifc/xml/vdomdocument.h"
|
||||||
#include "vpatternpiecedata.h"
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -173,7 +172,7 @@ void DialogDetail::UpdateList()
|
||||||
ui.listWidgetMCP->clear();
|
ui.listWidgetMCP->clear();
|
||||||
for (int i = 0; i < m_conMCP.count(); ++i)
|
for (int i = 0; i < m_conMCP.count(); ++i)
|
||||||
{
|
{
|
||||||
MaterialCutPlacement mcp = m_conMCP[i];
|
MaterialCutPlacement mcp = m_conMCP.at(i);
|
||||||
QString qsText = tr("Cut %1 of %2%3").arg(mcp.m_iCutNumber);
|
QString qsText = tr("Cut %1 of %2%3").arg(mcp.m_iCutNumber);
|
||||||
if (mcp.m_eMaterial < MaterialType::mtUserDefined)
|
if (mcp.m_eMaterial < MaterialType::mtUserDefined)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "ui_dialogdetail.h"
|
#include "ui_dialogdetail.h"
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#include "../vpatterndb/vdetail.h"
|
#include "../vpatterndb/vdetail.h"
|
||||||
#include "vpatternpiecedata.h"
|
#include "../vpatterndb/vpatternpiecedata.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The DialogDetail class dialog for ToolDetai. Help create detail and edit option.
|
* @brief The DialogDetail class dialog for ToolDetai. Help create detail and edit option.
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#include "../undocommands/movedetail.h"
|
#include "../undocommands/movedetail.h"
|
||||||
#include "../undocommands/adddet.h"
|
#include "../undocommands/adddet.h"
|
||||||
#include "../undocommands/deletedetail.h"
|
#include "../undocommands/deletedetail.h"
|
||||||
#include "vpatternpiecedata.h"
|
#include "../vpatterndb/vpatternpiecedata.h"
|
||||||
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
|
|
@ -27,10 +27,10 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "savedetailoptions.h"
|
#include "savedetailoptions.h"
|
||||||
#include "vpatternpiecedata.h"
|
|
||||||
#include "../tools/nodeDetails/vabstractnode.h"
|
#include "../tools/nodeDetails/vabstractnode.h"
|
||||||
#include "../../vwidgets/vmaingraphicsview.h"
|
#include "../../vwidgets/vmaingraphicsview.h"
|
||||||
#include "../ifc/xml/vabstractpattern.h"
|
#include "../ifc/xml/vabstractpattern.h"
|
||||||
|
#include "../vpatterndb/vpatternpiecedata.h"
|
||||||
|
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ void SaveDetailOptions::undo()
|
||||||
{
|
{
|
||||||
SaveDet(domElement, oldDet);
|
SaveDet(domElement, oldDet);
|
||||||
doc->RemoveAllChildren(domElement);
|
doc->RemoveAllChildren(domElement);
|
||||||
|
SavePatternPieceData(domElement, oldDet);
|
||||||
for (int i = 0; i < oldDet.CountNode(); ++i)
|
for (int i = 0; i < oldDet.CountNode(); ++i)
|
||||||
{
|
{
|
||||||
VToolDetail::AddNode(doc, domElement, oldDet.at(i));
|
VToolDetail::AddNode(doc, domElement, oldDet.at(i));
|
||||||
|
@ -81,21 +82,7 @@ void SaveDetailOptions::redo()
|
||||||
{
|
{
|
||||||
SaveDet(domElement, newDet);
|
SaveDet(domElement, newDet);
|
||||||
doc->RemoveAllChildren(domElement);
|
doc->RemoveAllChildren(domElement);
|
||||||
|
SavePatternPieceData(domElement, newDet);
|
||||||
QDomElement domData = doc->createElement(VAbstractPattern::TagData);
|
|
||||||
doc->SetAttribute(domData, VAbstractPattern::AttrLetter, newDet.GetPatternPieceData().GetLetter());
|
|
||||||
doc->SetAttribute(domData, VAbstractPattern::AttrName, newDet.GetPatternPieceData().GetName());
|
|
||||||
for (int i = 0; i < newDet.GetPatternPieceData().GetMCPCount(); ++i)
|
|
||||||
{
|
|
||||||
MaterialCutPlacement mcp = newDet.GetPatternPieceData().GetMCP(i);
|
|
||||||
QDomElement domMCP = doc->createElement(VAbstractPattern::TagMCP);
|
|
||||||
doc->SetAttribute(domMCP, VAbstractPattern::AttrMaterial, int(mcp.m_eMaterial));
|
|
||||||
doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef);
|
|
||||||
doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber);
|
|
||||||
doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement));
|
|
||||||
domData.appendChild(domMCP);
|
|
||||||
}
|
|
||||||
domElement.appendChild(domData);
|
|
||||||
|
|
||||||
for (int i = 0; i < newDet.CountNode(); ++i)
|
for (int i = 0; i < newDet.CountNode(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -142,3 +129,22 @@ void SaveDetailOptions::SaveDet(QDomElement &domElement, const VDetail &det)
|
||||||
doc->SetAttribute(domElement, VToolDetail::AttrClosed, QString().setNum(det.getClosed()));
|
doc->SetAttribute(domElement, VToolDetail::AttrClosed, QString().setNum(det.getClosed()));
|
||||||
doc->SetAttribute(domElement, VToolDetail::AttrWidth, QString().setNum(det.getWidth()));
|
doc->SetAttribute(domElement, VToolDetail::AttrWidth, QString().setNum(det.getWidth()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void SaveDetailOptions::SavePatternPieceData(QDomElement &domElement, const VDetail &det)
|
||||||
|
{
|
||||||
|
QDomElement domData = doc->createElement(VAbstractPattern::TagData);
|
||||||
|
doc->SetAttribute(domData, VAbstractPattern::AttrLetter, det.GetPatternPieceData().GetLetter());
|
||||||
|
doc->SetAttribute(domData, VAbstractPattern::AttrName, det.GetPatternPieceData().GetName());
|
||||||
|
for (int i = 0; i < det.GetPatternPieceData().GetMCPCount(); ++i)
|
||||||
|
{
|
||||||
|
MaterialCutPlacement mcp = det.GetPatternPieceData().GetMCP(i);
|
||||||
|
QDomElement domMCP = doc->createElement(VAbstractPattern::TagMCP);
|
||||||
|
doc->SetAttribute(domMCP, VAbstractPattern::AttrMaterial, int(mcp.m_eMaterial));
|
||||||
|
doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef);
|
||||||
|
doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber);
|
||||||
|
doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement));
|
||||||
|
domData.appendChild(domMCP);
|
||||||
|
}
|
||||||
|
domElement.appendChild(domData);
|
||||||
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ private:
|
||||||
VDetail newDet;
|
VDetail newDet;
|
||||||
QGraphicsScene *scene;
|
QGraphicsScene *scene;
|
||||||
void SaveDet(QDomElement &domElement, const VDetail &det);
|
void SaveDet(QDomElement &domElement, const VDetail &det);
|
||||||
|
void SavePatternPieceData(QDomElement &domElement, const VDetail &det);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user