[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Sun Aug 14 22:17:03 UTC 2005
SVN commit 449335 by okellogg:
Add Uml::Parameter_Direction.
M +14 -5 attribute.cpp
M +1 -0 classifier.cpp
M +14 -3 model_utils.cpp
M +7 -3 model_utils.h
M +2 -0 umllistview.cpp
M +7 -6 umllistviewitem.cpp
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/attribute.cpp #449334:449335
@@ -82,14 +82,16 @@
s = "- ";
else if(m_Scope == Uml::Protected)
s= "# ";
- } else
- s = "";
+ }
if(sig == Uml::st_ShowSig || sig == Uml::st_SigNoScope) {
// Determine whether the type name needs to be scoped.
UMLObject *owningObject = static_cast<UMLObject*>(parent());
- if (owningObject->getBaseType() == Uml::ot_Operation)
+ if (owningObject->getBaseType() == Uml::ot_Operation) {
+ // The immediate parent() is the UMLOperation but we want
+ // the UMLClassifier:
owningObject = static_cast<UMLObject*>(owningObject->parent());
+ }
UMLClassifier *ownParent = dynamic_cast<UMLClassifier*>(owningObject);
if (ownParent == NULL) {
kdError() << "UMLAttribute::toString: parent "
@@ -106,13 +108,20 @@
else
typeName = type->getName();
}
+ // The default direction, "in", is not mentioned.
+ // Perhaps we should include a pd_Unspecified in
+ // Uml::Parameter_Direction to have better control over this.
+ if (m_ParmKind == Uml::pd_InOut)
+ s += "inout ";
+ else if (m_ParmKind == Uml::pd_Out)
+ s += "out ";
// Construct the attribute text.
QString string = s + getName() + " : " + typeName;
if(m_InitialValue.length() > 0)
string += " = " + m_InitialValue;
return string;
- } else
- return s + getName();
+ }
+ return s + getName();
}
QString UMLAttribute::getFullyQualifiedName(QString separator) const {
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/classifier.cpp #449334:449335
@@ -163,6 +163,7 @@
const Model_Utils::NameAndType &nt = *it;
UMLAttribute *par = new UMLAttribute(op, nt.m_name);
par->setType(nt.m_type);
+ par->setParmKind(nt.m_direction);
par->setInitialValue(nt.m_initialValue);
op->addParm(par);
}
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/model_utils.cpp #449334:449335
@@ -303,12 +303,23 @@
Parse_Status parseAttribute(QString a, NameAndType& nmTp, UMLClassifier *owningScope) {
UMLDoc *pDoc = UMLApp::app()->getDocument();
- a = a.stripWhiteSpace();
+ a = a.simplifyWhiteSpace();
if (a.isEmpty())
return PS_Empty;
QStringList nameAndType = QStringList::split( QRegExp("\\s*:\\s*"), a);
- const QString &name = nameAndType[0];
+ QString name = nameAndType[0];
+ Uml::Parameter_Direction pd = Uml::pd_In;
+ if (name.startsWith("in ")) {
+ pd = Uml::pd_In;
+ name = name.mid(3);
+ } else if (name.startsWith("inout ")) {
+ pd = Uml::pd_InOut;
+ name = name.mid(6);
+ } else if (name.startsWith("out ")) {
+ pd = Uml::pd_Out;
+ name = name.mid(4);
+ }
UMLObject *pType = NULL;
QString initialValue;
if (nameAndType.count() == 2) {
@@ -321,7 +332,7 @@
initialValue = typeAndInitialValue[1];
}
}
- nmTp = NameAndType(name, pType, initialValue);
+ nmTp = NameAndType(name, pType, pd, initialValue);
return PS_OK;
}
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/model_utils.h #449334:449335
@@ -121,11 +121,15 @@
struct NameAndType {
QString m_name;
UMLObject *m_type;
+ Uml::Parameter_Direction m_direction;
QString m_initialValue;
- NameAndType() : m_type(0) {
+ NameAndType() : m_type(0), m_direction(Uml::pd_In) {
}
- NameAndType(QString name, UMLObject *type, QString initialValue = QString::null)
- : m_name(name), m_type(type), m_initialValue(initialValue) {
+ NameAndType(QString name, UMLObject *type,
+ Uml::Parameter_Direction direction = Uml::pd_In,
+ QString initialValue = QString::null)
+ : m_name(name), m_type(type),
+ m_direction(direction), m_initialValue(initialValue) {
}
};
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umllistview.cpp #449334:449335
@@ -1326,6 +1326,7 @@
UMLAttribute *newParm = new UMLAttribute(newParentClassifier, parm->getName());
newParm->setScope(parm->getScope());
newParm->setType(parm->getType());
+ newParm->setParmKind(parm->getParmKind());
newParm->setInitialValue(parm->getInitialValue());
newOp->addParm(newParm);
}
@@ -2395,6 +2396,7 @@
newObject = owningClass->createAttribute(nt.m_name);
UMLAttribute *att = static_cast<UMLAttribute*>(newObject);
att->setType(nt.m_type);
+ att->setParmKind(nt.m_direction);
att->setInitialValue(nt.m_initialValue);
text = att->toString(Uml::st_SigNoScope);
} else if ( type == Uml::ot_Operation ) {
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umllistviewitem.cpp #449334:449335
@@ -391,15 +391,15 @@
UMLAttribute *a;
if (i < parmList->count()) {
a = parmList->at(i);
- a->setName(nm_tp.m_name);
- a->setType(nm_tp.m_type);
- a->setInitialValue(nm_tp.m_initialValue);
} else {
a = new UMLAttribute(op);
a->setID( doc->getUniqueID() );
- a->setName(nm_tp.m_name);
- a->setType(nm_tp.m_type);
- a->setInitialValue(nm_tp.m_initialValue);
+ }
+ a->setName(nm_tp.m_name);
+ a->setType(nm_tp.m_type);
+ a->setParmKind(nm_tp.m_direction);
+ a->setInitialValue(nm_tp.m_initialValue);
+ if (i >= parmList->count()) {
op->addParm(a);
}
}
@@ -431,6 +431,7 @@
m_pObject->setName(nt.m_name);
UMLAttribute *pAtt = static_cast<UMLAttribute*>(m_pObject);
pAtt->setType(nt.m_type);
+ pAtt->setParmKind(nt.m_direction);
pAtt->setInitialValue(nt.m_initialValue);
m_Label = pAtt->toString(Uml::st_SigNoScope);
} else {
More information about the umbrello-devel
mailing list