Refactoring. Move all related to the visibility group undo command classes in one file.
This commit is contained in:
parent
4fa2b76f01
commit
9869ae249f
|
@ -29,9 +29,7 @@
|
|||
#include "vwidgetgroups.h"
|
||||
#include "ui_vwidgetgroups.h"
|
||||
#include "../vtools/dialogs/tools/dialoggroup.h"
|
||||
#include "../vtools/undocommands/delgroup.h"
|
||||
#include "../vtools/undocommands/changegroupvisibility.h"
|
||||
#include "../vtools/undocommands/changemultiplegroupsvisibility.h"
|
||||
#include "../vtools/undocommands/undogroup.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
|
||||
#include <QMenu>
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
#include "tools/vtooluniondetails.h"
|
||||
#include "dialogs/dialogs.h"
|
||||
#include "dialogs/vwidgetgroups.h"
|
||||
#include "../vtools/undocommands/addgroup.h"
|
||||
#include "../vtools/undocommands/undogroup.h"
|
||||
#include "dialogs/vwidgetdetails.h"
|
||||
#include "../vpatterndb/vpiecepath.h"
|
||||
#include "../qmuparser/qmuparsererror.h"
|
||||
|
|
|
@ -51,9 +51,7 @@
|
|||
#include "../vwidgets/vabstractmainwindow.h"
|
||||
#include "../vdatatool.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vtools/undocommands/addgroup.h"
|
||||
#include "../vtools/undocommands/additemtogroup.h"
|
||||
#include "../vtools/undocommands/removeitemfromgroup.h"
|
||||
#include "../vtools/undocommands/undogroup.h"
|
||||
|
||||
/**
|
||||
* @brief The VDrawTool abstract class for all draw tool.
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file addgroup.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 6 4, 2016
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 "addgroup.h"
|
||||
|
||||
#include <QDomNode>
|
||||
#include <QDomNodeList>
|
||||
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "../vwidgets/vmaingraphicsview.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "vundocommand.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
AddGroup::AddGroup(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent)
|
||||
: VUndoCommand(xml, doc, parent), nameActivDraw(doc->GetNameActivPP())
|
||||
{
|
||||
setText(tr("add group"));
|
||||
nodeId = doc->GetParametrId(xml);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
AddGroup::~AddGroup()
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void AddGroup::undo()
|
||||
{
|
||||
qCDebug(vUndo, "Undo.");
|
||||
|
||||
doc->ChangeActivPP(nameActivDraw);//Without this user will not see this change
|
||||
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
QDomElement group = doc->elementById(nodeId, VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
group.setAttribute(VAbstractPattern::AttrVisible, trueStr);
|
||||
doc->ParseGroups(groups);
|
||||
if (groups.removeChild(group).isNull())
|
||||
{
|
||||
qCDebug(vUndo, "Can't delete group.");
|
||||
return;
|
||||
}
|
||||
emit UpdateGroups();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (groups.childNodes().isEmpty())
|
||||
{
|
||||
QDomNode parent = groups.parentNode();
|
||||
parent.removeChild(groups);
|
||||
}
|
||||
|
||||
qCDebug(vUndo, "Can't get group by id = %u.", nodeId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get tag Groups.");
|
||||
return;
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void AddGroup::redo()
|
||||
{
|
||||
qCDebug(vUndo, "Redo.");
|
||||
|
||||
doc->ChangeActivPP(nameActivDraw);//Without this user will not see this change
|
||||
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
groups.appendChild(xml);
|
||||
doc->ParseGroups(groups);
|
||||
emit UpdateGroups();
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get tag Groups.");
|
||||
return;
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file addgroup.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 6 4, 2016
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 ADDGROUP_H
|
||||
#define ADDGROUP_H
|
||||
|
||||
#include <qcompilerdetection.h>
|
||||
#include <QDomElement>
|
||||
#include <QMetaObject>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "vundocommand.h"
|
||||
|
||||
class AddGroup : public VUndoCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AddGroup(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = nullptr);
|
||||
virtual ~AddGroup();
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
signals:
|
||||
void UpdateGroups();
|
||||
private:
|
||||
Q_DISABLE_COPY(AddGroup)
|
||||
const QString nameActivDraw;
|
||||
};
|
||||
|
||||
#endif // ADDGROUP_H
|
|
@ -1,122 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file addgroup.h
|
||||
** @author Ronan Le Tiec
|
||||
** @date 31 3, 2018
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 "additemtogroup.h"
|
||||
|
||||
#include <QDomNode>
|
||||
#include <QDomNodeList>
|
||||
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "../vwidgets/vmaingraphicsview.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "../vtools/tools/vdatatool.h"
|
||||
#include "vundocommand.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
AddItemToGroup::AddItemToGroup(const QDomElement &xml, VAbstractPattern *doc, quint32 groupId, QUndoCommand *parent)
|
||||
: VUndoCommand(xml, doc, parent), nameActivDraw(doc->GetNameActivPP())
|
||||
{
|
||||
setText(tr("Add item to group"));
|
||||
nodeId = groupId;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void AddItemToGroup::undo()
|
||||
{
|
||||
qCDebug(vUndo, "Undo the add item to group");
|
||||
performUndoRedo(true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void AddItemToGroup::redo()
|
||||
{
|
||||
qCDebug(vUndo, "Redo the add item to group");
|
||||
performUndoRedo(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void AddItemToGroup::performUndoRedo(bool isUndo)
|
||||
{
|
||||
doc->ChangeActivPP(nameActivDraw);//Without this user will not see this change
|
||||
|
||||
QDomElement group = doc->elementById(nodeId, VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
if(isUndo)
|
||||
{
|
||||
if (group.removeChild(xml).isNull())
|
||||
{
|
||||
qCDebug(vUndo, "Can't delete item.");
|
||||
return;
|
||||
}
|
||||
|
||||
// set the item visible. Because if the undo is done when unvisible and it's not in any group after the
|
||||
// undo, it stays unvisible until the entire drawing is completly rerendered.
|
||||
quint32 objectId = doc->GetParametrUInt(xml, QStringLiteral("object"), NULL_ID_STR);
|
||||
quint32 toolId = doc->GetParametrUInt(xml, QStringLiteral("tool"), NULL_ID_STR);
|
||||
VDataTool* tool = VAbstractPattern::getTool(toolId);
|
||||
tool->GroupVisibility(objectId,true);
|
||||
}
|
||||
else // is redo
|
||||
{
|
||||
|
||||
if (group.appendChild(xml).isNull())
|
||||
{
|
||||
qCDebug(vUndo, "Can't add item.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
doc->SetModified(true);
|
||||
emit qApp->getCurrentDocument()->patternChanged(false);
|
||||
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
doc->ParseGroups(groups);
|
||||
} else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get tag Groups.");
|
||||
return;
|
||||
}
|
||||
|
||||
emit UpdateGroups();
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get group by id = %u.", nodeId);
|
||||
return;
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file addgroup.h
|
||||
** @author Ronan Le Tiec
|
||||
** @date 31 3, 2018
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 ADDITEMTOGROUP_H
|
||||
#define ADDITEMTOGROUP_H
|
||||
|
||||
#include <qcompilerdetection.h>
|
||||
#include <QDomElement>
|
||||
#include <QMetaObject>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "vundocommand.h"
|
||||
|
||||
class AddItemToGroup : public VUndoCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AddItemToGroup(const QDomElement &xml, VAbstractPattern *doc, quint32 groupId, QUndoCommand *parent = nullptr);
|
||||
virtual ~AddItemToGroup()=default;
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
signals:
|
||||
void UpdateGroups();
|
||||
protected:
|
||||
void performUndoRedo(bool isUndo);
|
||||
private:
|
||||
Q_DISABLE_COPY(AddItemToGroup)
|
||||
const QString nameActivDraw;
|
||||
};
|
||||
|
||||
#endif // ADDITEMTOGROUP_H
|
|
@ -1,95 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file changegroupVisibility.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 14 7, 2019
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2019 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 "changegroupvisibility.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vwidgets/vmaingraphicsview.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
ChangeGroupVisibility::ChangeGroupVisibility(VAbstractPattern *doc, vidtype id, bool visible, QUndoCommand *parent)
|
||||
: VUndoCommand(QDomElement(), doc, parent),
|
||||
m_newVisibility(visible),
|
||||
m_nameActivDraw(doc->GetNameActivPP())
|
||||
{
|
||||
setText(tr("change group visibility"));
|
||||
nodeId = id;
|
||||
QDomElement group = doc->elementById(nodeId, VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
m_oldVisibility = doc->GetParametrBool(group, VAbstractPattern::AttrVisible, trueStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("Can't get group by id = %u.", id);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
ChangeGroupVisibility::~ChangeGroupVisibility()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void ChangeGroupVisibility::undo()
|
||||
{
|
||||
qCDebug(vUndo, "Undo.");
|
||||
|
||||
Do(m_oldVisibility);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void ChangeGroupVisibility::redo()
|
||||
{
|
||||
qCDebug(vUndo, "Redo.");
|
||||
|
||||
Do(m_newVisibility);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void ChangeGroupVisibility::Do(bool visible)
|
||||
{
|
||||
doc->ChangeActivPP(m_nameActivDraw);//Without this user will not see this change
|
||||
|
||||
QDomElement group = doc->elementById(nodeId, VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
doc->SetAttribute(group, VAbstractPattern::AttrVisible, visible);
|
||||
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
doc->ParseGroups(groups);
|
||||
}
|
||||
|
||||
emit UpdateGroup(nodeId, visible);
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("Can't get group by id = %u.", nodeId);
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file changegroupVisibility.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 14 7, 2019
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2019 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 CHANGEGROUPVISIBILITY_H
|
||||
#define CHANGEGROUPVISIBILITY_H
|
||||
|
||||
#include "vundocommand.h"
|
||||
|
||||
class ChangeGroupVisibility : public VUndoCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ChangeGroupVisibility(VAbstractPattern *doc, vidtype id, bool visible, QUndoCommand *parent = nullptr);
|
||||
virtual ~ChangeGroupVisibility();
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
|
||||
signals:
|
||||
void UpdateGroup(vidtype id, bool visible);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(ChangeGroupVisibility)
|
||||
|
||||
bool m_oldVisibility{true};
|
||||
bool m_newVisibility{true};
|
||||
const QString m_nameActivDraw{};
|
||||
|
||||
void Do(bool visible);
|
||||
};
|
||||
|
||||
#endif // CHANGEGROUPVISIBILITY_H
|
|
@ -1,131 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file changemultiplegroupsVisibility.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 15 7, 2019
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2019 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 "changemultiplegroupsvisibility.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vwidgets/vmaingraphicsview.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
ChangeMultipleGroupsVisibility::ChangeMultipleGroupsVisibility(VAbstractPattern *doc, const QVector<vidtype> &groups,
|
||||
bool visible, QUndoCommand *parent)
|
||||
: VUndoCommand(QDomElement(), doc, parent),
|
||||
m_groups(groups),
|
||||
m_newVisibility(visible),
|
||||
m_nameActivDraw(doc->GetNameActivPP())
|
||||
{
|
||||
setText(tr("change multiple groups visibility"));
|
||||
|
||||
for(auto & groupId : m_groups)
|
||||
{
|
||||
QDomElement group = doc->elementById(groupId, VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
m_oldVisibility.insert(groupId, doc->GetParametrBool(group, VAbstractPattern::AttrVisible, trueStr));
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("Can't get group by id = %u.", groupId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void ChangeMultipleGroupsVisibility::undo()
|
||||
{
|
||||
qCDebug(vUndo, "Undo.");
|
||||
|
||||
doc->ChangeActivPP(m_nameActivDraw);//Without this user will not see this change
|
||||
|
||||
QMap<vidtype, bool> groupsState;
|
||||
|
||||
QMap<vidtype, bool>::const_iterator i = m_oldVisibility.constBegin();
|
||||
while (i != m_oldVisibility.constEnd())
|
||||
{
|
||||
QDomElement group = doc->elementById(i.key(), VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
doc->SetAttribute(group, VAbstractPattern::AttrVisible, i.value());
|
||||
groupsState.insert(i.key(), i.value());
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("Can't get group by id = %u.", i.key());
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
if (not groupsState.isEmpty())
|
||||
{
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
doc->ParseGroups(groups);
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
|
||||
emit UpdateMultipleGroups(groupsState);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void ChangeMultipleGroupsVisibility::redo()
|
||||
{
|
||||
qCDebug(vUndo, "ChangeMultipleGroupsVisibility::redo");
|
||||
|
||||
doc->ChangeActivPP(m_nameActivDraw);//Without this user will not see this change
|
||||
|
||||
QMap<vidtype, bool> groupsState;
|
||||
|
||||
for (auto& groupId : m_groups)
|
||||
{
|
||||
QDomElement group = doc->elementById(groupId, VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
doc->SetAttribute(group, VAbstractPattern::AttrVisible, m_newVisibility);
|
||||
groupsState.insert(groupId, m_newVisibility);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("Can't get group by id = %u.", groupId);
|
||||
}
|
||||
}
|
||||
|
||||
if (not groupsState.isEmpty())
|
||||
{
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
doc->ParseGroups(groups);
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
|
||||
emit UpdateMultipleGroups(groupsState);
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file changemultiplegroupsVisibility.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 15 7, 2019
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2019 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 CHANGEMULTIPLEGROUPSVISIBILITY_H
|
||||
#define CHANGEMULTIPLEGROUPSVISIBILITY_H
|
||||
|
||||
#include "vundocommand.h"
|
||||
|
||||
class ChangeMultipleGroupsVisibility : public VUndoCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ChangeMultipleGroupsVisibility(VAbstractPattern *doc, const QVector<vidtype> &groups, bool visible,
|
||||
QUndoCommand *parent = nullptr);
|
||||
virtual ~ChangeMultipleGroupsVisibility() =default;
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
|
||||
signals:
|
||||
void UpdateMultipleGroups(const QMap<vidtype, bool> &groups);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(ChangeMultipleGroupsVisibility)
|
||||
|
||||
QVector<vidtype> m_groups;
|
||||
bool m_newVisibility{true};
|
||||
QMap<vidtype, bool> m_oldVisibility{};
|
||||
const QString m_nameActivDraw{};
|
||||
};
|
||||
|
||||
#endif // CHANGEMULTIPLEGROUPSVISIBILITY_H
|
|
@ -1,124 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file delgroup.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 6 4, 2016
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 "delgroup.h"
|
||||
|
||||
#include <QDomElement>
|
||||
#include <QDomNode>
|
||||
#include <QDomNodeList>
|
||||
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "../vwidgets/vmaingraphicsview.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "vundocommand.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DelGroup::DelGroup(VAbstractPattern *doc, quint32 id, QUndoCommand *parent)
|
||||
: VUndoCommand(QDomElement(), doc, parent), nameActivDraw(doc->GetNameActivPP())
|
||||
{
|
||||
setText(tr("delete group"));
|
||||
nodeId = id;
|
||||
xml = doc->CloneNodeById(nodeId);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DelGroup::~DelGroup()
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DelGroup::undo()
|
||||
{
|
||||
qCDebug(vUndo, "Undo.");
|
||||
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change
|
||||
}
|
||||
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
groups.appendChild(xml);
|
||||
doc->ParseGroups(groups);
|
||||
emit UpdateGroups();
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get tag Groups.");
|
||||
return;
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DelGroup::redo()
|
||||
{
|
||||
qCDebug(vUndo, "Redo.");
|
||||
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{//Keep first!
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change
|
||||
}
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
QDomElement group = doc->elementById(nodeId, VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
group.setAttribute(VAbstractPattern::AttrVisible, trueStr);
|
||||
doc->ParseGroups(groups);
|
||||
if (groups.removeChild(group).isNull())
|
||||
{
|
||||
qCDebug(vUndo, "Can't delete group.");
|
||||
return;
|
||||
}
|
||||
emit UpdateGroups();
|
||||
|
||||
if (groups.childNodes().isEmpty())
|
||||
{
|
||||
QDomNode parent = groups.parentNode();
|
||||
parent.removeChild(groups);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get group by id = %u.", nodeId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get tag Groups.");
|
||||
return;
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file delgroup.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 6 4, 2016
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 DELGROUP_H
|
||||
#define DELGROUP_H
|
||||
|
||||
#include <qcompilerdetection.h>
|
||||
#include <QMetaObject>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "vundocommand.h"
|
||||
|
||||
class DelGroup : public VUndoCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DelGroup(VAbstractPattern *doc, quint32 id, QUndoCommand *parent = nullptr);
|
||||
virtual ~DelGroup();
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
signals:
|
||||
void UpdateGroups();
|
||||
private:
|
||||
Q_DISABLE_COPY(DelGroup)
|
||||
const QString nameActivDraw;
|
||||
};
|
||||
|
||||
#endif // DELGROUP_H
|
|
@ -1,123 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file removeitemfromgroup.cpp
|
||||
** @author Ronan Le Tiec
|
||||
** @date 1 4, 2018
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 "removeitemfromgroup.h"
|
||||
|
||||
#include <QDomNode>
|
||||
#include <QDomNodeList>
|
||||
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "../vwidgets/vmaingraphicsview.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "../vtools/tools/vdatatool.h"
|
||||
#include "vundocommand.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
RemoveItemFromGroup::RemoveItemFromGroup(const QDomElement &xml, VAbstractPattern *doc, quint32 groupId, QUndoCommand *parent)
|
||||
: VUndoCommand(xml, doc, parent), nameActivDraw(doc->GetNameActivPP())
|
||||
{
|
||||
setText(tr("Remove item from group"));
|
||||
nodeId = groupId;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void RemoveItemFromGroup::undo()
|
||||
{
|
||||
qCDebug(vUndo, "Undo the remove item from group");
|
||||
performUndoRedo(true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void RemoveItemFromGroup::redo()
|
||||
{
|
||||
qCDebug(vUndo, "Redo the add item to group");
|
||||
performUndoRedo(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void RemoveItemFromGroup::performUndoRedo(bool isUndo)
|
||||
{
|
||||
doc->ChangeActivPP(nameActivDraw);//Without this user will not see this change
|
||||
|
||||
QDomElement group = doc->elementById(nodeId, VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
if(isUndo)
|
||||
{
|
||||
if (group.appendChild(xml).isNull())
|
||||
{
|
||||
qCDebug(vUndo, "Can't add the item.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else // is redo
|
||||
{
|
||||
if (group.removeChild(xml).isNull())
|
||||
{
|
||||
qCDebug(vUndo, "Can't delete item.");
|
||||
return;
|
||||
}
|
||||
|
||||
// set the item visible. Because if the undo is done when unvisibile and it's not in any group after the
|
||||
// undo, it stays unvisible until the entire drawing is completly rerendered.
|
||||
quint32 objectId = doc->GetParametrUInt(xml, QStringLiteral("object"), NULL_ID_STR);
|
||||
quint32 toolId = doc->GetParametrUInt(xml, QStringLiteral("tool"), NULL_ID_STR);
|
||||
VDataTool* tool = VAbstractPattern::getTool(toolId);
|
||||
tool->GroupVisibility(objectId,true);
|
||||
}
|
||||
|
||||
doc->SetModified(true);
|
||||
emit qApp->getCurrentDocument()->patternChanged(false);
|
||||
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
doc->ParseGroups(groups);
|
||||
} else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get tag Groups.");
|
||||
return;
|
||||
}
|
||||
|
||||
emit UpdateGroups();
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get group by id = %u.", nodeId);
|
||||
return;
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file removeitemfromgroup.h
|
||||
** @author Ronan Le Tiec
|
||||
** @date 31 3, 2018
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 REMOVEITEMFROMGROUP_H
|
||||
#define REMOVEITEMFROMGROUP_H
|
||||
|
||||
#include <qcompilerdetection.h>
|
||||
#include <QDomElement>
|
||||
#include <QMetaObject>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "vundocommand.h"
|
||||
|
||||
class RemoveItemFromGroup : public VUndoCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RemoveItemFromGroup(const QDomElement &xml, VAbstractPattern *doc, quint32 groupId, QUndoCommand *parent = nullptr);
|
||||
virtual ~RemoveItemFromGroup()=default;
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
signals:
|
||||
void UpdateGroups();
|
||||
protected:
|
||||
void performUndoRedo(bool isUndo);
|
||||
private:
|
||||
Q_DISABLE_COPY(RemoveItemFromGroup)
|
||||
const QString nameActivDraw;
|
||||
};
|
||||
|
||||
#endif // REMOVEITEMFROMGROUP_H
|
|
@ -4,20 +4,17 @@
|
|||
HEADERS += \
|
||||
$$PWD/addtocalc.h \
|
||||
$$PWD/addpatternpiece.h \
|
||||
$$PWD/changegroupvisibility.h \
|
||||
$$PWD/changemultiplegroupsvisibility.h \
|
||||
$$PWD/movespoint.h \
|
||||
$$PWD/movespline.h \
|
||||
$$PWD/movesplinepath.h \
|
||||
$$PWD/savetooloptions.h \
|
||||
$$PWD/deltool.h \
|
||||
$$PWD/deletepatternpiece.h \
|
||||
$$PWD/undogroup.h \
|
||||
$$PWD/vundocommand.h \
|
||||
$$PWD/renamepp.h \
|
||||
$$PWD/label/movelabel.h \
|
||||
$$PWD/label/movedoublelabel.h \
|
||||
$$PWD/addgroup.h \
|
||||
$$PWD/delgroup.h \
|
||||
$$PWD/label/moveabstractlabel.h \
|
||||
$$PWD/label/operationmovelabel.h \
|
||||
$$PWD/addpiece.h \
|
||||
|
@ -29,27 +26,22 @@ HEADERS += \
|
|||
$$PWD/label/showdoublelabel.h \
|
||||
$$PWD/label/operationshowlabel.h \
|
||||
$$PWD/saveplacelabeloptions.h \
|
||||
$$PWD/togglepiecestate.h \
|
||||
$$PWD/additemtogroup.h \
|
||||
$$PWD/removeitemfromgroup.h
|
||||
$$PWD/togglepiecestate.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/addtocalc.cpp \
|
||||
$$PWD/addpatternpiece.cpp \
|
||||
$$PWD/changegroupvisibility.cpp \
|
||||
$$PWD/changemultiplegroupsvisibility.cpp \
|
||||
$$PWD/movespoint.cpp \
|
||||
$$PWD/movespline.cpp \
|
||||
$$PWD/movesplinepath.cpp \
|
||||
$$PWD/savetooloptions.cpp \
|
||||
$$PWD/deltool.cpp \
|
||||
$$PWD/deletepatternpiece.cpp \
|
||||
$$PWD/undogroup.cpp \
|
||||
$$PWD/vundocommand.cpp \
|
||||
$$PWD/renamepp.cpp \
|
||||
$$PWD/label/movelabel.cpp \
|
||||
$$PWD/label/movedoublelabel.cpp \
|
||||
$$PWD/addgroup.cpp \
|
||||
$$PWD/delgroup.cpp \
|
||||
$$PWD/label/moveabstractlabel.cpp \
|
||||
$$PWD/label/operationmovelabel.cpp \
|
||||
$$PWD/addpiece.cpp \
|
||||
|
@ -61,6 +53,4 @@ SOURCES += \
|
|||
$$PWD/label/showdoublelabel.cpp \
|
||||
$$PWD/label/operationshowlabel.cpp \
|
||||
$$PWD/saveplacelabeloptions.cpp \
|
||||
$$PWD/togglepiecestate.cpp \
|
||||
$$PWD/additemtogroup.cpp \
|
||||
$$PWD/removeitemfromgroup.cpp
|
||||
$$PWD/togglepiecestate.cpp
|
||||
|
|
532
src/libs/vtools/undocommands/undogroup.cpp
Normal file
532
src/libs/vtools/undocommands/undogroup.cpp
Normal file
|
@ -0,0 +1,532 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file undogroup.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 18 3, 2020
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2020 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 "undogroup.h"
|
||||
|
||||
#include <QDomNode>
|
||||
#include <QDomNodeList>
|
||||
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "../vwidgets/vmaingraphicsview.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "vundocommand.h"
|
||||
#include "../vtools/tools/vdatatool.h"
|
||||
|
||||
//AddGroup
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
AddGroup::AddGroup(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent)
|
||||
: VUndoCommand(xml, doc, parent), nameActivDraw(doc->GetNameActivPP())
|
||||
{
|
||||
setText(tr("add group"));
|
||||
nodeId = doc->GetParametrId(xml);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void AddGroup::undo()
|
||||
{
|
||||
qCDebug(vUndo, "Undo.");
|
||||
|
||||
doc->ChangeActivPP(nameActivDraw);//Without this user will not see this change
|
||||
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
QDomElement group = doc->elementById(nodeId, VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
group.setAttribute(VAbstractPattern::AttrVisible, trueStr);
|
||||
doc->ParseGroups(groups);
|
||||
if (groups.removeChild(group).isNull())
|
||||
{
|
||||
qCDebug(vUndo, "Can't delete group.");
|
||||
return;
|
||||
}
|
||||
emit UpdateGroups();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (groups.childNodes().isEmpty())
|
||||
{
|
||||
QDomNode parent = groups.parentNode();
|
||||
parent.removeChild(groups);
|
||||
}
|
||||
|
||||
qCDebug(vUndo, "Can't get group by id = %u.", nodeId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get tag Groups.");
|
||||
return;
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void AddGroup::redo()
|
||||
{
|
||||
qCDebug(vUndo, "Redo.");
|
||||
|
||||
doc->ChangeActivPP(nameActivDraw);//Without this user will not see this change
|
||||
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
groups.appendChild(xml);
|
||||
doc->ParseGroups(groups);
|
||||
emit UpdateGroups();
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get tag Groups.");
|
||||
return;
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
}
|
||||
|
||||
//AddItemToGroup
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
AddItemToGroup::AddItemToGroup(const QDomElement &xml, VAbstractPattern *doc, quint32 groupId, QUndoCommand *parent)
|
||||
: VUndoCommand(xml, doc, parent), nameActivDraw(doc->GetNameActivPP())
|
||||
{
|
||||
setText(tr("Add item to group"));
|
||||
nodeId = groupId;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void AddItemToGroup::undo()
|
||||
{
|
||||
qCDebug(vUndo, "Undo the add item to group");
|
||||
performUndoRedo(true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void AddItemToGroup::redo()
|
||||
{
|
||||
qCDebug(vUndo, "Redo the add item to group");
|
||||
performUndoRedo(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void AddItemToGroup::performUndoRedo(bool isUndo)
|
||||
{
|
||||
doc->ChangeActivPP(nameActivDraw);//Without this user will not see this change
|
||||
|
||||
QDomElement group = doc->elementById(nodeId, VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
if(isUndo)
|
||||
{
|
||||
if (group.removeChild(xml).isNull())
|
||||
{
|
||||
qCDebug(vUndo, "Can't delete item.");
|
||||
return;
|
||||
}
|
||||
|
||||
// set the item visible. Because if the undo is done when unvisible and it's not in any group after the
|
||||
// undo, it stays unvisible until the entire drawing is completly rerendered.
|
||||
quint32 objectId = doc->GetParametrUInt(xml, QStringLiteral("object"), NULL_ID_STR);
|
||||
quint32 toolId = doc->GetParametrUInt(xml, QStringLiteral("tool"), NULL_ID_STR);
|
||||
VDataTool* tool = VAbstractPattern::getTool(toolId);
|
||||
tool->GroupVisibility(objectId,true);
|
||||
}
|
||||
else // is redo
|
||||
{
|
||||
|
||||
if (group.appendChild(xml).isNull())
|
||||
{
|
||||
qCDebug(vUndo, "Can't add item.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
doc->SetModified(true);
|
||||
emit qApp->getCurrentDocument()->patternChanged(false);
|
||||
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
doc->ParseGroups(groups);
|
||||
} else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get tag Groups.");
|
||||
return;
|
||||
}
|
||||
|
||||
emit UpdateGroups();
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get group by id = %u.", nodeId);
|
||||
return;
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo
|
||||
}
|
||||
}
|
||||
|
||||
//RemoveItemFromGroup
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
RemoveItemFromGroup::RemoveItemFromGroup(const QDomElement &xml, VAbstractPattern *doc, quint32 groupId,
|
||||
QUndoCommand *parent)
|
||||
: VUndoCommand(xml, doc, parent), nameActivDraw(doc->GetNameActivPP())
|
||||
{
|
||||
setText(tr("Remove item from group"));
|
||||
nodeId = groupId;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void RemoveItemFromGroup::undo()
|
||||
{
|
||||
qCDebug(vUndo, "Undo the remove item from group");
|
||||
performUndoRedo(true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void RemoveItemFromGroup::redo()
|
||||
{
|
||||
qCDebug(vUndo, "Redo the add item to group");
|
||||
performUndoRedo(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void RemoveItemFromGroup::performUndoRedo(bool isUndo)
|
||||
{
|
||||
doc->ChangeActivPP(nameActivDraw);//Without this user will not see this change
|
||||
|
||||
QDomElement group = doc->elementById(nodeId, VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
if(isUndo)
|
||||
{
|
||||
if (group.appendChild(xml).isNull())
|
||||
{
|
||||
qCDebug(vUndo, "Can't add the item.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else // is redo
|
||||
{
|
||||
if (group.removeChild(xml).isNull())
|
||||
{
|
||||
qCDebug(vUndo, "Can't delete item.");
|
||||
return;
|
||||
}
|
||||
|
||||
// set the item visible. Because if the undo is done when unvisibile and it's not in any group after the
|
||||
// undo, it stays unvisible until the entire drawing is completly rerendered.
|
||||
quint32 objectId = doc->GetParametrUInt(xml, QStringLiteral("object"), NULL_ID_STR);
|
||||
quint32 toolId = doc->GetParametrUInt(xml, QStringLiteral("tool"), NULL_ID_STR);
|
||||
VDataTool* tool = VAbstractPattern::getTool(toolId);
|
||||
tool->GroupVisibility(objectId,true);
|
||||
}
|
||||
|
||||
doc->SetModified(true);
|
||||
emit qApp->getCurrentDocument()->patternChanged(false);
|
||||
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
doc->ParseGroups(groups);
|
||||
} else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get tag Groups.");
|
||||
return;
|
||||
}
|
||||
|
||||
emit UpdateGroups();
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get group by id = %u.", nodeId);
|
||||
return;
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo
|
||||
}
|
||||
}
|
||||
|
||||
//ChangeGroupVisibility
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
ChangeGroupVisibility::ChangeGroupVisibility(VAbstractPattern *doc, vidtype id, bool visible, QUndoCommand *parent)
|
||||
: VUndoCommand(QDomElement(), doc, parent),
|
||||
m_newVisibility(visible),
|
||||
m_nameActivDraw(doc->GetNameActivPP())
|
||||
{
|
||||
setText(tr("change group visibility"));
|
||||
nodeId = id;
|
||||
QDomElement group = doc->elementById(nodeId, VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
m_oldVisibility = doc->GetParametrBool(group, VAbstractPattern::AttrVisible, trueStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("Can't get group by id = %u.", id);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void ChangeGroupVisibility::undo()
|
||||
{
|
||||
qCDebug(vUndo, "Undo.");
|
||||
|
||||
Do(m_oldVisibility);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void ChangeGroupVisibility::redo()
|
||||
{
|
||||
qCDebug(vUndo, "Redo.");
|
||||
|
||||
Do(m_newVisibility);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void ChangeGroupVisibility::Do(bool visible)
|
||||
{
|
||||
doc->ChangeActivPP(m_nameActivDraw);//Without this user will not see this change
|
||||
|
||||
QDomElement group = doc->elementById(nodeId, VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
doc->SetAttribute(group, VAbstractPattern::AttrVisible, visible);
|
||||
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
doc->ParseGroups(groups);
|
||||
}
|
||||
|
||||
emit UpdateGroup(nodeId, visible);
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("Can't get group by id = %u.", nodeId);
|
||||
}
|
||||
}
|
||||
|
||||
//ChangeMultipleGroupsVisibility
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
ChangeMultipleGroupsVisibility::ChangeMultipleGroupsVisibility(VAbstractPattern *doc, const QVector<vidtype> &groups,
|
||||
bool visible, QUndoCommand *parent)
|
||||
: VUndoCommand(QDomElement(), doc, parent),
|
||||
m_groups(groups),
|
||||
m_newVisibility(visible),
|
||||
m_nameActivDraw(doc->GetNameActivPP())
|
||||
{
|
||||
setText(tr("change multiple groups visibility"));
|
||||
|
||||
for(auto & groupId : m_groups)
|
||||
{
|
||||
QDomElement group = doc->elementById(groupId, VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
m_oldVisibility.insert(groupId, doc->GetParametrBool(group, VAbstractPattern::AttrVisible, trueStr));
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("Can't get group by id = %u.", groupId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void ChangeMultipleGroupsVisibility::undo()
|
||||
{
|
||||
qCDebug(vUndo, "Undo.");
|
||||
|
||||
doc->ChangeActivPP(m_nameActivDraw);//Without this user will not see this change
|
||||
|
||||
QMap<vidtype, bool> groupsState;
|
||||
|
||||
QMap<vidtype, bool>::const_iterator i = m_oldVisibility.constBegin();
|
||||
while (i != m_oldVisibility.constEnd())
|
||||
{
|
||||
QDomElement group = doc->elementById(i.key(), VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
doc->SetAttribute(group, VAbstractPattern::AttrVisible, i.value());
|
||||
groupsState.insert(i.key(), i.value());
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("Can't get group by id = %u.", i.key());
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
if (not groupsState.isEmpty())
|
||||
{
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
doc->ParseGroups(groups);
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
|
||||
emit UpdateMultipleGroups(groupsState);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void ChangeMultipleGroupsVisibility::redo()
|
||||
{
|
||||
qCDebug(vUndo, "ChangeMultipleGroupsVisibility::redo");
|
||||
|
||||
doc->ChangeActivPP(m_nameActivDraw);//Without this user will not see this change
|
||||
|
||||
QMap<vidtype, bool> groupsState;
|
||||
|
||||
for (auto& groupId : m_groups)
|
||||
{
|
||||
QDomElement group = doc->elementById(groupId, VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
doc->SetAttribute(group, VAbstractPattern::AttrVisible, m_newVisibility);
|
||||
groupsState.insert(groupId, m_newVisibility);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("Can't get group by id = %u.", groupId);
|
||||
}
|
||||
}
|
||||
|
||||
if (not groupsState.isEmpty())
|
||||
{
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
doc->ParseGroups(groups);
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
|
||||
emit UpdateMultipleGroups(groupsState);
|
||||
}
|
||||
}
|
||||
|
||||
//DelGroup
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DelGroup::DelGroup(VAbstractPattern *doc, quint32 id, QUndoCommand *parent)
|
||||
: VUndoCommand(QDomElement(), doc, parent), nameActivDraw(doc->GetNameActivPP())
|
||||
{
|
||||
setText(tr("delete group"));
|
||||
nodeId = id;
|
||||
xml = doc->CloneNodeById(nodeId);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DelGroup::undo()
|
||||
{
|
||||
qCDebug(vUndo, "Undo.");
|
||||
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change
|
||||
}
|
||||
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
groups.appendChild(xml);
|
||||
doc->ParseGroups(groups);
|
||||
emit UpdateGroups();
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get tag Groups.");
|
||||
return;
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DelGroup::redo()
|
||||
{
|
||||
qCDebug(vUndo, "Redo.");
|
||||
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{//Keep first!
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change
|
||||
}
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
QDomElement group = doc->elementById(nodeId, VAbstractPattern::TagGroup);
|
||||
if (group.isElement())
|
||||
{
|
||||
group.setAttribute(VAbstractPattern::AttrVisible, trueStr);
|
||||
doc->ParseGroups(groups);
|
||||
if (groups.removeChild(group).isNull())
|
||||
{
|
||||
qCDebug(vUndo, "Can't delete group.");
|
||||
return;
|
||||
}
|
||||
emit UpdateGroups();
|
||||
|
||||
if (groups.childNodes().isEmpty())
|
||||
{
|
||||
QDomNode parent = groups.parentNode();
|
||||
parent.removeChild(groups);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get group by id = %u.", nodeId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't get tag Groups.");
|
||||
return;
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
}
|
149
src/libs/vtools/undocommands/undogroup.h
Normal file
149
src/libs/vtools/undocommands/undogroup.h
Normal file
|
@ -0,0 +1,149 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file undogroup.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 18 3, 2020
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2020 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 UNDOGROUP_H
|
||||
#define UNDOGROUP_H
|
||||
|
||||
|
||||
#include <qcompilerdetection.h>
|
||||
#include <QDomElement>
|
||||
#include <QMetaObject>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "vundocommand.h"
|
||||
|
||||
class AddGroup : public VUndoCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AddGroup(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = nullptr);
|
||||
virtual ~AddGroup()=default;
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
signals:
|
||||
void UpdateGroups();
|
||||
private:
|
||||
Q_DISABLE_COPY(AddGroup)
|
||||
const QString nameActivDraw;
|
||||
};
|
||||
|
||||
class AddItemToGroup : public VUndoCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AddItemToGroup(const QDomElement &xml, VAbstractPattern *doc, quint32 groupId, QUndoCommand *parent = nullptr);
|
||||
virtual ~AddItemToGroup()=default;
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
signals:
|
||||
void UpdateGroups();
|
||||
protected:
|
||||
void performUndoRedo(bool isUndo);
|
||||
private:
|
||||
Q_DISABLE_COPY(AddItemToGroup)
|
||||
const QString nameActivDraw;
|
||||
};
|
||||
|
||||
class RemoveItemFromGroup : public VUndoCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RemoveItemFromGroup(const QDomElement &xml, VAbstractPattern *doc, quint32 groupId, QUndoCommand *parent = nullptr);
|
||||
virtual ~RemoveItemFromGroup()=default;
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
signals:
|
||||
void UpdateGroups();
|
||||
protected:
|
||||
void performUndoRedo(bool isUndo);
|
||||
private:
|
||||
Q_DISABLE_COPY(RemoveItemFromGroup)
|
||||
const QString nameActivDraw;
|
||||
};
|
||||
|
||||
class ChangeGroupVisibility : public VUndoCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ChangeGroupVisibility(VAbstractPattern *doc, vidtype id, bool visible, QUndoCommand *parent = nullptr);
|
||||
virtual ~ChangeGroupVisibility()=default;
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
|
||||
signals:
|
||||
void UpdateGroup(vidtype id, bool visible);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(ChangeGroupVisibility)
|
||||
|
||||
bool m_oldVisibility{true};
|
||||
bool m_newVisibility{true};
|
||||
const QString m_nameActivDraw{};
|
||||
|
||||
void Do(bool visible);
|
||||
};
|
||||
|
||||
class ChangeMultipleGroupsVisibility : public VUndoCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ChangeMultipleGroupsVisibility(VAbstractPattern *doc, const QVector<vidtype> &groups, bool visible,
|
||||
QUndoCommand *parent = nullptr);
|
||||
virtual ~ChangeMultipleGroupsVisibility() =default;
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
|
||||
signals:
|
||||
void UpdateMultipleGroups(const QMap<vidtype, bool> &groups);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(ChangeMultipleGroupsVisibility)
|
||||
|
||||
QVector<vidtype> m_groups;
|
||||
bool m_newVisibility{true};
|
||||
QMap<vidtype, bool> m_oldVisibility{};
|
||||
const QString m_nameActivDraw{};
|
||||
};
|
||||
|
||||
class DelGroup : public VUndoCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DelGroup(VAbstractPattern *doc, quint32 id, QUndoCommand *parent = nullptr);
|
||||
virtual ~DelGroup()=default;
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
signals:
|
||||
void UpdateGroups();
|
||||
private:
|
||||
Q_DISABLE_COPY(DelGroup)
|
||||
const QString nameActivDraw;
|
||||
};
|
||||
|
||||
#endif // UNDOGROUP_H
|
Loading…
Reference in New Issue
Block a user