/** * Create an Umbrello object from a PetalNode of the UseCase, Component, * or Deployment View. * * @return True for success. * Given a PetalNode for which the mapping to Umbrello is not yet * implemented umbrellify() is a no-op but also returns true. */ bool umbrellify(PetalNode *node, const QString& modelsName, UMLListViewItem *parent) { if (node == NULL) { uError() << "umbrellify(" << modelsName << "): node is NULL"; return false; } QStringList args = node->initialArgs(); QString objType = args[0]; QString name = clean(args[1]); Uml::IDType id = quid(node); UMLObject *obj = NULL; UMLListViewItem *item = NULL; if (objType == "Class_Category") { UMLListViewItem::ListViewType lvType = folderType(parent); item = new UMLListViewItem( parent, name, lvType, id ); } else if (objType == "Class") { QString stereotype = clean(node->findAttribute("stereotype").string); if (stereotype == "Actor") { UMLActor *act = new UMLActor(name, id); item = new UMLListViewItem(parent, name, UMLListViewItem::lvt_Actor, act); obj = act; } else { uDebug() << "umbrellify(" << name << "): handling of Class stereotype " << stereotype << " is not yet implemented"; } } else if (objType == "UseCase") { UMLUseCase *uc = new UMLUseCase(name, id); item = new UMLListViewItem(parent, name, UMLListViewItem::lvt_UseCase, uc); obj = uc; } else if (objType == "SubSystem") { UMLComponent *comp = new UMLComponent(name, id); item = new UMLListViewItem(parent, name, UMLListViewItem::lvt_Component, comp); obj = comp; } else if (objType == "Processor" || objType == "Device") { UMLNode *un = new UMLNode(name, id); un->setStereotype(objType.toLower()); item = new UMLListViewItem(parent, name, UMLListViewItem::lvt_Node, un); obj = un; } else { uDebug() << "umbrellify: object type " << objType << " is not yet implemented"; return true; } PetalNode *models = node->findAttribute(modelsName).node; if (models) { PetalNode::NameValueList atts = models->attributes(); for (int i = 0; i < atts.count(); ++i) { if (! umbrellify(atts[i].second.node, modelsName, item)) return false; } } if (obj) { QString doc = node->findAttribute("documentation").string; if (! doc.isEmpty()) obj->setDoc(doc); UMLDoc *theDocument = UMLApp::app()->document(); theDocument->addUMLObject(obj); } return true; }