Undo add detail and add union details.
--HG-- branch : feature
This commit is contained in:
parent
cf880a04cd
commit
fe67e8e57f
|
@ -185,8 +185,10 @@ void VToolSinglePoint::decrementReferens()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolSinglePoint::DeleteTool()
|
void VToolSinglePoint::DeleteTool(bool ask)
|
||||||
{
|
{
|
||||||
|
if (ask)
|
||||||
|
{
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setText(tr("Confirm the deletion."));
|
msgBox.setText(tr("Confirm the deletion."));
|
||||||
msgBox.setInformativeText(tr("Do you really want delete?"));
|
msgBox.setInformativeText(tr("Do you really want delete?"));
|
||||||
|
@ -197,6 +199,7 @@ void VToolSinglePoint::DeleteTool()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DeletePatternPiece *deletePP = new DeletePatternPiece(doc, nameActivDraw);
|
DeletePatternPiece *deletePP = new DeletePatternPiece(doc, nameActivDraw);
|
||||||
connect(deletePP, &DeletePatternPiece::NeedFullParsing, doc, &VPattern::NeedFullParsing);
|
connect(deletePP, &DeletePatternPiece::NeedFullParsing, doc, &VPattern::NeedFullParsing);
|
||||||
|
|
|
@ -59,7 +59,7 @@ protected:
|
||||||
virtual void RefreshDataInFile();
|
virtual void RefreshDataInFile();
|
||||||
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
|
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
|
||||||
virtual void decrementReferens();
|
virtual void decrementReferens();
|
||||||
virtual void DeleteTool();
|
virtual void DeleteTool(bool ask = true);
|
||||||
virtual void SaveDialog(QDomElement &domElement);
|
virtual void SaveDialog(QDomElement &domElement);
|
||||||
private:
|
private:
|
||||||
QString namePP;
|
QString namePP;
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include "vabstractnode.h"
|
#include "vabstractnode.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "../../xml/vpattern.h"
|
#include "../../xml/vpattern.h"
|
||||||
|
#include "../../undocommands/adddetnode.h"
|
||||||
|
#include "../../widgets/vapplication.h"
|
||||||
|
|
||||||
const QString VAbstractNode::AttrIdObject = QStringLiteral("idObject");
|
const QString VAbstractNode::AttrIdObject = QStringLiteral("idObject");
|
||||||
const QString VAbstractNode::AttrIdTool = QStringLiteral("idTool");
|
const QString VAbstractNode::AttrIdTool = QStringLiteral("idTool");
|
||||||
|
@ -74,17 +76,8 @@ void VAbstractNode::RestoreNode()
|
||||||
*/
|
*/
|
||||||
void VAbstractNode::AddToModeling(const QDomElement &domElement)
|
void VAbstractNode::AddToModeling(const QDomElement &domElement)
|
||||||
{
|
{
|
||||||
QDomElement modelingElement;
|
AddDetNode *addNode = new AddDetNode(domElement, doc);
|
||||||
bool ok = doc->GetActivNodeElement(VPattern::TagModeling, modelingElement);
|
qApp->getUndoStack()->push(addNode);
|
||||||
if (ok)
|
|
||||||
{
|
|
||||||
modelingElement.appendChild(domElement);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qCritical()<<tr("Can't find tag Modeling")<< Q_FUNC_INFO;
|
|
||||||
}
|
|
||||||
emit toolhaveChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -242,8 +242,10 @@ QPointF VAbstractTool::addVector(const QPointF &p, const QPointF &p1, const QPoi
|
||||||
* @brief DeleteTool full delete object form scene and file.
|
* @brief DeleteTool full delete object form scene and file.
|
||||||
* @param tool tool
|
* @param tool tool
|
||||||
*/
|
*/
|
||||||
void VAbstractTool::DeleteTool()
|
void VAbstractTool::DeleteTool(bool ask)
|
||||||
{
|
{
|
||||||
|
if (ask)
|
||||||
|
{
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setText(tr("Confirm the deletion."));
|
msgBox.setText(tr("Confirm the deletion."));
|
||||||
msgBox.setInformativeText(tr("Do you really want delete?"));
|
msgBox.setInformativeText(tr("Do you really want delete?"));
|
||||||
|
@ -254,6 +256,7 @@ void VAbstractTool::DeleteTool()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DelTool *delTool = new DelTool(doc, id);
|
DelTool *delTool = new DelTool(doc, id);
|
||||||
connect(delTool, &DelTool::NeedFullParsing, doc, &VPattern::NeedFullParsing);
|
connect(delTool, &DelTool::NeedFullParsing, doc, &VPattern::NeedFullParsing);
|
||||||
|
|
|
@ -145,7 +145,7 @@ protected:
|
||||||
* @brief RemoveReferens decrement value of reference.
|
* @brief RemoveReferens decrement value of reference.
|
||||||
*/
|
*/
|
||||||
virtual void RemoveReferens(){}
|
virtual void RemoveReferens(){}
|
||||||
virtual void DeleteTool();
|
virtual void DeleteTool(bool ask = true);
|
||||||
Qt::PenStyle LineStyle();
|
Qt::PenStyle LineStyle();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VAbstractTool)
|
Q_DISABLE_COPY(VAbstractTool)
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include "../undocommands/savedetailoptions.h"
|
#include "../undocommands/savedetailoptions.h"
|
||||||
#include "../undocommands/movedetail.h"
|
#include "../undocommands/movedetail.h"
|
||||||
|
#include "../undocommands/adddet.h"
|
||||||
|
|
||||||
const QString VToolDetail::TagName = QStringLiteral("detail");
|
const QString VToolDetail::TagName = QStringLiteral("detail");
|
||||||
const QString VToolDetail::TagNode = QStringLiteral("node");
|
const QString VToolDetail::TagNode = QStringLiteral("node");
|
||||||
|
@ -124,6 +125,10 @@ VToolDetail::VToolDetail(VPattern *doc, VContainer *data, const quint32 &id, con
|
||||||
if (typeCreation == Source::FromGui || typeCreation == Source::FromTool)
|
if (typeCreation == Source::FromGui || typeCreation == Source::FromTool)
|
||||||
{
|
{
|
||||||
AddToFile();
|
AddToFile();
|
||||||
|
if (typeCreation != Source::FromTool)
|
||||||
|
{
|
||||||
|
qApp->getUndoStack()->endMacro();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +166,7 @@ void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
|
||||||
SCASSERT(dialogTool != nullptr);
|
SCASSERT(dialogTool != nullptr);
|
||||||
VDetail detail = dialogTool->getDetails();
|
VDetail detail = dialogTool->getDetails();
|
||||||
VDetail det;
|
VDetail det;
|
||||||
|
qApp->getUndoStack()->beginMacro("add detail");
|
||||||
for (ptrdiff_t i = 0; i< detail.CountNode(); ++i)
|
for (ptrdiff_t i = 0; i< detail.CountNode(); ++i)
|
||||||
{
|
{
|
||||||
quint32 id = 0;
|
quint32 id = 0;
|
||||||
|
@ -219,6 +225,7 @@ void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
|
||||||
det.append(node);
|
det.append(node);
|
||||||
}
|
}
|
||||||
det.setName(detail.getName());
|
det.setName(detail.getName());
|
||||||
|
det.setWidth(detail.getWidth());
|
||||||
Create(0, det, scene, doc, data, Document::FullParse, Source::FromGui);
|
Create(0, det, scene, doc, data, Document::FullParse, Source::FromGui);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,9 +271,9 @@ void VToolDetail::Create(const quint32 &_id, const VDetail &newDetail, VMainGrap
|
||||||
/**
|
/**
|
||||||
* @brief Remove full delete detail.
|
* @brief Remove full delete detail.
|
||||||
*/
|
*/
|
||||||
void VToolDetail::Remove()
|
void VToolDetail::Remove(bool ask)
|
||||||
{
|
{
|
||||||
DeleteTool();
|
DeleteTool(ask);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -323,12 +330,9 @@ void VToolDetail::AddToFile()
|
||||||
AddNode(doc, domElement, detail.at(i));
|
AddNode(doc, domElement, detail.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement element;
|
AddDet *addDet = new AddDet(domElement, doc);
|
||||||
bool ok = doc->GetActivNodeElement(VPattern::TagDetails, element);
|
connect(addDet, &AddDet::NeedFullParsing, doc, &VPattern::NeedFullParsing);
|
||||||
if (ok)
|
qApp->getUndoStack()->push(addDet);
|
||||||
{
|
|
||||||
element.appendChild(domElement);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -80,7 +80,7 @@ public:
|
||||||
static const QString NodePoint;
|
static const QString NodePoint;
|
||||||
static const QString NodeSpline;
|
static const QString NodeSpline;
|
||||||
static const QString NodeSplinePath;
|
static const QString NodeSplinePath;
|
||||||
void Remove();
|
void Remove(bool ask);
|
||||||
static void AddNode(VPattern *doc, QDomElement &domElement, const VNodeDetail &node);
|
static void AddNode(VPattern *doc, QDomElement &domElement, const VNodeDetail &node);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile ();
|
virtual void FullUpdateFromFile ();
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "../geometry/varc.h"
|
#include "../geometry/varc.h"
|
||||||
#include "../geometry/vsplinepath.h"
|
#include "../geometry/vsplinepath.h"
|
||||||
#include "../dialogs/tools/dialoguniondetails.h"
|
#include "../dialogs/tools/dialoguniondetails.h"
|
||||||
|
#include "../undocommands/adduniondetails.h"
|
||||||
|
|
||||||
const QString VToolUnionDetails::TagName = QStringLiteral("tools");
|
const QString VToolUnionDetails::TagName = QStringLiteral("tools");
|
||||||
const QString VToolUnionDetails::ToolType = QStringLiteral("unionDetails");
|
const QString VToolUnionDetails::ToolType = QStringLiteral("unionDetails");
|
||||||
|
@ -492,6 +493,7 @@ void VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VP
|
||||||
VDetail d2 = data->GetDetail(dialogTool->getD2());
|
VDetail d2 = data->GetDetail(dialogTool->getD2());
|
||||||
quint32 indexD1 = static_cast<quint32>(dialogTool->getIndexD1());
|
quint32 indexD1 = static_cast<quint32>(dialogTool->getIndexD1());
|
||||||
quint32 indexD2 = static_cast<quint32>(dialogTool->getIndexD2());
|
quint32 indexD2 = static_cast<quint32>(dialogTool->getIndexD2());
|
||||||
|
qApp->getUndoStack()->beginMacro("union details");
|
||||||
Create(0, d1, d2, dialogTool->getD1(), dialogTool->getD2(), indexD1, indexD2, scene, doc, data, Document::FullParse,
|
Create(0, d1, d2, dialogTool->getD1(), dialogTool->getD2(), indexD1, indexD2, scene, doc, data, Document::FullParse,
|
||||||
Source::FromGui);
|
Source::FromGui);
|
||||||
}
|
}
|
||||||
|
@ -603,6 +605,7 @@ void VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDeta
|
||||||
} while (i < d1.RemoveEdge(indexD1).CountNode());
|
} while (i < d1.RemoveEdge(indexD1).CountNode());
|
||||||
|
|
||||||
newDetail.setName("Detail");
|
newDetail.setName("Detail");
|
||||||
|
newDetail.setWidth(d1.getWidth());
|
||||||
VToolDetail::Create(0, newDetail, scene, doc, data, parse, Source::FromTool);
|
VToolDetail::Create(0, newDetail, scene, doc, data, parse, Source::FromTool);
|
||||||
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
||||||
SCASSERT(tools != nullptr);
|
SCASSERT(tools != nullptr);
|
||||||
|
@ -610,12 +613,14 @@ void VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDeta
|
||||||
{
|
{
|
||||||
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(d1id));
|
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(d1id));
|
||||||
SCASSERT(toolDet != nullptr);
|
SCASSERT(toolDet != nullptr);
|
||||||
toolDet->Remove();
|
bool ask = false;
|
||||||
|
toolDet->Remove(ask);
|
||||||
}
|
}
|
||||||
|
|
||||||
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(d2id));
|
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(d2id));
|
||||||
SCASSERT(toolDet != nullptr);
|
SCASSERT(toolDet != nullptr);
|
||||||
toolDet->Remove();
|
bool ask = false;
|
||||||
|
toolDet->Remove(ask);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -645,6 +650,11 @@ void VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDeta
|
||||||
}
|
}
|
||||||
} while (i<d1.RemoveEdge(indexD1).CountNode());
|
} while (i<d1.RemoveEdge(indexD1).CountNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeCreation == Source::FromGui)
|
||||||
|
{
|
||||||
|
qApp->getUndoStack()->endMacro();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -896,15 +906,7 @@ QDomNode VToolUnionDetails::UpdateDetail(const QDomNode &domNode, const VDetail
|
||||||
*/
|
*/
|
||||||
void VToolUnionDetails::AddToModeling(const QDomElement &domElement)
|
void VToolUnionDetails::AddToModeling(const QDomElement &domElement)
|
||||||
{
|
{
|
||||||
QDomElement modelingElement;
|
AddUnionDetails *addUnion = new AddUnionDetails(domElement, doc);
|
||||||
bool ok = doc->GetActivNodeElement(VPattern::TagModeling, modelingElement);
|
connect(addUnion, &AddUnionDetails::NeedFullParsing, doc, &VPattern::NeedFullParsing);
|
||||||
if (ok)
|
qApp->getUndoStack()->push(addUnion);
|
||||||
{
|
|
||||||
modelingElement.appendChild(domElement);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qCritical()<<tr("Can't find tag Modeling")<< Q_FUNC_INFO;
|
|
||||||
}
|
|
||||||
emit toolhaveChange();
|
|
||||||
}
|
}
|
||||||
|
|
77
src/app/undocommands/adddet.cpp
Normal file
77
src/app/undocommands/adddet.cpp
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file adddet.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 15 6, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2014 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "adddet.h"
|
||||||
|
#include "../xml/vpattern.h"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
AddDet::AddDet(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
||||||
|
: QObject(), QUndoCommand(parent), xml(xml), doc(doc), redoFlag(false)
|
||||||
|
{
|
||||||
|
setText(tr("Add detail"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
AddDet::~AddDet()
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void AddDet::undo()
|
||||||
|
{
|
||||||
|
QDomElement element;
|
||||||
|
if (doc->GetActivNodeElement(VPattern::TagDetails, element))
|
||||||
|
{
|
||||||
|
element.removeChild(xml);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't find tag"<<VPattern::TagDetails<< Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emit NeedFullParsing();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void AddDet::redo()
|
||||||
|
{
|
||||||
|
QDomElement element;
|
||||||
|
if (doc->GetActivNodeElement(VPattern::TagDetails, element))
|
||||||
|
{
|
||||||
|
element.appendChild(xml);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't find tag"<<VPattern::TagDetails<< Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (redoFlag)
|
||||||
|
{
|
||||||
|
emit NeedFullParsing();
|
||||||
|
}
|
||||||
|
redoFlag = true;
|
||||||
|
}
|
54
src/app/undocommands/adddet.h
Normal file
54
src/app/undocommands/adddet.h
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file adddet.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 15 6, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2014 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef ADDDET_H
|
||||||
|
#define ADDDET_H
|
||||||
|
|
||||||
|
#include <QDomElement>
|
||||||
|
#include <QUndoCommand>
|
||||||
|
|
||||||
|
class VPattern;
|
||||||
|
|
||||||
|
class AddDet : public QObject, public QUndoCommand
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
AddDet(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0);
|
||||||
|
virtual ~AddDet();
|
||||||
|
virtual void undo();
|
||||||
|
virtual void redo();
|
||||||
|
signals:
|
||||||
|
void NeedFullParsing();
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(AddDet)
|
||||||
|
const QDomElement xml;
|
||||||
|
VPattern *doc;
|
||||||
|
bool redoFlag;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ADDDET_H
|
71
src/app/undocommands/adddetnode.cpp
Normal file
71
src/app/undocommands/adddetnode.cpp
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file adddetnode.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 15 6, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2014 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "adddetnode.h"
|
||||||
|
#include "../xml/vpattern.h"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
AddDetNode::AddDetNode(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
||||||
|
: QUndoCommand(parent), xml(xml), doc(doc)
|
||||||
|
{
|
||||||
|
setText(QObject::tr("Add node"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
AddDetNode::~AddDetNode()
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void AddDetNode::undo()
|
||||||
|
{
|
||||||
|
QDomElement modelingElement;
|
||||||
|
if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement))
|
||||||
|
{
|
||||||
|
modelingElement.removeChild(xml);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't find tag"<<VPattern::TagModeling<< Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void AddDetNode::redo()
|
||||||
|
{
|
||||||
|
QDomElement modelingElement;
|
||||||
|
if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement))
|
||||||
|
{
|
||||||
|
modelingElement.appendChild(xml);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't find tag"<<VPattern::TagModeling<< Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
50
src/app/undocommands/adddetnode.h
Normal file
50
src/app/undocommands/adddetnode.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file adddetnode.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 15 6, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2014 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef ADDDETNODE_H
|
||||||
|
#define ADDDETNODE_H
|
||||||
|
|
||||||
|
#include <QDomElement>
|
||||||
|
#include <QUndoCommand>
|
||||||
|
|
||||||
|
class VPattern;
|
||||||
|
|
||||||
|
class AddDetNode : public QUndoCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AddDetNode(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0);
|
||||||
|
virtual ~AddDetNode();
|
||||||
|
virtual void undo();
|
||||||
|
virtual void redo();
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(AddDetNode)
|
||||||
|
const QDomElement xml;
|
||||||
|
VPattern *doc;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ADDDETNODE_H
|
|
@ -59,6 +59,7 @@ void AddToCalc::undo()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find tag Calculation"<< Q_FUNC_INFO;
|
qDebug()<<"Can't find tag Calculation"<< Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
emit NeedFullParsing();
|
emit NeedFullParsing();
|
||||||
}
|
}
|
||||||
|
@ -87,12 +88,14 @@ void AddToCalc::redo()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can not find the element after which you want to insert."<< Q_FUNC_INFO;
|
qDebug()<<"Can not find the element after which you want to insert."<< Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find tag Calculation"<< Q_FUNC_INFO;
|
qDebug()<<"Can't find tag Calculation"<< Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (redoFlag)
|
if (redoFlag)
|
||||||
{
|
{
|
||||||
|
|
77
src/app/undocommands/adduniondetails.cpp
Normal file
77
src/app/undocommands/adduniondetails.cpp
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file adduniondetails.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 15 6, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2014 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "adduniondetails.h"
|
||||||
|
#include "../xml/vpattern.h"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
AddUnionDetails::AddUnionDetails(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
||||||
|
: QObject(), QUndoCommand(parent), xml(xml), doc(doc), redoFlag(false)
|
||||||
|
{
|
||||||
|
setText(tr("Add union details"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
AddUnionDetails::~AddUnionDetails()
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void AddUnionDetails::undo()
|
||||||
|
{
|
||||||
|
QDomElement modelingElement;
|
||||||
|
if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement))
|
||||||
|
{
|
||||||
|
modelingElement.removeChild(xml);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't find tag"<<VPattern::TagModeling<< Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emit NeedFullParsing();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void AddUnionDetails::redo()
|
||||||
|
{
|
||||||
|
QDomElement modelingElement;
|
||||||
|
if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement))
|
||||||
|
{
|
||||||
|
modelingElement.appendChild(xml);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't find tag"<<VPattern::TagModeling<< Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (redoFlag)
|
||||||
|
{
|
||||||
|
emit NeedFullParsing();
|
||||||
|
}
|
||||||
|
redoFlag = true;
|
||||||
|
}
|
54
src/app/undocommands/adduniondetails.h
Normal file
54
src/app/undocommands/adduniondetails.h
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file adduniondetails.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 15 6, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2014 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef ADDUNIONDETAILS_H
|
||||||
|
#define ADDUNIONDETAILS_H
|
||||||
|
|
||||||
|
#include <QDomElement>
|
||||||
|
#include <QUndoCommand>
|
||||||
|
|
||||||
|
class VPattern;
|
||||||
|
|
||||||
|
class AddUnionDetails : public QObject, public QUndoCommand
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
AddUnionDetails(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0);
|
||||||
|
virtual ~AddUnionDetails();
|
||||||
|
virtual void undo();
|
||||||
|
virtual void redo();
|
||||||
|
signals:
|
||||||
|
void NeedFullParsing();
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(AddUnionDetails)
|
||||||
|
const QDomElement xml;
|
||||||
|
VPattern *doc;
|
||||||
|
bool redoFlag;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ADDUNIONDETAILS_H
|
|
@ -45,6 +45,7 @@ DelTool::DelTool(VPattern *doc, quint32 id, QUndoCommand *parent)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't get tool by id = "<<toolId<<Q_FUNC_INFO;
|
qDebug()<<"Can't get tool by id = "<<toolId<<Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,5 +72,6 @@ void DelTool::redo()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't get tool by id = "<<toolId<<Q_FUNC_INFO;
|
qDebug()<<"Can't get tool by id = "<<toolId<<Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ MoveDetail::MoveDetail(VPattern *doc, const double &x, const double &y, const qu
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO;
|
qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +76,7 @@ void MoveDetail::undo()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO;
|
qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +97,7 @@ void MoveDetail::redo()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO;
|
qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ void MoveSpline::undo()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find spline with id ="<< splineId << Q_FUNC_INFO;
|
qDebug()<<"Can't find spline with id ="<< splineId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +91,7 @@ void MoveSpline::redo()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find spline with id ="<< splineId << Q_FUNC_INFO;
|
qDebug()<<"Can't find spline with id ="<< splineId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ void MoveSplinePath::undo()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find spline path with id ="<< splinePathId << Q_FUNC_INFO;
|
qDebug()<<"Can't find spline path with id ="<< splinePathId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +84,7 @@ void MoveSplinePath::redo()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find spline path with id ="<< splinePathId << Q_FUNC_INFO;
|
qDebug()<<"Can't find spline path with id ="<< splinePathId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ MoveSPoint::MoveSPoint(VPattern *doc, const double &x, const double &y, const qu
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find spoint with id ="<< sPointId << Q_FUNC_INFO;
|
qDebug()<<"Can't find spoint with id ="<< sPointId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +76,7 @@ void MoveSPoint::undo()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find spoint with id ="<< sPointId << Q_FUNC_INFO;
|
qDebug()<<"Can't find spoint with id ="<< sPointId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +97,7 @@ void MoveSPoint::redo()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find spoint with id ="<< sPointId << Q_FUNC_INFO;
|
qDebug()<<"Can't find spoint with id ="<< sPointId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,7 @@ void SaveDetailOptions::undo()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO;
|
qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +112,7 @@ void SaveDetailOptions::redo()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO;
|
qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ void SaveToolOptions::undo()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find tool with id ="<< toolId << Q_FUNC_INFO;
|
qDebug()<<"Can't find tool with id ="<< toolId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +73,7 @@ void SaveToolOptions::redo()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find tool with id ="<< toolId << Q_FUNC_INFO;
|
qDebug()<<"Can't find tool with id ="<< toolId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,10 @@ HEADERS += \
|
||||||
undocommands/savedetailoptions.h \
|
undocommands/savedetailoptions.h \
|
||||||
undocommands/movedetail.h \
|
undocommands/movedetail.h \
|
||||||
undocommands/deltool.h \
|
undocommands/deltool.h \
|
||||||
undocommands/deletepatternpiece.h
|
undocommands/deletepatternpiece.h \
|
||||||
|
undocommands/adddetnode.h \
|
||||||
|
undocommands/adddet.h \
|
||||||
|
undocommands/adduniondetails.h
|
||||||
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
@ -22,5 +25,8 @@ SOURCES += \
|
||||||
undocommands/savedetailoptions.cpp \
|
undocommands/savedetailoptions.cpp \
|
||||||
undocommands/movedetail.cpp \
|
undocommands/movedetail.cpp \
|
||||||
undocommands/deltool.cpp \
|
undocommands/deltool.cpp \
|
||||||
undocommands/deletepatternpiece.cpp
|
undocommands/deletepatternpiece.cpp \
|
||||||
|
undocommands/adddetnode.cpp \
|
||||||
|
undocommands/adddet.cpp \
|
||||||
|
undocommands/adduniondetails.cpp
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user