Add alias attribute for geometric object.

This commit is contained in:
Roman Telezhynskyi 2020-11-04 10:55:34 +02:00
parent 8a6003752e
commit 788aa92d44
3 changed files with 57 additions and 8 deletions

View File

@ -243,6 +243,36 @@ void VGObject::setId(const quint32 &id)
d->_id = id;
}
//---------------------------------------------------------------------------------------------------------------------
void VGObject::SetAlias(const QString &alias)
{
d->m_alias = alias;
}
//---------------------------------------------------------------------------------------------------------------------
QString VGObject::GetAlias() const
{
return d->m_alias;
}
//---------------------------------------------------------------------------------------------------------------------
void VGObject::SetAliasSuffix(const QString &aliasSuffix)
{
d->m_aliasSuffix = aliasSuffix;
}
//---------------------------------------------------------------------------------------------------------------------
QString VGObject::GetAliasSuffix() const
{
return d->m_aliasSuffix;
}
//---------------------------------------------------------------------------------------------------------------------
QString VGObject::ObjectName() const
{
return not d->m_alias.isEmpty() ? QString("%1 (%2)").arg(d->m_alias, d->_name) : d->_name;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VGObject::getIdTool() const
{

View File

@ -78,6 +78,14 @@ public:
quint32 id() const;
virtual void setId(const quint32 &id);
void SetAlias(const QString &alias);
QString GetAlias() const;
virtual void SetAliasSuffix(const QString &aliasSuffix);
QString GetAliasSuffix() const;
QString ObjectName() const;
quint32 getIdTool() const;
virtual QJsonObject ToJson() const;

View File

@ -42,33 +42,44 @@ class VGObjectData : public QSharedData
{
public:
VGObjectData()
:_id(NULL_ID), type(GOType::Unknown), idObject(NULL_ID), _name(QString()), mode(Draw::Calculation)
{}
VGObjectData(const GOType &type, const quint32 &idObject, const Draw &mode)
:_id(NULL_ID), type(type), idObject(idObject), _name(QString()), mode(mode)
:type(type),
idObject(idObject),
mode(mode)
{}
VGObjectData(const VGObjectData &obj)
:QSharedData(obj), _id(obj._id), type(obj.type), idObject(obj.idObject), _name(obj._name), mode(obj.mode)
:QSharedData(obj),
_id(obj._id),
type(obj.type),
idObject(obj.idObject),
_name(obj._name),
mode(obj.mode),
m_alias(obj.m_alias),
m_aliasSuffix(obj.m_aliasSuffix)
{}
virtual ~VGObjectData();
/** @brief _id id in container. Ned for arcs, spline and spline paths. */
quint32 _id;
quint32 _id{NULL_ID};
/** @brief type type of graphical object */
GOType type;
GOType type{GOType::Unknown};
/** @brief idObject id of parent object. */
quint32 idObject;
quint32 idObject{NULL_ID};
/** @brief _name object name */
QString _name;
QString _name{};
/** @brief mode object created in calculation or drawing mode */
Draw mode;
Draw mode{Draw::Calculation};
QString m_alias{};
QString m_aliasSuffix{};
private:
Q_DISABLE_ASSIGN(VGObjectData)