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

Sharan Rao sharanrao at gmail.com
Fri Jul 27 03:02:21 UTC 2007


SVN commit 693097 by sharan:

*Application asks for alternate names when a duplicate named class is added to a package


 M  +13 -10    dialogs/classgenpage.cpp  
 M  +5 -1      dialogs/classwizard.cpp  
 M  +21 -0     package.cpp  
 M  +1 -1      uml.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/classgenpage.cpp #693096:693097
@@ -398,6 +398,9 @@
     if(m_pObject) {
         QString name = m_pClassNameLE -> text();
 
+        // set name first. We'll check for clashes later.
+        m_pObject->setName( name );
+
         m_pObject -> setDoc(m_pDoc -> text());
 
         if(m_pStereoTypeCB)
@@ -419,19 +422,19 @@
         lv->moveObject(m_pObject->getID(),
                          Model_Utils::convert_OT_LVT(m_pObject),
                            newLVParent);
+        // the name may have changed when the class was added to the package
+        name = m_pObject->getName();
 
-        m_pObject->emitModified();
-
         if( m_pAbstractCB )
             m_pObject -> setAbstract( m_pAbstractCB -> isChecked() );
-        //make sure unique name
-        UMLObject *o = m_pUmldoc -> findUMLObject(name);
-        if(o && m_pObject != o) {
-            KMessageBox::sorry(this, i18n("The name you have chosen\nis already being used.\nThe name has been reset."),
-                               i18n("Name is Not Unique"), false);
-            m_pClassNameLE -> setText( m_pObject -> getName() );
-        } else
-            m_pObject -> setName(name);
+//         //make sure unique name
+//         UMLObject *o = m_pUmldoc -> findUMLObject(name);
+//         if(o && m_pObject != o) {
+//             KMessageBox::sorry(this, i18n("The name you have chosen\nis already being used.\nThe name has been reset."),
+//                                i18n("Name is Not Unique"), false);
+//             m_pClassNameLE -> setText( m_pObject -> getName() );
+//         } else
+//             m_pObject -> setName(name);
         Uml::Visibility s;
         if(m_pPublicRB -> isChecked())
           s = Uml::Visibility::Public;
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/classwizard.cpp #693096:693097
@@ -41,7 +41,6 @@
         num.setNum( ++i);
         newName = name;
         newName.append("_").append( num );
-        m_pDoc->signalUMLObjectCreated(m_pClass);
     } while( pTemp );
     //setup pages
     setupPages();
@@ -94,10 +93,15 @@
     m_pDoc -> addUMLObject( m_pClass );
     m_pDoc->signalUMLObjectCreated(m_pClass);
 
+    // call updateObject of General Page again so as to bind to package
+    // now that the classifier object is in the document.
+    m_pGenPage->updateObject();
+
     Q3Wizard::accept();
 }
 
 void ClassWizard::reject() {
+    m_pDoc->removeUMLObject(m_pClass);
     delete m_pClass;
     Q3Wizard::reject();
 }
--- trunk/KDE/kdesdk/umbrello/umbrello/package.cpp #693096:693097
@@ -15,6 +15,8 @@
 // system includes
 #include <kdebug.h>
 #include <klocale.h>
+#include <kinputdialog.h>
+#include <kmessagebox.h>
 
 // local includes
 #include "uml.h"
@@ -120,6 +122,25 @@
             addAssocToConcepts(assoc);
         }
     }
+    QString name = pObject->getName();
+    QString oldName = name;
+    while ( findObject( name ) != NULL  ) {
+       name = Model_Utils::uniqObjectName(pObject->getBaseType(),this);
+       bool ok = true;
+       name = KInputDialog::getText(i18n("Name"), i18n("An object with this name already exists in the package %1.<br /> Please enter a new name:", this->getName()), name, &ok, (QWidget*)UMLApp::app());
+        if (!ok) {
+            name = oldName;
+            continue;
+        }
+        if (name.length() == 0) {
+            KMessageBox::error(0, i18n("That is an invalid name."),
+                               i18n("Invalid Name"));
+            continue;
+        }
+    }
+    if ( oldName != name ) {
+        pObject->setName(name);
+    }
     m_objects.append( pObject );
     return true;
 }
--- trunk/KDE/kdesdk/umbrello/umbrello/uml.cpp #693096:693097
@@ -116,9 +116,9 @@
     ///////////////////////////////////////////////////////////////////
     // call inits to invoke all other construction parts
     readOptionState();
+    m_pUndoStack = new KUndoStack(this);
     m_doc = new UMLDoc();
     m_doc->init();
-    m_pUndoStack = new KUndoStack(this);
     m_hasBegunMacro = false;
     initActions(); //now calls initStatusBar() because it is affected by setupGUI()
     initView();




More information about the umbrello-devel mailing list