Commit 4173448d authored by Ralf Habacker's avatar Ralf Habacker

Move code returning localization string of uml object type to class UMLObject.

Add new method UMLObject::toI18nString().

CCBUG:342137
parent 23de6499
......@@ -62,50 +62,8 @@ ClassGeneralPage::ClassGeneralPage(UMLDoc* d, QWidget* parent, UMLObject* o)
topLayout->setSpacing(6);
// setup name
QString name;
UMLObject::ObjectType t = m_pObject->baseType();
switch (t) {
case UMLObject::ot_Class:
name = i18n("Class &name:");
break;
case UMLObject::ot_Actor:
name = i18n("Actor &name:");
break;
case UMLObject::ot_Package:
name = i18n("Package &name:");
break;
case UMLObject::ot_UseCase:
name = i18n("Use case &name:");
break;
case UMLObject::ot_Interface:
name = i18n("Interface &name:");
break;
case UMLObject::ot_Component:
name = i18n("Component &name:");
break;
case UMLObject::ot_Port:
name = i18n("Port &name:");
break;
case UMLObject::ot_Node:
name = i18n("Node &name:");
break;
case UMLObject::ot_Artifact:
name = i18n("Artifact &name:");
break;
case UMLObject::ot_Enum:
name = i18n("Enum &name:");
break;
case UMLObject::ot_Datatype:
name = i18n("Datatype &name:");
break;
case UMLObject::ot_Entity:
name = i18n("Entity &name:");
break;
default:
name = QLatin1String("<unknown> &name:");
uWarning() << "creating class gen page for unknown widget type";
break;
}
QString name = UMLObject::toI18nString(t);
QGridLayout * m_pNameLayout = new QGridLayout();
m_pNameLayout->setSpacing(6);
topLayout->addLayout(m_pNameLayout, 4);
......
......@@ -1081,6 +1081,63 @@ QString UMLObject::toString(ObjectType ot)
return QLatin1String(ENUM_NAME(UMLObject, ObjectType, ot));
}
/**
* Returns the given object type value as localized string.
* @param ot ObjectType of which a string representation is wanted
* @return the ObjectType as localized string
*/
QString UMLObject::toI18nString(ObjectType t)
{
QString name;
switch (t) {
case UMLObject::ot_Actor:
name = i18n("Actor &name:");
break;
case UMLObject::ot_Artifact:
name = i18n("Artifact &name:");
break;
case UMLObject::ot_Class:
name = i18n("Class &name:");
break;
case UMLObject::ot_Component:
name = i18n("Component &name:");
break;
case UMLObject::ot_Datatype:
name = i18n("Datatype &name:");
break;
case UMLObject::ot_Entity:
name = i18n("Entity &name:");
break;
case UMLObject::ot_Enum:
name = i18n("Enum &name:");
break;
case UMLObject::ot_Interface:
name = i18n("Interface &name:");
break;
case UMLObject::ot_Node:
name = i18n("Node &name:");
break;
case UMLObject::ot_Package:
name = i18n("Package &name:");
break;
case UMLObject::ot_Port:
name = i18n("Port &name:");
break;
case UMLObject::ot_Stereotype:
name = i18n("Stereotype &name:");
break;
case UMLObject::ot_UseCase:
name = i18n("Use case &name:");
break;
default:
name = QLatin1String("<unknown> &name:");
uWarning() << "unknown object type";
break;
}
return name;
}
/**
* Print UML Object to debug output stream, so it can be used like
* uDebug() << "This object shouldn't be here: " << illegalObject;
......
......@@ -77,6 +77,7 @@ public:
};
static QString toString(ObjectType ot);
static QString toI18nString(ObjectType t);
explicit UMLObject(UMLObject* parent, const QString& name, Uml::ID::Type id = Uml::ID::None);
explicit UMLObject(UMLObject* parent);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment