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

Oliver Kellogg okellogg at users.sourceforge.net
Fri Jul 20 20:47:07 UTC 2007


SVN commit 690372 by okellogg:

apply r690368 from trunk

 M  +14 -3     enum.cpp  
 M  +1 -1      enum.h  
 M  +8 -1      listpopupmenu.cpp  
 M  +12 -1     umllistview.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/enum.cpp #690371:690372
@@ -19,6 +19,7 @@
 #include "enumliteral.h"
 #include "umldoc.h"
 #include "uml.h"
+#include "uniqueid.h"
 #include "clipboard/idchangelog.h"
 
 UMLEnum::UMLEnum(const QString& name, Uml::IDType id) : UMLClassifier(name, id) {
@@ -51,14 +52,23 @@
     setStereotype( "enum" );
 }
 
-UMLObject* UMLEnum::createEnumLiteral() {
-    QString currentName = uniqChildName(Uml::ot_EnumLiteral);
+UMLObject* UMLEnum::createEnumLiteral(const QString& name) {
+    Uml::IDType id = UniqueID::gen();
+    QString currentName;
+    if (name.isNull())  {
+        currentName = uniqChildName(Uml::ot_EnumLiteral);
+    } else {
+        currentName = name;
+    }
+
     UMLEnumLiteral* newEnumLiteral = new UMLEnumLiteral(this, currentName);
 
     bool ok = true;
     bool goodName = false;
 
-    while (ok && !goodName) {
+    //check for name.isNull() stops dialog being shown
+    //when creating enum literal via list view
+    while (ok && !goodName && name.isNull()) {
         ok = newEnumLiteral->showPropertiesDialog( UMLApp::app() );
         QString name = newEnumLiteral->getName();
 
@@ -70,6 +80,7 @@
     }
 
     if (!ok) {
+        delete newEnumLiteral;
         return NULL;
     }
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/enum.h #690371:690372
@@ -63,7 +63,7 @@
      *
      * @return  The UMLEnum created
      */
-    UMLObject* createEnumLiteral();
+    UMLObject* createEnumLiteral(const QString& name = QString());
 
     /**
      * Adds an enumliteral to the enum.
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/listpopupmenu.cpp #690371:690372
@@ -1150,8 +1150,15 @@
         insertStdItems(false);
         break;
 
+    case mt_Enum:
+        m_pInsert = new KPopupMenu(this);
+        m_pInsert->insertItem(SmallIcon("source"), i18n("Enum Literal..."), mt_EnumLiteral);
+        insertFileNew();
+        insertStdItems();
+        insertStdItem(mt_Properties);
+        break;
+
     case mt_Datatype:
-    case mt_Enum:
     case mt_Node:
     case mt_Artifact:
     case mt_Actor:
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umllistview.cpp #690371:690372
@@ -37,6 +37,7 @@
 #include "node.h"
 #include "artifact.h"
 #include "enum.h"
+#include "enumliteral.h"
 #include "entity.h"
 #include "docwindow.h"
 #include "listpopupmenu.h"
@@ -281,6 +282,10 @@
         addNewItem(temp, Uml::lvt_Enum);
         break;
 
+    case ListPopupMenu::mt_EnumLiteral:
+        addNewItem(temp, Uml::lvt_EnumLiteral);
+        break;
+
     case ListPopupMenu::mt_Template:
         addNewItem(temp, Uml::lvt_Template);
         break;
@@ -2096,7 +2101,13 @@
 
     //kDebug() << "UMLListView::createChildUMLObject (" << text << ")" << endl;
     UMLObject* newObject = NULL;
-    if ( type == Uml::ot_Template )  {
+    if ( type == Uml::ot_EnumLiteral ) {
+        UMLEnum *owningEnum = static_cast<UMLEnum*>(parent);
+        newObject = owningEnum->createEnumLiteral(text);
+
+        UMLEnumLiteral* enumLiteral = static_cast<UMLEnumLiteral*>(newObject);
+        text = enumLiteral->toString(Uml::st_SigNoVis);
+    } else if ( type == Uml::ot_Template )  {
         UMLClassifier *owningClassifier = static_cast<UMLClassifier*>(parent);
         Model_Utils::NameAndType nt;
         Model_Utils::Parse_Status st = Model_Utils::parseTemplate(text, nt, owningClassifier);




More information about the umbrello-devel mailing list