Implicit Sharing for class VVariable.
--HG-- branch : develop
This commit is contained in:
parent
3c731d9f35
commit
327705da44
|
@ -24,4 +24,5 @@ HEADERS += \
|
||||||
container/varclength.h \
|
container/varclength.h \
|
||||||
container/vlinelength.h \
|
container/vlinelength.h \
|
||||||
container/vsplinelength.h \
|
container/vsplinelength.h \
|
||||||
container/vinternalvariable_p.h
|
container/vinternalvariable_p.h \
|
||||||
|
container/vvariable_p.h
|
||||||
|
|
|
@ -46,9 +46,6 @@ public:
|
||||||
|
|
||||||
quint32 getId() const;
|
quint32 getId() const;
|
||||||
void setId(const quint32 &value);
|
void setId(const quint32 &value);
|
||||||
void setKsize(const qreal &value);
|
|
||||||
void setKheight(const qreal &value);
|
|
||||||
void setDescription(const QString &value);
|
|
||||||
private:
|
private:
|
||||||
/** @brief id each increment have unique identificator */
|
/** @brief id each increment have unique identificator */
|
||||||
quint32 id;
|
quint32 id;
|
||||||
|
@ -74,34 +71,4 @@ inline void VIncrement::setId(const quint32 &value)
|
||||||
id = value;
|
id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief setKsize set increment in sizes
|
|
||||||
* @param value value of increment
|
|
||||||
*/
|
|
||||||
inline void VIncrement::setKsize(const qreal &value)
|
|
||||||
{
|
|
||||||
ksize = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief setKheight set increment in growths
|
|
||||||
* @param value value of increment
|
|
||||||
*/
|
|
||||||
inline void VIncrement::setKheight(const qreal &value)
|
|
||||||
{
|
|
||||||
kheight = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief setDescription set description for row
|
|
||||||
* @param value description
|
|
||||||
*/
|
|
||||||
inline void VIncrement::setDescription(const QString &value)
|
|
||||||
{
|
|
||||||
description = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // VINCREMENTTABLEROW_H
|
#endif // VINCREMENTTABLEROW_H
|
||||||
|
|
|
@ -27,29 +27,30 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vvariable.h"
|
#include "vvariable.h"
|
||||||
|
#include "vvariable_p.h"
|
||||||
#include "../widgets/vapplication.h"
|
#include "../widgets/vapplication.h"
|
||||||
#include "../xml/vabstractmeasurements.h"
|
#include "../xml/vabstractmeasurements.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VVariable::VVariable()
|
VVariable::VVariable()
|
||||||
:VInternalVariable(), base(0), ksize(0), kheight(0), description(QString())
|
:VInternalVariable(), d(new VVariableData)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
VInternalVariable::SetValue(base);
|
VInternalVariable::SetValue(d->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VVariable::VVariable(const QString &name, const qreal &base, const qreal &ksize, const qreal &kheight,
|
VVariable::VVariable(const QString &name, const qreal &base, const qreal &ksize, const qreal &kheight,
|
||||||
const QString &description)
|
const QString &description)
|
||||||
:VInternalVariable(), base(base), ksize(ksize), kheight(kheight), description(description)
|
:VInternalVariable(), d(new VVariableData(base, ksize, kheight, description))
|
||||||
{
|
{
|
||||||
VInternalVariable::SetValue(base);
|
VInternalVariable::SetValue(d->base);
|
||||||
SetName(name);
|
SetName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VVariable::VVariable(const QString &name, const qreal &base, const QString &description)
|
VVariable::VVariable(const QString &name, const qreal &base, const QString &description)
|
||||||
:base(base), ksize(0), kheight(0), description(description)
|
:d(new VVariableData(base, description))
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
VInternalVariable::SetValue(base);
|
VInternalVariable::SetValue(base);
|
||||||
|
@ -58,8 +59,7 @@ VVariable::VVariable(const QString &name, const qreal &base, const QString &desc
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VVariable::VVariable(const VVariable &var)
|
VVariable::VVariable(const VVariable &var)
|
||||||
:VInternalVariable(var), base(var.GetBase()), ksize(var.GetKsize()), kheight(var.GetKheight()),
|
:VInternalVariable(var), d(var.d)
|
||||||
description(var.GetDescription())
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -70,10 +70,7 @@ VVariable &VVariable::operator=(const VVariable &var)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
VInternalVariable::operator=(var);
|
VInternalVariable::operator=(var);
|
||||||
this->base = var.GetBase();
|
d = var.d;
|
||||||
this->ksize = var.GetKsize();
|
|
||||||
this->kheight = var.GetKheight();
|
|
||||||
this->description = var.GetDescription();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +94,7 @@ void VVariable::SetValue(const qreal &size, const qreal &height)
|
||||||
// Formula for calculation gradation
|
// Formula for calculation gradation
|
||||||
const qreal k_size = ( size - baseSize ) / sizeIncrement;
|
const qreal k_size = ( size - baseSize ) / sizeIncrement;
|
||||||
const qreal k_height = ( height - baseHeight ) / heightIncrement;
|
const qreal k_height = ( height - baseHeight ) / heightIncrement;
|
||||||
VInternalVariable::SetValue(base + k_size * ksize + k_height * kheight);
|
VInternalVariable::SetValue(d->base + k_size * d->ksize + k_height * d->kheight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -105,7 +102,69 @@ void VVariable::Init()
|
||||||
{
|
{
|
||||||
if (qApp->patternUnit() != Unit::Inch)
|
if (qApp->patternUnit() != Unit::Inch)
|
||||||
{
|
{
|
||||||
ksize = VAbstractMeasurements::UnitConvertor(50.0, Unit::Cm, qApp->patternUnit());
|
d->ksize = VAbstractMeasurements::UnitConvertor(50.0, Unit::Cm, qApp->patternUnit());
|
||||||
kheight = VAbstractMeasurements::UnitConvertor(176.0, Unit::Cm, qApp->patternUnit());
|
d->kheight = VAbstractMeasurements::UnitConvertor(176.0, Unit::Cm, qApp->patternUnit());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief GetBase return value in base size and height
|
||||||
|
* @return value
|
||||||
|
*/
|
||||||
|
qreal VVariable::GetBase() const
|
||||||
|
{
|
||||||
|
return d->base;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VVariable::SetBase(const qreal &value)
|
||||||
|
{
|
||||||
|
d->base = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief GetKsize return increment in sizes
|
||||||
|
* @return increment
|
||||||
|
*/
|
||||||
|
qreal VVariable::GetKsize() const
|
||||||
|
{
|
||||||
|
return d->ksize;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VVariable::SetKsize(const qreal &value)
|
||||||
|
{
|
||||||
|
d->ksize = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief GetKheight return increment in heights
|
||||||
|
* @return increment
|
||||||
|
*/
|
||||||
|
qreal VVariable::GetKheight() const
|
||||||
|
{
|
||||||
|
return d->kheight;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VVariable::SetKheight(const qreal &value)
|
||||||
|
{
|
||||||
|
d->kheight = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VVariable::GetDescription() const
|
||||||
|
{
|
||||||
|
return d->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VVariable::SetDescription(const QString &desc)
|
||||||
|
{
|
||||||
|
d->description = desc;
|
||||||
|
}
|
||||||
|
|
|
@ -31,11 +31,13 @@
|
||||||
|
|
||||||
#include "vinternalvariable.h"
|
#include "vinternalvariable.h"
|
||||||
|
|
||||||
|
class VVariableData;
|
||||||
|
|
||||||
class VVariable :public VInternalVariable
|
class VVariable :public VInternalVariable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VVariable();
|
VVariable();
|
||||||
VVariable(const QString &name, const qreal &base, const qreal &ksize, const qreal &kheight,
|
VVariable(const QString &name, const qreal &base, const qreal &ksize = 0, const qreal &kheight = 0,
|
||||||
const QString &description = QString());
|
const QString &description = QString());
|
||||||
VVariable(const QString &name, const qreal &base, const QString &description = QString());
|
VVariable(const QString &name, const qreal &base, const QString &description = QString());
|
||||||
VVariable(const VVariable &var);
|
VVariable(const VVariable &var);
|
||||||
|
@ -44,66 +46,20 @@ public:
|
||||||
|
|
||||||
qreal GetBase() const;
|
qreal GetBase() const;
|
||||||
void SetBase(const qreal &value);
|
void SetBase(const qreal &value);
|
||||||
|
|
||||||
qreal GetKsize() const;
|
qreal GetKsize() const;
|
||||||
|
void SetKsize(const qreal &value);
|
||||||
|
|
||||||
qreal GetKheight() const;
|
qreal GetKheight() const;
|
||||||
|
void SetKheight(const qreal &value);
|
||||||
|
|
||||||
QString GetDescription() const;
|
QString GetDescription() const;
|
||||||
|
void SetDescription(const QString &desc);
|
||||||
|
|
||||||
void SetValue(const qreal &size, const qreal &height);
|
void SetValue(const qreal &size, const qreal &height);
|
||||||
protected:
|
|
||||||
/** @brief base value in base size and height */
|
|
||||||
qreal base;
|
|
||||||
|
|
||||||
/** @brief ksize increment in sizes */
|
|
||||||
qreal ksize;
|
|
||||||
|
|
||||||
/** @brief kgrowth increment in heights */
|
|
||||||
qreal kheight;
|
|
||||||
|
|
||||||
/** @brief description description of increment */
|
|
||||||
QString description;
|
|
||||||
private:
|
private:
|
||||||
|
QSharedDataPointer<VVariableData> d;
|
||||||
void Init();
|
void Init();
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief GetBase return value in base size and height
|
|
||||||
* @return value
|
|
||||||
*/
|
|
||||||
inline qreal VVariable::GetBase() const
|
|
||||||
{
|
|
||||||
return base;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
inline void VVariable::SetBase(const qreal &value)
|
|
||||||
{
|
|
||||||
base = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief GetKsize return increment in sizes
|
|
||||||
* @return increment
|
|
||||||
*/
|
|
||||||
inline qreal VVariable::GetKsize() const
|
|
||||||
{
|
|
||||||
return ksize;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief GetKheight return increment in heights
|
|
||||||
* @return increment
|
|
||||||
*/
|
|
||||||
inline qreal VVariable::GetKheight() const
|
|
||||||
{
|
|
||||||
return kheight;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
inline QString VVariable::GetDescription() const
|
|
||||||
{
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // VVARIABLE_H
|
#endif // VVARIABLE_H
|
||||||
|
|
70
src/app/container/vvariable_p.h
Normal file
70
src/app/container/vvariable_p.h
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vvariable_p.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @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
|
||||||
|
** <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 VVARIABLE_P_H
|
||||||
|
#define VVARIABLE_P_H
|
||||||
|
|
||||||
|
#include <QSharedData>
|
||||||
|
#include "../options.h"
|
||||||
|
|
||||||
|
class VVariableData : public QSharedData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
VVariableData()
|
||||||
|
:base(0), ksize(0), kheight(0), description(QString())
|
||||||
|
{}
|
||||||
|
|
||||||
|
VVariableData(const qreal &base, const qreal &ksize, const qreal &kheight, const QString &description)
|
||||||
|
:base(base), ksize(ksize), kheight(kheight), description(description)
|
||||||
|
{}
|
||||||
|
|
||||||
|
VVariableData(const qreal &base, const QString &description)
|
||||||
|
:base(base), ksize(0), kheight(0), description(description)
|
||||||
|
{}
|
||||||
|
|
||||||
|
VVariableData(const VVariableData &var)
|
||||||
|
:QSharedData(var), base(var.base), ksize(var.ksize), kheight(var.kheight), description(var.description)
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual ~VVariableData() {}
|
||||||
|
|
||||||
|
/** @brief base value in base size and height */
|
||||||
|
qreal base;
|
||||||
|
|
||||||
|
/** @brief ksize increment in sizes */
|
||||||
|
qreal ksize;
|
||||||
|
|
||||||
|
/** @brief kgrowth increment in heights */
|
||||||
|
qreal kheight;
|
||||||
|
|
||||||
|
/** @brief description description of increment */
|
||||||
|
QString description;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VVARIABLE_P_H
|
|
@ -695,7 +695,7 @@ void DialogIncrements::IncrementChanged ( qint32 row, qint32 column )
|
||||||
{
|
{
|
||||||
doc->SetAttribute(domElement, VPattern::IncrementDescription, item->text());
|
doc->SetAttribute(domElement, VPattern::IncrementDescription, item->text());
|
||||||
VIncrement *incr = data->GetVariable<VIncrement*>(itemName->text());
|
VIncrement *incr = data->GetVariable<VIncrement*>(itemName->text());
|
||||||
incr->setDescription(item->text());
|
incr->SetDescription(item->text());
|
||||||
ui->tableWidgetIncrement->resizeColumnsToContents();
|
ui->tableWidgetIncrement->resizeColumnsToContents();
|
||||||
ui->tableWidgetIncrement->resizeRowsToContents();
|
ui->tableWidgetIncrement->resizeRowsToContents();
|
||||||
this->column = 0;
|
this->column = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user