diff options
Diffstat (limited to 'src/uml/qumllinkenddata.cpp')
-rw-r--r-- | src/uml/qumllinkenddata.cpp | 145 |
1 files changed, 65 insertions, 80 deletions
diff --git a/src/uml/qumllinkenddata.cpp b/src/uml/qumllinkenddata.cpp index b3dd203d..b0bd6cde 100644 --- a/src/uml/qumllinkenddata.cpp +++ b/src/uml/qumllinkenddata.cpp @@ -40,133 +40,118 @@ ****************************************************************************/ #include "qumllinkenddata.h" -#include <QtUml/QUmlComment> -#include <QtUml/QUmlElement> +#include "private/qumllinkenddataobject_p.h" + #include <QtUml/QUmlInputPin> #include <QtUml/QUmlProperty> #include <QtUml/QUmlQualifierValue> -QT_BEGIN_NAMESPACE - /*! - \class UmlLinkEndData + \class QUmlLinkEndData \inmodule QtUml \brief A link end data is not an action. It is an element that identifies links. It identifies one end of a link to be read or written by the children of a link action. A link cannot be passed as a runtime value to or from an action. Instead, a link is identified by its end objects and qualifier values, if any. This requires more than one piece of data, namely, the statically-specified end in the user model, the object on the end, and the qualifier values for that end, if any. These pieces are brought together around a link end data. Each association end is identified separately with an instance of the LinkEndData class. */ - -QUmlLinkEndData::QUmlLinkEndData(QObject *parent) : - QObject(parent) -{ -} - -// OWNED ATTRIBUTES [Element] - -/*! - The Comments owned by this element. - */ -const QSet<QUmlComment *> QUmlLinkEndData::ownedComment() const -{ - return *(reinterpret_cast<const QSet<QUmlComment *> *>(&_ownedComment)); -} - -/*! - The Elements owned by this element. - */ -const QSet<QUmlElement *> QUmlLinkEndData::ownedElement() const +QUmlLinkEndData::QUmlLinkEndData(bool createQObject) : + _end(0), + _value(0) { - return *(reinterpret_cast<const QSet<QUmlElement *> *>(&_ownedElement)); + if (createQObject) + _qObject = new QUmlLinkEndDataObject(this); } -/*! - The Element that owns this element. - */ -QUmlElement *QUmlLinkEndData::owner() const +QUmlLinkEndData::~QUmlLinkEndData() { - return reinterpret_cast<QUmlElement *>(_owner); + if (!deletingFromQObject) { + _qObject->setProperty("deletingFromModelingObject", true); + delete _qObject; + } } -// OWNED ATTRIBUTES [LinkEndData] +// OWNED ATTRIBUTES /*! Association end for which this link-end data specifies values. */ -QUmlProperty *QUmlLinkEndData::end() const +QUmlProperty * +QUmlLinkEndData::end() const { - return reinterpret_cast<QUmlProperty *>(_end); -} + // This is a read-write association end -/*! - List of qualifier values - */ -const QSet<QUmlQualifierValue *> QUmlLinkEndData::qualifier() const -{ - return *(reinterpret_cast<const QSet<QUmlQualifierValue *> *>(&_qualifier)); + return _end; } -/*! - Input pin that provides the specified object for the given end. This pin is omitted if the link-end data specifies an 'open' end for reading. - */ -QUmlInputPin *QUmlLinkEndData::value() const +void QUmlLinkEndData::setEnd(QUmlProperty *end) { - return reinterpret_cast<QUmlInputPin *>(_value); -} + // This is a read-write association end -// OPERATIONS [Element] + if (_end != end) { + _end = end; + if (end->asQObject() && this->asQObject()) + QObject::connect(end->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setEnd())); + } +} /*! - The query allOwnedElements() gives all of the direct and indirect owned elements of an element. + List of qualifier values */ -QSet<QUmlElement *> QUmlLinkEndData::allOwnedElements() const +const QSet<QUmlQualifierValue *> +QUmlLinkEndData::qualifier() const { - QSet<QUmlElement *> r; - foreach (UmlElement *element, UmlElement::allOwnedElements()) - r.insert(reinterpret_cast<QUmlElement *>(element)); - return r; + // This is a read-write association end + + return _qualifier; } -/*! - The query mustBeOwned() indicates whether elements of this type must have an owner. Subclasses of Element that do not require an owner must override this operation. - */ -bool QUmlLinkEndData::mustBeOwned() const +void QUmlLinkEndData::addQualifier(QUmlQualifierValue *qualifier) { - return UmlElement::mustBeOwned(); -} + // This is a read-write association end -// SLOTS FOR OWNED ATTRIBUTES [Element] + if (!_qualifier.contains(qualifier)) { + _qualifier.insert(qualifier); + if (qualifier->asQObject() && this->asQObject()) + QObject::connect(qualifier->asQObject(), SIGNAL(destroyed(QObject*)), this->asQObject(), SLOT(removeQualifier(QObject *))); + qualifier->asQObject()->setParent(this->asQObject()); -void QUmlLinkEndData::addOwnedComment(UmlComment *ownedComment) -{ - UmlElement::addOwnedComment(ownedComment); + // Adjust subsetted properties + addOwnedElement(qualifier); + } } -void QUmlLinkEndData::removeOwnedComment(UmlComment *ownedComment) +void QUmlLinkEndData::removeQualifier(QUmlQualifierValue *qualifier) { - UmlElement::removeOwnedComment(ownedComment); -} + // This is a read-write association end -// SLOTS FOR OWNED ATTRIBUTES [LinkEndData] + if (_qualifier.contains(qualifier)) { + _qualifier.remove(qualifier); + if (qualifier->asQObject()) + qualifier->asQObject()->setParent(0); -void QUmlLinkEndData::setEnd(QUmlProperty *end) -{ - UmlLinkEndData::setEnd(end); + // Adjust subsetted properties + removeOwnedElement(qualifier); + } } -void QUmlLinkEndData::addQualifier(UmlQualifierValue *qualifier) +/*! + Input pin that provides the specified object for the given end. This pin is omitted if the link-end data specifies an 'open' end for reading. + */ +QUmlInputPin * +QUmlLinkEndData::value() const { - UmlLinkEndData::addQualifier(qualifier); -} + // This is a read-write association end -void QUmlLinkEndData::removeQualifier(UmlQualifierValue *qualifier) -{ - UmlLinkEndData::removeQualifier(qualifier); + return _value; } void QUmlLinkEndData::setValue(QUmlInputPin *value) { - UmlLinkEndData::setValue(value); -} + // This is a read-write association end -QT_END_NAMESPACE + if (_value != value) { + _value = value; + if (value->asQObject() && this->asQObject()) + QObject::connect(value->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setValue())); + } +} |