2014-06-14 08:37:25 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file deltool.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 13 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.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2014-06-14 08:37:25 +02:00
|
|
|
** <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 "deltool.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
|
|
|
|
#include <QDomElement>
|
|
|
|
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../ifc/ifcdef.h"
|
|
|
|
#include "../ifc/xml/vabstractpattern.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../vmisc/logging.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "vundocommand.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
|
|
|
|
class QUndoCommand;
|
2014-06-14 08:37:25 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-06-16 10:30:25 +02:00
|
|
|
DelTool::DelTool(VAbstractPattern *doc, quint32 id, QUndoCommand *parent)
|
2014-11-10 15:49:39 +01:00
|
|
|
: VUndoCommand(QDomElement(), doc, parent), parentNode(QDomNode()), siblingId(NULL_ID),
|
|
|
|
nameActivDraw(doc->GetNameActivPP())
|
2014-06-14 08:37:25 +02:00
|
|
|
{
|
2015-06-24 16:48:57 +02:00
|
|
|
setText(tr("delete tool"));
|
2014-07-16 14:37:38 +02:00
|
|
|
nodeId = id;
|
2014-11-10 15:49:39 +01:00
|
|
|
siblingId = doc->SiblingNodeId(nodeId);
|
|
|
|
parentNode = doc->ParentNodeById(nodeId);
|
|
|
|
xml = doc->CloneNodeById(nodeId);
|
2014-06-14 08:37:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DelTool::~DelTool()
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DelTool::undo()
|
|
|
|
{
|
2015-04-01 19:08:35 +02:00
|
|
|
qCDebug(vUndo, "Undo.");
|
2014-11-20 18:52:51 +01:00
|
|
|
|
2014-10-29 11:57:58 +01:00
|
|
|
UndoDeleteAfterSibling(parentNode, siblingId);
|
2014-06-14 08:37:25 +02:00
|
|
|
emit NeedFullParsing();
|
2015-03-03 16:31:18 +01:00
|
|
|
//Keep last!
|
|
|
|
doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change
|
2014-06-14 08:37:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DelTool::redo()
|
|
|
|
{
|
2015-04-01 19:08:35 +02:00
|
|
|
qCDebug(vUndo, "Redo.");
|
2014-11-20 18:52:51 +01:00
|
|
|
|
2015-03-03 16:31:18 +01:00
|
|
|
//Keep first!
|
|
|
|
doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change
|
2014-11-10 15:49:39 +01:00
|
|
|
QDomElement domElement = doc->NodeById(nodeId);
|
|
|
|
parentNode.removeChild(domElement);
|
|
|
|
emit NeedFullParsing();
|
2014-06-14 08:37:25 +02:00
|
|
|
}
|