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

Ralf Habacker ralf.habacker at gmail.com
Wed Dec 21 07:20:10 UTC 2011


SVN commit 1269646 by habacker:

added lightweidgt UML object search function

 M  +28 -0     model_utils.cpp  
 M  +5 -0      model_utils.h  
 M  +37 -0     umldoc.cpp  
 M  +8 -0      umldoc.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/model_utils.cpp #1269645:1269646
@@ -273,6 +273,34 @@
 }
 
 /**
+ * Find the UML object of the given type and name in the passed-in list.
+ * This methods search for the raw name.
+ *
+ * @param inList        List in which to seek the object.
+ * @param name          Name of the object to find.
+ * @param type          ObjectType of the object to find (optional.)
+ *                      When the given type is ot_UMLObject the type is
+ *                      disregarded, i.e. the given name is the only
+ *                      search criterion.
+ * @param currentObj    Object relative to which to search (optional.)
+ *                      If given then the enclosing scope(s) of this
+ *                      object are searched before the global scope.
+ * @return      Pointer to the UMLObject found, or NULL if not found.
+ */
+UMLObject* findUMLObjectRaw(const UMLObjectList& inList,
+                            const QString& name,
+                            UMLObject::ObjectType type /* = ot_UMLObject */,
+                            UMLObject *currentObj /*= 0*/)
+{
+    for (UMLObjectListIt oit(inList); oit.hasNext(); ) {
+        UMLObject *obj = oit.next();
+        if (obj->name() == name && type == obj->baseType())
+            return obj;
+    }
+    return NULL;
+}
+
+/**
  * Add the given list of views to the tree view.
  * @param viewList   the list of views to add
  */
--- trunk/KDE/kdesdk/umbrello/umbrello/model_utils.h #1269645:1269646
@@ -43,6 +43,11 @@
                           UMLObject::ObjectType type = UMLObject::ot_UMLObject,
                           UMLObject *currentObj = 0);
 
+UMLObject* findUMLObjectRaw( const UMLObjectList& inList,
+                             const QString& name,
+                             UMLObject::ObjectType type = UMLObject::ot_UMLObject,
+                             UMLObject *currentObj = 0);
+
 void treeViewAddViews(const UMLViewList& viewList);
 void treeViewChangeIcon(UMLObject* object, Icon_Utils::IconType to);
 void treeViewSetCurrentItem(UMLObject* object);
--- trunk/KDE/kdesdk/umbrello/umbrello/umldoc.cpp #1269645:1269646
@@ -815,6 +815,8 @@
     }
     for (int i = 0; i < Uml::ModelType::N_MODELTYPES; ++i) {
         UMLObjectList list = m_root[i]->containedObjects();
+        if (list.size() == 0)
+            continue;
         o = Model_Utils::findUMLObject(list, name, type, currentObj);
         if (o) {
             return o;
@@ -827,6 +829,41 @@
     return 0;
 }
 
+/**
+ * Used to find a @ref UMLObject by its type and raw name.
+ *
+ * @param modelType    The Mmdel type in which to search for the object
+ * @param name         The raw name of the @ref UMLObject to find.
+ * @param type         ObjectType of the object to find
+ * @return  Pointer to the UMLObject found, or NULL if not found.
+ */
+UMLObject* UMLDoc::findUMLObjectRaw(Uml::ModelType::Value modelType,
+                                    const QString &name,
+                                    UMLObject::ObjectType type)
+{
+    return findUMLObjectRaw(rootFolder(modelType), name, type);
+}
+
+/**
+ * Used to find a @ref UMLObject by its type and raw name.
+ *
+ * @param folder       The UMLFolder in which to search for the object
+ * @param name         The raw name of the @ref UMLObject to find.
+ * @param type         ObjectType of the object to find
+ * @return  Pointer to the UMLObject found, or NULL if not found.
+ */
+UMLObject* UMLDoc::findUMLObjectRaw(UMLFolder *folder,
+                                    const QString &name,
+                                    UMLObject::ObjectType type)
+{
+    if (folder == 0)
+        return 0;
+    UMLObjectList list = folder->containedObjects();
+    if (list.size() == 0)
+        return 0;
+    return Model_Utils::findUMLObjectRaw(list, name, type, 0);
+}
+
 //:TODO:
 //    /**
 //     * Used to find a reference to a @ref UMLObject given its non-numeric
--- trunk/KDE/kdesdk/umbrello/umbrello/umldoc.h #1269645:1269646
@@ -119,6 +119,14 @@
                              UMLObject::ObjectType type = UMLObject::ot_UMLObject,
                              UMLObject *currentObj = 0);
 
+    UMLObject* findUMLObjectRaw(Uml::ModelType::Value,
+                                const QString &name,
+                                UMLObject::ObjectType type = UMLObject::ot_UMLObject);
+
+    UMLObject* findUMLObjectRaw(UMLFolder *folder,
+                                const QString &name,
+                                UMLObject::ObjectType type = UMLObject::ot_UMLObject);
+
     //:TODO: UMLObject* findObjectByAuxId(const QString &idStr);
 
     UMLClassifier * findUMLClassifier(const QString &name);




More information about the umbrello-devel mailing list