parent
814e414b4b
commit
2b000cd59f
|
@ -137,7 +137,7 @@ protected:
|
|||
}
|
||||
if (selectedAction == actionRemove)
|
||||
{
|
||||
DeleteTool(tool);
|
||||
DeleteTool();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,9 +184,8 @@ void VToolSinglePoint::decrementReferens()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSinglePoint::DeleteTool(QGraphicsItem *tool, bool ask)
|
||||
void VToolSinglePoint::DeleteTool(bool ask)
|
||||
{
|
||||
Q_UNUSED(tool)
|
||||
if (ask)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
|
|
|
@ -59,7 +59,7 @@ protected:
|
|||
virtual void RefreshDataInFile();
|
||||
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
|
||||
virtual void decrementReferens();
|
||||
virtual void DeleteTool(QGraphicsItem *tool, bool ask = true);
|
||||
virtual void DeleteTool(bool ask = true);
|
||||
virtual void SaveDialog(QDomElement &domElement);
|
||||
private:
|
||||
QString namePP;
|
||||
|
|
|
@ -242,9 +242,8 @@ QPointF VAbstractTool::addVector(const QPointF &p, const QPointF &p1, const QPoi
|
|||
* @brief DeleteTool full delete object form scene and file.
|
||||
* @param tool tool
|
||||
*/
|
||||
void VAbstractTool::DeleteTool(QGraphicsItem *tool, bool ask)
|
||||
void VAbstractTool::DeleteTool(bool ask)
|
||||
{
|
||||
DelTool *delTool = new DelTool(doc, id, tool);
|
||||
if (ask)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
|
@ -257,9 +256,9 @@ void VAbstractTool::DeleteTool(QGraphicsItem *tool, bool ask)
|
|||
{
|
||||
return;
|
||||
}
|
||||
/*Ugly hack. If UnionDetails delete detail no need emit FullParsing */
|
||||
connect(delTool, &DelTool::NeedFullParsing, doc, &VPattern::NeedFullParsing);
|
||||
}
|
||||
DelTool *delTool = new DelTool(doc, id);
|
||||
connect(delTool, &DelTool::NeedFullParsing, doc, &VPattern::NeedFullParsing);
|
||||
qApp->getUndoStack()->push(delTool);
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ protected:
|
|||
* @brief RemoveReferens decrement value of reference.
|
||||
*/
|
||||
virtual void RemoveReferens(){}
|
||||
virtual void DeleteTool(QGraphicsItem *tool, bool ask = true);
|
||||
virtual void DeleteTool(bool ask = true);
|
||||
Qt::PenStyle LineStyle();
|
||||
private:
|
||||
Q_DISABLE_COPY(VAbstractTool)
|
||||
|
|
|
@ -38,9 +38,11 @@
|
|||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QMenu>
|
||||
#include <QGraphicsView>
|
||||
#include <QMessageBox>
|
||||
#include "../undocommands/savedetailoptions.h"
|
||||
#include "../undocommands/movedetail.h"
|
||||
#include "../undocommands/adddet.h"
|
||||
#include "../undocommands/deletedetail.h"
|
||||
|
||||
const QString VToolDetail::TagName = QStringLiteral("detail");
|
||||
const QString VToolDetail::TagNode = QStringLiteral("node");
|
||||
|
@ -273,7 +275,7 @@ void VToolDetail::Create(const quint32 &_id, const VDetail &newDetail, VMainGrap
|
|||
*/
|
||||
void VToolDetail::Remove(bool ask)
|
||||
{
|
||||
DeleteTool(this, ask);
|
||||
DeleteTool(ask);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -552,6 +554,27 @@ void VToolDetail::RefreshGeometry()
|
|||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
}
|
||||
|
||||
void VToolDetail::DeleteTool(bool ask)
|
||||
{
|
||||
DeleteDetail *delDet = new DeleteDetail(doc, id);
|
||||
if (ask)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("Confirm the deletion."));
|
||||
msgBox.setInformativeText(tr("Do you really want delete?"));
|
||||
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.setIcon(QMessageBox::Question);
|
||||
if (msgBox.exec() == QMessageBox::Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/*Ugly hack. If UnionDetails delete detail no need emit FullParsing */
|
||||
connect(delDet, &DeleteDetail::NeedFullParsing, doc, &VPattern::NeedFullParsing);
|
||||
}
|
||||
qApp->getUndoStack()->push(delDet);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename Tool>
|
||||
//cppcheck-suppress unusedFunction
|
||||
|
|
|
@ -109,6 +109,7 @@ private:
|
|||
* @param node node of detail.
|
||||
*/
|
||||
void InitTool(VMainGraphicsScene *scene, const VNodeDetail &node);
|
||||
virtual void DeleteTool(bool ask = true);
|
||||
};
|
||||
|
||||
#endif // VTOOLDETAIL_H
|
||||
|
|
|
@ -467,7 +467,7 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data,
|
|||
* @param angle angle rotation.
|
||||
*/
|
||||
void VToolUnionDetails::BiasRotatePoint(VPointF *point, const qreal &dx, const qreal &dy, const QPointF &pRotate,
|
||||
const qreal angle)
|
||||
const qreal &angle)
|
||||
{
|
||||
point->setX(point->x()+dx);
|
||||
point->setY(point->y()+dy);
|
||||
|
@ -496,6 +496,7 @@ void VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VP
|
|||
qApp->getUndoStack()->beginMacro("union details");
|
||||
Create(0, d1, d2, dialogTool->getD1(), dialogTool->getD2(), indexD1, indexD2, scene, doc, data, Document::FullParse,
|
||||
Source::FromGui);
|
||||
qApp->getUndoStack()->endMacro();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -650,11 +651,6 @@ void VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDeta
|
|||
}
|
||||
} while (i<d1.RemoveEdge(indexD1).CountNode());
|
||||
}
|
||||
|
||||
if (typeCreation == Source::FromGui)
|
||||
{
|
||||
qApp->getUndoStack()->endMacro();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
quint32 &idCount, const qreal &dx = 0, const qreal &dy = 0, const quint32 &pRotate = 0,
|
||||
const qreal &angle = 0);
|
||||
static void BiasRotatePoint(VPointF *point, const qreal &dx, const qreal &dy, const QPointF &pRotate,
|
||||
const qreal angle);
|
||||
const qreal &angle);
|
||||
public slots:
|
||||
/**
|
||||
* @brief FullUpdateFromFile update tool data form file.
|
||||
|
|
83
src/app/undocommands/deletedetail.cpp
Normal file
83
src/app/undocommands/deletedetail.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file deletedetail.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 16 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 "deletedetail.h"
|
||||
#include "../xml/vpattern.h"
|
||||
#include "../tools/vtooldetail.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DeleteDetail::DeleteDetail(VPattern *doc, quint32 id, QUndoCommand *parent)
|
||||
: QObject(), QUndoCommand(parent), xml(QDomElement()), doc(doc), detId(id), parentNode(QDomNode())
|
||||
{
|
||||
setText(tr("Delete tool"));
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
xml = domElement.cloneNode().toElement();
|
||||
parentNode = domElement.parentNode();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"Can't get detail by id = "<<detId<<Q_FUNC_INFO;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DeleteDetail::~DeleteDetail()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DeleteDetail::undo()
|
||||
{
|
||||
parentNode.appendChild(xml);
|
||||
emit NeedFullParsing();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DeleteDetail::redo()
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(detId));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
parentNode.removeChild(domElement);
|
||||
|
||||
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
||||
SCASSERT(tools != nullptr);
|
||||
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(detId));
|
||||
SCASSERT(toolDet != nullptr);
|
||||
toolDet->hide();
|
||||
|
||||
emit NeedFullParsing();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"Can't get detail by id = "<<detId<<Q_FUNC_INFO;
|
||||
return;
|
||||
}
|
||||
}
|
56
src/app/undocommands/deletedetail.h
Normal file
56
src/app/undocommands/deletedetail.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file deletedetail.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 16 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 DELETEDETAIL_H
|
||||
#define DELETEDETAIL_H
|
||||
|
||||
#include <QDomElement>
|
||||
#include <QUndoCommand>
|
||||
|
||||
class VPattern;
|
||||
class QGraphicsItem;
|
||||
|
||||
class DeleteDetail : public QObject, public QUndoCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DeleteDetail(VPattern *doc, quint32 id, QUndoCommand *parent = 0);
|
||||
virtual ~DeleteDetail();
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
signals:
|
||||
void NeedFullParsing();
|
||||
private:
|
||||
Q_DISABLE_COPY(DeleteDetail)
|
||||
QDomElement xml;
|
||||
VPattern *doc;
|
||||
quint32 detId;
|
||||
QDomNode parentNode;
|
||||
};
|
||||
|
||||
#endif // DELETEDETAIL_H
|
|
@ -29,11 +29,12 @@
|
|||
#include "deltool.h"
|
||||
#include "../xml/vpattern.h"
|
||||
#include <QGraphicsItem>
|
||||
#include "../tools/vtooldetail.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DelTool::DelTool(VPattern *doc, quint32 id, QGraphicsItem *tool, QUndoCommand *parent)
|
||||
: QObject(), QUndoCommand(parent), xml(QDomElement()), parentNode(QDomNode()), previousNode(QDomNode()),
|
||||
doc(doc), toolId(id), tool(tool)
|
||||
DelTool::DelTool(VPattern *doc, quint32 id, QUndoCommand *parent)
|
||||
: QObject(), QUndoCommand(parent), xml(QDomElement()), parentNode(QDomNode()), doc(doc), toolId(id),
|
||||
cursor(doc->getCursor())
|
||||
{
|
||||
setText(tr("Delete tool"));
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
|
@ -41,7 +42,6 @@ DelTool::DelTool(VPattern *doc, quint32 id, QGraphicsItem *tool, QUndoCommand *p
|
|||
{
|
||||
xml = domElement.cloneNode().toElement();
|
||||
parentNode = domElement.parentNode();
|
||||
previousNode = domElement.previousSibling();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -57,7 +57,18 @@ DelTool::~DelTool()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DelTool::undo()
|
||||
{
|
||||
parentNode.insertAfter(xml, previousNode);
|
||||
if (cursor <= 0)
|
||||
{
|
||||
parentNode.appendChild(xml);
|
||||
}
|
||||
else
|
||||
{
|
||||
QDomElement refElement = doc->elementById(QString().setNum(cursor));
|
||||
if (refElement.isElement())
|
||||
{
|
||||
parentNode.insertAfter(xml, refElement);
|
||||
}
|
||||
}
|
||||
emit NeedFullParsing();
|
||||
}
|
||||
|
||||
|
@ -68,7 +79,6 @@ void DelTool::redo()
|
|||
if (domElement.isElement())
|
||||
{
|
||||
parentNode.removeChild(domElement);
|
||||
tool->hide();
|
||||
emit NeedFullParsing();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -39,7 +39,7 @@ class DelTool : public QObject, public QUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DelTool(VPattern *doc, quint32 id, QGraphicsItem *tool, QUndoCommand *parent = 0);
|
||||
DelTool(VPattern *doc, quint32 id, QUndoCommand *parent = 0);
|
||||
virtual ~DelTool();
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
|
@ -49,10 +49,9 @@ private:
|
|||
Q_DISABLE_COPY(DelTool)
|
||||
QDomElement xml;
|
||||
QDomNode parentNode;
|
||||
QDomNode previousNode;
|
||||
VPattern *doc;
|
||||
quint32 toolId;
|
||||
QGraphicsItem *tool;
|
||||
quint32 cursor;
|
||||
};
|
||||
|
||||
#endif // DELTOOL_H
|
||||
|
|
|
@ -68,7 +68,6 @@ void MoveDetail::undo()
|
|||
{
|
||||
doc->SetAttribute(domElement, VAbstractTool::AttrMx, QString().setNum(qApp->fromPixel(oldX)));
|
||||
doc->SetAttribute(domElement, VAbstractTool::AttrMy, QString().setNum(qApp->fromPixel(oldY)));
|
||||
qDebug()<<"undo move detail"<<oldX<<oldY;
|
||||
|
||||
emit NeedLiteParsing();
|
||||
|
||||
|
@ -90,7 +89,6 @@ void MoveDetail::redo()
|
|||
{
|
||||
doc->SetAttribute(domElement, VAbstractTool::AttrMx, QString().setNum(qApp->fromPixel(newX)));
|
||||
doc->SetAttribute(domElement, VAbstractTool::AttrMy, QString().setNum(qApp->fromPixel(newY)));
|
||||
qDebug()<<"redo move detail"<<newX<<newY;
|
||||
|
||||
if (redoFlag)
|
||||
{
|
||||
|
|
|
@ -12,7 +12,8 @@ HEADERS += \
|
|||
undocommands/deletepatternpiece.h \
|
||||
undocommands/adddetnode.h \
|
||||
undocommands/adddet.h \
|
||||
undocommands/adduniondetails.h
|
||||
undocommands/adduniondetails.h \
|
||||
undocommands/deletedetail.h
|
||||
|
||||
|
||||
SOURCES += \
|
||||
|
@ -28,5 +29,6 @@ SOURCES += \
|
|||
undocommands/deletepatternpiece.cpp \
|
||||
undocommands/adddetnode.cpp \
|
||||
undocommands/adddet.cpp \
|
||||
undocommands/adduniondetails.cpp
|
||||
undocommands/adduniondetails.cpp \
|
||||
undocommands/deletedetail.cpp
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user