Copy-on-write for class VAbstractFloatItemData.
--HG-- branch : feature
This commit is contained in:
parent
c5c3c73429
commit
9714e8cb07
|
@ -27,13 +27,29 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vabstractfloatitemdata.h"
|
#include "vabstractfloatitemdata.h"
|
||||||
|
#include "vabstractfloatitemdata_p.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VAbstractFloatItemData::VAbstractFloatItemData()
|
VAbstractFloatItemData::VAbstractFloatItemData()
|
||||||
: m_ptPos(),
|
: d(new VAbstractFloatItemDataPrivate())
|
||||||
m_bVisible(false)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VAbstractFloatItemData::VAbstractFloatItemData(const VAbstractFloatItemData &data)
|
||||||
|
: d (data.d)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VAbstractFloatItemData &VAbstractFloatItemData::operator=(const VAbstractFloatItemData &data)
|
||||||
|
{
|
||||||
|
if ( &data == this )
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
d = data.d;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VAbstractFloatItemData::~VAbstractFloatItemData()
|
VAbstractFloatItemData::~VAbstractFloatItemData()
|
||||||
{}
|
{}
|
||||||
|
@ -41,23 +57,23 @@ VAbstractFloatItemData::~VAbstractFloatItemData()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QPointF VAbstractFloatItemData::GetPos() const
|
QPointF VAbstractFloatItemData::GetPos() const
|
||||||
{
|
{
|
||||||
return m_ptPos;
|
return d->m_ptPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractFloatItemData::SetPos(const QPointF &ptPos)
|
void VAbstractFloatItemData::SetPos(const QPointF &ptPos)
|
||||||
{
|
{
|
||||||
m_ptPos = ptPos;
|
d->m_ptPos = ptPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool VAbstractFloatItemData::IsVisible() const
|
bool VAbstractFloatItemData::IsVisible() const
|
||||||
{
|
{
|
||||||
return m_bVisible;
|
return d->m_bVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractFloatItemData::SetVisible(bool bVisible)
|
void VAbstractFloatItemData::SetVisible(bool bVisible)
|
||||||
{
|
{
|
||||||
m_bVisible = bVisible;
|
d->m_bVisible = bVisible;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,16 @@
|
||||||
#define VABSTRACTFLOATITEMDATA_H
|
#define VABSTRACTFLOATITEMDATA_H
|
||||||
|
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
|
#include <QSharedDataPointer>
|
||||||
|
|
||||||
|
class VAbstractFloatItemDataPrivate;
|
||||||
|
|
||||||
class VAbstractFloatItemData
|
class VAbstractFloatItemData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VAbstractFloatItemData();
|
VAbstractFloatItemData();
|
||||||
|
VAbstractFloatItemData(const VAbstractFloatItemData &data);
|
||||||
|
VAbstractFloatItemData &operator=(const VAbstractFloatItemData &data);
|
||||||
virtual ~VAbstractFloatItemData();
|
virtual ~VAbstractFloatItemData();
|
||||||
|
|
||||||
// methods, which set and return values of different parameters
|
// methods, which set and return values of different parameters
|
||||||
|
@ -44,11 +49,8 @@ public:
|
||||||
bool IsVisible() const;
|
bool IsVisible() const;
|
||||||
void SetVisible(bool bVisible);
|
void SetVisible(bool bVisible);
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
/** @brief m_ptPos position of label's top left corner */
|
QSharedDataPointer<VAbstractFloatItemDataPrivate> d;
|
||||||
QPointF m_ptPos;
|
|
||||||
/** @brief m_bVisible visibility flag */
|
|
||||||
bool m_bVisible;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VABSTRACTFLOATITEMDATA_H
|
#endif // VABSTRACTFLOATITEMDATA_H
|
||||||
|
|
71
src/libs/vpatterndb/floatItemData/vabstractfloatitemdata_p.h
Normal file
71
src/libs/vpatterndb/floatItemData/vabstractfloatitemdata_p.h
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @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 VABSTRACTFLOATITEMDATA_P_H
|
||||||
|
#define VABSTRACTFLOATITEMDATA_P_H
|
||||||
|
|
||||||
|
#include <QPointF>
|
||||||
|
#include <QSharedData>
|
||||||
|
|
||||||
|
#include "../vmisc/diagnostic.h"
|
||||||
|
|
||||||
|
QT_WARNING_PUSH
|
||||||
|
QT_WARNING_DISABLE_GCC("-Weffc++")
|
||||||
|
|
||||||
|
class VAbstractFloatItemDataPrivate : public QSharedData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VAbstractFloatItemDataPrivate()
|
||||||
|
: m_ptPos(),
|
||||||
|
m_bVisible(false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
VAbstractFloatItemDataPrivate(const VAbstractFloatItemDataPrivate &data)
|
||||||
|
: QSharedData(data),
|
||||||
|
m_ptPos(data.m_ptPos),
|
||||||
|
m_bVisible(data.m_bVisible)
|
||||||
|
{}
|
||||||
|
|
||||||
|
~VAbstractFloatItemDataPrivate();
|
||||||
|
|
||||||
|
/** @brief m_ptPos position of label's top left corner */
|
||||||
|
QPointF m_ptPos;
|
||||||
|
/** @brief m_bVisible visibility flag */
|
||||||
|
bool m_bVisible;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VAbstractFloatItemDataPrivate &operator=(const VAbstractFloatItemDataPrivate &) Q_DECL_EQ_DELETE;
|
||||||
|
};
|
||||||
|
|
||||||
|
VAbstractFloatItemDataPrivate::~VAbstractFloatItemDataPrivate()
|
||||||
|
{}
|
||||||
|
|
||||||
|
QT_WARNING_POP
|
||||||
|
|
||||||
|
#endif // VABSTRACTFLOATITEMDATA_P_H
|
||||||
|
|
|
@ -67,4 +67,5 @@ HEADERS += \
|
||||||
$$PWD/floatItemData/vpiecelabeldata.h \
|
$$PWD/floatItemData/vpiecelabeldata.h \
|
||||||
$$PWD/floatItemData/vpatternlabeldata.h \
|
$$PWD/floatItemData/vpatternlabeldata.h \
|
||||||
$$PWD/floatItemData/vgrainlinedata.h \
|
$$PWD/floatItemData/vgrainlinedata.h \
|
||||||
$$PWD/floatItemData/vabstractfloatitemdata.h
|
$$PWD/floatItemData/vabstractfloatitemdata.h \
|
||||||
|
$$PWD/floatItemData/vabstractfloatitemdata_p.h
|
||||||
|
|
Loading…
Reference in New Issue
Block a user