From 788aa92d44ff73b81a5f7a858059b7fea87f50d3 Mon Sep 17 00:00:00 2001
From: Roman Telezhynskyi <dismine@gmail.com>
Date: Wed, 4 Nov 2020 10:55:34 +0200
Subject: [PATCH] Add alias attribute for geometric object.

---
 src/libs/vgeometry/vgobject.cpp | 30 ++++++++++++++++++++++++++++++
 src/libs/vgeometry/vgobject.h   |  8 ++++++++
 src/libs/vgeometry/vgobject_p.h | 27 +++++++++++++++++++--------
 3 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/src/libs/vgeometry/vgobject.cpp b/src/libs/vgeometry/vgobject.cpp
index b49269a4f..5f30ba6b6 100644
--- a/src/libs/vgeometry/vgobject.cpp
+++ b/src/libs/vgeometry/vgobject.cpp
@@ -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
 {
diff --git a/src/libs/vgeometry/vgobject.h b/src/libs/vgeometry/vgobject.h
index e402ad037..2078d40c8 100644
--- a/src/libs/vgeometry/vgobject.h
+++ b/src/libs/vgeometry/vgobject.h
@@ -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;
diff --git a/src/libs/vgeometry/vgobject_p.h b/src/libs/vgeometry/vgobject_p.h
index cddf99acf..963956e87 100644
--- a/src/libs/vgeometry/vgobject_p.h
+++ b/src/libs/vgeometry/vgobject_p.h
@@ -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)