summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <[email protected]>2017-05-08 11:39:27 +0200
committerRalf Habacker <[email protected]>2017-05-08 11:46:40 +0200
commitec44b8bc270593056e56567ec2d7400c6219272c (patch)
tree4309944de2d1991d55097ba8248469b68fdab84f
parent028ecc83cb37b6ef9c6a4c69169e8a503a496336 (diff)
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.
-rw-r--r--umbrello/uml1model/classifier.cpp82
-rw-r--r--umbrello/uml1model/entity.cpp26
-rw-r--r--umbrello/uml1model/entity.h2
-rw-r--r--umbrello/uml1model/enum.cpp20
-rw-r--r--umbrello/uml1model/folder.cpp2
-rw-r--r--umbrello/uml1model/instance.cpp2
-rw-r--r--umbrello/uml1model/package.cpp2
-rw-r--r--umbrello/uml1model/umlcanvasobject.cpp40
-rw-r--r--umbrello/uml1model/umlcanvasobject.h6
9 files changed, 91 insertions, 91 deletions
diff --git a/umbrello/uml1model/classifier.cpp b/umbrello/uml1model/classifier.cpp
index 960ca96..b4d5dd0 100644
--- a/umbrello/uml1model/classifier.cpp
+++ b/umbrello/uml1model/classifier.cpp
@@ -305,7 +305,7 @@ UMLOperation* UMLClassifier::createOperation(
bool UMLClassifier::addOperation(UMLOperation* op, int position)
{
Q_ASSERT(op);
- if (m_List.indexOf(op) != -1) {
+ if (subordinates().indexOf(op) != -1) {
uDebug() << "findRef(" << op->name() << ") finds op (bad)";
return false;
}
@@ -314,9 +314,9 @@ bool UMLClassifier::addOperation(UMLOperation* op, int position)
return false;
}
- if (position >= 0 && position <= m_List.count()) {
+ if (position >= 0 && position <= subordinates().count()) {
uDebug() << op->name() << ": inserting at position " << position;
- m_List.insert(position, op);
+ subordinates().insert(position, op);
UMLClassifierListItemList itemList = getFilteredList(UMLObject::ot_Operation);
QString buf;
foreach (UMLClassifierListItem* currentAtt, itemList) {
@@ -325,7 +325,7 @@ bool UMLClassifier::addOperation(UMLOperation* op, int position)
uDebug() << " list after change: " << buf;
}
else {
- m_List.append(op);
+ subordinates().append(op);
}
emit operationAdded(op);
UMLObject::emitModified();
@@ -368,7 +368,7 @@ int UMLClassifier::removeOperation(UMLOperation *op)
uDebug() << "called on NULL op";
return -1;
}
- if (!m_List.removeAll(op)) {
+ if (!subordinates().removeAll(op)) {
uDebug() << "cannot find op " << op->name() << " in list";
return -1;
}
@@ -377,7 +377,7 @@ int UMLClassifier::removeOperation(UMLOperation *op)
disconnect(op, SIGNAL(modified()), this, SIGNAL(modified()));
emit operationRemoved(op);
UMLObject::emitModified();
- return m_List.count();
+ return subordinates().count();
}
/**
@@ -431,7 +431,7 @@ UMLObject* UMLClassifier::createTemplate(const QString& currentName /*= QString(
UMLAttributeList UMLClassifier::getAttributeList() const
{
UMLAttributeList attributeList;
- foreach (UMLObject* listItem, m_List) {
+ foreach (UMLObject* listItem, subordinates()) {
uIgnoreZeroPointer(listItem);
if (listItem->baseType() == UMLObject::ot_Attribute) {
attributeList.append(listItem->asUMLAttribute());
@@ -519,7 +519,7 @@ UMLOperationList UMLClassifier::findOperations(const QString &n)
{
const bool caseSensitive = UMLApp::app()->activeLanguageIsCaseSensitive();
UMLOperationList list;
- foreach (UMLObject* obj, m_List) {
+ foreach (UMLObject* obj, subordinates()) {
uIgnoreZeroPointer(obj);
if (obj->baseType() != UMLObject::ot_Operation)
continue;
@@ -650,8 +650,8 @@ void UMLClassifier::copyInto(UMLObject *lhs) const
UMLCanvasObject::copyInto(target);
target->setBaseType(m_BaseType);
// CHECK: association property m_pClassAssoc is not copied
- m_List.copyInto(&(target->m_List));
- foreach(UMLObject *o, target->m_List) {
+ subordinates().copyInto(&(target->subordinates()));
+ foreach(UMLObject *o, target->subordinates()) {
uIgnoreZeroPointer(o);
o->setUMLParent(target);
}
@@ -679,11 +679,11 @@ bool UMLClassifier::resolveRef()
{
bool success = UMLPackage::resolveRef();
// Using reentrant iteration is a bare necessity here:
- foreach (UMLObject* obj, m_List) {
+ foreach (UMLObject* obj, subordinates()) {
uIgnoreZeroPointer(obj);
/**** For reference, here is the non-reentrant iteration scheme -
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()) {
@@ -797,14 +797,14 @@ UMLAttribute* UMLClassifier::createAttribute(const QString &name,
UMLAttribute* UMLClassifier::addAttribute(const QString &name, Uml::ID::Type id /* = Uml::id_None */)
{
- foreach (UMLObject* obj, m_List) {
+ foreach (UMLObject* obj, subordinates()) {
uIgnoreZeroPointer(obj);
if (obj->baseType() == UMLObject::ot_Attribute && obj->name() == name)
return obj->asUMLAttribute();
}
Uml::Visibility::Enum scope = Settings::optionState().classState.defaultAttributeScope;
UMLAttribute *a = new UMLAttribute(this, name, id, scope);
- m_List.append(a);
+ subordinates().append(a);
emit attributeAdded(a);
UMLObject::emitModified();
connect(a, SIGNAL(modified()), this, SIGNAL(modified()));
@@ -829,7 +829,7 @@ UMLAttribute* UMLClassifier::addAttribute(const QString &name, UMLObject *type,
if (type) {
a->setType(type);
}
- m_List.append(a);
+ subordinates().append(a);
emit attributeAdded(a);
UMLObject::emitModified();
connect(a, SIGNAL(modified()), this, SIGNAL(modified()));
@@ -854,11 +854,11 @@ bool UMLClassifier::addAttribute(UMLAttribute* att, IDChangeLog* log /* = 0 */,
Q_ASSERT(att);
if (findChildObject(att->name()) == 0) {
att->setParent(this);
- if (position >= 0 && position < (int)m_List.count()) {
- m_List.insert(position, att);
+ if (position >= 0 && position < (int)subordinates().count()) {
+ subordinates().insert(position, att);
}
else {
- m_List.append(att);
+ subordinates().append(att);
}
emit attributeAdded(att);
UMLObject::emitModified();
@@ -880,7 +880,7 @@ bool UMLClassifier::addAttribute(UMLAttribute* att, IDChangeLog* log /* = 0 */,
*/
int UMLClassifier::removeAttribute(UMLAttribute* att)
{
- if (!m_List.removeAll(att)) {
+ if (!subordinates().removeAll(att)) {
uDebug() << "cannot find att given in list";
return -1;
}
@@ -888,7 +888,7 @@ int UMLClassifier::removeAttribute(UMLAttribute* att)
disconnect(att, SIGNAL(modified()), this, SIGNAL(modified()));
emit attributeRemoved(att);
UMLObject::emitModified();
- return m_List.count();
+ return subordinates().count();
}
/**
@@ -946,7 +946,7 @@ int UMLClassifier::operations()
UMLOperationList UMLClassifier::getOpList(bool includeInherited, UMLClassifierSet *alreadyTraversed)
{
UMLOperationList ops;
- foreach (UMLObject* li, m_List) {
+ foreach (UMLObject* li, subordinates()) {
uIgnoreZeroPointer(li);
if (li->baseType() == ot_Operation) {
ops.append(li->asUMLOperation());
@@ -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
* are returned.
* @param ot the requested object type
@@ -1005,7 +1005,7 @@ UMLOperationList UMLClassifier::getOpList(bool includeInherited, UMLClassifierSe
UMLClassifierListItemList UMLClassifier::getFilteredList(UMLObject::ObjectType ot) const
{
UMLClassifierListItemList resultList;
- foreach (UMLObject* o, m_List) {
+ foreach (UMLObject* o, subordinates()) {
uIgnoreZeroPointer(o);
if (!o || o->baseType() == UMLObject::ot_Association) {
continue;
@@ -1035,7 +1035,7 @@ UMLTemplate* UMLClassifier::addTemplate(const QString &name, Uml::ID::Type id)
return templt;
}
templt = new UMLTemplate(this, name, id);
- m_List.append(templt);
+ subordinates().append(templt);
emit templateAdded(templt);
UMLObject::emitModified();
connect(templt, SIGNAL(modified()), this, SIGNAL(modified()));
@@ -1055,7 +1055,7 @@ bool UMLClassifier::addTemplate(UMLTemplate* newTemplate, IDChangeLog* log /* =
QString name = newTemplate->name();
if (findChildObject(name) == 0) {
newTemplate->setParent(this);
- m_List.append(newTemplate);
+ subordinates().append(newTemplate);
emit templateAdded(newTemplate);
UMLObject::emitModified();
connect(newTemplate, SIGNAL(modified()), this, SIGNAL(modified()));
@@ -1084,11 +1084,11 @@ bool UMLClassifier::addTemplate(UMLTemplate* templt, int position)
QString name = templt->name();
if (findChildObject(name) == 0) {
templt->setParent(this);
- if (position >= 0 && position <= (int)m_List.count()) {
- m_List.insert(position, templt);
+ if (position >= 0 && position <= (int)subordinates().count()) {
+ subordinates().insert(position, templt);
}
else {
- m_List.append(templt);
+ subordinates().append(templt);
}
emit templateAdded(templt);
UMLObject::emitModified();
@@ -1108,14 +1108,14 @@ bool UMLClassifier::addTemplate(UMLTemplate* templt, int position)
*/
int UMLClassifier::removeTemplate(UMLTemplate* umltemplate)
{
- if (!m_List.removeAll(umltemplate)) {
+ if (!subordinates().removeAll(umltemplate)) {
uWarning() << "cannot find att given in list";
return -1;
}
emit templateRemoved(umltemplate);
UMLObject::emitModified();
disconnect(umltemplate, SIGNAL(modified()), this, SIGNAL(modified()));
- return m_List.count();
+ return subordinates().count();
}
/**
@@ -1155,7 +1155,7 @@ int UMLClassifier::templates()
UMLTemplateList UMLClassifier::getTemplateList() const
{
UMLTemplateList templateList;
- foreach (UMLObject* listItem, m_List) {
+ foreach (UMLObject* listItem, subordinates()) {
uIgnoreZeroPointer(listItem);
if (listItem->baseType() == UMLObject::ot_Template) {
templateList.append(listItem->asUMLTemplate());
@@ -1169,13 +1169,13 @@ UMLTemplateList UMLClassifier::getTemplateList() const
* Ownership of the item is passed to the caller.
*
* @param item Subordinate item to take.
- * @return Index in m_List of the item taken.
- * Return -1 if the item is not found in m_List.
+ * @return Index in subordinates of the item taken.
+ * Return -1 if the item is not found in subordinates.
*/
int UMLClassifier::takeItem(UMLClassifierListItem *item)
{
QString buf;
- foreach (UMLObject* currentAtt, m_List) {
+ foreach (UMLObject* currentAtt, subordinates()) {
uIgnoreZeroPointer(currentAtt);
QString txt = currentAtt->name();
if (txt.isEmpty()) {
@@ -1183,9 +1183,9 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
}
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) {
return -1;
}
@@ -1197,7 +1197,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
break;
}
case UMLObject::ot_Attribute: {
- UMLAttribute *retval = m_List.takeAt(index)->asUMLAttribute();
+ UMLAttribute *retval = subordinates().takeAt(index)->asUMLAttribute();
if (retval) {
emit attributeRemoved(retval);
UMLObject::emitModified();
@@ -1207,7 +1207,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
break;
}
case UMLObject::ot_Template: {
- UMLTemplate *templt = m_List.takeAt(index)->asUMLTemplate();
+ UMLTemplate *templt = subordinates().takeAt(index)->asUMLTemplate();
if (templt) {
emit templateRemoved(templt);
UMLObject::emitModified();
@@ -1217,7 +1217,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
break;
}
case UMLObject::ot_EnumLiteral: {
- UMLEnumLiteral *el = m_List.takeAt(index)->asUMLEnumLiteral();
+ UMLEnumLiteral *el = subordinates().takeAt(index)->asUMLEnumLiteral();
if (el) {
UMLEnum *e = this->asUMLEnum();
e->signalEnumLiteralRemoved(el);
@@ -1228,7 +1228,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
break;
}
case UMLObject::ot_EntityAttribute: {
- UMLEntityAttribute* el = m_List.takeAt(index)->asUMLEntityAttribute();
+ UMLEntityAttribute* el = subordinates().takeAt(index)->asUMLEntityAttribute();
if (el) {
UMLEntity *e = this->asUMLEntity();
e->signalEntityAttributeRemoved(el);
@@ -1239,7 +1239,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
break;
}
case UMLObject::ot_InstanceAttribute: {
- UMLInstanceAttribute *ia = m_List.takeAt(index)->asUMLInstanceAttribute();
+ UMLInstanceAttribute *ia = subordinates().takeAt(index)->asUMLInstanceAttribute();
if(ia) {
emit attributeRemoved(ia);
UMLObject::emitModified();
diff --git a/umbrello/uml1model/entity.cpp b/umbrello/uml1model/entity.cpp
index f79d22e..8d33391 100644
--- a/umbrello/uml1model/entity.cpp
+++ b/umbrello/uml1model/entity.cpp
@@ -52,7 +52,7 @@ UMLEntity::UMLEntity(const QString& name, Uml::ID::Type id)
*/
UMLEntity::~UMLEntity()
{
- m_List.clear();
+ subordinates().clear();
}
/**
@@ -305,7 +305,7 @@ UMLCheckConstraint* UMLEntity::createCheckConstraint(const QString &name)
UMLObject* UMLEntity::addEntityAttribute(const QString& name, Uml::ID::Type id)
{
UMLEntityAttribute* literal = new UMLEntityAttribute(this, name, id);
- m_List.append(literal);
+ subordinates().append(literal);
emit entityAttributeAdded(literal);
UMLObject::emitModified();
connect(literal, SIGNAL(modified()), this, SIGNAL(modified()));
@@ -324,7 +324,7 @@ bool UMLEntity::addEntityAttribute(UMLEntityAttribute* att, IDChangeLog* log /*
QString name = (QString)att->name();
if (findChildObject(name) == 0) {
att->setParent(this);
- m_List.append(att);
+ subordinates().append(att);
emit entityAttributeAdded(att);
UMLObject::emitModified();
connect(att, SIGNAL(modified()), this, SIGNAL(modified()));
@@ -351,10 +351,10 @@ bool UMLEntity::addEntityAttribute(UMLEntityAttribute* att, int position)
QString name = (QString)att->name();
if (findChildObject(name) == 0) {
att->setParent(this);
- if (position >= 0 && position <= (int)m_List.count()) {
- m_List.insert(position, att);
+ if (position >= 0 && position <= (int)subordinates().count()) {
+ subordinates().insert(position, att);
} else {
- m_List.append(att);
+ subordinates().append(att);
}
emit entityAttributeAdded(att);
UMLObject::emitModified();
@@ -372,7 +372,7 @@ bool UMLEntity::addEntityAttribute(UMLEntityAttribute* att, int position)
*/
int UMLEntity::removeEntityAttribute(UMLClassifierListItem* att)
{
- if (!m_List.removeAll((UMLEntityAttribute*)att)) {
+ if (!subordinates().removeAll((UMLEntityAttribute*)att)) {
uDebug() << "cannot find att given in list";
return -1;
}
@@ -382,7 +382,7 @@ int UMLEntity::removeEntityAttribute(UMLClassifierListItem* att)
// for us by QObject. -b.t.
// disconnect(att, SIGNAL(modified()), this, SIGNAL(modified()));
delete att;
- return m_List.count();
+ return subordinates().count();
}
/**
@@ -410,7 +410,7 @@ void UMLEntity::signalEntityAttributeRemoved(UMLClassifierListItem *eattr)
bool UMLEntity::resolveRef()
{
bool success = UMLClassifier::resolveRef();
- for (UMLObjectListIt oit(m_List); oit.hasNext();) {
+ for (UMLObjectListIt oit(subordinates()); oit.hasNext();) {
UMLObject* obj = oit.next();
if (obj->resolveRef()) {
UMLClassifierListItem *cli = obj->asUMLClassifierListItem();
@@ -471,7 +471,7 @@ bool UMLEntity::load1(QDomElement& element)
if(!pEntityAttribute->loadFromXMI1(tempElement)) {
return false;
}
- m_List.append(pEntityAttribute);
+ subordinates().append(pEntityAttribute);
} else if (UMLDoc::tagEq(tag, QLatin1String("UniqueConstraint"))) {
UMLUniqueConstraint* pUniqueConstraint = new UMLUniqueConstraint(this);
if (!pUniqueConstraint->loadFromXMI1(tempElement)) {
@@ -582,7 +582,7 @@ bool UMLEntity::addConstraint(UMLEntityConstraint* constr)
return false;
}
- m_List.append(constr);
+ subordinates().append(constr);
emit entityConstraintAdded(constr);
UMLObject::emitModified();
@@ -609,7 +609,7 @@ bool UMLEntity::removeConstraint(UMLEntityConstraint* constr)
unsetPrimaryKey();
}
- m_List.removeAll(constr);
+ subordinates().removeAll(constr);
emit entityConstraintRemoved(constr);
UMLObject::emitModified();
@@ -693,7 +693,7 @@ bool UMLEntity::isPrimaryKey(UMLUniqueConstraint* uConstr) const
UMLEntityAttributeList UMLEntity::getEntityAttributes() const
{
UMLEntityAttributeList entityAttributeList;
- for (UMLObjectListIt lit(m_List); lit.hasNext();) {
+ for (UMLObjectListIt lit(subordinates()); lit.hasNext();) {
UMLObject *listItem = lit.next();
if (listItem->baseType() == UMLObject::ot_EntityAttribute) {
entityAttributeList.append(listItem->asUMLEntityAttribute());
diff --git a/umbrello/uml1model/entity.h b/umbrello/uml1model/entity.h
index e9520f8..ab9f4da 100644
--- a/umbrello/uml1model/entity.h
+++ b/umbrello/uml1model/entity.h
@@ -97,7 +97,7 @@ private:
/**
* Primary Key of this Entity
* 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)
*/
UMLUniqueConstraint* m_PrimaryKey;
diff --git a/umbrello/uml1model/enum.cpp b/umbrello/uml1model/enum.cpp
index 74366e4..8a95662 100644
--- a/umbrello/uml1model/enum.cpp
+++ b/umbrello/uml1model/enum.cpp
@@ -38,7 +38,7 @@ UMLEnum::UMLEnum(const QString& name, Uml::ID::Type id) : UMLClassifier(name, id
*/
UMLEnum::~UMLEnum()
{
- m_List.clear();
+ subordinates().clear();
}
/**
@@ -137,7 +137,7 @@ UMLObject* UMLEnum::addEnumLiteral(const QString &name, Uml::ID::Type id, const
return el;
}
UMLEnumLiteral* literal = new UMLEnumLiteral(this, name, id, value);
- m_List.append(literal);
+ subordinates().append(literal);
UMLObject::emitModified();
emit enumLiteralAdded(literal);
connect(literal, SIGNAL(modified()), this, SIGNAL(modified()));
@@ -156,7 +156,7 @@ bool UMLEnum::addEnumLiteral(UMLEnumLiteral* literal, IDChangeLog* Log /* = 0*/)
QString name = (QString)literal->name();
if (findChildObject(name) == 0) {
literal->setParent(this);
- m_List.append(literal);
+ subordinates().append(literal);
UMLObject::emitModified();
emit enumLiteralAdded(literal);
connect(literal, SIGNAL(modified()), this, SIGNAL(modified()));
@@ -183,10 +183,10 @@ bool UMLEnum::addEnumLiteral(UMLEnumLiteral* literal, int position)
QString name = (QString)literal->name();
if (findChildObject(name) == 0) {
literal->setParent(this);
- if (position >= 0 && position <= (int)m_List.count()) {
- m_List.insert(position, literal);
+ if (position >= 0 && position <= (int)subordinates().count()) {
+ subordinates().insert(position, literal);
} else {
- m_List.append(literal);
+ subordinates().append(literal);
}
UMLObject::emitModified();
emit enumLiteralAdded(literal);
@@ -204,7 +204,7 @@ bool UMLEnum::addEnumLiteral(UMLEnumLiteral* literal, int position)
*/
int UMLEnum::removeEnumLiteral(UMLEnumLiteral* literal)
{
- if (!m_List.removeAll(literal)) {
+ if (!subordinates().removeAll(literal)) {
uDebug() << "cannot find att given in list";
return -1;
}
@@ -214,7 +214,7 @@ int UMLEnum::removeEnumLiteral(UMLEnumLiteral* literal)
// for us by QObject. -b.t.
// disconnect(a, SIGNAL(modified()), this, SIGNAL(modified()));
delete literal;
- return m_List.count();
+ return subordinates().count();
}
/**
@@ -223,7 +223,7 @@ int UMLEnum::removeEnumLiteral(UMLEnumLiteral* literal)
*/
int UMLEnum::enumLiterals()
{
- return m_List.count();
+ return subordinates().count();
}
/**
@@ -270,7 +270,7 @@ bool UMLEnum::load1(QDomElement& element)
if(!pEnumLiteral->loadFromXMI1(tempElement)) {
return false;
}
- m_List.append(pEnumLiteral);
+ subordinates().append(pEnumLiteral);
} else if (UMLDoc::tagEq(tag, QLatin1String("Enumeration.literal"))) { // UML 1.4
if (! load1(tempElement))
return false;
diff --git a/umbrello/uml1model/folder.cpp b/umbrello/uml1model/folder.cpp
index 9edd443..af58d2e 100644
--- a/umbrello/uml1model/folder.cpp
+++ b/umbrello/uml1model/folder.cpp
@@ -277,7 +277,7 @@ void UMLFolder::saveContents1(QDomDocument& qDoc, QDomElement& qElement)
obj->saveToXMI1 (qDoc, ownedElement);
}
// Save asscociations if any.
- for (UMLObjectListIt ait(m_List); ait.hasNext();) {
+ for (UMLObjectListIt ait(subordinates()); ait.hasNext();) {
obj = ait.next();
obj->saveToXMI1 (qDoc, ownedElement);
}
diff --git a/umbrello/uml1model/instance.cpp b/umbrello/uml1model/instance.cpp
index 447ec98..c9997ac 100644
--- a/umbrello/uml1model/instance.cpp
+++ b/umbrello/uml1model/instance.cpp
@@ -176,7 +176,7 @@ bool UMLInstance::load1(QDomElement &element)
if(!pInstanceAttribute->loadFromXMI1(tempElement)) {
return false;
}
- m_List.append(pInstanceAttribute);
+ subordinates().append(pInstanceAttribute);
}
node = node.nextSibling();
}//end while
diff --git a/umbrello/uml1model/package.cpp b/umbrello/uml1model/package.cpp
index 076901d..0c736c6 100644
--- a/umbrello/uml1model/package.cpp
+++ b/umbrello/uml1model/package.cpp
@@ -403,7 +403,7 @@ void UMLPackage::saveToXMI1(QDomDocument& qDoc, QDomElement& qElement)
obj->saveToXMI1 (qDoc, ownedElement);
}
// save associations
- for (UMLObjectListIt ait(m_List); ait.hasNext();) {
+ for (UMLObjectListIt ait(subordinates()); ait.hasNext();) {
obj = ait.next();
obj->saveToXMI1 (qDoc, ownedElement);
}
diff --git a/umbrello/uml1model/umlcanvasobject.cpp b/umbrello/uml1model/umlcanvasobject.cpp
index 8feea24..de15df5 100644
--- a/umbrello/uml1model/umlcanvasobject.cpp
+++ b/umbrello/uml1model/umlcanvasobject.cpp
@@ -53,7 +53,7 @@ UMLCanvasObject::~UMLCanvasObject()
}
/**
- * Return the subset of m_List that matches the given type.
+ * Return the subset of subordinates that matches the given type.
*
* @param assocType The AssociationType::Enum to match.
* @return The list of associations that match assocType.
@@ -62,7 +62,7 @@ UMLAssociationList UMLCanvasObject::getSpecificAssocs(Uml::AssociationType::Enum
{
UMLAssociationList list;
UMLObject *o = 0;
- for (UMLObjectListIt oit(m_List); oit.hasNext();) {
+ for (UMLObjectListIt oit(subordinates()); oit.hasNext();) {
o = oit.next();
uIgnoreZeroPointer(o);
if (o->baseType() != UMLObject::ot_Association)
@@ -75,7 +75,7 @@ UMLAssociationList UMLCanvasObject::getSpecificAssocs(Uml::AssociationType::Enum
}
/**
- * Adds an association end to m_List.
+ * Adds an association end to subordinates.
*
* @param assoc The association to add.
* @todo change param type to UMLRole
@@ -86,7 +86,7 @@ bool UMLCanvasObject::addAssociationEnd(UMLAssociation* assoc)
// add association only if not already present in list
if (!hasAssociation(assoc))
{
- m_List.append(assoc);
+ subordinates().append(assoc);
// Don't emit signals during load from XMI
UMLObject::emitModified();
@@ -103,7 +103,7 @@ bool UMLCanvasObject::addAssociationEnd(UMLAssociation* assoc)
*/
bool UMLCanvasObject::hasAssociation(UMLAssociation* assoc)
{
- uint cnt = m_List.count(assoc);
+ uint cnt = subordinates().count(assoc);
DEBUG(DBG_SRC) << "count is " << cnt;
return (cnt > 0);
}
@@ -116,14 +116,14 @@ bool UMLCanvasObject::hasAssociation(UMLAssociation* assoc)
*/
int UMLCanvasObject::removeAssociationEnd(UMLAssociation * assoc)
{
- if (!hasAssociation(assoc) || !m_List.removeAll(assoc)) {
+ if (!hasAssociation(assoc) || !subordinates().removeAll(assoc)) {
DEBUG(DBG_SRC) << "cannot find given assoc " << assoc << " in list";
return -1;
}
UMLApp::app()->document()->removeAssociation(assoc, false);
UMLObject::emitModified();
emit sigAssociationEndRemoved(assoc);
- return m_List.count();
+ return subordinates().count();
}
/**
@@ -131,8 +131,8 @@ int UMLCanvasObject::removeAssociationEnd(UMLAssociation * assoc)
*/
void UMLCanvasObject::removeAllAssociationEnds()
{
- for (int i = 0; i < m_List.count(); i++) {
- UMLObject *o = m_List.at(i);
+ for (int i = 0; i < subordinates().count(); i++) {
+ UMLObject *o = subordinates().at(i);
uIgnoreZeroPointer(o);
if (o->baseType() != UMLObject::ot_Association) {
continue;
@@ -165,9 +165,9 @@ void UMLCanvasObject::removeAllAssociationEnds()
*/
void UMLCanvasObject::removeAllChildObjects()
{
- if (!m_List.isEmpty()) {
+ if (!subordinates().isEmpty()) {
removeAllAssociationEnds();
- m_List.clear();
+ subordinates().clear();
}
}
@@ -244,7 +244,7 @@ UMLObject * UMLCanvasObject::findChildObject(const QString &n, UMLObject::Object
{
const bool caseSensitive = UMLApp::app()->activeLanguageIsCaseSensitive();
UMLObject *obj = 0;
- for (UMLObjectListIt oit(m_List); oit.hasNext();) {
+ for (UMLObjectListIt oit(subordinates()); oit.hasNext();) {
obj = oit.next();
uIgnoreZeroPointer(obj);
if (t != UMLObject::ot_UMLObject && obj->baseType() != t)
@@ -270,7 +270,7 @@ UMLObject* UMLCanvasObject::findChildObjectById(Uml::ID::Type id, bool considerA
{
Q_UNUSED(considerAncestors);
UMLObject *o = 0;
- for (UMLObjectListIt oit(m_List); oit.hasNext();) {
+ for (UMLObjectListIt oit(subordinates()); oit.hasNext();) {
o = oit.next();
uIgnoreZeroPointer(o);
if (o->id() == id)
@@ -290,10 +290,10 @@ bool UMLCanvasObject::operator==(const UMLCanvasObject& rhs) const
if (!UMLObject::operator==(rhs)) {
return false;
}
- if (m_List.count() != rhs.m_List.count()) {
+ if (subordinates().count() != rhs.subordinates().count()) {
return false;
}
- if (&m_List != &(rhs.m_List)) {
+ if (&subordinates() != &(rhs.subordinates())) {
return false;
}
return true;
@@ -310,7 +310,7 @@ void UMLCanvasObject::copyInto(UMLObject *lhs) const
// TODO Associations are not copied at the moment. This because
// the duplicate function (on umlwidgets) do not copy the associations.
//
- //target->m_List = m_List;
+ //target->subordinates() = subordinates();
}
/**
@@ -323,7 +323,7 @@ int UMLCanvasObject::associations()
{
int count = 0;
UMLObject *obj = 0;
- for (UMLObjectListIt oit(m_List); oit.hasNext();) {
+ for (UMLObjectListIt oit(subordinates()); oit.hasNext();) {
obj = oit.next();
uIgnoreZeroPointer(obj);
if (obj->baseType() == UMLObject::ot_Association)
@@ -341,7 +341,7 @@ UMLAssociationList UMLCanvasObject::getAssociations()
{
UMLAssociationList assocs;
UMLObject *o = 0;
- for (UMLObjectListIt oit(m_List); oit.hasNext() ;) {
+ for (UMLObjectListIt oit(subordinates()); oit.hasNext() ;) {
o = oit.next();
uIgnoreZeroPointer(o);
if (o->baseType() != UMLObject::ot_Association)
@@ -454,11 +454,11 @@ UMLAssociationList UMLCanvasObject::getRelationships()
bool UMLCanvasObject::resolveRef()
{
bool overallSuccess = UMLObject::resolveRef();
- for (UMLObjectListIt ait(m_List); ait.hasNext();) {
+ for (UMLObjectListIt ait(subordinates()); ait.hasNext();) {
UMLObject *obj = ait.next();
uIgnoreZeroPointer(obj);
if (! obj->resolveRef()) {
- m_List.removeAll(obj);
+ subordinates().removeAll(obj);
overallSuccess = false;
}
}
diff --git a/umbrello/uml1model/umlcanvasobject.h b/umbrello/uml1model/umlcanvasobject.h
index e1249ee..72d56c4 100644
--- a/umbrello/uml1model/umlcanvasobject.h
+++ b/umbrello/uml1model/umlcanvasobject.h
@@ -77,7 +77,7 @@ public:
virtual void removeAllChildObjects();
- UMLObjectList &subordinates() {
+ UMLObjectList &subordinates() const {
return m_List;
}
@@ -86,7 +86,7 @@ public:
// The abstract method UMLObject::saveToXMI1() is implemented
// in the classes inheriting from UMLCanvasObject.
-protected:
+private:
/**
* List of all the associations in this object.
@@ -96,7 +96,7 @@ protected:
* @todo Only a pointer to the appropriate assocation end object
* (UMLRole) should be saved here, not the entire UMLAssociation.
*/
- UMLObjectList m_List;
+ mutable UMLObjectList m_List;
signals: