New undo command Add Group.
--HG-- branch : feature
This commit is contained in:
parent
d73256f119
commit
cb67249b54
|
@ -54,6 +54,7 @@
|
||||||
#include "tools/vtooldetail.h"
|
#include "tools/vtooldetail.h"
|
||||||
#include "tools/vtooluniondetails.h"
|
#include "tools/vtooluniondetails.h"
|
||||||
#include "dialogs/dialogs.h"
|
#include "dialogs/dialogs.h"
|
||||||
|
#include "../vtools/undocommands/addgroup.h"
|
||||||
|
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -1012,7 +1013,12 @@ void MainWindow::ClosedDialogGroup(int result)
|
||||||
|
|
||||||
DialogGroup *dialog = qobject_cast<DialogGroup*>(dialogTool);
|
DialogGroup *dialog = qobject_cast<DialogGroup*>(dialogTool);
|
||||||
SCASSERT(dialog != nullptr);
|
SCASSERT(dialog != nullptr);
|
||||||
doc->AddGroup(pattern->getNextId(), dialog->GetName(), dialog->GetGroup());
|
const QDomElement group = doc->CreateGroup(pattern->getNextId(), dialog->GetName(), dialog->GetGroup());
|
||||||
|
if (not group.isNull())
|
||||||
|
{
|
||||||
|
AddGroup *addGroup = new AddGroup(group, doc);
|
||||||
|
qApp->getUndoStack()->push(addGroup);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ArrowTool();
|
ArrowTool();
|
||||||
}
|
}
|
||||||
|
|
|
@ -466,7 +466,7 @@ void VPattern::customEvent(QEvent *event)
|
||||||
*/
|
*/
|
||||||
void VPattern::ParseDrawElement(const QDomNode &node, const Document &parse)
|
void VPattern::ParseDrawElement(const QDomNode &node, const Document &parse)
|
||||||
{
|
{
|
||||||
QStringList tags = QStringList() << TagCalculation << TagModeling << TagDetails;
|
QStringList tags = QStringList() << TagCalculation << TagModeling << TagDetails << TagGroups;
|
||||||
QDomNode domNode = node.firstChild();
|
QDomNode domNode = node.firstChild();
|
||||||
while (domNode.isNull() == false)
|
while (domNode.isNull() == false)
|
||||||
{
|
{
|
||||||
|
@ -490,6 +490,10 @@ void VPattern::ParseDrawElement(const QDomNode &node, const Document &parse)
|
||||||
qCDebug(vXML, "Tag details.");
|
qCDebug(vXML, "Tag details.");
|
||||||
ParseDetails(domElement, parse);
|
ParseDetails(domElement, parse);
|
||||||
break;
|
break;
|
||||||
|
case 3: // TagGroups
|
||||||
|
qCDebug(vXML, "Tag groups.");
|
||||||
|
ParseGroups(domElement);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
VException e(tr("Wrong tag name '%1'.").arg(domElement.tagName()));
|
VException e(tr("Wrong tag name '%1'.").arg(domElement.tagName()));
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -112,9 +112,9 @@ private:
|
||||||
|
|
||||||
void ParseDrawElement(const QDomNode& node, const Document &parse);
|
void ParseDrawElement(const QDomNode& node, const Document &parse);
|
||||||
void ParseDrawMode(const QDomNode& node, const Document &parse, const Draw &mode);
|
void ParseDrawMode(const QDomNode& node, const Document &parse, const Draw &mode);
|
||||||
void ParseDetailElement(const QDomElement &domElement,
|
void ParseDetailElement(const QDomElement &domElement, const Document &parse);
|
||||||
const Document &parse);
|
|
||||||
void ParseDetails(const QDomElement &domElement, const Document &parse);
|
void ParseDetails(const QDomElement &domElement, const Document &parse);
|
||||||
|
|
||||||
void ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement,
|
void ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement,
|
||||||
const Document &parse, const QString &type);
|
const Document &parse, const QString &type);
|
||||||
void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include "exception/vexceptionemptyparameter.h"
|
#include "exception/vexceptionemptyparameter.h"
|
||||||
#include "vpatternconverter.h"
|
#include "vpatternconverter.h"
|
||||||
#include "../qmuparser/qmutokenparser.h"
|
#include "../qmuparser/qmutokenparser.h"
|
||||||
|
#include "../exception/vexceptionobjecterror.h"
|
||||||
|
#include "../vtools/tools/vdatatool.h"
|
||||||
|
|
||||||
const QString VAbstractPattern::TagPattern = QStringLiteral("pattern");
|
const QString VAbstractPattern::TagPattern = QStringLiteral("pattern");
|
||||||
const QString VAbstractPattern::TagCalculation = QStringLiteral("calculation");
|
const QString VAbstractPattern::TagCalculation = QStringLiteral("calculation");
|
||||||
|
@ -44,7 +46,8 @@ const QString VAbstractPattern::TagIncrements = QStringLiteral("increments");
|
||||||
const QString VAbstractPattern::TagIncrement = QStringLiteral("increment");
|
const QString VAbstractPattern::TagIncrement = QStringLiteral("increment");
|
||||||
const QString VAbstractPattern::TagDraw = QStringLiteral("draw");
|
const QString VAbstractPattern::TagDraw = QStringLiteral("draw");
|
||||||
const QString VAbstractPattern::TagGroups = QStringLiteral("groups");
|
const QString VAbstractPattern::TagGroups = QStringLiteral("groups");
|
||||||
const QString VAbstractPattern::TagItem = QStringLiteral("item");
|
const QString VAbstractPattern::TagGroup = QStringLiteral("group");
|
||||||
|
const QString VAbstractPattern::TagGroupItem = QStringLiteral("item");
|
||||||
const QString VAbstractPattern::TagPoint = QStringLiteral("point");
|
const QString VAbstractPattern::TagPoint = QStringLiteral("point");
|
||||||
const QString VAbstractPattern::TagLine = QStringLiteral("line");
|
const QString VAbstractPattern::TagLine = QStringLiteral("line");
|
||||||
const QString VAbstractPattern::TagSpline = QStringLiteral("spline");
|
const QString VAbstractPattern::TagSpline = QStringLiteral("spline");
|
||||||
|
@ -292,6 +295,54 @@ bool VAbstractPattern::GetActivNodeElement(const QString &name, QDomElement &ele
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VAbstractPattern::ParseGroups(const QDomElement &domElement)
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
||||||
|
|
||||||
|
QMap<quint32, quint32> itemTool;
|
||||||
|
QMap<quint32, bool> itemVisibility;
|
||||||
|
|
||||||
|
QDomNode domNode = domElement.firstChild();
|
||||||
|
while (domNode.isNull() == false)
|
||||||
|
{
|
||||||
|
if (domNode.isElement())
|
||||||
|
{
|
||||||
|
const QDomElement domElement = domNode.toElement();
|
||||||
|
if (domElement.isNull() == false)
|
||||||
|
{
|
||||||
|
if (domElement.tagName() == TagGroup)
|
||||||
|
{
|
||||||
|
const QPair<bool, QMap<quint32, quint32> > groupData = ParseItemElement(domElement);
|
||||||
|
const QMap<quint32, quint32> group = groupData.second;
|
||||||
|
auto i = group.constBegin();
|
||||||
|
while (i != group.constEnd())
|
||||||
|
{
|
||||||
|
if (not itemTool.contains(i.key()))
|
||||||
|
{
|
||||||
|
itemTool.insert(i.key(), i.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool previous = itemVisibility.value(i.key(), true);
|
||||||
|
itemVisibility.insert(i.key(), previous || groupData.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
domNode = domNode.nextSibling();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto i = itemTool.constBegin();
|
||||||
|
while (i != itemTool.constEnd())
|
||||||
|
{
|
||||||
|
if (tools.contains(i.value()))
|
||||||
|
{
|
||||||
|
VDataTool* tool = tools.value(i.value());
|
||||||
|
tool->GroupVisibility(i.key(), itemVisibility.value(i.key(), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
int VAbstractPattern::CountPP() const
|
int VAbstractPattern::CountPP() const
|
||||||
{
|
{
|
||||||
|
@ -1325,6 +1376,44 @@ bool VAbstractPattern::IsFunction(const QString &token) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QPair<bool, QMap<quint32, quint32> > VAbstractPattern::ParseItemElement(const QDomElement &domElement)
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const bool visible = GetParametrBool(domElement, AttrVisible, trueStr);
|
||||||
|
|
||||||
|
QMap<quint32, quint32> items;
|
||||||
|
|
||||||
|
const QDomNodeList nodeList = domElement.childNodes();
|
||||||
|
const qint32 num = nodeList.size();
|
||||||
|
for (qint32 i = 0; i < num; ++i)
|
||||||
|
{
|
||||||
|
const QDomElement element = nodeList.at(i).toElement();
|
||||||
|
if (not element.isNull() && element.tagName() == TagGroupItem)
|
||||||
|
{
|
||||||
|
const quint32 object = GetParametrUInt(element, AttrObject, NULL_ID_STR);
|
||||||
|
const quint32 tool = GetParametrUInt(element, AttrTool, NULL_ID_STR);
|
||||||
|
items.insert(object, tool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair<bool, QMap<quint32, quint32> > group;
|
||||||
|
group.first = visible;
|
||||||
|
group.second = items;
|
||||||
|
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
catch (const VExceptionBadId &e)
|
||||||
|
{
|
||||||
|
VExceptionObjectError excep(tr("Error creating or updating group"), domElement);
|
||||||
|
excep.AddMoreInformation(e.ErrorMessage());
|
||||||
|
throw excep;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief IsModified state of the document for cases that do not cover QUndoStack.
|
* @brief IsModified state of the document for cases that do not cover QUndoStack.
|
||||||
|
@ -1381,31 +1470,27 @@ QDomElement VAbstractPattern::CreateGroups()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractPattern::AddGroup(quint32 id, const QString &name, const QMap<quint32, quint32> &group)
|
QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const QMap<quint32, quint32> &groupData)
|
||||||
{
|
{
|
||||||
if (id == NULL_ID || group.isEmpty())
|
if (id == NULL_ID || groupData.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return QDomElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement groups = CreateGroups();
|
QDomElement group = createElement(TagGroup);
|
||||||
|
group.setAttribute(AttrId, id);
|
||||||
|
group.setAttribute(AttrName, name);
|
||||||
|
group.setAttribute(AttrVisible, trueStr);
|
||||||
|
|
||||||
if (groups.isNull())
|
auto i = groupData.constBegin();
|
||||||
|
while (i != groupData.constEnd())
|
||||||
{
|
{
|
||||||
return;
|
QDomElement item = createElement(TagGroupItem);
|
||||||
}
|
|
||||||
|
|
||||||
groups.setAttribute(AttrId, id);
|
|
||||||
groups.setAttribute(AttrName, name);
|
|
||||||
groups.setAttribute(AttrVisible, trueStr);
|
|
||||||
|
|
||||||
auto i = group.constBegin();
|
|
||||||
while (i != group.constEnd())
|
|
||||||
{
|
|
||||||
QDomElement item = createElement(TagItem);
|
|
||||||
item.setAttribute(AttrObject, i.key());
|
item.setAttribute(AttrObject, i.key());
|
||||||
item.setAttribute(AttrTool, i.value());
|
item.setAttribute(AttrTool, i.value());
|
||||||
groups.appendChild(item);
|
group.appendChild(item);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return group;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,8 @@ public:
|
||||||
bool GetActivDrawElement(QDomElement &element) const;
|
bool GetActivDrawElement(QDomElement &element) const;
|
||||||
bool GetActivNodeElement(const QString& name, QDomElement& element) const;
|
bool GetActivNodeElement(const QString& name, QDomElement& element) const;
|
||||||
|
|
||||||
|
void ParseGroups(const QDomElement &domElement);
|
||||||
|
|
||||||
quint32 getCursor() const;
|
quint32 getCursor() const;
|
||||||
void setCursor(const quint32 &value);
|
void setCursor(const quint32 &value);
|
||||||
|
|
||||||
|
@ -115,7 +117,7 @@ public:
|
||||||
QDomElement GetDraw(const QString &name) const;
|
QDomElement GetDraw(const QString &name) const;
|
||||||
|
|
||||||
QDomElement CreateGroups();
|
QDomElement CreateGroups();
|
||||||
void AddGroup(quint32 id, const QString &name, const QMap<quint32, quint32> &group);
|
QDomElement CreateGroup(quint32 id, const QString &name, const QMap<quint32, quint32> &groupData);
|
||||||
|
|
||||||
static const QString TagPattern;
|
static const QString TagPattern;
|
||||||
static const QString TagCalculation;
|
static const QString TagCalculation;
|
||||||
|
@ -129,7 +131,8 @@ public:
|
||||||
static const QString TagIncrement;
|
static const QString TagIncrement;
|
||||||
static const QString TagDraw;
|
static const QString TagDraw;
|
||||||
static const QString TagGroups;
|
static const QString TagGroups;
|
||||||
static const QString TagItem;
|
static const QString TagGroup;
|
||||||
|
static const QString TagGroupItem;
|
||||||
static const QString TagPoint;
|
static const QString TagPoint;
|
||||||
static const QString TagLine;
|
static const QString TagLine;
|
||||||
static const QString TagSpline;
|
static const QString TagSpline;
|
||||||
|
@ -281,6 +284,8 @@ private:
|
||||||
bool IsVariable(const QString& token) const;
|
bool IsVariable(const QString& token) const;
|
||||||
bool IsPostfixOperator(const QString& token) const;
|
bool IsPostfixOperator(const QString& token) const;
|
||||||
bool IsFunction(const QString& token) const;
|
bool IsFunction(const QString& token) const;
|
||||||
|
|
||||||
|
QPair<bool, QMap<quint32, quint32> > ParseItemElement(const QDomElement &domElement);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -334,3 +334,10 @@ QString VAbstractSpline::name() const
|
||||||
{
|
{
|
||||||
return ObjectName<VAbstractCurve>(id);
|
return ObjectName<VAbstractCurve>(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VAbstractSpline::GroupVisibility(quint32 object, bool visible)
|
||||||
|
{
|
||||||
|
Q_UNUSED(object);
|
||||||
|
setVisible(visible);
|
||||||
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
|
||||||
|
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
|
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
|
||||||
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
|
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
|
||||||
|
|
|
@ -92,6 +92,19 @@ void VToolDoublePoint::SetEnabled(bool enabled)
|
||||||
SetToolEnabled(this, enabled);
|
SetToolEnabled(this, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolDoublePoint::GroupVisibility(quint32 object, bool visible)
|
||||||
|
{
|
||||||
|
if (object == p1id)
|
||||||
|
{
|
||||||
|
firstPoint->setVisible(visible);
|
||||||
|
}
|
||||||
|
else if (object == p2id)
|
||||||
|
{
|
||||||
|
secondPoint->setVisible(visible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolDoublePoint::Label1ChangePosition(const QPointF &pos)
|
void VToolDoublePoint::Label1ChangePosition(const QPointF &pos)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,6 +56,7 @@ public:
|
||||||
|
|
||||||
void SetEnabled(bool enabled);
|
void SetEnabled(bool enabled);
|
||||||
|
|
||||||
|
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||||
public slots:
|
public slots:
|
||||||
void Label1ChangePosition(const QPointF &pos);
|
void Label1ChangePosition(const QPointF &pos);
|
||||||
void Label2ChangePosition(const QPointF &pos);
|
void Label2ChangePosition(const QPointF &pos);
|
||||||
|
|
|
@ -96,6 +96,13 @@ void VToolSinglePoint::SetEnabled(bool enabled)
|
||||||
SetToolEnabled(lineName, enabled);
|
SetToolEnabled(lineName, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolSinglePoint::GroupVisibility(quint32 object, bool visible)
|
||||||
|
{
|
||||||
|
Q_UNUSED(object);
|
||||||
|
setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief NameChangePosition handle change posion point label.
|
* @brief NameChangePosition handle change posion point label.
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
|
|
||||||
void SetEnabled(bool enabled);
|
void SetEnabled(bool enabled);
|
||||||
|
|
||||||
|
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||||
public slots:
|
public slots:
|
||||||
void NameChangePosition(const QPointF &pos);
|
void NameChangePosition(const QPointF &pos);
|
||||||
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
|
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
|
||||||
|
|
|
@ -470,6 +470,13 @@ void VToolLine::SetLineColor(const QString &value)
|
||||||
SaveOption(obj);
|
SaveOption(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolLine::GroupVisibility(quint32 object, bool visible)
|
||||||
|
{
|
||||||
|
Q_UNUSED(object);
|
||||||
|
setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
quint32 VToolLine::GetFirstPoint() const
|
quint32 VToolLine::GetFirstPoint() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
|
|
||||||
virtual void SetTypeLine(const QString &value) Q_DECL_OVERRIDE;
|
virtual void SetTypeLine(const QString &value) Q_DECL_OVERRIDE;
|
||||||
virtual void SetLineColor(const QString &value) Q_DECL_OVERRIDE;
|
virtual void SetLineColor(const QString &value) Q_DECL_OVERRIDE;
|
||||||
|
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
|
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
|
||||||
virtual void ShowTool(quint32 id, bool enable) Q_DECL_OVERRIDE;
|
virtual void ShowTool(quint32 id, bool enable) Q_DECL_OVERRIDE;
|
||||||
|
|
|
@ -108,6 +108,13 @@ void VAbstractNode::SetParentType(const ParentType &value)
|
||||||
parentType = value;
|
parentType = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VAbstractNode::GroupVisibility(quint32 object, bool visible)
|
||||||
|
{
|
||||||
|
Q_UNUSED(object);
|
||||||
|
Q_UNUSED(visible);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief AddToModeling add tag to modeling tag current pattern peace.
|
* @brief AddToModeling add tag to modeling tag current pattern peace.
|
||||||
|
|
|
@ -54,6 +54,8 @@ public:
|
||||||
ParentType GetParentType() const;
|
ParentType GetParentType() const;
|
||||||
void SetParentType(const ParentType &value);
|
void SetParentType(const ParentType &value);
|
||||||
|
|
||||||
|
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ParentType parentType;
|
ParentType parentType;
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -46,11 +46,12 @@ class VDataTool : public QObject
|
||||||
public:
|
public:
|
||||||
explicit VDataTool(VContainer *data, QObject *parent = nullptr);
|
explicit VDataTool(VContainer *data, QObject *parent = nullptr);
|
||||||
virtual ~VDataTool() Q_DECL_OVERRIDE;
|
virtual ~VDataTool() Q_DECL_OVERRIDE;
|
||||||
VContainer getData() const;
|
VContainer getData() const;
|
||||||
void setData(const VContainer *value);
|
void setData(const VContainer *value);
|
||||||
virtual quint32 referens() const;
|
virtual quint32 referens() const;
|
||||||
virtual void incrementReferens();
|
virtual void incrementReferens();
|
||||||
virtual void decrementReferens();
|
virtual void decrementReferens();
|
||||||
|
virtual void GroupVisibility(quint32 object, bool visible)=0;
|
||||||
protected:
|
protected:
|
||||||
/** @brief data container with data */
|
/** @brief data container with data */
|
||||||
VContainer data;
|
VContainer data;
|
||||||
|
|
|
@ -628,6 +628,13 @@ void VToolDetail::ShowVisualization(bool show)
|
||||||
Q_UNUSED(show)
|
Q_UNUSED(show)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolDetail::GroupVisibility(quint32 object, bool visible)
|
||||||
|
{
|
||||||
|
Q_UNUSED(object);
|
||||||
|
Q_UNUSED(visible);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief RefreshGeometry refresh item on scene.
|
* @brief RefreshGeometry refresh item on scene.
|
||||||
|
|
|
@ -86,6 +86,7 @@ public:
|
||||||
enum { Type = UserType + static_cast<int>(Tool::Detail)};
|
enum { Type = UserType + static_cast<int>(Tool::Detail)};
|
||||||
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
||||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||||
|
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
|
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
|
||||||
virtual void FullUpdateFromGuiOk(int result);
|
virtual void FullUpdateFromGuiOk(int result);
|
||||||
|
|
|
@ -488,6 +488,13 @@ void VToolUnionDetails::decrementReferens()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolUnionDetails::GroupVisibility(quint32 object, bool visible)
|
||||||
|
{
|
||||||
|
Q_UNUSED(object);
|
||||||
|
Q_UNUSED(visible);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool from GUI.
|
* @brief Create help create tool from GUI.
|
||||||
|
|
|
@ -84,6 +84,7 @@ public:
|
||||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||||
virtual void incrementReferens() Q_DECL_OVERRIDE;
|
virtual void incrementReferens() Q_DECL_OVERRIDE;
|
||||||
virtual void decrementReferens() Q_DECL_OVERRIDE;
|
virtual void decrementReferens() Q_DECL_OVERRIDE;
|
||||||
|
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* @brief FullUpdateFromFile update tool data form file.
|
* @brief FullUpdateFromFile update tool data form file.
|
||||||
|
|
104
src/libs/vtools/undocommands/addgroup.cpp
Normal file
104
src/libs/vtools/undocommands/addgroup.cpp
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file addgroup.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 6 4, 2016
|
||||||
|
**
|
||||||
|
** @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) 2016 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 "addgroup.h"
|
||||||
|
#include "../vwidgets/vmaingraphicsscene.h"
|
||||||
|
#include "../vwidgets/vmaingraphicsview.h"
|
||||||
|
#include "../vmisc/vabstractapplication.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);
|
||||||
|
if (group.isElement())
|
||||||
|
{
|
||||||
|
group.setAttribute(VAbstractPattern::AttrVisible, trueStr);
|
||||||
|
doc->ParseGroups(groups);
|
||||||
|
if (groups.removeChild(group).isNull())
|
||||||
|
{
|
||||||
|
qCDebug(vUndo, "Can't delete group.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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());
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qCDebug(vUndo, "Can't get tag Groups.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||||
|
}
|
47
src/libs/vtools/undocommands/addgroup.h
Normal file
47
src/libs/vtools/undocommands/addgroup.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file addgroup.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 6 4, 2016
|
||||||
|
**
|
||||||
|
** @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) 2016 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 ADDGROUP_H
|
||||||
|
#define ADDGROUP_H
|
||||||
|
|
||||||
|
#include "vundocommand.h"
|
||||||
|
|
||||||
|
class AddGroup : public VUndoCommand
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
AddGroup(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = nullptr);
|
||||||
|
virtual ~AddGroup();
|
||||||
|
virtual void undo() Q_DECL_OVERRIDE;
|
||||||
|
virtual void redo() Q_DECL_OVERRIDE;
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(AddGroup)
|
||||||
|
const QString nameActivDraw;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ADDGROUP_H
|
|
@ -18,7 +18,8 @@ HEADERS += \
|
||||||
$$PWD/vundocommand.h \
|
$$PWD/vundocommand.h \
|
||||||
$$PWD/renamepp.h \
|
$$PWD/renamepp.h \
|
||||||
$$PWD/movelabel.h \
|
$$PWD/movelabel.h \
|
||||||
$$PWD/movedoublelabel.h
|
$$PWD/movedoublelabel.h \
|
||||||
|
$$PWD/addgroup.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/addtocalc.cpp \
|
$$PWD/addtocalc.cpp \
|
||||||
|
@ -37,4 +38,5 @@ SOURCES += \
|
||||||
$$PWD/vundocommand.cpp \
|
$$PWD/vundocommand.cpp \
|
||||||
$$PWD/renamepp.cpp \
|
$$PWD/renamepp.cpp \
|
||||||
$$PWD/movelabel.cpp \
|
$$PWD/movelabel.cpp \
|
||||||
$$PWD/movedoublelabel.cpp
|
$$PWD/movedoublelabel.cpp \
|
||||||
|
$$PWD/addgroup.cpp
|
||||||
|
|
Loading…
Reference in New Issue
Block a user