Commit ec44b8bc authored by Ralf Habacker's avatar Ralf Habacker

Let client code use UMLCancasObject::subordinates() instead of accessing class member directly.

Make UMLCancasObject::m_List a private variable and replace references
to UMLCancasObject::m_List with UMLCancasObject::subordinates().

This makes it possible to deal with zero pointers in one place.
parent 028ecc83
...@@ -305,7 +305,7 @@ UMLOperation* UMLClassifier::createOperation( ...@@ -305,7 +305,7 @@ UMLOperation* UMLClassifier::createOperation(
bool UMLClassifier::addOperation(UMLOperation* op, int position) bool UMLClassifier::addOperation(UMLOperation* op, int position)
{ {
Q_ASSERT(op); Q_ASSERT(op);
if (m_List.indexOf(op) != -1) { if (subordinates().indexOf(op) != -1) {
uDebug() << "findRef(" << op->name() << ") finds op (bad)"; uDebug() << "findRef(" << op->name() << ") finds op (bad)";
return false; return false;
} }
...@@ -314,9 +314,9 @@ bool UMLClassifier::addOperation(UMLOperation* op, int position) ...@@ -314,9 +314,9 @@ bool UMLClassifier::addOperation(UMLOperation* op, int position)
return false; return false;
} }
if (position >= 0 && position <= m_List.count()) { if (position >= 0 && position <= subordinates().count()) {
uDebug() << op->name() << ": inserting at position " << position; uDebug() << op->name() << ": inserting at position " << position;
m_List.insert(position, op); subordinates().insert(position, op);
UMLClassifierListItemList itemList = getFilteredList(UMLObject::ot_Operation); UMLClassifierListItemList itemList = getFilteredList(UMLObject::ot_Operation);
QString buf; QString buf;
foreach (UMLClassifierListItem* currentAtt, itemList) { foreach (UMLClassifierListItem* currentAtt, itemList) {
...@@ -325,7 +325,7 @@ bool UMLClassifier::addOperation(UMLOperation* op, int position) ...@@ -325,7 +325,7 @@ bool UMLClassifier::addOperation(UMLOperation* op, int position)
uDebug() << " list after change: " << buf; uDebug() << " list after change: " << buf;
} }
else { else {
m_List.append(op); subordinates().append(op);
} }
emit operationAdded(op); emit operationAdded(op);
UMLObject::emitModified(); UMLObject::emitModified();
...@@ -368,7 +368,7 @@ int UMLClassifier::removeOperation(UMLOperation *op) ...@@ -368,7 +368,7 @@ int UMLClassifier::removeOperation(UMLOperation *op)
uDebug() << "called on NULL op"; uDebug() << "called on NULL op";
return -1; return -1;
} }
if (!m_List.removeAll(op)) { if (!subordinates().removeAll(op)) {
uDebug() << "cannot find op " << op->name() << " in list"; uDebug() << "cannot find op " << op->name() << " in list";
return -1; return -1;
} }
...@@ -377,7 +377,7 @@ int UMLClassifier::removeOperation(UMLOperation *op) ...@@ -377,7 +377,7 @@ int UMLClassifier::removeOperation(UMLOperation *op)
disconnect(op, SIGNAL(modified()), this, SIGNAL(modified())); disconnect(op, SIGNAL(modified()), this, SIGNAL(modified()));
emit operationRemoved(op); emit operationRemoved(op);
UMLObject::emitModified(); UMLObject::emitModified();
return m_List.count(); return subordinates().count();
} }
/** /**
...@@ -431,7 +431,7 @@ UMLObject* UMLClassifier::createTemplate(const QString& currentName /*= QString( ...@@ -431,7 +431,7 @@ UMLObject* UMLClassifier::createTemplate(const QString& currentName /*= QString(
UMLAttributeList UMLClassifier::getAttributeList() const UMLAttributeList UMLClassifier::getAttributeList() const
{ {
UMLAttributeList attributeList; UMLAttributeList attributeList;
foreach (UMLObject* listItem, m_List) { foreach (UMLObject* listItem, subordinates()) {
uIgnoreZeroPointer(listItem); uIgnoreZeroPointer(listItem);
if (listItem->baseType() == UMLObject::ot_Attribute) { if (listItem->baseType() == UMLObject::ot_Attribute) {
attributeList.append(listItem->asUMLAttribute()); attributeList.append(listItem->asUMLAttribute());
...@@ -519,7 +519,7 @@ UMLOperationList UMLClassifier::findOperations(const QString &n) ...@@ -519,7 +519,7 @@ UMLOperationList UMLClassifier::findOperations(const QString &n)
{ {
const bool caseSensitive = UMLApp::app()->activeLanguageIsCaseSensitive(); const bool caseSensitive = UMLApp::app()->activeLanguageIsCaseSensitive();
UMLOperationList list; UMLOperationList list;
foreach (UMLObject* obj, m_List) { foreach (UMLObject* obj, subordinates()) {
uIgnoreZeroPointer(obj); uIgnoreZeroPointer(obj);
if (obj->baseType() != UMLObject::ot_Operation) if (obj->baseType() != UMLObject::ot_Operation)
continue; continue;
...@@ -650,8 +650,8 @@ void UMLClassifier::copyInto(UMLObject *lhs) const ...@@ -650,8 +650,8 @@ void UMLClassifier::copyInto(UMLObject *lhs) const
UMLCanvasObject::copyInto(target); UMLCanvasObject::copyInto(target);
target->setBaseType(m_BaseType); target->setBaseType(m_BaseType);
// CHECK: association property m_pClassAssoc is not copied // CHECK: association property m_pClassAssoc is not copied
m_List.copyInto(&(target->m_List)); subordinates().copyInto(&(target->subordinates()));
foreach(UMLObject *o, target->m_List) { foreach(UMLObject *o, target->subordinates()) {
uIgnoreZeroPointer(o); uIgnoreZeroPointer(o);
o->setUMLParent(target); o->setUMLParent(target);
} }
...@@ -679,11 +679,11 @@ bool UMLClassifier::resolveRef() ...@@ -679,11 +679,11 @@ bool UMLClassifier::resolveRef()
{ {
bool success = UMLPackage::resolveRef(); bool success = UMLPackage::resolveRef();
// Using reentrant iteration is a bare necessity here: // Using reentrant iteration is a bare necessity here:
foreach (UMLObject* obj, m_List) { foreach (UMLObject* obj, subordinates()) {
uIgnoreZeroPointer(obj); uIgnoreZeroPointer(obj);
/**** For reference, here is the non-reentrant iteration scheme - /**** For reference, here is the non-reentrant iteration scheme -
DO NOT USE THIS ! DO NOT USE THIS !
for (UMLObject *obj = m_List.first(); obj; obj = m_List.next()) for (UMLObject *obj = subordinates().first(); obj; obj = subordinates().next())
{ .... } { .... }
****/ ****/
if (obj->resolveRef()) { if (obj->resolveRef()) {
...@@ -797,14 +797,14 @@ UMLAttribute* UMLClassifier::createAttribute(const QString &name, ...@@ -797,14 +797,14 @@ UMLAttribute* UMLClassifier::createAttribute(const QString &name,
UMLAttribute* UMLClassifier::addAttribute(const QString &name, Uml::ID::Type id /* = Uml::id_None */) UMLAttribute* UMLClassifier::addAttribute(const QString &name, Uml::ID::Type id /* = Uml::id_None */)
{ {
foreach (UMLObject* obj, m_List) { foreach (UMLObject* obj, subordinates()) {
uIgnoreZeroPointer(obj); uIgnoreZeroPointer(obj);
if (obj->baseType() == UMLObject::ot_Attribute && obj->name() == name) if (obj->baseType() == UMLObject::ot_Attribute && obj->name() == name)
return obj->asUMLAttribute(); return obj->asUMLAttribute();
} }
Uml::Visibility::Enum scope = Settings::optionState().classState.defaultAttributeScope; Uml::Visibility::Enum scope = Settings::optionState().classState.defaultAttributeScope;
UMLAttribute *a = new UMLAttribute(this, name, id, scope); UMLAttribute *a = new UMLAttribute(this, name, id, scope);
m_List.append(a); subordinates().append(a);
emit attributeAdded(a); emit attributeAdded(a);
UMLObject::emitModified(); UMLObject::emitModified();
connect(a, SIGNAL(modified()), this, SIGNAL(modified())); connect(a, SIGNAL(modified()), this, SIGNAL(modified()));
...@@ -829,7 +829,7 @@ UMLAttribute* UMLClassifier::addAttribute(const QString &name, UMLObject *type, ...@@ -829,7 +829,7 @@ UMLAttribute* UMLClassifier::addAttribute(const QString &name, UMLObject *type,
if (type) { if (type) {
a->setType(type); a->setType(type);
} }
m_List.append(a); subordinates().append(a);
emit attributeAdded(a); emit attributeAdded(a);
UMLObject::emitModified(); UMLObject::emitModified();
connect(a, SIGNAL(modified()), this, SIGNAL(modified())); connect(a, SIGNAL(modified()), this, SIGNAL(modified()));
...@@ -854,11 +854,11 @@ bool UMLClassifier::addAttribute(UMLAttribute* att, IDChangeLog* log /* = 0 */, ...@@ -854,11 +854,11 @@ bool UMLClassifier::addAttribute(UMLAttribute* att, IDChangeLog* log /* = 0 */,
Q_ASSERT(att); Q_ASSERT(att);
if (findChildObject(att->name()) == 0) { if (findChildObject(att->name()) == 0) {
att->setParent(this); att->setParent(this);
if (position >= 0 && position < (int)m_List.count()) { if (position >= 0 && position < (int)subordinates().count()) {
m_List.insert(position, att); subordinates().insert(position, att);
} }
else { else {
m_List.append(att); subordinates().append(att);
} }
emit attributeAdded(att); emit attributeAdded(att);
UMLObject::emitModified(); UMLObject::emitModified();
...@@ -880,7 +880,7 @@ bool UMLClassifier::addAttribute(UMLAttribute* att, IDChangeLog* log /* = 0 */, ...@@ -880,7 +880,7 @@ bool UMLClassifier::addAttribute(UMLAttribute* att, IDChangeLog* log /* = 0 */,
*/ */
int UMLClassifier::removeAttribute(UMLAttribute* att) int UMLClassifier::removeAttribute(UMLAttribute* att)
{ {
if (!m_List.removeAll(att)) { if (!subordinates().removeAll(att)) {
uDebug() << "cannot find att given in list"; uDebug() << "cannot find att given in list";
return -1; return -1;
} }
...@@ -888,7 +888,7 @@ int UMLClassifier::removeAttribute(UMLAttribute* att) ...@@ -888,7 +888,7 @@ int UMLClassifier::removeAttribute(UMLAttribute* att)
disconnect(att, SIGNAL(modified()), this, SIGNAL(modified())); disconnect(att, SIGNAL(modified()), this, SIGNAL(modified()));
emit attributeRemoved(att); emit attributeRemoved(att);
UMLObject::emitModified(); UMLObject::emitModified();
return m_List.count(); return subordinates().count();
} }
/** /**
...@@ -946,7 +946,7 @@ int UMLClassifier::operations() ...@@ -946,7 +946,7 @@ int UMLClassifier::operations()
UMLOperationList UMLClassifier::getOpList(bool includeInherited, UMLClassifierSet *alreadyTraversed) UMLOperationList UMLClassifier::getOpList(bool includeInherited, UMLClassifierSet *alreadyTraversed)
{ {
UMLOperationList ops; UMLOperationList ops;
foreach (UMLObject* li, m_List) { foreach (UMLObject* li, subordinates()) {
uIgnoreZeroPointer(li); uIgnoreZeroPointer(li);
if (li->baseType() == ot_Operation) { if (li->baseType() == ot_Operation) {
ops.append(li->asUMLOperation()); ops.append(li->asUMLOperation());
...@@ -996,7 +996,7 @@ UMLOperationList UMLClassifier::getOpList(bool includeInherited, UMLClassifierSe ...@@ -996,7 +996,7 @@ UMLOperationList UMLClassifier::getOpList(bool includeInherited, UMLClassifierSe
} }
/** /**
* Returns the entries in m_List that are of the requested type. * Returns the entries in subordinates that are of the requested type.
* If the requested type is UMLObject::ot_UMLObject then all entries * If the requested type is UMLObject::ot_UMLObject then all entries
* are returned. * are returned.
* @param ot the requested object type * @param ot the requested object type
...@@ -1005,7 +1005,7 @@ UMLOperationList UMLClassifier::getOpList(bool includeInherited, UMLClassifierSe ...@@ -1005,7 +1005,7 @@ UMLOperationList UMLClassifier::getOpList(bool includeInherited, UMLClassifierSe
UMLClassifierListItemList UMLClassifier::getFilteredList(UMLObject::ObjectType ot) const UMLClassifierListItemList UMLClassifier::getFilteredList(UMLObject::ObjectType ot) const
{ {
UMLClassifierListItemList resultList; UMLClassifierListItemList resultList;
foreach (UMLObject* o, m_List) { foreach (UMLObject* o, subordinates()) {
uIgnoreZeroPointer(o); uIgnoreZeroPointer(o);
if (!o || o->baseType() == UMLObject::ot_Association) { if (!o || o->baseType() == UMLObject::ot_Association) {
continue; continue;
...@@ -1035,7 +1035,7 @@ UMLTemplate* UMLClassifier::addTemplate(const QString &name, Uml::ID::Type id) ...@@ -1035,7 +1035,7 @@ UMLTemplate* UMLClassifier::addTemplate(const QString &name, Uml::ID::Type id)
return templt; return templt;
} }
templt = new UMLTemplate(this, name, id); templt = new UMLTemplate(this, name, id);
m_List.append(templt); subordinates().append(templt);
emit templateAdded(templt); emit templateAdded(templt);
UMLObject::emitModified(); UMLObject::emitModified();
connect(templt, SIGNAL(modified()), this, SIGNAL(modified())); connect(templt, SIGNAL(modified()), this, SIGNAL(modified()));
...@@ -1055,7 +1055,7 @@ bool UMLClassifier::addTemplate(UMLTemplate* newTemplate, IDChangeLog* log /* = ...@@ -1055,7 +1055,7 @@ bool UMLClassifier::addTemplate(UMLTemplate* newTemplate, IDChangeLog* log /* =
QString name = newTemplate->name(); QString name = newTemplate->name();
if (findChildObject(name) == 0) { if (findChildObject(name) == 0) {
newTemplate->setParent(this); newTemplate->setParent(this);
m_List.append(newTemplate); subordinates().append(newTemplate);
emit templateAdded(newTemplate); emit templateAdded(newTemplate);
UMLObject::emitModified(); UMLObject::emitModified();
connect(newTemplate, SIGNAL(modified()), this, SIGNAL(modified())); connect(newTemplate, SIGNAL(modified()), this, SIGNAL(modified()));
...@@ -1084,11 +1084,11 @@ bool UMLClassifier::addTemplate(UMLTemplate* templt, int position) ...@@ -1084,11 +1084,11 @@ bool UMLClassifier::addTemplate(UMLTemplate* templt, int position)
QString name = templt->name(); QString name = templt->name();
if (findChildObject(name) == 0) { if (findChildObject(name) == 0) {
templt->setParent(this); templt->setParent(this);
if (position >= 0 && position <= (int)m_List.count()) { if (position >= 0 && position <= (int)subordinates().count()) {
m_List.insert(position, templt); subordinates().insert(position, templt);
} }
else { else {
m_List.append(templt); subordinates().append(templt);
} }
emit templateAdded(templt); emit templateAdded(templt);
UMLObject::emitModified(); UMLObject::emitModified();
...@@ -1108,14 +1108,14 @@ bool UMLClassifier::addTemplate(UMLTemplate* templt, int position) ...@@ -1108,14 +1108,14 @@ bool UMLClassifier::addTemplate(UMLTemplate* templt, int position)
*/ */
int UMLClassifier::removeTemplate(UMLTemplate* umltemplate) int UMLClassifier::removeTemplate(UMLTemplate* umltemplate)
{ {
if (!m_List.removeAll(umltemplate)) { if (!subordinates().removeAll(umltemplate)) {
uWarning() << "cannot find att given in list"; uWarning() << "cannot find att given in list";
return -1; return -1;
} }
emit templateRemoved(umltemplate); emit templateRemoved(umltemplate);
UMLObject::emitModified(); UMLObject::emitModified();
disconnect(umltemplate, SIGNAL(modified()), this, SIGNAL(modified())); disconnect(umltemplate, SIGNAL(modified()), this, SIGNAL(modified()));
return m_List.count(); return subordinates().count();
} }
/** /**
...@@ -1155,7 +1155,7 @@ int UMLClassifier::templates() ...@@ -1155,7 +1155,7 @@ int UMLClassifier::templates()
UMLTemplateList UMLClassifier::getTemplateList() const UMLTemplateList UMLClassifier::getTemplateList() const
{ {
UMLTemplateList templateList; UMLTemplateList templateList;
foreach (UMLObject* listItem, m_List) { foreach (UMLObject* listItem, subordinates()) {
uIgnoreZeroPointer(listItem); uIgnoreZeroPointer(listItem);
if (listItem->baseType() == UMLObject::ot_Template) { if (listItem->baseType() == UMLObject::ot_Template) {
templateList.append(listItem->asUMLTemplate()); templateList.append(listItem->asUMLTemplate());
...@@ -1169,13 +1169,13 @@ UMLTemplateList UMLClassifier::getTemplateList() const ...@@ -1169,13 +1169,13 @@ UMLTemplateList UMLClassifier::getTemplateList() const
* Ownership of the item is passed to the caller. * Ownership of the item is passed to the caller.
* *
* @param item Subordinate item to take. * @param item Subordinate item to take.
* @return Index in m_List of the item taken. * @return Index in subordinates of the item taken.
* Return -1 if the item is not found in m_List. * Return -1 if the item is not found in subordinates.
*/ */
int UMLClassifier::takeItem(UMLClassifierListItem *item) int UMLClassifier::takeItem(UMLClassifierListItem *item)
{ {
QString buf; QString buf;
foreach (UMLObject* currentAtt, m_List) { foreach (UMLObject* currentAtt, subordinates()) {
uIgnoreZeroPointer(currentAtt); uIgnoreZeroPointer(currentAtt);
QString txt = currentAtt->name(); QString txt = currentAtt->name();
if (txt.isEmpty()) { if (txt.isEmpty()) {
...@@ -1183,9 +1183,9 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item) ...@@ -1183,9 +1183,9 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
} }
buf.append(QLatin1Char(' ') + currentAtt->name()); buf.append(QLatin1Char(' ') + currentAtt->name());
} }
uDebug() << " UMLClassifier::takeItem (before): m_List is " << buf; uDebug() << " UMLClassifier::takeItem (before): subordinates() is " << buf;
int index = m_List.indexOf(item); int index = subordinates().indexOf(item);
if (index == -1) { if (index == -1) {
return -1; return -1;
} }
...@@ -1197,7 +1197,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item) ...@@ -1197,7 +1197,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
break; break;
} }
case UMLObject::ot_Attribute: { case UMLObject::ot_Attribute: {
UMLAttribute *retval = m_List.takeAt(index)->asUMLAttribute(); UMLAttribute *retval = subordinates().takeAt(index)->asUMLAttribute();
if (retval) { if (retval) {
emit attributeRemoved(retval); emit attributeRemoved(retval);
UMLObject::emitModified(); UMLObject::emitModified();
...@@ -1207,7 +1207,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item) ...@@ -1207,7 +1207,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
break; break;
} }
case UMLObject::ot_Template: { case UMLObject::ot_Template: {
UMLTemplate *templt = m_List.takeAt(index)->asUMLTemplate(); UMLTemplate *templt = subordinates().takeAt(index)->asUMLTemplate();
if (templt) { if (templt) {
emit templateRemoved(templt); emit templateRemoved(templt);
UMLObject::emitModified(); UMLObject::emitModified();
...@@ -1217,7 +1217,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item) ...@@ -1217,7 +1217,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
break; break;
} }
case UMLObject::ot_EnumLiteral: { case UMLObject::ot_EnumLiteral: {
UMLEnumLiteral *el = m_List.takeAt(index)->asUMLEnumLiteral(); UMLEnumLiteral *el = subordinates().takeAt(index)->asUMLEnumLiteral();
if (el) { if (el) {
UMLEnum *e = this->asUMLEnum(); UMLEnum *e = this->asUMLEnum();
e->signalEnumLiteralRemoved(el); e->signalEnumLiteralRemoved(el);
...@@ -1228,7 +1228,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item) ...@@ -1228,7 +1228,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
break; break;
} }
case UMLObject::ot_EntityAttribute: { case UMLObject::ot_EntityAttribute: {
UMLEntityAttribute* el = m_List.takeAt(index)->asUMLEntityAttribute(); UMLEntityAttribute* el = subordinates().takeAt(index)->asUMLEntityAttribute();
if (el) { if (el) {
UMLEntity *e = this->asUMLEntity(); UMLEntity *e = this->asUMLEntity();
e->signalEntityAttributeRemoved(el); e->signalEntityAttributeRemoved(el);
...@@ -1239,7 +1239,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item) ...@@ -1239,7 +1239,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
break; break;
} }
case UMLObject::ot_InstanceAttribute: { case UMLObject::ot_InstanceAttribute: {
UMLInstanceAttribute *ia = m_List.takeAt(index)->asUMLInstanceAttribute(); UMLInstanceAttribute *ia = subordinates().takeAt(index)->asUMLInstanceAttribute();
if(ia) { if(ia) {
emit attributeRemoved(ia); emit attributeRemoved(ia);
UMLObject::emitModified(); UMLObject::emitModified();
......
...@@ -52,7 +52,7 @@ UMLEntity::UMLEntity(const QString& name, Uml::ID::Type id) ...@@ -52,7 +52,7 @@ UMLEntity::UMLEntity(const QString& name, Uml::ID::Type id)
*/ */
UMLEntity::~UMLEntity() UMLEntity::~UMLEntity()
{ {
m_List.clear(); subordinates().clear();
} }
/** /**
...@@ -305,7 +305,7 @@ UMLCheckConstraint* UMLEntity::createCheckConstraint(const QString &name) ...@@ -305,7 +305,7 @@ UMLCheckConstraint* UMLEntity::createCheckConstraint(const QString &name)
UMLObject* UMLEntity::addEntityAttribute(const QString& name, Uml::ID::Type id) UMLObject* UMLEntity::addEntityAttribute(const QString& name, Uml::ID::Type id)
{ {
UMLEntityAttribute* literal = new UMLEntityAttribute(this, name, id); UMLEntityAttribute* literal = new UMLEntityAttribute(this, name, id);
m_List.append(literal); subordinates().append(literal);
emit entityAttributeAdded(literal); emit entityAttributeAdded(literal);
UMLObject::emitModified(); UMLObject::emitModified();
connect(literal, SIGNAL(modified()), this, SIGNAL(modified())); connect(literal, SIGNAL(modified()), this, SIGNAL(modified()));
...@@ -324,7 +324,7 @@ bool UMLEntity::addEntityAttribute(UMLEntityAttribute* att, IDChangeLog* log /* ...@@ -324,7 +324,7 @@ bool UMLEntity::addEntityAttribute(UMLEntityAttribute* att, IDChangeLog* log /*
QString name = (QString)att->name(); QString name = (QString)att->name();
if (findChildObject(name) == 0) { if (findChildObject(name) == 0) {
att->setParent(this); att->setParent(this);
m_List.append(att); subordinates().append(att);
emit entityAttributeAdded(att); emit entityAttributeAdded(att);
UMLObject::emitModified(); UMLObject::emitModified();
connect(att, SIGNAL(modified()), this, SIGNAL(modified())); connect(att, SIGNAL(modified()), this, SIGNAL(modified()));
...@@ -351,10 +351,10 @@ bool UMLEntity::addEntityAttribute(UMLEntityAttribute* att, int position) ...@@ -351,10 +351,10 @@ bool UMLEntity::addEntityAttribute(UMLEntityAttribute* att, int position)
QString name = (QString)att->name(); QString name = (QString)att->name();
if (findChildObject(name) == 0) { if (findChildObject(name) == 0) {
att->setParent(this); att->setParent(this);
if (position >= 0 && position <= (int)m_List.count()) { if (position >= 0 && position <= (int)subordinates().count()) {
m_List.insert(position, att); subordinates().insert(position, att);
} else { } else {
m_List.append(att); subordinates().append(att);
} }
emit entityAttributeAdded(att); emit entityAttributeAdded(att);
UMLObject::emitModified(); UMLObject::emitModified();
...@@ -372,7 +372,7 @@ bool UMLEntity::addEntityAttribute(UMLEntityAttribute* att, int position) ...@@ -372,7 +372,7 @@ bool UMLEntity::addEntityAttribute(UMLEntityAttribute* att, int position)
*/ */
int UMLEntity::removeEntityAttribute(UMLClassifierListItem* att) int UMLEntity::removeEntityAttribute(UMLClassifierListItem* att)
{ {
if (!m_List.removeAll((UMLEntityAttribute*)att)) { if (!subordinates().removeAll((UMLEntityAttribute*)att)) {
uDebug() << "cannot find att given in list"; uDebug() << "cannot find att given in list";
return -1; return -1;
} }
...@@ -382,7 +382,7 @@ int UMLEntity::removeEntityAttribute(UMLClassifierListItem* att) ...@@ -382,7 +382,7 @@ int UMLEntity::removeEntityAttribute(UMLClassifierListItem* att)
// for us by QObject. -b.t. // for us by QObject. -b.t.
// disconnect(att, SIGNAL(modified()), this, SIGNAL(modified())); // disconnect(att, SIGNAL(modified()), this, SIGNAL(modified()));
delete att; delete att;
return m_List.count(); return subordinates().count();
} }
/** /**
...@@ -410,7 +410,7 @@ void UMLEntity::signalEntityAttributeRemoved(UMLClassifierListItem *eattr) ...@@ -410,7 +410,7 @@ void UMLEntity::signalEntityAttributeRemoved(UMLClassifierListItem *eattr)
bool UMLEntity::resolveRef() bool UMLEntity::resolveRef()
{ {
bool success = UMLClassifier::resolveRef(); bool success = UMLClassifier::resolveRef();
for (UMLObjectListIt oit(m_List); oit.hasNext();) { for (UMLObjectListIt oit(subordinates()); oit.hasNext();) {
UMLObject* obj = oit.next(); UMLObject* obj = oit.next();
if (obj->resolveRef()) { if (obj->resolveRef()) {
UMLClassifierListItem *cli = obj->asUMLClassifierListItem(); UMLClassifierListItem *cli = obj->asUMLClassifierListItem();
...@@ -471,7 +471,7 @@ bool UMLEntity::load1(QDomElement& element) ...@@ -471,7 +471,7 @@ bool UMLEntity::load1(QDomElement& element)
if(!pEntityAttribute->loadFromXMI1(tempElement)) { if(!pEntityAttribute->loadFromXMI1(tempElement)) {
return false; return false;
} }
m_List.append(pEntityAttribute); subordinates().append(pEntityAttribute);
} else if (UMLDoc::tagEq(tag, QLatin1String("UniqueConstraint"))) { } else if (UMLDoc::tagEq(tag, QLatin1String("UniqueConstraint"))) {
UMLUniqueConstraint* pUniqueConstraint = new UMLUniqueConstraint(this); UMLUniqueConstraint* pUniqueConstraint = new UMLUniqueConstraint(this);
if (!pUniqueConstraint->loadFromXMI1(tempElement)) { if (!pUniqueConstraint->loadFromXMI1(tempElement)) {
...@@ -582,7 +582,7 @@ bool UMLEntity::addConstraint(UMLEntityConstraint* constr) ...@@ -582,7 +582,7 @@ bool UMLEntity::addConstraint(UMLEntityConstraint* constr)
return false; return false;
} }
m_List.append(constr); subordinates().append(constr);
emit entityConstraintAdded(constr); emit entityConstraintAdded(constr);
UMLObject::emitModified(); UMLObject::emitModified();
...@@ -609,7 +609,7 @@ bool UMLEntity::removeConstraint(UMLEntityConstraint* constr) ...@@ -609,7 +609,7 @@ bool UMLEntity::removeConstraint(UMLEntityConstraint* constr)
unsetPrimaryKey(); unsetPrimaryKey();
} }
m_List.removeAll(constr); subordinates().removeAll(constr);
emit entityConstraintRemoved(constr); emit entityConstraintRemoved(constr);
UMLObject::emitModified(); UMLObject::emitModified();
...@@ -693,7 +693,7 @@ bool UMLEntity::isPrimaryKey(UMLUniqueConstraint* uConstr) const ...@@ -693,7 +693,7 @@ bool UMLEntity::isPrimaryKey(UMLUniqueConstraint* uConstr) const
UMLEntityAttributeList UMLEntity::getEntityAttributes() const UMLEntityAttributeList UMLEntity::getEntityAttributes() const
{ {
UMLEntityAttributeList entityAttributeList; UMLEntityAttributeList entityAttributeList;
for (UMLObjectListIt lit(m_List); lit.hasNext();) { for (UMLObjectListIt lit(subordinates()); lit.hasNext();) {
UMLObject *listItem = lit.next(); UMLObject *listItem = lit.next();
if (listItem->baseType() == UMLObject::ot_EntityAttribute) { if (listItem->baseType() == UMLObject::ot_EntityAttribute) {
entityAttributeList.append(listItem->asUMLEntityAttribute()); entityAttributeList.append(listItem->asUMLEntityAttribute());
......
...@@ -97,7 +97,7 @@ private: ...@@ -97,7 +97,7 @@ private:
/** /**
* Primary Key of this Entity * Primary Key of this Entity
* This is a pointer kept for easy access to the primary key, and to distinguish it * This is a pointer kept for easy access to the primary key, and to distinguish it
* from all other UniqueConstraints. It is also there in m_List (inherited from * from all other UniqueConstraints. It is also there in subordinates (inherited from
* UMLCanvasObject) * UMLCanvasObject)
*/ */
UMLUniqueConstraint* m_PrimaryKey; UMLUniqueConstraint* m_PrimaryKey;
......
...@@ -38,7 +38,7 @@ UMLEnum::UMLEnum(const QString& name, Uml::ID::Type id) : UMLClassifier(name, id ...@@ -38,7 +38,7 @@ UMLEnum::UMLEnum(const QString& name, Uml::ID::Type id) : UMLClassifier(name, id
*/ */
UMLEnum::~UMLEnum() UMLEnum::~UMLEnum()
{ {