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

Sharan Rao sharanrao at gmail.com
Fri Jul 20 20:36:25 UTC 2007


SVN commit 690368 by sharan:

Added -
 Right-Click on Enum in listview -> New Enum Literal . And stuff related to that.



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


--- trunk/KDE/kdesdk/umbrello/umbrello/enum.cpp #690367:690368
@@ -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;
     }
 
--- trunk/KDE/kdesdk/umbrello/umbrello/enum.h #690367:690368
@@ -63,7 +63,7 @@
      *
      * @return  The UMLEnum created
      */
-    UMLObject* createEnumLiteral();
+    UMLObject* createEnumLiteral(const QString& name = QString());
 
     /**
      * Adds an enumliteral to the enum.
--- trunk/KDE/kdesdk/umbrello/umbrello/listpopupmenu.cpp #690367:690368
@@ -1288,8 +1288,15 @@
         insertStdItem(mt_Properties);
         break;
 
+    case mt_Enum:
+        m_pInsert = new KMenu(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_EnumLiteral:
     case mt_Node:
     case mt_Artifact:
--- trunk/KDE/kdesdk/umbrello/umbrello/umllistview.cpp #690367:690368
@@ -42,6 +42,7 @@
 #include "node.h"
 #include "artifact.h"
 #include "enum.h"
+#include "enumliteral.h"
 #include "entity.h"
 #include "category.h"
 #include "docwindow.h"
@@ -294,6 +295,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;
@@ -2235,7 +2240,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