diff --git a/ChangeLog.txt b/ChangeLog.txt
index 6fd89eb7d..6ccc36261 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -19,6 +19,7 @@
- Improve validation grainline position.
- Increased the limit for the Letter field.
- Fix double call of a main path context menu.
+- Improve storing visibility group items. Don't store duplicate information.
# Valentina 0.7.49 July 1, 2021
- Fix crash.
diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc
index 96f6d0b17..58af0de67 100644
--- a/src/libs/ifc/schema.qrc
+++ b/src/libs/ifc/schema.qrc
@@ -64,6 +64,7 @@
schema/pattern/v0.8.10.xsd
schema/pattern/v0.8.11.xsd
schema/pattern/v0.8.12.xsd
+ schema/pattern/v0.8.13.xsd
schema/multisize_measurements/v0.3.0.xsd
schema/multisize_measurements/v0.4.0.xsd
schema/multisize_measurements/v0.4.1.xsd
diff --git a/src/libs/ifc/schema/pattern/v0.8.13.xsd b/src/libs/ifc/schema/pattern/v0.8.13.xsd
new file mode 100644
index 000000000..fd4684858
--- /dev/null
+++ b/src/libs/ifc/schema/pattern/v0.8.13.xsd
@@ -0,0 +1,1134 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp
index 6c23b1158..6b9bd2592 100644
--- a/src/libs/ifc/xml/vabstractpattern.cpp
+++ b/src/libs/ifc/xml/vabstractpattern.cpp
@@ -1847,8 +1847,9 @@ QPair > VAbstractPattern::ParseItemElement(const QD
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);
+ const quint32 object = GetParametrUInt(element, AttrObject, QString::number(tool));
+
items.insert(object, tool);
}
}
@@ -2037,8 +2038,9 @@ QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const
while (i != groupData.constEnd())
{
QDomElement item = createElement(TagGroupItem);
- item.setAttribute(AttrObject, i.key());
item.setAttribute(AttrTool, i.value());
+ SetAttributeOrRemoveIf(item, AttrObject, i.key(), [i](vidtype object) noexcept
+ {return object == i.value();});
group.appendChild(item);
++i;
}
@@ -2256,7 +2258,7 @@ bool VAbstractPattern::GroupHasItem(const QDomElement &groupDomElement, quint32
if (item.isNull() == false)
{
quint32 toolIdIterate= GetParametrUInt(item, AttrTool, QChar('0'));
- quint32 objectIdIterate= GetParametrUInt(item, AttrObject, QChar('0'));
+ quint32 objectIdIterate= GetParametrUInt(item, AttrObject, QString::number(toolIdIterate));
if(toolIdIterate == toolId && objectIdIterate == objectId)
{
@@ -2358,7 +2360,8 @@ QDomElement VAbstractPattern::AddItemToGroup(quint32 toolId, quint32 objectId, q
QDomElement item = createElement(TagGroupItem);
item.setAttribute(AttrTool, toolId);
- item.setAttribute(AttrObject, objectId);
+ SetAttributeOrRemoveIf(item, AttrObject, objectId, [toolId](vidtype object) noexcept
+ {return object == toolId;});
group.appendChild(item);
// to signalised that the pattern was changed and need to be saved
@@ -2413,7 +2416,7 @@ QDomElement VAbstractPattern::RemoveItemFromGroup(quint32 toolId, quint32 object
if (item.isNull() == false)
{
quint32 toolIdIterate= GetParametrUInt(item, AttrTool, QChar('0'));
- quint32 objectIdIterate= GetParametrUInt(item, AttrObject, QChar('0'));
+ quint32 objectIdIterate= GetParametrUInt(item, AttrObject, QString::number(toolIdIterate));
if(toolIdIterate == toolId && objectIdIterate == objectId)
{
diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp
index deaa80405..cf1655dad 100644
--- a/src/libs/ifc/xml/vpatternconverter.cpp
+++ b/src/libs/ifc/xml/vpatternconverter.cpp
@@ -60,8 +60,8 @@ class QDomElement;
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4");
-const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.12");
-const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.12.xsd");
+const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.13");
+const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.13.xsd");
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@@ -245,7 +245,8 @@ auto VPatternConverter::XSDSchema(unsigned ver) const -> QString
std::make_pair(FormatVersion(0, 8, 9), QStringLiteral("://schema/pattern/v0.8.9.xsd")),
std::make_pair(FormatVersion(0, 8, 10), QStringLiteral("://schema/pattern/v0.8.10.xsd")),
std::make_pair(FormatVersion(0, 8, 11), QStringLiteral("://schema/pattern/v0.8.11.xsd")),
- std::make_pair(FormatVersion(0, 8, 12), CurrentSchema)
+ std::make_pair(FormatVersion(0, 8, 12), QStringLiteral("://schema/pattern/v0.8.12.xsd")),
+ std::make_pair(FormatVersion(0, 8, 13), CurrentSchema)
};
if (schemas.contains(ver))
@@ -514,6 +515,10 @@ void VPatternConverter::ApplyPatches()
ValidateXML(XSDSchema(FormatVersion(0, 8, 12)));
Q_FALLTHROUGH();
case (FormatVersion(0, 8, 12)):
+ ToV0_8_13();
+ ValidateXML(XSDSchema(FormatVersion(0, 8, 13)));
+ Q_FALLTHROUGH();
+ case (FormatVersion(0, 8, 13)):
break;
default:
InvalidVersion(m_ver);
@@ -531,7 +536,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
bool VPatternConverter::IsReadOnly() const
{
// Check if attribute readOnly was not changed in file format
- Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FormatVersion(0, 8, 12),
+ Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FormatVersion(0, 8, 13),
"Check attribute readOnly.");
// Possibly in future attribute readOnly will change position etc.
@@ -1223,6 +1228,16 @@ void VPatternConverter::ToV0_8_12()
Save();
}
+//---------------------------------------------------------------------------------------------------------------------
+void VPatternConverter::ToV0_8_13()
+{
+ // TODO. Delete if minimal supported version is 0.8.13
+ Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 8, 13),
+ "Time to refactor the code.");
+ SetVersion(QStringLiteral("0.8.13"));
+ Save();
+}
+
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{
diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h
index 43a1deb94..bd140e23c 100644
--- a/src/libs/ifc/xml/vpatternconverter.h
+++ b/src/libs/ifc/xml/vpatternconverter.h
@@ -53,7 +53,7 @@ public:
static const QString PatternMaxVerStr;
static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const unsigned PatternMinVer = FormatVersion(0, 1, 4);
- static Q_DECL_CONSTEXPR const unsigned PatternMaxVer = FormatVersion(0, 8, 12);
+ static Q_DECL_CONSTEXPR const unsigned PatternMaxVer = FormatVersion(0, 8, 13);
protected:
virtual unsigned MinVer() const override;
@@ -135,6 +135,7 @@ private:
void ToV0_8_10();
void ToV0_8_11();
void ToV0_8_12();
+ void ToV0_8_13();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();