Auto-created Visibility Group for group operation. Closes smart-pattern/valentina#18.

This commit is contained in:
Roman Telezhynskyi 2020-03-18 14:45:47 +02:00
parent 9869ae249f
commit 526892ed5a
30 changed files with 2026 additions and 87 deletions

View File

@ -43,6 +43,7 @@
- Change default values for grainline length and pattern label size to 10 cm.
- Tool Point at distance and angle now allows negative length.
- Export pattern to DXF-ASTM.
- [smart-pattern/valentina#18] Auto-created Visibility Group for group operation.
# Version 0.6.2 (unreleased)
- [#903] Bug in tool Cut Spline path.

View File

@ -148,9 +148,9 @@ void VWidgetGroups::RenameGroup(int row, int column)
}
const quint32 id = ui->tableWidget->item(row, 0)->data(Qt::UserRole).toUInt();
doc->SetGroupName(id, ui->tableWidget->item(row, column)->text());
UpdateGroups();
::RenameGroup *renameGroup = new ::RenameGroup(doc, id, ui->tableWidget->item(row, column)->text());
connect(renameGroup, &RenameGroup::UpdateGroups, this, &VWidgetGroups::UpdateGroups);
qApp->getUndoStack()->push(renameGroup);
}
//---------------------------------------------------------------------------------------------------------------------
@ -209,9 +209,9 @@ void VWidgetGroups::CtxMenu(const QPoint &pos)
if (result == QDialog::Accepted)
{
doc->SetGroupName(id, dialog->GetName());
item = ui->tableWidget->item(row, 1);
item->setText(dialog->GetName());
::RenameGroup *renameGroup = new ::RenameGroup(doc, id, dialog->GetName());
connect(renameGroup, &RenameGroup::UpdateGroups, this, &VWidgetGroups::UpdateGroups);
qApp->getUndoStack()->push(renameGroup);
}
}
else if (selectedAction == actionDelete)

View File

@ -58,6 +58,7 @@
<file>schema/pattern/v0.8.4.xsd</file>
<file>schema/pattern/v0.8.5.xsd</file>
<file>schema/pattern/v0.8.6.xsd</file>
<file>schema/pattern/v0.8.7.xsd</file>
<file>schema/standard_measurements/v0.3.0.xsd</file>
<file>schema/standard_measurements/v0.4.0.xsd</file>
<file>schema/standard_measurements/v0.4.1.xsd</file>

File diff suppressed because it is too large Load Diff

View File

@ -1730,6 +1730,12 @@ void VAbstractPattern::SelectedDetail(quint32 id)
emit ShowDetail(id);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::UpdateVisiblityGroups()
{
emit UpdateGroups();
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::ToolExists(const quint32 &id)
{
@ -2422,7 +2428,8 @@ QDomElement VAbstractPattern::CreateGroups()
}
//---------------------------------------------------------------------------------------------------------------------
QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const QMap<quint32, quint32> &groupData)
QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const QMap<quint32, quint32> &groupData,
vidtype tool)
{
if (id == NULL_ID || groupData.isEmpty())
{
@ -2433,6 +2440,7 @@ QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const
SetAttribute(group, AttrId, id);
SetAttribute(group, AttrName, name);
SetAttribute(group, AttrVisible, true);
SetAttributeOrRemoveIf(group, AttrTool, tool, tool == null_id);
auto i = groupData.constBegin();
while (i != groupData.constEnd())
@ -2446,44 +2454,43 @@ QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const
return group;
}
//---------------------------------------------------------------------------------------------------------------------
vidtype VAbstractPattern::GroupLinkedToTool(vidtype toolId) const
{
const QDomNodeList groups = elementsByTagName(TagGroup);
for (int i=0; i < groups.size(); ++i)
{
const QDomElement group = groups.at(i).toElement();
if (not group.isNull() && group.hasAttribute(AttrTool))
{
const quint32 id = GetParametrUInt(group, AttrTool, NULL_ID_STR);
if (toolId == id)
{
return GetParametrUInt(group, AttrId, NULL_ID_STR);
}
}
}
return null_id;
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::GetGroupName(quint32 id)
{
QString name = tr("New group");
QDomElement groups = CreateGroups();
if (not groups.isNull())
{
QDomElement group = elementById(id, TagGroup);
if (group.isElement())
{
name = GetParametrString(group, AttrName, name);
return name;
}
else
{
if (groups.childNodes().isEmpty())
{
QDomNode parent = groups.parentNode();
parent.removeChild(groups);
}
qDebug("Can't get group by id = %u.", id);
return name;
}
}
else
{
qDebug("Can't get tag Groups.");
return name;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetGroupName(quint32 id, const QString &name)
{
QDomElement groups = CreateGroups();
if (not groups.isNull())
{
QDomElement group = elementById(id, TagGroup);
if (group.isElement())
@ -2492,21 +2499,6 @@ void VAbstractPattern::SetGroupName(quint32 id, const QString &name)
modified = true;
emit patternChanged(false);
}
else
{
if (groups.childNodes().isEmpty())
{
QDomNode parent = groups.parentNode();
parent.removeChild(groups);
}
qDebug("Can't get group by id = %u.", id);
}
}
else
{
qDebug("Can't get tag Groups.");
}
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -200,7 +200,9 @@ public:
void ParseGroups(const QDomElement &domElement);
QDomElement CreateGroups();
QDomElement CreateGroup(quint32 id, const QString &name, const QMap<quint32, quint32> &groupData);
QDomElement CreateGroup(quint32 id, const QString &name, const QMap<quint32, quint32> &groupData,
vidtype tool=null_id);
vidtype GroupLinkedToTool(vidtype toolId) const;
QString GetGroupName(quint32 id);
void SetGroupName(quint32 id, const QString &name);
QMap<quint32, QPair<QString, bool> > GetGroups();
@ -413,6 +415,7 @@ public slots:
void ClearScene();
void CheckInLayoutList();
void SelectedDetail(quint32 id);
void UpdateVisiblityGroups();
protected:
/** @brief nameActivDraw name current pattern peace. */

View File

@ -59,8 +59,8 @@ class QDomElement;
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.6");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.6.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.7");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.7.xsd");
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -236,7 +236,8 @@ QString VPatternConverter::XSDSchema(int ver) const
std::make_pair(FORMAT_VERSION(0, 8, 3), QStringLiteral("://schema/pattern/v0.8.3.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 4), QStringLiteral("://schema/pattern/v0.8.4.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 5), QStringLiteral("://schema/pattern/v0.8.5.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 6), CurrentSchema)
std::make_pair(FORMAT_VERSION(0, 8, 6), QStringLiteral("://schema/pattern/v0.8.6.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 7), CurrentSchema)
};
if (schemas.contains(ver))
@ -481,6 +482,10 @@ void VPatternConverter::ApplyPatches()
ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 6)));
Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 8, 6)):
ToV0_8_7();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 7)));
Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 8, 7)):
break;
default:
InvalidVersion(m_ver);
@ -498,7 +503,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
bool VPatternConverter::IsReadOnly() const
{
// Check if attribute readOnly was not changed in file format
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 6),
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 7),
"Check attribute readOnly.");
// Possibly in future attribute readOnly will change position etc.
@ -1128,6 +1133,16 @@ void VPatternConverter::ToV0_8_6()
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_8_7()
{
// TODO. Delete if minimal supported version is 0.8.7
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FORMAT_VERSION(0, 8, 7),
"Time to refactor the code.");
SetVersion(QStringLiteral("0.8.7"));
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{

View File

@ -53,7 +53,7 @@ public:
static const QString PatternMaxVerStr;
static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int PatternMinVer = FORMAT_VERSION(0, 1, 4);
static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 6);
static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 7);
protected:
virtual int MinVer() const override;
@ -129,6 +129,7 @@ private:
void ToV0_8_4();
void ToV0_8_5();
void ToV0_8_6();
void ToV0_8_7();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();

View File

@ -67,6 +67,7 @@ DialogFlippingByAxis::DialogFlippingByAxis(const VContainer *data, quint32 toolI
stage1(true),
m_suffix(),
flagName(true),
flagGroupName(true),
flagError(false)
{
ui->setupUi(this);
@ -81,6 +82,7 @@ DialogFlippingByAxis::DialogFlippingByAxis(const VContainer *data, quint32 toolI
ui->comboBoxOriginPoint->setCurrentIndex(-1);
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogFlippingByAxis::SuffixChanged);
connect(ui->lineEditVisibilityGroup, &QLineEdit::textChanged, this, &DialogFlippingByAxis::GroupNameChanged);
connect(ui->comboBoxOriginPoint, &QComboBox::currentTextChanged,
this, &DialogFlippingByAxis::PointChanged);
@ -147,6 +149,30 @@ QVector<quint32> DialogFlippingByAxis::GetObjects() const
return ConvertToVector(objects);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogFlippingByAxis::GetVisibilityGroupName() const
{
return ui->lineEditVisibilityGroup->text();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::SetVisibilityGroupName(const QString &name)
{
ui->lineEditVisibilityGroup->setText(name.isEmpty() ? tr("Rotation") : name);
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogFlippingByAxis::HasLinkedVisibilityGroup() const
{
return ui->groupBoxVisibilityGroup->isChecked();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::SetHasLinkedVisibilityGroup(bool linked)
{
ui->groupBoxVisibilityGroup->setChecked(linked);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::ShowDialog(bool click)
{
@ -277,6 +303,27 @@ void DialogFlippingByAxis::SuffixChanged()
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::GroupNameChanged()
{
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
if (edit)
{
const QString name = edit->text();
if (name.isEmpty())
{
flagGroupName = false;
ChangeColor(ui->labelGroupName, errorColor);
CheckState();
return;
}
flagGroupName = true;
ChangeColor(ui->labelGroupName, OkColor(this));
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::ShowVisualization()
{

View File

@ -65,6 +65,12 @@ public:
QVector<quint32> GetObjects() const;
QString GetVisibilityGroupName() const;
void SetVisibilityGroupName(const QString &name);
bool HasLinkedVisibilityGroup() const;
void SetHasLinkedVisibilityGroup(bool linked);
virtual void ShowDialog(bool click) override;
public slots:
@ -73,6 +79,7 @@ public slots:
private slots:
void SuffixChanged();
void GroupNameChanged();
protected:
virtual void ShowVisualization() override;
@ -96,6 +103,7 @@ private:
QString m_suffix;
bool flagName;
bool flagGroupName;
bool flagError;
static void FillComboBoxAxisType(QComboBox *box);
@ -104,7 +112,7 @@ private:
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogFlippingByAxis::IsValid() const
{
return flagError && flagName;
return flagError && flagName && flagGroupName;
}
#endif // DIALOGFLIPPINGBYAXIS_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>285</width>
<height>146</height>
<width>304</width>
<height>207</height>
</rect>
</property>
<property name="windowTitle">
@ -48,6 +48,41 @@
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxVisibilityGroup">
<property name="toolTip">
<string>Enable to create a visibility gropup from original objects</string>
</property>
<property name="title">
<string>Visibility Group</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="labelGroupName">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditVisibilityGroup">
<property name="text">
<string>Flipping by axis</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">

View File

@ -79,6 +79,7 @@ DialogFlippingByLine::DialogFlippingByLine(const VContainer *data, quint32 toolI
FillComboBoxPoints(ui->comboBoxSecondLinePoint);
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogFlippingByLine::SuffixChanged);
connect(ui->lineEditVisibilityGroup, &QLineEdit::textChanged, this, &DialogFlippingByLine::GroupNameChanged);
connect(ui->comboBoxFirstLinePoint, &QComboBox::currentTextChanged,
this, &DialogFlippingByLine::PointChanged);
connect(ui->comboBoxSecondLinePoint, &QComboBox::currentTextChanged,
@ -142,6 +143,30 @@ QVector<quint32> DialogFlippingByLine::GetObjects() const
return ConvertToVector(objects);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogFlippingByLine::GetVisibilityGroupName() const
{
return ui->lineEditVisibilityGroup->text();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::SetVisibilityGroupName(const QString &name)
{
ui->lineEditVisibilityGroup->setText(name.isEmpty() ? tr("Rotation") : name);
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogFlippingByLine::HasLinkedVisibilityGroup() const
{
return ui->groupBoxVisibilityGroup->isChecked();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::SetHasLinkedVisibilityGroup(bool linked)
{
ui->groupBoxVisibilityGroup->setChecked(linked);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::ShowDialog(bool click)
{
@ -301,6 +326,27 @@ void DialogFlippingByLine::SuffixChanged()
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::GroupNameChanged()
{
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
if (edit)
{
const QString name = edit->text();
if (name.isEmpty())
{
flagGroupName = false;
ChangeColor(ui->labelGroupName, errorColor);
CheckState();
return;
}
flagGroupName = true;
ChangeColor(ui->labelGroupName, OkColor(this));
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::ShowVisualization()
{

View File

@ -65,6 +65,12 @@ public:
QVector<quint32> GetObjects() const;
QString GetVisibilityGroupName() const;
void SetVisibilityGroupName(const QString &name);
bool HasLinkedVisibilityGroup() const;
void SetHasLinkedVisibilityGroup(bool linked);
virtual void ShowDialog(bool click) override;
public slots:
@ -73,6 +79,7 @@ public slots:
private slots:
void SuffixChanged();
void GroupNameChanged();
protected:
virtual void ShowVisualization() override;
@ -96,13 +103,14 @@ private:
QString m_suffix;
bool flagName;
bool flagGroupName;
bool flagError;
};
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogFlippingByLine::IsValid() const
{
return flagError && flagName;
return flagError && flagName && flagGroupName;
}
#endif // DIALOGFLIPPINGBYLINE_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>285</width>
<height>146</height>
<width>304</width>
<height>207</height>
</rect>
</property>
<property name="windowTitle">
@ -52,6 +52,41 @@
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxVisibilityGroup">
<property name="toolTip">
<string>Enable to create a visibility gropup from original objects</string>
</property>
<property name="title">
<string>Visibility Group</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="labelGroupName">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditVisibilityGroup">
<property name="text">
<string>Flipping by line</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">

View File

@ -85,7 +85,8 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
flagAngle(false),
flagRotationAngle(false),
flagLength(false),
flagName(true)
flagName(true),
flagGroupName(true)
{
ui->setupUi(this);
@ -118,6 +119,7 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
ui->comboBoxRotationOriginPoint->blockSignals(false);
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogMove::SuffixChanged);
connect(ui->lineEditVisibilityGroup, &QLineEdit::textChanged, this, &DialogMove::GroupNameChanged);
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogMove::FXAngle);
connect(ui->toolButtonExprRotationAngle, &QPushButton::clicked, this, &DialogMove::FXRotationAngle);
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogMove::FXLength);
@ -257,6 +259,30 @@ QVector<quint32> DialogMove::GetObjects() const
return ConvertToVector(objects);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogMove::GetVisibilityGroupName() const
{
return ui->lineEditVisibilityGroup->text();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::SetVisibilityGroupName(const QString &name)
{
ui->lineEditVisibilityGroup->setText(name.isEmpty() ? tr("Rotation") : name);
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogMove::HasLinkedVisibilityGroup() const
{
return ui->groupBoxVisibilityGroup->isChecked();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::SetHasLinkedVisibilityGroup(bool linked)
{
ui->groupBoxVisibilityGroup->setChecked(linked);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::ShowDialog(bool click)
{
@ -481,6 +507,27 @@ void DialogMove::SuffixChanged()
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::GroupNameChanged()
{
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
if (edit)
{
const QString name = edit->text();
if (name.isEmpty())
{
flagGroupName = false;
ChangeColor(ui->labelGroupName, errorColor);
CheckState();
return;
}
flagGroupName = true;
ChangeColor(ui->labelGroupName, OkColor(this));
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::ShowVisualization()
{

View File

@ -70,6 +70,12 @@ public:
QVector<quint32> GetObjects() const;
QString GetVisibilityGroupName() const;
void SetVisibilityGroupName(const QString &name);
bool HasLinkedVisibilityGroup() const;
void SetHasLinkedVisibilityGroup(bool linked);
virtual void ShowDialog(bool click) override;
public slots:
@ -87,6 +93,7 @@ private slots:
void FXLength();
void SuffixChanged();
void GroupNameChanged();
protected:
virtual void ShowVisualization() override;
@ -129,6 +136,7 @@ private:
bool flagRotationAngle;
bool flagLength;
bool flagName;
bool flagGroupName;
void EvalAngle();
void EvalRotationAngle();
@ -138,7 +146,7 @@ private:
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogMove::IsValid() const
{
return flagAngle && flagRotationAngle && flagLength && flagName;
return flagAngle && flagRotationAngle && flagLength && flagName && flagGroupName;
}
#endif // DIALOGMOVING_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>292</width>
<height>332</height>
<width>304</width>
<height>402</height>
</rect>
</property>
<property name="windowTitle">
@ -591,6 +591,41 @@
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxVisibilityGroup">
<property name="toolTip">
<string>Enable to create a visibility gropup from original objects</string>
</property>
<property name="title">
<string>Visibility Group</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="labelGroupName">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditVisibilityGroup">
<property name="text">
<string>Move</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">

View File

@ -77,6 +77,7 @@ DialogRotation::DialogRotation(const VContainer *data, quint32 toolId, QWidget *
m_firstRelease(false),
flagAngle(false),
flagName(true),
flagGroupName(true),
flagError(false)
{
ui->setupUi(this);
@ -94,6 +95,7 @@ DialogRotation::DialogRotation(const VContainer *data, quint32 toolId, QWidget *
FillComboBoxPoints(ui->comboBoxOriginPoint);
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogRotation::SuffixChanged);
connect(ui->lineEditVisibilityGroup, &QLineEdit::textChanged, this, &DialogRotation::GroupNameChanged);
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogRotation::FXAngle);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
{
@ -170,6 +172,30 @@ QVector<quint32> DialogRotation::GetObjects() const
return ConvertToVector(objects);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogRotation::GetVisibilityGroupName() const
{
return ui->lineEditVisibilityGroup->text();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::SetVisibilityGroupName(const QString &name)
{
ui->lineEditVisibilityGroup->setText(name.isEmpty() ? tr("Rotation") : name);
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogRotation::HasLinkedVisibilityGroup() const
{
return ui->groupBoxVisibilityGroup->isChecked();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::SetHasLinkedVisibilityGroup(bool linked)
{
ui->groupBoxVisibilityGroup->setChecked(linked);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::ShowDialog(bool click)
{
@ -366,6 +392,27 @@ void DialogRotation::SuffixChanged()
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::GroupNameChanged()
{
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
if (edit)
{
const QString name = edit->text();
if (name.isEmpty())
{
flagGroupName = false;
ChangeColor(ui->labelGroupName, errorColor);
CheckState();
return;
}
flagGroupName = true;
ChangeColor(ui->labelGroupName, OkColor(this));
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::ShowVisualization()
{

View File

@ -63,6 +63,12 @@ public:
QVector<quint32> GetObjects() const;
QString GetVisibilityGroupName() const;
void SetVisibilityGroupName(const QString &name);
bool HasLinkedVisibilityGroup() const;
void SetHasLinkedVisibilityGroup(bool linked);
virtual void ShowDialog(bool click) override;
public slots:
@ -74,6 +80,7 @@ private slots:
void DeployAngleTextEdit();
void FXAngle();
void SuffixChanged();
void GroupNameChanged();
void EvalAngle();
protected:
@ -111,13 +118,14 @@ private:
/** @brief flagAngle true if value of angle is correct */
bool flagAngle;
bool flagName;
bool flagGroupName;
bool flagError;
};
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogRotation::IsValid() const
{
return flagAngle && flagName && flagError;
return flagAngle && flagName && flagError && flagGroupName;
}
#endif // DIALOGROTATION_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>285</width>
<height>189</height>
<width>392</width>
<height>252</height>
</rect>
</property>
<property name="windowTitle">
@ -222,6 +222,41 @@
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxVisibilityGroup">
<property name="toolTip">
<string>Enable to create a visibility gropup from original objects</string>
</property>
<property name="title">
<string>Visibility Group</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="labelGroupName">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditVisibilityGroup">
<property name="text">
<string>Rotation</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">

View File

@ -74,6 +74,17 @@ void VToolFlippingByAxis::setDialog()
dialogTool->SetOriginPointId(m_originPointId);
dialogTool->SetAxisType(m_axisType);
dialogTool->SetSuffix(suffix);
vidtype group = doc->GroupLinkedToTool(m_id);
if (group != null_id)
{
dialogTool->SetHasLinkedVisibilityGroup(true);
dialogTool->SetVisibilityGroupName(doc->GetGroupName(group));
}
else
{
dialogTool->SetHasLinkedVisibilityGroup(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -89,6 +100,8 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(const QPointer<DialogTool> &dia
initData.axisType = dialogTool->GetAxisType();
initData.suffix = dialogTool->GetSuffix();
initData.source = dialogTool->GetObjects();
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
initData.scene = scene;
initData.doc = doc;
initData.data = data;
@ -123,6 +136,11 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(VToolFlippingByAxisInitData ini
if (initData.parse == Document::FullParse)
{
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
{
qApp->getUndoStack()->beginMacro(tr("Flipping by axis"));
}
VAbstractTool::AddRecord(initData.id, Tool::FlippingByAxis, initData.doc);
VToolFlippingByAxis *tool = new VToolFlippingByAxis(initData);
initData.scene->addItem(tool);
@ -133,6 +151,13 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(VToolFlippingByAxisInitData ini
{
initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
}
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
{
VAbstractOperation::CreateVisibilityGroup(initData);
qApp->getUndoStack()->endMacro();
}
return tool;
}
return nullptr;
@ -208,6 +233,10 @@ void VToolFlippingByAxis::SaveDialog(QDomElement &domElement, QList<quint32> &ol
doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetOriginPointId()));
doc->SetAttribute(domElement, AttrAxisType, QString().setNum(static_cast<int>(dialogTool->GetAxisType())));
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
// Save for later use.
hasLinkedGroup = dialogTool->HasLinkedVisibilityGroup();
groupName = dialogTool->GetVisibilityGroupName();
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -74,6 +74,17 @@ void VToolFlippingByLine::setDialog()
dialogTool->SetFirstLinePointId(m_firstLinePointId);
dialogTool->SetSecondLinePointId(m_secondLinePointId);
dialogTool->SetSuffix(suffix);
vidtype group = doc->GroupLinkedToTool(m_id);
if (group != null_id)
{
dialogTool->SetHasLinkedVisibilityGroup(true);
dialogTool->SetVisibilityGroupName(doc->GetGroupName(group));
}
else
{
dialogTool->SetHasLinkedVisibilityGroup(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -89,6 +100,8 @@ VToolFlippingByLine *VToolFlippingByLine::Create(const QPointer<DialogTool> &dia
initData.secondLinePointId = dialogTool->GetSecondLinePointId();
initData.suffix = dialogTool->GetSuffix();
initData.source = dialogTool->GetObjects();
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
initData.scene = scene;
initData.doc = doc;
initData.data = data;
@ -116,6 +129,11 @@ VToolFlippingByLine *VToolFlippingByLine::Create(VToolFlippingByLineInitData ini
if (initData.parse == Document::FullParse)
{
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
{
qApp->getUndoStack()->beginMacro(tr("flipping by line"));
}
VAbstractTool::AddRecord(initData.id, Tool::FlippingByLine, initData.doc);
VToolFlippingByLine *tool = new VToolFlippingByLine(initData);
initData.scene->addItem(tool);
@ -127,6 +145,13 @@ VToolFlippingByLine *VToolFlippingByLine::Create(VToolFlippingByLineInitData ini
{
initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
}
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
{
VAbstractOperation::CreateVisibilityGroup(initData);
qApp->getUndoStack()->endMacro();
}
return tool;
}
return nullptr;
@ -195,6 +220,10 @@ void VToolFlippingByLine::SaveDialog(QDomElement &domElement, QList<quint32> &ol
doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetFirstLinePointId()));
doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetSecondLinePointId()));
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
// Save for later use.
hasLinkedGroup = dialogTool->HasLinkedVisibilityGroup();
groupName = dialogTool->GetVisibilityGroupName();
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -29,12 +29,42 @@
#include "vabstractoperation.h"
#include "../../../undocommands/label/operationmovelabel.h"
#include "../../../undocommands/label/operationshowlabel.h"
#include "../../../undocommands/savetooloptions.h"
#include "../../../undocommands/undogroup.h"
#include "../vgeometry/vpointf.h"
const QString VAbstractOperation::TagItem = QStringLiteral("item");
const QString VAbstractOperation::TagSource = QStringLiteral("source");
const QString VAbstractOperation::TagDestination = QStringLiteral("destination");
namespace
{
/**
* @brief VisibilityGroupDataFromSource
* @param initData
* @return
*/
QMap<quint32, quint32> VisibilityGroupDataFromSource(const VContainer *data, const QVector<quint32> &source)
{
QMap<quint32, quint32> groupData;
for (auto &sId : source)
{
try
{
groupData.insert(sId, data->GetGObject(sId)->getIdTool());
}
catch (const VExceptionBadId &)
{
// ignore
}
}
return groupData;
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractOperation::getTagName() const
{
@ -528,6 +558,66 @@ void VAbstractOperation::ChangeLabelVisibility(quint32 id, bool visible)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::ApplyToolOptions(const QList<quint32> &oldDependencies, const QList<quint32> &newDependencies,
const QDomElement &oldDomElement, const QDomElement &newDomElement)
{
bool updateToolOptions =
newDependencies != oldDependencies || not VDomDocument::Compare(newDomElement, oldDomElement);
bool updateVisibilityOptions = NeedUpdateVisibilityGroup();
if (updateToolOptions && updateVisibilityOptions)
{
qApp->getUndoStack()->beginMacro(tr("operation options"));
}
if (updateToolOptions)
{
SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, oldDependencies,
newDependencies, doc, m_id);
connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
qApp->getUndoStack()->push(saveOptions);
}
if (updateVisibilityOptions)
{
vidtype group = doc->GroupLinkedToTool(m_id);
if (hasLinkedGroup)
{
if (group != null_id)
{
RenameGroup *renameGroup = new RenameGroup(doc, group, groupName);
connect(renameGroup, &RenameGroup::UpdateGroups, doc, &VAbstractPattern::UpdateVisiblityGroups);
qApp->getUndoStack()->push(renameGroup);
}
else
{
VAbstractOperationInitData initData;
initData.id = m_id;
initData.hasLinkedVisibilityGroup = hasLinkedGroup;
initData.visibilityGroupName = groupName;
initData.data = &(VDataTool::data);
initData.doc = doc;
initData.source = source;
VAbstractOperation::CreateVisibilityGroup(initData);
}
}
else
{
DelGroup *delGroup = new DelGroup(doc, group);
connect(delGroup, &DelGroup::UpdateGroups, doc, &VAbstractPattern::UpdateVisiblityGroups);
qApp->getUndoStack()->push(delGroup);
}
}
if (updateToolOptions && updateVisibilityOptions)
{
qApp->getUndoStack()->endMacro();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::UpdateNamePosition(quint32 id, const QPointF &pos)
{
@ -641,6 +731,33 @@ void VAbstractOperation::AllowCurveSelecting(bool enabled, GOType type)
}
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractOperation::NeedUpdateVisibilityGroup() const
{
vidtype group = doc->GroupLinkedToTool(m_id);
if (hasLinkedGroup)
{
if (group != null_id)
{
if (groupName != doc->GetGroupName(group))
{
return true; // rename group
}
}
else
{
return true; // create group
}
}
else
{
return group != null_id; // remove group
}
return false;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::InitOperatedObjects()
{
@ -725,3 +842,24 @@ QString VAbstractOperation::ComplexCurveToolTip(quint32 itemId) const
.arg(UnitsToStr(qApp->patternUnit(), true), MakeToolTip());
return toolTip;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::CreateVisibilityGroup(const VAbstractOperationInitData &initData)
{
if (not initData.hasLinkedVisibilityGroup && not initData.visibilityGroupName.isEmpty())
{
return;
}
const QMap<quint32, quint32> groupData = VisibilityGroupDataFromSource(initData.data, initData.source);
vidtype groupId = initData.data->getNextId();
const QDomElement group = initData.doc->CreateGroup(groupId, initData.visibilityGroupName, groupData, initData.id);
if (not group.isNull())
{
AddGroup *addGroup = new AddGroup(group, initData.doc);
connect(addGroup, &AddGroup::UpdateGroups, initData.doc, &VAbstractPattern::UpdateVisiblityGroups);
qApp->getUndoStack()->push(addGroup);
}
return;
}

View File

@ -53,15 +53,14 @@ struct DestinationItem
struct VAbstractOperationInitData : VAbstractToolInitData
{
VAbstractOperationInitData()
: VAbstractToolInitData(),
suffix(),
source(),
destination()
: VAbstractToolInitData()
{}
QString suffix;
QVector<quint32> source;
QVector<DestinationItem> destination;
QString suffix{};
QVector<quint32> source{};
QVector<DestinationItem> destination{};
QString visibilityGroupName{};
bool hasLinkedVisibilityGroup{false};
};
// FIXME. I don't know how to use QGraphicsItem properly, so just took first available finished class.
@ -133,12 +132,17 @@ protected:
QMap<quint32, VAbstractSimple *> operatedObjects;
bool hasLinkedGroup{false};
QString groupName{};
VAbstractOperation(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
QGraphicsItem *parent = nullptr);
virtual void AddToFile() override;
virtual void ChangeLabelVisibility(quint32 id, bool visible) override;
virtual void ApplyToolOptions(const QList<quint32> &oldDependencies, const QList<quint32> &newDependencies,
const QDomElement &oldDomElement, const QDomElement &newDomElement) override;
void UpdateNamePosition(quint32 id, const QPointF &pos);
void SaveSourceDestination(QDomElement &tag);
@ -155,11 +159,15 @@ protected:
QString ComplexPointToolTip(quint32 itemId) const;
QString ComplexCurveToolTip(quint32 itemId) const;
static void CreateVisibilityGroup(const VAbstractOperationInitData & initData);
private:
Q_DISABLE_COPY(VAbstractOperation)
void AllowCurveHover(bool enabled, GOType type);
void AllowCurveSelecting(bool enabled, GOType type);
bool NeedUpdateVisibilityGroup() const;
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -128,6 +128,17 @@ void VToolMove::setDialog()
dialogTool->SetLength(formulaLength);
dialogTool->SetSuffix(suffix);
dialogTool->SetRotationOrigPointId(origPointId);
vidtype group = doc->GroupLinkedToTool(m_id);
if (group != null_id)
{
dialogTool->SetHasLinkedVisibilityGroup(true);
dialogTool->SetVisibilityGroupName(doc->GetGroupName(group));
}
else
{
dialogTool->SetHasLinkedVisibilityGroup(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -145,6 +156,8 @@ VToolMove *VToolMove::Create(const QPointer<DialogTool> &dialog, VMainGraphicsSc
initData.rotationOrigin = dialogTool->GetRotationOrigPointId();
initData.suffix = dialogTool->GetSuffix();
initData.source = dialogTool->GetObjects();
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
initData.scene = scene;
initData.doc = doc;
initData.data = data;
@ -309,6 +322,11 @@ QT_WARNING_POP
if (initData.parse == Document::FullParse)
{
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
{
qApp->getUndoStack()->beginMacro(tr("move"));
}
VAbstractTool::AddRecord(initData.id, Tool::Move, initData.doc);
VToolMove *tool = new VToolMove(initData);
initData.scene->addItem(tool);
@ -324,6 +342,13 @@ QT_WARNING_POP
{
initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
}
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
{
VAbstractOperation::CreateVisibilityGroup(initData);
qApp->getUndoStack()->endMacro();
}
return tool;
}
return nullptr;
@ -464,6 +489,10 @@ void VToolMove::SaveDialog(QDomElement &domElement, QList<quint32> &oldDependenc
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetRotationOrigPointId()));
doc->SetAttribute(domElement, AttrRotationAngle, dialogTool->GetRotationAngle());
// Save for later use.
hasLinkedGroup = dialogTool->HasLinkedVisibilityGroup();
groupName = dialogTool->GetVisibilityGroupName();
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -98,6 +98,17 @@ void VToolRotation::setDialog()
dialogTool->SetOrigPointId(origPointId);
dialogTool->SetAngle(formulaAngle);
dialogTool->SetSuffix(suffix);
vidtype group = doc->GroupLinkedToTool(m_id);
if (group != null_id)
{
dialogTool->SetHasLinkedVisibilityGroup(true);
dialogTool->SetVisibilityGroupName(doc->GetGroupName(group));
}
else
{
dialogTool->SetHasLinkedVisibilityGroup(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -113,6 +124,8 @@ VToolRotation *VToolRotation::Create(const QPointer<DialogTool> &dialog, VMainGr
initData.angle = dialogTool->GetAngle();
initData.suffix = dialogTool->GetSuffix();
initData.source = dialogTool->GetObjects();
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
initData.scene = scene;
initData.doc = doc;
initData.data = data;
@ -251,6 +264,11 @@ QT_WARNING_POP
if (initData.parse == Document::FullParse)
{
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
{
qApp->getUndoStack()->beginMacro(tr("rotate"));
}
VAbstractTool::AddRecord(initData.id, Tool::Rotation, initData.doc);
VToolRotation *tool = new VToolRotation(initData);
initData.scene->addItem(tool);
@ -261,6 +279,13 @@ QT_WARNING_POP
{
initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
}
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
{
VAbstractOperation::CreateVisibilityGroup(initData);
qApp->getUndoStack()->endMacro();
}
return tool;
}
return nullptr;
@ -344,6 +369,10 @@ void VToolRotation::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepen
doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetOrigPointId()));
doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle());
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
// Save for later use.
hasLinkedGroup = dialogTool->HasLinkedVisibilityGroup();
groupName = dialogTool->GetVisibilityGroupName();
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -114,7 +114,18 @@ void VDrawTool::SaveDialogChange(const QString &undoText)
QList<quint32> oldDependencies;
QList<quint32> newDependencies;
SaveDialog(newDomElement, oldDependencies, newDependencies);
ApplyToolOptions(oldDependencies, newDependencies, oldDomElement, newDomElement);
}
else
{
qCDebug(vTool, "Can't find tool with id = %u", m_id);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VDrawTool::ApplyToolOptions(const QList<quint32> &oldDependencies, const QList<quint32> &newDependencies,
const QDomElement &oldDomElement, const QDomElement &newDomElement)
{
if (newDependencies != oldDependencies || not VDomDocument::Compare(newDomElement, oldDomElement))
{
SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, oldDependencies,
@ -123,11 +134,6 @@ void VDrawTool::SaveDialogChange(const QString &undoText)
qApp->getUndoStack()->push(saveOptions);
}
}
else
{
qCDebug(vTool, "Can't find tool with id = %u", m_id);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**

View File

@ -99,6 +99,8 @@ protected:
virtual void SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies,
QList<quint32> &newDependencies)=0;
virtual void SaveDialogChange(const QString &undoText = QString()) final;
virtual void ApplyToolOptions(const QList<quint32> &oldDependencies, const QList<quint32> &newDependencies,
const QDomElement &oldDomElement, const QDomElement &newDomElement);
virtual void AddToFile() override;
void SaveOption(QSharedPointer<VGObject> &obj);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);

View File

@ -117,6 +117,34 @@ void AddGroup::redo()
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
}
//RenameGroup
//---------------------------------------------------------------------------------------------------------------------
RenameGroup::RenameGroup(VAbstractPattern *doc, quint32 id, const QString &name, QUndoCommand *parent)
: VUndoCommand(QDomElement(), doc, parent),
newName(name)
{
setText(tr("rename group"));
nodeId = id;
oldName = doc->GetGroupName(nodeId);
}
//---------------------------------------------------------------------------------------------------------------------
void RenameGroup::undo()
{
qCDebug(vUndo, "Undo.");
doc->SetGroupName(nodeId, oldName);
emit UpdateGroups();
}
//---------------------------------------------------------------------------------------------------------------------
void RenameGroup::redo()
{
qCDebug(vUndo, "Redo.");
doc->SetGroupName(nodeId, newName);
emit UpdateGroups();
}
//AddItemToGroup
//---------------------------------------------------------------------------------------------------------------------
AddItemToGroup::AddItemToGroup(const QDomElement &xml, VAbstractPattern *doc, quint32 groupId, QUndoCommand *parent)

View File

@ -53,6 +53,22 @@ private:
const QString nameActivDraw;
};
class RenameGroup : public VUndoCommand
{
Q_OBJECT
public:
RenameGroup(VAbstractPattern *doc, quint32 id, const QString &name, QUndoCommand *parent = nullptr);
virtual ~RenameGroup()=default;
virtual void undo() override;
virtual void redo() override;
signals:
void UpdateGroups();
private:
Q_DISABLE_COPY(RenameGroup)
QString newName;
QString oldName{};
};
class AddItemToGroup : public VUndoCommand
{
Q_OBJECT