umbrello/umbrello
model_utils.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef MODEL_UTILS_H
00012 #define MODEL_UTILS_H
00013
00014 #include <QtCore/QString>
00015 #include <QtCore/QLinkedList>
00016
00017 #include "umlnamespace.h"
00018 #include "umlobjectlist.h"
00019 #include "umlviewlist.h"
00020 #include "foreignkeyconstraint.h"
00021 #include "icon_utils.h"
00022
00023
00024 class UMLClassifier;
00025 class UMLPackage;
00026 class UMLEntity;
00027
00033 namespace Model_Utils {
00034
00035 bool isCloneable(Uml::Widget_Type type);
00036
00037 UMLObject* findObjectInList(Uml::IDType id, const UMLObjectList& inList);
00038
00039 UMLObject* findUMLObject( const UMLObjectList& inList,
00040 const QString& name,
00041 Uml::Object_Type type = Uml::ot_UMLObject,
00042 UMLObject *currentObj = NULL);
00043
00044 void treeViewAddViews(const UMLViewList& viewList);
00045 void treeViewChangeIcon(UMLObject* object, Icon_Utils::Icon_Type to);
00046 void treeViewSetCurrentItem(UMLObject* object);
00047 void treeViewMoveObjectTo(UMLObject* container, UMLObject* object);
00048 UMLObject* treeViewGetCurrentObject();
00049 UMLPackage* treeViewGetPackageFromCurrent();
00050 QString treeViewBuildDiagramName(Uml::IDType id);
00051
00052 QString uniqObjectName(Uml::Object_Type type,
00053 UMLPackage *parentPkg,
00054 QString prefix = QString());
00055
00056 bool isCommonXMIAttribute(const QString &tag);
00057 bool isCommonDataType(QString type);
00058 bool isClassifierListitem(Uml::Object_Type ot);
00059
00060 bool typeIsCanvasWidget(Uml::ListView_Type type);
00061 bool typeIsRootView(Uml::ListView_Type type);
00062 bool typeIsFolder(Uml::ListView_Type type);
00063 bool typeIsContainer(Uml::ListView_Type type);
00064 bool typeIsDiagram(Uml::ListView_Type type);
00065 bool typeIsClassifierList(Uml::ListView_Type type);
00066 bool typeIsClassifier(Uml::ListView_Type type);
00067
00068 Uml::Model_Type convert_DT_MT(Uml::Diagram_Type dt);
00069 Uml::ListView_Type convert_MT_LVT(Uml::Model_Type mt);
00070 Uml::Model_Type convert_LVT_MT(Uml::ListView_Type lvt);
00071 Uml::ListView_Type convert_DT_LVT(Uml::Diagram_Type dt);
00072 Uml::Object_Type convert_LVT_OT(Uml::ListView_Type lvt);
00073 Uml::ListView_Type convert_OT_LVT(UMLObject *o);
00074 Icon_Utils::Icon_Type convert_LVT_IT(Uml::ListView_Type lvt);
00075 Uml::Diagram_Type convert_LVT_DT(Uml::ListView_Type lvt);
00076 Uml::Model_Type convert_OT_MT(Uml::Object_Type ot);
00077
00078 Uml::Model_Type guessContainer(UMLObject *o);
00079
00080 int stringToDirection(QString input, Uml::Parameter_Direction & result);
00081
00082 QString progLangToString(Uml::Programming_Language pl);
00083 Uml::Programming_Language stringToProgLang(QString str);
00084
00085 QString diagramTypeToString(Uml::Diagram_Type dt);
00086
00087 enum Parse_Status {
00088 PS_OK, PS_Empty, PS_Malformed_Arg, PS_Unknown_ArgType,
00089 PS_Illegal_MethodName, PS_Unknown_ReturnType, PS_Unspecified_Error
00090 };
00091
00092 struct NameAndType {
00093 QString m_name;
00094 UMLObject *m_type;
00095 Uml::Parameter_Direction m_direction;
00096 QString m_initialValue;
00097 NameAndType() : m_type(0), m_direction(Uml::pd_In) {
00098 }
00099 NameAndType(QString name, UMLObject *type,
00100 Uml::Parameter_Direction direction = Uml::pd_In,
00101 QString initialValue = QString())
00102 : m_name(name), m_type(type),
00103 m_direction(direction), m_initialValue(initialValue) {
00104 }
00105 };
00106
00107 typedef QLinkedList<NameAndType> NameAndType_List;
00108 typedef QLinkedList<NameAndType>::iterator NameAndType_ListIt;
00109
00110 struct OpDescriptor {
00111 QString m_name;
00112 NameAndType_List m_args;
00113 UMLObject *m_pReturnType;
00114 };
00115
00116 Parse_Status parseTemplate(QString t, NameAndType& nmTp, UMLClassifier *owningScope);
00117 Parse_Status parseAttribute(QString a, NameAndType& nmTp, UMLClassifier *owningScope,
00118 Uml::Visibility *vis = 0);
00119 Parse_Status parseOperation(QString m, OpDescriptor& desc, UMLClassifier *owningScope);
00120 Parse_Status parseConstraint(QString m, QString& name, UMLEntity* owningScope);
00121
00122 QString psText(Parse_Status value);
00123
00124 QString updateDeleteActionToString( UMLForeignKeyConstraint::UpdateDeleteAction uda );
00125
00126 }
00127
00128 #endif