Remember selected dimension values.
This commit is contained in:
parent
18e2554907
commit
df68bfefc8
|
@ -16,6 +16,7 @@
|
|||
- Add function's argument template with name in the Formula Wizard.
|
||||
- Unit type for increments.
|
||||
- Support for options Force Flipping and Forbid Flipping in Puzzle.
|
||||
- Remember selected dimension values.
|
||||
|
||||
# Valentina 0.7.51 April 18, 2022
|
||||
- Z value change for a layout piece.
|
||||
|
|
|
@ -559,9 +559,14 @@ bool MainWindow::LoadMeasurements(const QString &path)
|
|||
}
|
||||
else if (m->Type() == MeasurementsType::Multisize)
|
||||
{
|
||||
m_currentDimensionA = m->DimensionABase();
|
||||
m_currentDimensionB = m->DimensionBBase();
|
||||
m_currentDimensionC = m->DimensionCBase();
|
||||
auto DimensionBase = [](qreal current, qreal tableBase)
|
||||
{
|
||||
return not VFuzzyComparePossibleNulls(current, -1) ? current : tableBase;
|
||||
};
|
||||
|
||||
m_currentDimensionA = DimensionBase(doc->GetDimensionAValue(), m->DimensionABase());
|
||||
m_currentDimensionB = DimensionBase(doc->GetDimensionBValue(), m->DimensionBBase());
|
||||
m_currentDimensionC = DimensionBase(doc->GetDimensionCValue(), m->DimensionCBase());
|
||||
}
|
||||
ToolBarOption();
|
||||
SetDimensionBases();
|
||||
|
@ -575,7 +580,7 @@ bool MainWindow::LoadMeasurements(const QString &path)
|
|||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
if (not VApplication::IsGUIMode())
|
||||
{
|
||||
qApp->exit(V_EX_NOINPUT);
|
||||
QCoreApplication::exit(V_EX_NOINPUT);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -2339,7 +2344,7 @@ void MainWindow::SetDimensionBases()
|
|||
{
|
||||
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
|
||||
|
||||
auto SetBase = [dimensions](int index, QPointer<QComboBox> control, double &value)
|
||||
auto SetBase = [dimensions](int index, const QPointer<QComboBox>& control, double &value)
|
||||
{
|
||||
if (dimensions.size() > index)
|
||||
{
|
||||
|
@ -2347,8 +2352,6 @@ void MainWindow::SetDimensionBases()
|
|||
|
||||
control->blockSignals(true);
|
||||
|
||||
MeasurementDimension_p dimension = dimensions.at(index);
|
||||
|
||||
const qint32 i = control->findData(value);
|
||||
if (i != -1)
|
||||
{
|
||||
|
@ -4296,6 +4299,7 @@ void MainWindow::DimensionABaseChanged()
|
|||
{
|
||||
const qreal oldValue = m_currentDimensionA;
|
||||
m_currentDimensionA = dimensionA->currentData().toDouble();
|
||||
doc->SetDimensionAValue(m_currentDimensionA);
|
||||
|
||||
if (not VFuzzyComparePossibleNulls(oldValue, m_currentDimensionA))
|
||||
{
|
||||
|
@ -4321,6 +4325,7 @@ void MainWindow::DimensionBBaseChanged()
|
|||
{
|
||||
const qreal oldValue = m_currentDimensionB;
|
||||
m_currentDimensionB = dimensionB->currentData().toDouble();
|
||||
doc->SetDimensionBValue(m_currentDimensionB);
|
||||
|
||||
if (not VFuzzyComparePossibleNulls(oldValue, m_currentDimensionB))
|
||||
{
|
||||
|
@ -4341,6 +4346,7 @@ void MainWindow::DimensionCBaseChanged()
|
|||
{
|
||||
const qreal oldValue = m_currentDimensionC;
|
||||
m_currentDimensionC = dimensionC->currentData().toDouble();
|
||||
doc->SetDimensionCValue(m_currentDimensionC);
|
||||
|
||||
if (not VFuzzyComparePossibleNulls(oldValue, m_currentDimensionC))
|
||||
{
|
||||
|
|
|
@ -82,7 +82,14 @@
|
|||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="measurements" type="xs:string"/>
|
||||
<xs:element name="measurements">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="path" type="xs:string"/>
|
||||
<xs:attribute name="dimensionA" type="dimesionValue"/>
|
||||
<xs:attribute name="dimensionB" type="dimesionValue"/>
|
||||
<xs:attribute name="dimensionC" type="dimesionValue"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="increments">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="0" maxOccurs="unbounded">
|
||||
|
@ -1163,4 +1170,10 @@
|
|||
<xs:pattern value="([-+]?\d+\.?\d*([eE][-+]?\d+)?;){8,}[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="dimesionValue">
|
||||
<xs:restriction base="xs:double">
|
||||
<xs:minInclusive value="1"/>
|
||||
<xs:maxInclusive value="2720"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:schema>
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
#include "vtoolrecord.h"
|
||||
#include "../vmisc/vabstractvalapplication.h"
|
||||
#include "../vmisc/compatibility.h"
|
||||
#include "../vlayout/vtextmanager.h"
|
||||
#include "vpatternimage.h"
|
||||
#include "vbackgroundpatternimage.h"
|
||||
#include "vvalentinasettings.h"
|
||||
|
@ -147,6 +146,9 @@ const QString VAbstractPattern::AttrTransform = QStringLiteral("transfor
|
|||
const QString VAbstractPattern::AttrHold = QStringLiteral("hold");
|
||||
const QString VAbstractPattern::AttrZValue = QStringLiteral("zValue");
|
||||
const QString VAbstractPattern::AttrImageId = QStringLiteral("imageId");
|
||||
const QString VAbstractPattern::AttrDimensionA = QStringLiteral("dimensionA");
|
||||
const QString VAbstractPattern::AttrDimensionB = QStringLiteral("dimensionB");
|
||||
const QString VAbstractPattern::AttrDimensionC = QStringLiteral("dimensionC");
|
||||
|
||||
const QString VAbstractPattern::AttrContentType = QStringLiteral("contentType");
|
||||
|
||||
|
@ -167,6 +169,8 @@ bool VAbstractPattern::patternLabelWasChanged = false;
|
|||
|
||||
namespace
|
||||
{
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, dimensionDefValue, (QLatin1String("-1")))
|
||||
|
||||
void ReadExpressionAttribute(QVector<VFormulaField> &expressions, const QDomElement &element, const QString &attribute)
|
||||
{
|
||||
VFormulaField formula;
|
||||
|
@ -888,8 +892,20 @@ QString VAbstractPattern::MPath() const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractPattern::SetMPath(const QString &path)
|
||||
{
|
||||
if (setTagText(TagMeasurements, path))
|
||||
QDomElement domElement = UniqueTag(TagMeasurements);
|
||||
if (not domElement.isNull())
|
||||
{
|
||||
if (not path.isEmpty())
|
||||
{
|
||||
SetAttribute(domElement, AttrPath, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
domElement.removeAttribute(AttrPath);
|
||||
domElement.removeAttribute(AttrDimensionA);
|
||||
domElement.removeAttribute(AttrDimensionB);
|
||||
domElement.removeAttribute(AttrDimensionC);
|
||||
}
|
||||
m_MPath = path;
|
||||
patternLabelWasChanged = true;
|
||||
modified = true;
|
||||
|
@ -2405,6 +2421,93 @@ void VAbstractPattern::SetGroupTags(quint32 id, const QStringList &tags)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VAbstractPattern::GetDimensionAValue() -> double
|
||||
{
|
||||
QDomElement domElement = UniqueTag(TagMeasurements);
|
||||
if (not domElement.isNull())
|
||||
{
|
||||
return GetParametrDouble(domElement, AttrDimensionA, *dimensionDefValue);
|
||||
}
|
||||
|
||||
qDebug()<<"Can't save dimension A of measurements"<<Q_FUNC_INFO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractPattern::SetDimensionAValue(double value)
|
||||
{
|
||||
QDomElement domElement = UniqueTag(TagMeasurements);
|
||||
if (not domElement.isNull())
|
||||
{
|
||||
SetAttribute(domElement, AttrDimensionA, value);
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"Can't save dimension A of measurements"<<Q_FUNC_INFO;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VAbstractPattern::GetDimensionBValue() -> double
|
||||
{
|
||||
QDomElement domElement = UniqueTag(TagMeasurements);
|
||||
if (not domElement.isNull())
|
||||
{
|
||||
return GetParametrDouble(domElement, AttrDimensionB, *dimensionDefValue);
|
||||
}
|
||||
|
||||
qDebug()<<"Can't save dimension B of measurements"<<Q_FUNC_INFO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractPattern::SetDimensionBValue(double value)
|
||||
{
|
||||
QDomElement domElement = UniqueTag(TagMeasurements);
|
||||
if (not domElement.isNull())
|
||||
{
|
||||
SetAttribute(domElement, AttrDimensionB, value);
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"Can't save dimension B of measurements"<<Q_FUNC_INFO;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VAbstractPattern::GetDimensionCValue() -> double
|
||||
{
|
||||
QDomElement domElement = UniqueTag(TagMeasurements);
|
||||
if (not domElement.isNull())
|
||||
{
|
||||
return GetParametrDouble(domElement, AttrDimensionC, *dimensionDefValue);
|
||||
}
|
||||
|
||||
qDebug()<<"Can't save dimension C of measurements"<<Q_FUNC_INFO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractPattern::SetDimensionCValue(double value)
|
||||
{
|
||||
QDomElement domElement = UniqueTag(TagMeasurements);
|
||||
if (not domElement.isNull())
|
||||
{
|
||||
SetAttribute(domElement, AttrDimensionC, value);
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"Can't save dimension C of measurements"<<Q_FUNC_INFO;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VAbstractPattern::GetGroupCategories() const
|
||||
{
|
||||
|
@ -2626,9 +2729,15 @@ QString VAbstractPattern::ReadPatternName() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstractPattern::ReadMPath() const
|
||||
auto VAbstractPattern::ReadMPath() const -> QString
|
||||
{
|
||||
return UniqueTagText(TagMeasurements);
|
||||
QDomElement domElement = UniqueTag(TagMeasurements);
|
||||
if (not domElement.isNull())
|
||||
{
|
||||
return domElement.attribute(AttrPath);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -233,6 +233,15 @@ public:
|
|||
QStringList GetGroupTags(vidtype id);
|
||||
void SetGroupTags(quint32 id, const QStringList &tags);
|
||||
|
||||
auto GetDimensionAValue() -> double;
|
||||
void SetDimensionAValue(double value);
|
||||
|
||||
auto GetDimensionBValue() -> double;
|
||||
void SetDimensionBValue(double value);
|
||||
|
||||
auto GetDimensionCValue() -> double;
|
||||
void SetDimensionCValue(double value);
|
||||
|
||||
QStringList GetGroupCategories() const;
|
||||
|
||||
QMap<quint32, VGroupData> GetGroups(const QString &patternPieceName = QString());
|
||||
|
@ -332,6 +341,9 @@ public:
|
|||
static const QString AttrHold;
|
||||
static const QString AttrZValue;
|
||||
static const QString AttrImageId;
|
||||
static const QString AttrDimensionA;
|
||||
static const QString AttrDimensionB;
|
||||
static const QString AttrDimensionC;
|
||||
|
||||
static const QString AttrContentType;
|
||||
|
||||
|
|
|
@ -635,33 +635,20 @@ quint32 VDomDocument::GetParametrId(const QDomElement &domElement)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VDomDocument::UniqueTagText(const QString &tagName, const QString &defVal) const
|
||||
auto VDomDocument::UniqueTagText(const QString &tagName, const QString &defVal) const -> QString
|
||||
{
|
||||
const QDomNodeList nodeList = this->elementsByTagName(tagName);
|
||||
if (nodeList.isEmpty())
|
||||
QDomElement domElement = UniqueTag(tagName);
|
||||
if (not domElement.isNull())
|
||||
{
|
||||
return defVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
const QDomNode domNode = nodeList.at(0);
|
||||
if (domNode.isNull() == false && domNode.isElement())
|
||||
const QString text = domElement.text();
|
||||
if (text.isEmpty())
|
||||
{
|
||||
const QDomElement domElement = domNode.toElement();
|
||||
if (domElement.isNull() == false)
|
||||
{
|
||||
const QString text = domElement.text();
|
||||
if (text.isEmpty())
|
||||
{
|
||||
return defVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
return text;
|
||||
}
|
||||
}
|
||||
return defVal;
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
return defVal;
|
||||
}
|
||||
|
||||
|
@ -940,6 +927,27 @@ auto VDomDocument::setTagText(QDomElement &domElement, const QString &text) -> b
|
|||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDomElement VDomDocument::UniqueTag(const QString &tagName) const
|
||||
{
|
||||
const QDomNodeList nodeList = this->elementsByTagName(tagName);
|
||||
if (nodeList.isEmpty())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
const QDomNode domNode = nodeList.at(0);
|
||||
if (not domNode.isNull() && domNode.isElement())
|
||||
{
|
||||
const QDomElement domElement = domNode.toElement();
|
||||
if (not domElement.isNull())
|
||||
{
|
||||
return domElement;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RemoveAllChildren remove all children from file.
|
||||
|
|
|
@ -151,6 +151,7 @@ public:
|
|||
protected:
|
||||
bool setTagText(const QString &tag, const QString &text);
|
||||
bool setTagText(QDomElement &domElement, const QString &text);
|
||||
QDomElement UniqueTag(const QString &tagName) const;
|
||||
QString UniqueTagText(const QString &tagName, const QString &defVal = QString()) const;
|
||||
void CollectId(const QDomElement &node, QVector<quint32> &vector)const;
|
||||
|
||||
|
|
|
@ -557,6 +557,7 @@ void VPatternConverter::ToV0_9_1()
|
|||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 1),
|
||||
"Time to refactor the code.");
|
||||
|
||||
ConvertMeasurementsPathToV0_9_1();
|
||||
SetVersion(QStringLiteral("0.9.1"));
|
||||
Save();
|
||||
}
|
||||
|
@ -2168,6 +2169,39 @@ void VPatternConverter::ConvertImageToV0_9_0()
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternConverter::ConvertMeasurementsPathToV0_9_1()
|
||||
{
|
||||
// TODO. Delete if minimal supported version is 0.9.1
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 1),
|
||||
"Time to refactor the code.");
|
||||
|
||||
const QDomNodeList nodeList = this->elementsByTagName(*strMeasurements);
|
||||
if (nodeList.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const QDomNode domNode = nodeList.at(0);
|
||||
if (not domNode.isNull() && domNode.isElement())
|
||||
{
|
||||
QDomElement domElement = domNode.toElement();
|
||||
if (not domElement.isNull())
|
||||
{
|
||||
const QString path = domElement.text();
|
||||
if (path.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Clean text
|
||||
RemoveAllChildren(domElement);
|
||||
|
||||
domElement.setAttribute(*strPath, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternConverter::TagUnionDetailsToV0_4_0()
|
||||
{
|
||||
|
|
|
@ -143,6 +143,8 @@ private:
|
|||
void AddPieceUUIDV0_8_8();
|
||||
|
||||
void ConvertImageToV0_9_0();
|
||||
|
||||
void ConvertMeasurementsPathToV0_9_1();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user