[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Sat Aug 27 11:38:23 UTC 2005
SVN commit 454021 by okellogg:
UMLListView::slotObjectCreated(): The classifier might already have
UMLClassifierListItems, therefore add them in the list view using
childObjectAdded().
M +1 -13 dialogs/classwizard.cpp
M +36 -7 umllistview.cpp
M +15 -8 umllistview.h
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/dialogs/classwizard.cpp #454020:454021
@@ -1,5 +1,5 @@
/*
- * copyright (C) 2002-2004
+ * copyright (C) 2002-2005
* Umbrello UML Modeller Authors <uml-devel@ uml.sf.net>
*/
@@ -25,7 +25,6 @@
#include "../classifier.h"
#include "../attribute.h"
#include "../operation.h"
-#include "../umllistview.h"
#include "../umlclassifierlistitemlist.h"
#include "../classifierlistitem.h"
@@ -96,17 +95,6 @@
m_pDoc -> addUMLObject( m_pClass );
m_pDoc->signalUMLObjectCreated(m_pClass);
- UMLListView *listView = UMLApp::app()->getListView();
- UMLClassifierListItemList attributes = m_pClass->getFilteredList(Uml::ot_Attribute);
- for ( UMLClassifierListItem* attribute = attributes.first(); attribute; attribute = attributes.next() ) {
- listView->childObjectAdded(attribute, m_pClass);
- }
-
- UMLOperationList operations = m_pClass->getOpList();
- for ( UMLOperation* operation = operations.first(); operation; operation = operations.next() ) {
- listView->childObjectAdded(operation, m_pClass);
- }
-
QWizard::accept();
}
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umllistview.cpp #454020:454021
@@ -656,6 +656,21 @@
return parentItem;
}
+bool UMLListView::mayHaveChildItems(Uml::Object_Type type) {
+ bool retval = false;
+ switch (type) {
+ case Uml::ot_Class:
+ case Uml::ot_Interface:
+ case Uml::ot_Enum:
+ case Uml::ot_Entity: // CHECK: more?
+ retval = true;
+ break;
+ default:
+ break;
+ }
+ return retval;
+}
+
void UMLListView::slotObjectCreated(UMLObject* object) {
UMLListViewItem* newItem = findUMLObject(object);
if (newItem) {
@@ -671,6 +686,13 @@
connectNewObjectsSlots(object);
newItem = new UMLListViewItem(parentItem, object->getName(), convert_OT_LVT(type), object);
+ if (mayHaveChildItems(type)) {
+ UMLClassifier *c = static_cast<UMLClassifier*>(object);
+ UMLClassifierListItemList cListItems = c->getFilteredList(Uml::ot_UMLObject);
+ UMLClassifierListItem *cli;
+ for (UMLClassifierListItemListIt it(cListItems); (cli = it.current()) != NULL; ++it)
+ childObjectAdded(cli, c);
+ }
if (m_doc->loading())
return;
ensureItemVisible(newItem);
@@ -747,6 +769,8 @@
void UMLListView::childObjectAdded(UMLClassifierListItem* child, UMLClassifier* parent) {
if (!m_bCreatingChildObject) {
+ const QString text = child->toString(Uml::st_SigNoScope);
+ UMLListViewItem *childItem = NULL;
UMLListViewItem *parentItem = findUMLObject(parent);
if (parentItem == NULL) {
kdDebug() << "UMLListView::childObjectAdded(" << child->getName()
@@ -755,17 +779,22 @@
parentItem = new UMLListViewItem(m_lv, parent->getName(),
convert_OT_LVT(parent->getBaseType()),
parent);
+ } else {
+ childItem = parentItem->findUMLObject(child);
}
- QString text = child->toString(Uml::st_SigNoScope);
- UMLListViewItem *newItem = new UMLListViewItem(parentItem, text,
+ if (childItem) {
+ childItem->setText(text);
+ } else {
+ childItem = new UMLListViewItem(parentItem, text,
convert_OT_LVT(child->getBaseType()), child);
- if (! m_doc->loading()) {
- ensureItemVisible(newItem);
- clearSelection();
- setSelected(newItem, true);
+ if (! m_doc->loading()) {
+ ensureItemVisible(childItem);
+ clearSelection();
+ setSelected(childItem, true);
+ }
+ connectNewObjectsSlots(child);
}
}
- connectNewObjectsSlots(child);
}
void UMLListView::childObjectRemoved(UMLClassifierListItem* obj) {
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umllistview.h #454020:454021
@@ -169,6 +169,13 @@
UMLListViewItem* determineParentItem(Uml::ListView_Type lvt) const;
/**
+ * Return true if the given Object_Type permits child items.
+ * A "child item" is anything that qualifies as a UMLClassifierListItem,
+ * e.g. operations and attributes of classifiers.
+ */
+ static bool mayHaveChildItems(Uml::Object_Type type);
+
+ /**
* Return the amount of items selected.
*/
int getSelectedCount();
@@ -423,6 +430,14 @@
*/
void deleteChildrenOf( QListViewItem *parent );
+ /**
+ * Adds a new operation, attribute or template item to a classifier, identical to
+ * childObjectAdded(obj) but with an explicit parent.
+ * @param child the child object
+ * @param parent the parent object
+ */
+ void childObjectAdded(UMLClassifierListItem* child, UMLClassifier* parent);
+
public slots:
/**
@@ -455,14 +470,6 @@
void childObjectAdded(UMLClassifierListItem* obj);
/**
- * Adds a new operation, attribute or template item to a classifier, identical to
- * childObjectAdded(obj) but with an explicit parent. Used by ClassWizard.
- * @param child the child object
- * @param parent the parent object
- */
- void childObjectAdded(UMLClassifierListItem* child, UMLClassifier* parent);
-
- /**
* disconnects signals and removes the list view item
* @param object the object about to be removed
*/
More information about the umbrello-devel
mailing list