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

Oliver Kellogg okellogg at users.sourceforge.net
Tue Feb 6 20:54:03 UTC 2007


SVN commit 630940 by okellogg:

sync with branches/KDE/3.5 (r629858:630936)

 M  +24 -15    clipboard/umlclipboard.cpp  
 M  +26 -19    umlcanvasobject.cpp  
 M  +6 -5      umlcanvasobject.h  
 M  +2 -7      umldoc.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/clipboard/umlclipboard.cpp #630939:630940
@@ -581,31 +581,45 @@
         return false;
     }
 
-    bool objectAlreadyExists = false;
     UMLObject   *obj = 0;
-    UMLObjectListIt object_it(objects);
     doc->setModified(true);
     idchanges = doc->getChangeLog();
+    // Assume success if at least one child object could be pasted
+    if (objects.count())
+        result = false;
 
-    while ( (obj=object_it.current()) != 0 ) {
+    for (UMLObjectListIt it(objects); (obj = it.current()) != NULL; ++it) {
         obj->setID(doc->assignNewID(obj->getID()));
         switch(obj->getBaseType()) {
         case Uml::ot_Attribute :
             {
-                if (parent->addAttribute(dynamic_cast<UMLAttribute*>(obj), idchanges)) {
-                    //FIXME                                     doc -> signalChildUMLObjectCreated(obj);
+                UMLObject *exist = parent->findChildObject(obj->getName(), Uml::ot_Attribute);
+                if (exist) {
+                    QString newName = parent->uniqChildName(Uml::ot_Attribute, obj->getName());
+                    obj->setName(newName);
+                }
+                UMLAttribute *att = static_cast<UMLAttribute*>(obj);
+                if (parent->addAttribute(att, idchanges)) {
+                    result = true;
                 } else {
-                    objectAlreadyExists = true;
+                    kError() << "UMLClipboard::pasteClip5: " << parent->getName()
+                        << "->addAttribute(" << att->getName() << ") failed" << endl;
                 }
                 break;
             }
         case Uml::ot_Operation :
             {
-                UMLClassifier * parent = dynamic_cast<UMLClassifier *>(lvitem -> getUMLObject());
-                if (parent -> addOperation(dynamic_cast<UMLOperation*>(obj), idchanges)) {
-                    //FIXME                             doc -> signalChildUMLObjectCreated(obj);
+                UMLOperation *op = static_cast<UMLOperation*>(obj);
+                UMLOperation *exist = parent->checkOperationSignature(op->getName(), op->getParmList());
+                if (exist) {
+                    QString newName = parent->uniqChildName(Uml::ot_Operation, obj->getName());
+                    op->setName(newName);
+                }
+                if (parent->addOperation(op, idchanges)) {
+                    result = true;
                 } else {
-                    objectAlreadyExists = true;
+                    kError() << "UMLClipboard::pasteClip5: " << parent->getName()
+                        << "->addOperation(" << op->getName() << ") failed" << endl;
                 }
                 break;
             }
@@ -613,13 +627,8 @@
             kWarning() << "pasteing unknown children type in clip type 5" << endl;
             return false;
         }
-        ++object_it;
     }
 
-    if (objectAlreadyExists) {
-        pasteItemAlreadyExists();
-    }
-
     return result;
 }
 
--- trunk/KDE/kdesdk/umbrello/umbrello/umlcanvasobject.cpp #630939:630940
@@ -136,25 +136,32 @@
 }
 
 QString UMLCanvasObject::uniqChildName( const Uml::Object_Type type,
-                                        bool seekStereo /* = false */ ) {
-    QString currentName;
-    if (seekStereo) {
-        currentName = i18n("new_stereotype");
-    } else if (type == Uml::ot_Association) {
-        currentName = i18n("new_association");
-    } else if (type == Uml::ot_Attribute) {
-        currentName = i18n("new_attribute");
-    } else if (type == Uml::ot_Template) {
-        currentName = i18n("new_template");
-    } else if (type == Uml::ot_Operation) {
-        currentName = i18n("new_operation");
-    } else if (type == Uml::ot_EnumLiteral) {
-        currentName = i18n("new_literal");
-    } else if (type == Uml::ot_EntityAttribute) {
-        currentName = i18n("new_field");
-    } else {
-        kWarning() << "uniqChildName() called for unknown child type " << type << endl;
-        return "ERROR_in_UMLCanvasObject_uniqChildName";
+                                        const QString &prefix /* = QString() */ ) {
+    QString currentName = prefix;
+    if (currentName.isEmpty()) {
+        switch (type) {
+            case Uml::ot_Association:
+                currentName = i18n("new_association");
+                break;
+            case Uml::ot_Attribute:
+                currentName = i18n("new_attribute");
+                break;
+            case Uml::ot_Template:
+                currentName = i18n("new_template");
+                break;
+            case Uml::ot_Operation:
+                currentName = i18n("new_operation");
+                break;
+            case Uml::ot_EnumLiteral:
+                currentName = i18n("new_literal");
+                break;
+            case Uml::ot_EntityAttribute:
+                currentName = i18n("new_field");
+                break;
+            default:
+                kWarning() << "uniqChildName() called for unknown child type " << type << endl;
+                return "ERROR_in_UMLCanvasObject_uniqChildName";
+        }
     }
 
     QString name = currentName;
--- trunk/KDE/kdesdk/umbrello/umbrello/umlcanvasobject.h #630939:630940
@@ -172,7 +172,7 @@
     /**
      * Find an association.
      *
-     * @param id                The id of the object to find.
+     * @param id        The id of the object to find.
      * @return  Pointer to the object found (NULL if not found.)
      */
     virtual UMLObject *findChildObjectById(Uml::IDType id, bool considerAncestors = false);
@@ -182,13 +182,14 @@
      * or attribute appended with a number if the default name is
      * taken e.g. new_association, new_association_1 etc.
      *
-     * @param type              The object type for which to make a name.
-     * @param seekStereo        Set this true if we should look at the object's
-     *                  stereotype instead of its name.
+     * @param type      The object type for which to make a name.
+     * @param prefix    Optional prefix to use for the name.
+     *                  If not given then uniqChildName() will choose the prefix
+     *                  internally based on the object type.
      * @return  Unique name string for the Object_Type given.
      */
     virtual QString uniqChildName(const Uml::Object_Type type,
-                                  bool seekStereo = false);
+                                  const QString &prefix = QString());
 
     virtual void removeAllChildObjects();
 
--- trunk/KDE/kdesdk/umbrello/umbrello/umldoc.cpp #630939:630940
@@ -150,15 +150,10 @@
     if ( pApp->getListView() )
         connect(this, SIGNAL(sigObjectRemoved(UMLObject *)), view, SLOT(slotObjectRemoved(UMLObject *)));
 
-    UMLView * previousView = pApp->getCurrentView();
     pApp->setCurrentView(view);
     if ( ! m_bLoading ) {
-        if (previousView == NULL) {
-            view -> show();
-            emit sigDiagramChanged(view ->getType());
-        } else {
-            view -> hide();
-        }
+        view -> show();
+        emit sigDiagramChanged(view ->getType());
     }
 
     Settings::OptionState optionState = Settings::getOptionState();




More information about the umbrello-devel mailing list