[Uml-devel] KDE/kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Sat Feb 18 14:11:11 UTC 2012


SVN commit 1280651 by okellogg:

UMLListView::addNewItem(): Restore pre-2.0 behavior of giving the user the
chance to edit the name of the item.


 M  +24 -5     umllistview.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/umllistview.cpp #1280650:1280651
@@ -146,11 +146,27 @@
  */
 void UMLListView::slotItemChanged(QTreeWidgetItem * item, int column)
 {
-    if (m_editItem) {
-        DEBUG(DBG_SRC) << item->text(column);
-        endRename(static_cast<UMLListViewItem*>(item));
+    QString text = item->text(column);
+    UMLListViewItem *lvitem = static_cast<UMLListViewItem*>(item);
+
+    if (lvitem->creating()) {
+        DEBUG(DBG_SRC) << "creating text: " << text;
+        UMLObject *o = lvitem->umlObject();
+        if (o && !text.isEmpty()) {
+            // addNewItem() already did the createItem(), therefore
+            // we don't want any further signal or undo stack entry.
+            // In fact, we _cannot_ have signals enabled here because
+            // it gives an endless recursion.
+            blockSignals(true);
+            o->setNameCmd(text);
+            blockSignals(false);
     }
+        lvitem->setCreating(false);
+    } else if (m_editItem) {
+        DEBUG(DBG_SRC) << "text: " << text;
+        endRename(lvitem);
 }
+}
 
 /**
  * Handlerfor item selection changed signals.
@@ -2241,6 +2257,8 @@
         Uml::DiagramType dt = Model_Utils::convert_LVT_DT(type);
         name = uniqueDiagramName(dt);
         newItem = new UMLListViewItem(parentItem, name, type, Uml::id_None);
+        newItem->setIcon(icon);
+        newItem->setOpen(true);
     } else {
         UMLObject::ObjectType ot = Model_Utils::convert_LVT_OT(type);
         if (ot == UMLObject::ot_UMLObject) {
@@ -2261,12 +2279,13 @@
             name = Model_Utils::uniqObjectName(ot, parentPkg);
         }
         newItem = new UMLListViewItem(parentItem, name, type, (UMLObject *)0);
-        createItem(newItem, type);
-    }
     newItem->setIcon(icon);
     newItem->setOpen(true);
     newItem->setCreating(true);
+        editItem(newItem, 0);
+        createItem(newItem, type);
 }
+}
 
 /**
  * Called for informing the list view that an item was renamed.




More information about the umbrello-devel mailing list