diff --git a/src/app/container/container.pri b/src/app/container/container.pri index 7ee5145f1..3e8dd7bfe 100644 --- a/src/app/container/container.pri +++ b/src/app/container/container.pri @@ -26,4 +26,5 @@ HEADERS += \ container/vsplinelength.h \ container/vinternalvariable_p.h \ container/vvariable_p.h \ - container/vincrement_p.h + container/vincrement_p.h \ + container/vcurvelength_p.h diff --git a/src/app/container/vcurvelength.cpp b/src/app/container/vcurvelength.cpp index 6d2d62e08..1709066e5 100644 --- a/src/app/container/vcurvelength.cpp +++ b/src/app/container/vcurvelength.cpp @@ -27,19 +27,20 @@ *************************************************************************/ #include "vcurvelength.h" +#include "vcurvelength_p.h" #include "../widgets/vapplication.h" #include "../geometry/vabstractcurve.h" //--------------------------------------------------------------------------------------------------------------------- VCurveLength::VCurveLength() - :VInternalVariable(), id(NULL_ID), parentId(NULL_ID) + :VInternalVariable(), d(new VCurveLengthData) { SetType(VarType::Unknown); } //--------------------------------------------------------------------------------------------------------------------- VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *curve) - :VInternalVariable(), id(id), parentId(parentId) + :VInternalVariable(), d(new VCurveLengthData(id, parentId)) { SetType(VarType::Unknown); SCASSERT(curve != nullptr); @@ -49,7 +50,7 @@ VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const VAb //--------------------------------------------------------------------------------------------------------------------- VCurveLength::VCurveLength(const VCurveLength &var) - :VInternalVariable(var), id(var.GetId()), parentId(var.GetParentId()) + :VInternalVariable(var), d(var.d) {} //--------------------------------------------------------------------------------------------------------------------- @@ -60,8 +61,7 @@ VCurveLength &VCurveLength::operator=(const VCurveLength &var) return *this; } VInternalVariable::operator=(var); - this->id = var.GetId(); - this->parentId = var.GetParentId(); + d = var.d; return *this; } @@ -72,12 +72,36 @@ VCurveLength::~VCurveLength() //--------------------------------------------------------------------------------------------------------------------- bool VCurveLength::Filter(quint32 id) { - if (parentId != 0)//Do not check if value zero + if (d->parentId != 0)//Do not check if value zero {// Not all curves have parents. Only those who was created after cutting the parent curve. - return this->id == id || parentId == id; + return d->id == id || d->parentId == id; } else { - return this->id == id; + return d->id == id; } } + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VCurveLength::GetId() const +{ + return d->id; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VCurveLength::SetId(const quint32 &id) +{ + d->id = id; +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VCurveLength::GetParentId() const +{ + return d->parentId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VCurveLength::SetParentId(const quint32 &value) +{ + d->parentId = value; +} diff --git a/src/app/container/vcurvelength.h b/src/app/container/vcurvelength.h index ab4b97e3b..15d45f672 100644 --- a/src/app/container/vcurvelength.h +++ b/src/app/container/vcurvelength.h @@ -32,6 +32,7 @@ #include "vinternalvariable.h" class VAbstractCurve; +class VCurveLengthData; class VCurveLength : public VInternalVariable { @@ -43,23 +44,14 @@ public: virtual ~VCurveLength(); virtual bool Filter(quint32 id); + quint32 GetId() const; + void SetId(const quint32 &id); + quint32 GetParentId() const; -protected: - quint32 id; - quint32 parentId; + void SetParentId(const quint32 &value); +private: + QSharedDataPointer d; }; -//--------------------------------------------------------------------------------------------------------------------- -inline quint32 VCurveLength::GetId() const -{ - return id; -} - -//--------------------------------------------------------------------------------------------------------------------- -inline quint32 VCurveLength::GetParentId() const -{ - return parentId; -} - #endif // VCURVELENGTH_H diff --git a/src/app/container/vcurvelength_p.h b/src/app/container/vcurvelength_p.h new file mode 100644 index 000000000..1135bcebb --- /dev/null +++ b/src/app/container/vcurvelength_p.h @@ -0,0 +1,58 @@ +/************************************************************************ + ** + ** @file vcurvelength_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 + ** + ** @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) 2014 Valentina project + ** 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 . + ** + *************************************************************************/ + +#ifndef VCURVELENGTH_P_H +#define VCURVELENGTH_P_H + +#include +#include "../options.h" + +class VCurveLengthData : public QSharedData +{ +public: + + VCurveLengthData() + :id(NULL_ID), parentId(NULL_ID) + {} + + VCurveLengthData(const quint32 &id, const quint32 &parentId) + :id(id), parentId(parentId) + {} + + VCurveLengthData(const VCurveLengthData &var) + :QSharedData(var), id(var.id), parentId(var.parentId) + {} + + virtual ~VCurveLengthData() {} + + quint32 id; + quint32 parentId; +}; + + +#endif // VCURVELENGTH_P_H diff --git a/src/app/container/vsplinelength.cpp b/src/app/container/vsplinelength.cpp index ae92567e7..45d277b10 100644 --- a/src/app/container/vsplinelength.cpp +++ b/src/app/container/vsplinelength.cpp @@ -43,8 +43,8 @@ VSplineLength::VSplineLength(const quint32 &id, const quint32 &parentId, const Q SetType(VarType::SplineLength); SetName(name); SetValue(value); - this->id = id; - this->parentId = parentId; + SetId(id); + SetParentId(parentId); } //---------------------------------------------------------------------------------------------------------------------