Copy-on-write for class VPieceLabelData.
--HG-- branch : feature
This commit is contained in:
parent
2b1cd5c96c
commit
67a12ef86c
|
@ -29,6 +29,9 @@
|
||||||
#ifndef FLOATITEMDEF_H
|
#ifndef FLOATITEMDEF_H
|
||||||
#define FLOATITEMDEF_H
|
#define FLOATITEMDEF_H
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
// denotes the type of arrow for the grainline
|
// denotes the type of arrow for the grainline
|
||||||
enum class ArrowType : char
|
enum class ArrowType : char
|
||||||
{
|
{
|
||||||
|
@ -37,5 +40,40 @@ enum class ArrowType : char
|
||||||
atRear
|
atRear
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class MaterialType : char
|
||||||
|
{
|
||||||
|
mtFabric = 0,
|
||||||
|
mtLining = 1,
|
||||||
|
mtInterfacing = 2,
|
||||||
|
mtInterlining = 3,
|
||||||
|
mtUserDefined = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class PlacementType : char
|
||||||
|
{
|
||||||
|
ptNone = 0,
|
||||||
|
ptCutOnFold = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The MaterialCutPlacement struct used to hold a material, cut number and placement 3-tuple
|
||||||
|
*/
|
||||||
|
struct MaterialCutPlacement
|
||||||
|
{
|
||||||
|
MaterialType m_eMaterial;
|
||||||
|
QString m_qsMaterialUserDef;
|
||||||
|
int m_iCutNumber;
|
||||||
|
PlacementType m_ePlacement;
|
||||||
|
|
||||||
|
MaterialCutPlacement()
|
||||||
|
: m_eMaterial(MaterialType::mtFabric),
|
||||||
|
m_qsMaterialUserDef(),
|
||||||
|
m_iCutNumber(0),
|
||||||
|
m_ePlacement(PlacementType::ptNone)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef QList<MaterialCutPlacement> MCPContainer;
|
||||||
|
|
||||||
#endif // FLOATITEMDEF_H
|
#endif // FLOATITEMDEF_H
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ public:
|
||||||
quint32 BottomRightPin() const;
|
quint32 BottomRightPin() const;
|
||||||
void SetBottomRightPin(const quint32 &bottomRightPin);
|
void SetBottomRightPin(const quint32 &bottomRightPin);
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
QSharedDataPointer<VPatternLabelDataPrivate> d;
|
QSharedDataPointer<VPatternLabelDataPrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -27,24 +27,34 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vpiecelabeldata.h"
|
#include "vpiecelabeldata.h"
|
||||||
|
#include "vpiecelabeldata_p.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
MaterialCutPlacement::MaterialCutPlacement()
|
VPieceLabelData::VPieceLabelData()
|
||||||
: m_eMaterial(MaterialType::mtFabric),
|
: VPatternLabelData(),
|
||||||
m_qsMaterialUserDef(),
|
d(new VPieceLabelDataPrivate())
|
||||||
m_iCutNumber(0),
|
|
||||||
m_ePlacement(PlacementType::ptNone)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPieceLabelData::VPieceLabelData()
|
VPieceLabelData::VPieceLabelData(const VPieceLabelData &data)
|
||||||
: VPatternLabelData(),
|
: VPatternLabelData(data),
|
||||||
m_qsLetter(),
|
d (data.d)
|
||||||
m_conMCP()
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VPieceLabelData &VPieceLabelData::operator=(const VPieceLabelData &data)
|
||||||
|
{
|
||||||
|
if ( &data == this )
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
VPatternLabelData::operator=(data);
|
||||||
|
d = data.d;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPieceLabelData::~VPieceLabelData()
|
VPieceLabelData::~VPieceLabelData()
|
||||||
{}
|
{}
|
||||||
|
@ -52,7 +62,7 @@ VPieceLabelData::~VPieceLabelData()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPieceLabelData::Append(const MaterialCutPlacement& rMCP)
|
void VPieceLabelData::Append(const MaterialCutPlacement& rMCP)
|
||||||
{
|
{
|
||||||
m_conMCP.append(rMCP);
|
d->m_conMCP.append(rMCP);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -60,7 +70,7 @@ void VPieceLabelData::Insert(int i, const MaterialCutPlacement& rMCP)
|
||||||
{
|
{
|
||||||
Q_ASSERT(i >= 0);
|
Q_ASSERT(i >= 0);
|
||||||
Q_ASSERT(i <= GetMCPCount());
|
Q_ASSERT(i <= GetMCPCount());
|
||||||
m_conMCP.insert(i, rMCP);
|
d->m_conMCP.insert(i, rMCP);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -68,13 +78,13 @@ void VPieceLabelData::Set(int i, const MaterialCutPlacement& rMCP)
|
||||||
{
|
{
|
||||||
Q_ASSERT(i >= 0);
|
Q_ASSERT(i >= 0);
|
||||||
Q_ASSERT(i < GetMCPCount());
|
Q_ASSERT(i < GetMCPCount());
|
||||||
m_conMCP[i] = rMCP;
|
d->m_conMCP[i] = rMCP;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
int VPieceLabelData::GetMCPCount() const
|
int VPieceLabelData::GetMCPCount() const
|
||||||
{
|
{
|
||||||
return m_conMCP.count();
|
return d->m_conMCP.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -82,7 +92,7 @@ const MaterialCutPlacement& VPieceLabelData::GetMCP(int i) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(i >= 0);
|
Q_ASSERT(i >= 0);
|
||||||
Q_ASSERT(i < GetMCPCount());
|
Q_ASSERT(i < GetMCPCount());
|
||||||
return m_conMCP.at(i);
|
return d->m_conMCP.at(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -90,24 +100,24 @@ void VPieceLabelData::RemoveMCP(int i)
|
||||||
{
|
{
|
||||||
Q_ASSERT(i >= 0);
|
Q_ASSERT(i >= 0);
|
||||||
Q_ASSERT(i < GetMCPCount());
|
Q_ASSERT(i < GetMCPCount());
|
||||||
m_conMCP.removeAt(i);
|
d->m_conMCP.removeAt(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPieceLabelData::Clear()
|
void VPieceLabelData::Clear()
|
||||||
{
|
{
|
||||||
m_qsLetter.clear();
|
d->m_qsLetter.clear();
|
||||||
m_conMCP.clear();
|
d->m_conMCP.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
const QString& VPieceLabelData::GetLetter() const
|
const QString& VPieceLabelData::GetLetter() const
|
||||||
{
|
{
|
||||||
return m_qsLetter;
|
return d->m_qsLetter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPieceLabelData::SetLetter(QString qsLetter)
|
void VPieceLabelData::SetLetter(QString qsLetter)
|
||||||
{
|
{
|
||||||
m_qsLetter = qsLetter.left(3);
|
d->m_qsLetter = qsLetter.left(3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,40 +29,12 @@
|
||||||
#ifndef VPATTERNPIECEDATA_H
|
#ifndef VPATTERNPIECEDATA_H
|
||||||
#define VPATTERNPIECEDATA_H
|
#define VPATTERNPIECEDATA_H
|
||||||
|
|
||||||
#include <QList>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "vpatternlabeldata.h"
|
#include "vpatternlabeldata.h"
|
||||||
|
#include "floatitemdef.h"
|
||||||
|
|
||||||
enum class MaterialType : char
|
class VPieceLabelDataPrivate;
|
||||||
{
|
|
||||||
mtFabric = 0,
|
|
||||||
mtLining = 1,
|
|
||||||
mtInterfacing = 2,
|
|
||||||
mtInterlining = 3,
|
|
||||||
mtUserDefined = 4
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class PlacementType : char
|
|
||||||
{
|
|
||||||
ptNone = 0,
|
|
||||||
ptCutOnFold = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The MaterialCutPlacement struct used to hold a material, cut number and placement 3-tuple
|
|
||||||
*/
|
|
||||||
struct MaterialCutPlacement
|
|
||||||
{
|
|
||||||
MaterialType m_eMaterial;
|
|
||||||
QString m_qsMaterialUserDef;
|
|
||||||
int m_iCutNumber;
|
|
||||||
PlacementType m_ePlacement;
|
|
||||||
|
|
||||||
MaterialCutPlacement();
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef QList<MaterialCutPlacement> MCPContainer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VPieceLabelData class holds some information about a single
|
* @brief The VPieceLabelData class holds some information about a single
|
||||||
|
@ -72,6 +44,8 @@ class VPieceLabelData : public VPatternLabelData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VPieceLabelData();
|
VPieceLabelData();
|
||||||
|
VPieceLabelData(const VPieceLabelData &data);
|
||||||
|
VPieceLabelData &operator=(const VPieceLabelData &data);
|
||||||
virtual ~VPieceLabelData();
|
virtual ~VPieceLabelData();
|
||||||
|
|
||||||
// methods, which operate on MaterialCutPlacement container
|
// methods, which operate on MaterialCutPlacement container
|
||||||
|
@ -88,10 +62,7 @@ public:
|
||||||
void SetLetter(QString qsLetter);
|
void SetLetter(QString qsLetter);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** @brief m_qsLetter Detail letter (should be no more than 3 characters) */
|
QSharedDataPointer<VPieceLabelDataPrivate> d;
|
||||||
QString m_qsLetter;
|
|
||||||
/** @brief m_conMCP List of material, cut, placement tuples */
|
|
||||||
MCPContainer m_conMCP;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VPATTERNPIECEDATA_H
|
#endif // VPATTERNPIECEDATA_H
|
||||||
|
|
72
src/libs/vpatterndb/floatItemData/vpiecelabeldata_p.h
Normal file
72
src/libs/vpatterndb/floatItemData/vpiecelabeldata_p.h
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 23 2, 2017
|
||||||
|
**
|
||||||
|
** @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) 2017 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 VPIECELABELDATA_P_H
|
||||||
|
#define VPIECELABELDATA_P_H
|
||||||
|
|
||||||
|
#include <QSharedData>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
#include "../vmisc/diagnostic.h"
|
||||||
|
#include "floatitemdef.h"
|
||||||
|
|
||||||
|
QT_WARNING_PUSH
|
||||||
|
QT_WARNING_DISABLE_GCC("-Weffc++")
|
||||||
|
|
||||||
|
class VPieceLabelDataPrivate : public QSharedData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VPieceLabelDataPrivate()
|
||||||
|
: m_qsLetter(),
|
||||||
|
m_conMCP()
|
||||||
|
{}
|
||||||
|
|
||||||
|
VPieceLabelDataPrivate(const VPieceLabelDataPrivate &data)
|
||||||
|
: QSharedData(data),
|
||||||
|
m_qsLetter(data.m_qsLetter),
|
||||||
|
m_conMCP(data.m_conMCP)
|
||||||
|
{}
|
||||||
|
|
||||||
|
~VPieceLabelDataPrivate();
|
||||||
|
|
||||||
|
/** @brief m_qsLetter Detail letter (should be no more than 3 characters) */
|
||||||
|
QString m_qsLetter;
|
||||||
|
/** @brief m_conMCP List of material, cut, placement tuples */
|
||||||
|
MCPContainer m_conMCP;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VPieceLabelDataPrivate &operator=(const VPieceLabelDataPrivate &) Q_DECL_EQ_DELETE;
|
||||||
|
};
|
||||||
|
|
||||||
|
VPieceLabelDataPrivate::~VPieceLabelDataPrivate()
|
||||||
|
{}
|
||||||
|
|
||||||
|
QT_WARNING_POP
|
||||||
|
|
||||||
|
#endif // VPIECELABELDATA_P_H
|
||||||
|
|
|
@ -71,4 +71,5 @@ HEADERS += \
|
||||||
$$PWD/floatItemData/vabstractfloatitemdata_p.h \
|
$$PWD/floatItemData/vabstractfloatitemdata_p.h \
|
||||||
$$PWD/floatItemData/vgrainlinedata_p.h \
|
$$PWD/floatItemData/vgrainlinedata_p.h \
|
||||||
$$PWD/floatItemData/floatitemdef.h \
|
$$PWD/floatItemData/floatitemdef.h \
|
||||||
$$PWD/floatItemData/vpatternlabeldata_p.h
|
$$PWD/floatItemData/vpatternlabeldata_p.h \
|
||||||
|
$$PWD/floatItemData/vpiecelabeldata_p.h
|
||||||
|
|
Loading…
Reference in New Issue
Block a user