From fcbc1b3aefa7d31722cccb85cd1e4b91a094f9ce Mon Sep 17 00:00:00 2001 From: Tats Date: Sat, 5 Mar 2016 16:56:31 -0500 Subject: [PATCH] Arranged name properties in Element.cpp. --- Element.cpp | 11 +++++++++-- Element.h | 5 ++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Element.cpp b/Element.cpp index 7240926..25c68b9 100644 --- a/Element.cpp +++ b/Element.cpp @@ -32,14 +32,21 @@ Element::Element(uid id, UidAllocator* allocator) : _name(""), _isLocked(false), } // Assign id. _id = id; - // Reset name. - unsetName(); } Element::~Element() { _allocator->free(_id); } +void Element::setName(const QString& name) +{ + if (name != _name) + { + _name = name; + _emitPropertyChanged("name"); + } +} + void Element::setLocked(bool locked) { if (locked != _isLocked) diff --git a/Element.h b/Element.h index fafe6d2..6199801 100644 --- a/Element.h +++ b/Element.h @@ -35,7 +35,7 @@ class Element : public Serializable Q_OBJECT Q_PROPERTY(uid id READ getId) - Q_PROPERTY(QString name READ getName WRITE setName RESET unsetName) + Q_PROPERTY(QString name READ getName WRITE setName) Q_PROPERTY(bool locked READ isLocked WRITE setLocked) Q_PROPERTY(float opacity READ getOpacity WRITE setOpacity NOTIFY propertyChanged) Q_PROPERTY(QIcon icon READ getIcon) @@ -48,9 +48,8 @@ public: uid getId() const { return _id; } - void setName(const QString& name) { _name = name; } + void setName(const QString& name); QString getName() const { return _name; } - virtual void unsetName() { _name = _id; } float getOpacity() const { return _opacity; } void setOpacity(float opacity);