Fixed the SaveDetailOption::undo method and few code style issues

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-06-21 19:53:15 +02:00
parent 553f8dc2d2
commit b14a3c9551
7 changed files with 30 additions and 24 deletions

View File

@ -47,7 +47,7 @@
#include "../vgeometry/vcubicbezierpath.h"
#include "../core/vapplication.h"
#include "../vpatterndb/calculator.h"
#include "vpatternpiecedata.h"
#include "../vpatterndb/vpatternpiecedata.h"
#include <QMessageBox>
#include <QUndoStack>

View File

@ -69,7 +69,7 @@ const MaterialCutPlacement& VPatternPieceData::GetMCP(int i) const
{
Q_ASSERT(i >= 0);
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()
{
m_qsLetter = "";
m_qsName = "";
m_qsLetter.clear();
m_qsName.clear();
m_conMCP.clear();
}

View File

@ -36,7 +36,6 @@
#include "../../../vgeometry/vsplinepath.h"
#include "../../../vpatterndb/vcontainer.h"
#include "../../../ifc/xml/vdomdocument.h"
#include "vpatternpiecedata.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -173,7 +172,7 @@ void DialogDetail::UpdateList()
ui.listWidgetMCP->clear();
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);
if (mcp.m_eMaterial < MaterialType::mtUserDefined)
{

View File

@ -32,7 +32,7 @@
#include "ui_dialogdetail.h"
#include "dialogtool.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.

View File

@ -40,7 +40,7 @@
#include "../undocommands/movedetail.h"
#include "../undocommands/adddet.h"
#include "../undocommands/deletedetail.h"
#include "vpatternpiecedata.h"
#include "../vpatterndb/vpatternpiecedata.h"
#include <QKeyEvent>
#include <QGraphicsSceneMouseEvent>

View File

@ -27,10 +27,10 @@
*************************************************************************/
#include "savedetailoptions.h"
#include "vpatternpiecedata.h"
#include "../tools/nodeDetails/vabstractnode.h"
#include "../../vwidgets/vmaingraphicsview.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../vpatterndb/vpatternpiecedata.h"
#include <QGraphicsView>
@ -57,6 +57,7 @@ void SaveDetailOptions::undo()
{
SaveDet(domElement, oldDet);
doc->RemoveAllChildren(domElement);
SavePatternPieceData(domElement, oldDet);
for (int i = 0; i < oldDet.CountNode(); ++i)
{
VToolDetail::AddNode(doc, domElement, oldDet.at(i));
@ -81,21 +82,7 @@ void SaveDetailOptions::redo()
{
SaveDet(domElement, newDet);
doc->RemoveAllChildren(domElement);
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);
SavePatternPieceData(domElement, newDet);
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::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);
}

View File

@ -53,6 +53,7 @@ private:
VDetail newDet;
QGraphicsScene *scene;
void SaveDet(QDomElement &domElement, const VDetail &det);
void SavePatternPieceData(QDomElement &domElement, const VDetail &det);
};
//---------------------------------------------------------------------------------------------------------------------