Commit 18747a69 authored by Oliver Kellogg's avatar Oliver Kellogg

Reverting commit 92d13fb6 prepares for work on tagged values:

umbrello/uml1model/package.{h,cpp}
- Function containedObjects() shall return UMLObjectList by value.
  Reason: In near future we will not be returning a class member.

umbrello/model_utils.cpp
umbrello/models/objectsmodel.cpp
umbrello/umldoc.cpp
umbrello/umllistview.cpp
umbrello/dialogs/pages/packagecontentspage.cpp
- At calls to UMLPackage::containedObjects() receive returned list by
  value.

CCBUG: 73847
parent 4fa1d999
......@@ -79,7 +79,7 @@ void PackageContentsPage::slotDoubleClick(QListWidgetItem *item)
if (index == -1) {
return;
}
UMLObjectList &contents = m_package->containedObjects();
UMLObjectList contents = m_package->containedObjects();
UMLObject *o = contents.at(index);
QPointer<ClassPropertiesDialog> dlg = new ClassPropertiesDialog(this, o, true);
dlg->exec();
......@@ -92,7 +92,7 @@ void PackageContentsPage::slotDoubleClick(QListWidgetItem *item)
void PackageContentsPage::fillListBox()
{
m_contentLW->clear();
UMLObjectList &contents = m_package->containedObjects();
UMLObjectList contents = m_package->containedObjects();
UMLObjectListIt objList_it(contents);
UMLObject* umlo = 0;
while (objList_it.hasNext()) {
......@@ -119,7 +119,7 @@ void PackageContentsPage::slotMenuSelection(QAction* action)
switch(id) {
case ListPopupMenu::mt_Delete:
{
UMLObjectList &contents = m_package->containedObjects();
UMLObjectList contents = m_package->containedObjects();
if (m_contentLW->currentRow() == -1)
break;
UMLObject *o = contents.at(m_contentLW->currentRow());
......
......@@ -222,7 +222,7 @@ UMLObject* findUMLObject(const UMLObjectList& inList,
foundType != UMLObject::ot_Component) {
continue;
}
UMLObjectList &objectsInCurrentScope = pkg->containedObjects();
UMLObjectList objectsInCurrentScope = pkg->containedObjects();
for (UMLObjectListIt oit(objectsInCurrentScope); oit.hasNext();) {
UMLObject *obj = oit.next();
uIgnoreZeroPointer(obj);
......
......@@ -135,9 +135,11 @@ QVariant ObjectsModel::data(const QModelIndex & index, int role) const
if (o->umlPackage()) {
UMLFolder *f = o->umlPackage()->asUMLFolder();
if (f) {
if (f->containedObjects().contains(o))
UMLObjectList content = f->containedObjects();
if (content.contains(o))
return QLatin1String("package +");
else if (f->subordinates().contains(o))
content = f->subordinates();
if (content.contains(o))
return QLatin1String("list +");
}
else
......
......@@ -243,7 +243,7 @@ void UMLPackage::removeAllObjects()
/**
* Returns the list of objects contained in this package.
*/
UMLObjectList &UMLPackage::containedObjects()
UMLObjectList UMLPackage::containedObjects()
{
return m_objects;
}
......
......@@ -45,7 +45,7 @@ public:
virtual void removeAllObjects();
UMLObjectList &containedObjects();
UMLObjectList containedObjects();
void addAssocToConcepts(UMLAssociation* assoc);
void removeAssocFromConcepts(UMLAssociation *assoc);
......
......@@ -1071,7 +1071,7 @@ UMLObject* UMLDoc::findUMLObject(const QString &name,
return o;
}
for (int i = 0; i < Uml::ModelType::N_MODELTYPES; ++i) {
UMLObjectList &list = m_root[i]->containedObjects();
UMLObjectList list = m_root[i]->containedObjects();
if (list.size() == 0)
continue;
o = Model_Utils::findUMLObject(list, name, type, currentObj);
......@@ -1115,7 +1115,7 @@ UMLObject* UMLDoc::findUMLObjectRaw(UMLFolder *folder,
{
if (folder == 0)
return 0;
UMLObjectList &list = folder->containedObjects();
UMLObjectList list = folder->containedObjects();
if (list.size() == 0)
return 0;
return Model_Utils::findUMLObjectRaw(list, name, type, 0);
......@@ -1150,7 +1150,7 @@ UMLObject* UMLDoc::findUMLObjectRecursive(UMLFolder *folder,
{
if (folder == 0)
return 0;
UMLObjectList &list = folder->containedObjects();
UMLObjectList list = folder->containedObjects();
if (list.size() == 0)
return 0;
return Model_Utils::findUMLObjectRecursive(list, name, type);
......@@ -1945,7 +1945,7 @@ void UMLDoc::removeUMLObject(UMLObject* umlobject, bool deleteObject)
uError() << umlobject->name() << ": root package is not set !";
return;
}
UMLObjectList &rootObjects = rootPkg->containedObjects();
UMLObjectList rootObjects = rootPkg->containedObjects();
// Store the associations to remove in a buffer because we
// should not remove elements from m_objectList while it is
// being iterated over.
......@@ -2779,11 +2779,13 @@ bool UMLDoc::loadUMLObjectsFromXMI1(QDomElement& element)
continue;
}
if (pkg) {
UMLObjectList &objects = pkg->containedObjects();
UMLObjectList objects = pkg->containedObjects();
if (! objects.contains(pObject)) {
DEBUG(DBG_SRC) << "CHECK: adding " << pObject->name()
<< " to " << pkg->name();
pkg->addObject(pObject);
if (!pkg->addObject(pObject)) {
DEBUG(DBG_SRC) << "pkg->addObject failed";
}
}
}
else if (ot != UMLObject::ot_Stereotype) {
......@@ -3035,7 +3037,7 @@ UMLEntityList UMLDoc::entities(bool includeNested /* =true */)
*/
UMLClassifierList UMLDoc::datatypes()
{
UMLObjectList &objects = m_datatypeRoot->containedObjects();
UMLObjectList objects = m_datatypeRoot->containedObjects();
UMLClassifierList datatypeList;
foreach (UMLObject *obj, objects) {
uIgnoreZeroPointer(obj);
......@@ -3482,7 +3484,7 @@ void UMLDoc::addDefaultDatatypes()
*/
void UMLDoc::createDatatype(const QString &name)
{
UMLObjectList &datatypes = m_datatypeRoot->containedObjects();
UMLObjectList datatypes = m_datatypeRoot->containedObjects();
UMLObject* umlobject = Model_Utils::findUMLObject(datatypes, name,
UMLObject::ot_Datatype, m_datatypeRoot);
if (!umlobject) {
......
......@@ -2756,7 +2756,7 @@ bool UMLListView::deleteItem(UMLListViewItem *temp)
} else if (Model_Utils::typeIsCanvasWidget(lvt) || Model_Utils::typeIsClassifierList(lvt)) {
UMLPackage *nmSpc = object->asUMLPackage();
if (nmSpc) {
UMLObjectList &contained = nmSpc->containedObjects();
UMLObjectList contained = nmSpc->containedObjects();
if (contained.count()) {
if (nmSpc->baseType() == UMLObject::ot_Class) {
KMessageBox::error(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment