[Uml-devel] KDE_3_2_BRANCH: kdesdk/umbrello/umbrello

Jonathan Riddell jri at jriddell.org
Sat Feb 28 06:39:01 UTC 2004


CVS commit by jriddell: 

Backport fix from 23 Feb which stopped it asking it confirm new operations when importing C++ headers
--
CVS commit by okellogg:

createOperation: Support non-interactive operating mode, required by
class import code.


  M +26 -5     umldoc.cpp   1.122.2.4
  M +11 -8     umldoc.h   1.56.2.1


--- kdesdk/umbrello/umbrello/umldoc.cpp  #1.122.2.3:1.122.2.4
@@ -865,5 +865,5 @@ UMLObject* UMLDoc::createStereotype(UMLC
 UMLOperation* UMLDoc::createOperation(UMLClassifier* classifier,
                                       const QString &name /*=null*/,
-                                      UMLAttributeList *params )
+                                      UMLAttributeList *params  /*=NULL*/)
 {
         if(!classifier)
@@ -873,5 +873,6 @@ UMLOperation* UMLDoc::createOperation(UM
                 return NULL;
         }
-        if (name != QString::null && !name.isEmpty()) {
+        bool nameNotSet = (name == QString::null || name.isEmpty());
+        if (! nameNotSet) {
                 UMLOperation *existingOp = classifier->checkOperationSignature(name, params);
                 if (existingOp)
@@ -879,5 +880,4 @@ UMLOperation* UMLDoc::createOperation(UM
         }
         UMLOperation *op = new UMLOperation(NULL, name, getUniqueID());
-        op->setName( classifier->uniqChildName(Uml::ot_Operation) );
         if (params)
         {
@@ -890,4 +890,5 @@ UMLOperation* UMLDoc::createOperation(UM
                 }
         }
+        /*
         do {
                 UMLOperationDialog operationDialogue(0, op);
@@ -897,4 +898,24 @@ UMLOperation* UMLDoc::createOperation(UM
                 }
         } while (classifier->checkOperationSignature(op->getName(), op->getParmList()));
+        */
+        if (nameNotSet || params == NULL) {
+                if (nameNotSet)
+                        op->setName( classifier->uniqChildName(Uml::ot_Operation) );
+                do {
+                        UMLOperationDialog operationDialogue(0, op);
+                        if( operationDialogue.exec() != QDialog::Accepted ) {
+                                delete op;
+                                return NULL;
+                        } else if (classifier->checkOperationSignature(op->getName(), op->getParmList())) {
+                                KMessageBox::information(0,
+//no new i18n                                                    i18n("An operation with the same name and signature already exists. "
+//                                                            "You can not add it again.")
+                                                         "");
+                        } else {
+                                break;
+                        }
+                } while(1);
+        }
+//FIXMEnow
 
         // operation name is ok, formally add it to the classifier

--- kdesdk/umbrello/umbrello/umldoc.h  #1.56:1.56.2.1
@@ -237,12 +237,15 @@ public:
         /**
          * Creates an operation in the current document.
-         * The new Operation is already initialized with name, id, etc.
-         * If no name is provided, or if the name given as parameter conflicts with
-         * other operations in the classifier, an Operation Dialog is shown to ask the user
-         * for a name and gives the chance to set other Op. properties
-         * The Operation's signature is checked for validity within the parent classifier.
+         * The new operation is initialized with name, id, etc.
+         * If a method with the given profile already exists in the classifier,
+         * no new method is created and the existing operation is returned.
+         * If no name is provided, or if the params are NULL, an Operation
+         * Dialog is shown to ask the user for a name and parameters.
+         * The operation's signature is checked for validity within the parent
+         * classifier.
          *
-         * @return The new operation, or NULL if the operation could not be created because
-         *         for example, the user canceled the dialog or no appropriate name can be found.
+         * @return The new operation, or NULL if the operation could not be
+         *         created because for example, the user canceled the dialog
+         *         or no appropriate name can be found.
         */
         UMLOperation* createOperation( UMLClassifier *parent,






More information about the umbrello-devel mailing list