umbrello: umbrello/model_utils.h Source File

umbrello 2.32.0 Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology

model_utils.h
Go to the documentation of this file.
1 /***************************************************************************
2 * This program is free software; you can redistribute it and/or modify *
3 * it under the terms of the GNU General Public License as published by *
4 * the Free Software Foundation; either version 2 of the License, or *
5 * (at your option) any later version. *
6 * *
7 * copyright (C) 2004-2020 *
8 * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
9 ***************************************************************************/
10
11 #ifndef MODEL_UTILS_H
12 #define MODEL_UTILS_H
13
14 #include "basictypes.h"
15 #include "umllistviewitem.h"
16 #include "umlobjectlist.h"
17 #include "umlviewlist.h"
18 #include "foreignkeyconstraint.h"
19 #include "icon_utils.h"
20 #include "multipagedialogbase.h"
21 #include "widgetbase.h"
22
23 #include <QLinkedList>
24 #include <QString>
25
26 // forward declarations
27 class UMLClassifier;
28 class UMLPackage;
29 class UMLEntity;
30
36 namespace Model_Utils {
37
38 bool isCloneable(WidgetBase::WidgetType type);
39
40 UMLObject* findObjectInList(Uml::ID::Type id, const UMLObjectList& inList);
41
42 UMLObject* findUMLObject(const UMLObjectList& inList,
43 const QString& name,
44 UMLObject::ObjectType type = UMLObject::ot_UMLObject,
45 UMLObject *currentObj = 0);
46
47 UMLObject* findUMLObjectRaw(const UMLObjectList& inList,
48 const QString& name,
49 UMLObject::ObjectType type = UMLObject::ot_UMLObject,
50 UMLObject *currentObj = 0);
51
52 UMLObject* findUMLObjectRecursive(const UMLObjectList& inList,
53 const QString& name,
54 UMLObject::ObjectType type = UMLObject::ot_UMLObject);
55
56 UMLPackage* rootPackage(UMLObject* obj);
57
58 void treeViewAddViews(const UMLViewList& viewList);
59 void treeViewChangeIcon(UMLObject* object, Icon_Utils::IconType to);
60 void treeViewSetCurrentItem(UMLObject* object);
61 void treeViewMoveObjectTo(UMLObject* container, UMLObject* object);
62 UMLObject* treeViewGetCurrentObject();
63 UMLPackage* treeViewGetPackageFromCurrent();
64 QString treeViewBuildDiagramName(Uml::ID::Type id);
65
66 QString uniqObjectName(UMLObject::ObjectType type,
67 UMLPackage *parentPkg,
68 QString prefix = QString());
69 QString newTitle(UMLObject::ObjectType type);
70 QString newText(UMLObject::ObjectType type);
71 QString renameTitle(UMLObject::ObjectType type);
72 QString renameText(UMLObject::ObjectType type);
73
74 QString getXmiId(QDomElement element);
75 bool isCommonXMI1Attribute(const QString &tag);
76 bool isCommonDataType(QString type);
77 bool isClassifierListitem(UMLObject::ObjectType ot);
78
79 bool typeIsCanvasWidget(UMLListViewItem::ListViewType type);
80 bool typeIsRootView(UMLListViewItem::ListViewType type);
81 bool typeIsFolder(UMLListViewItem::ListViewType type);
82 bool typeIsContainer(UMLListViewItem::ListViewType type);
83 bool typeIsDiagram(UMLListViewItem::ListViewType type);
84 bool typeIsClassifierList(UMLListViewItem::ListViewType type);
85 bool typeIsClassifier(UMLListViewItem::ListViewType type);
86 bool typeIsProperties(UMLListViewItem::ListViewType type);
87 bool typeIsAllowedInType(UMLListViewItem::ListViewType childType,
88 UMLListViewItem::ListViewType parentType);
89 bool typeIsAllowedInDiagram(UMLObject *o, UMLScene *scene);
90 bool typeIsAllowedInDiagram(UMLWidget *w, UMLScene *scene);
91 bool hasAssociations(UMLObject::ObjectType type);
92
93 Uml::ModelType::Enum convert_DT_MT(Uml::DiagramType::Enum dt);
94 UMLListViewItem::ListViewType convert_MT_LVT(Uml::ModelType::Enum mt);
95 Uml::ModelType::Enum convert_LVT_MT(UMLListViewItem::ListViewType lvt);
96 UMLListViewItem::ListViewType convert_DT_LVT(Uml::DiagramType::Enum dt);
97 UMLObject::ObjectType convert_LVT_OT(UMLListViewItem::ListViewType lvt);
98 UMLListViewItem::ListViewType convert_OT_LVT(UMLObject *o);
99 Icon_Utils::IconType convert_LVT_IT(UMLListViewItem::ListViewType lvt, UMLObject *o=0);
100 Uml::DiagramType::Enum convert_LVT_DT(UMLListViewItem::ListViewType lvt);
101 MultiPageDialogBase::PageType convert_LVT_PT(UMLListViewItem::ListViewType type);
102 Uml::ModelType::Enum convert_OT_MT(UMLObject::ObjectType ot);
103
104 Uml::ModelType::Enum guessContainer(UMLObject *o); // deprecated !
105
106 int stringToDirection(QString input, Uml::ParameterDirection::Enum & result);
107
108 enum Parse_Status {
109 PS_OK, PS_Empty, PS_Malformed_Arg, PS_Unknown_ArgType,
110 PS_Illegal_MethodName, PS_Unknown_ReturnType, PS_Unspecified_Error
111 };
112
113 struct NameAndType {
114 QString m_name;
115 UMLObject *m_type;
116 Uml::ParameterDirection::Enum m_direction;
117 QString m_initialValue;
118 NameAndType() : m_type(0), m_direction(Uml::ParameterDirection::In) {}
119 NameAndType(QString name, UMLObject *type,
120 Uml::ParameterDirection::Enum direction = Uml::ParameterDirection::In,
121 QString initialValue = QString())
122 : m_name(name), m_type(type),
123 m_direction(direction), m_initialValue(initialValue) {}
124 };
125
126 typedef QLinkedList<NameAndType> NameAndType_List;
127 typedef QLinkedList<NameAndType>::iterator NameAndType_ListIt;
128
129 struct OpDescriptor {
130 QString m_name;
131 NameAndType_List m_args;
132 UMLObject *m_pReturnType;
133 };
134
135 Parse_Status parseTemplate(QString t, NameAndType& nmTp, UMLClassifier *owningScope);
136 Parse_Status parseAttribute(QString a, NameAndType& nmTp, UMLClassifier *owningScope,
137 Uml::Visibility::Enum *vis = 0);
138 Parse_Status parseOperation(QString m, OpDescriptor& desc, UMLClassifier *owningScope);
139 Parse_Status parseConstraint(QString m, QString& name, UMLEntity* owningScope);
140
141 QString psText(Parse_Status value);
142
143 QString updateDeleteActionToString(UMLForeignKeyConstraint::UpdateDeleteAction uda);
144
145 }
146
147 #endif
basictypes.h
MultiPageDialogBase::PageType
PageType
Available page types.
Definition: multipagedialogbase.h:57
UMLClassifier
Information for a non-graphical Concept/Class.
Definition: classifier.h:40
UMLEntity
Non-graphical Information for an Entity.
Definition: entity.h:35
UMLForeignKeyConstraint::UpdateDeleteAction
UpdateDeleteAction
Definition: foreignkeyconstraint.h:42
UMLListViewItem::ListViewType
ListViewType
Definition: umllistviewitem.h:44
UMLObjectList
Definition: umlobjectlist.h:29
UMLObject
The base class for UML objects.
Definition: umlobject.h:75
UMLObject::ObjectType
ObjectType
Definition: umlobject.h:81
UMLObject::ot_UMLObject
@ ot_UMLObject
Definition: umlobject.h:83
UMLPackage
Non-graphical information for a Package.
Definition: package.h:33
UMLScene
Definition: umlscene.h:70
UMLWidget
The base class for graphical UML objects.
Definition: umlwidget.h:41
WidgetBase::WidgetType
WidgetType
Definition: widgetbase.h:112
foreignkeyconstraint.h
icon_utils.h
multipagedialogbase.h
Icon_Utils::IconType
IconType
Definition: icon_utils.h:47
Model_Utils
Definition: model_utils.cpp:46
Model_Utils::convert_MT_LVT
UMLListViewItem::ListViewType convert_MT_LVT(Uml::ModelType::Enum mt)
Definition: model_utils.cpp:1459
Model_Utils::typeIsClassifier
bool typeIsClassifier(UMLListViewItem::ListViewType type)
Definition: model_utils.cpp:1275
Model_Utils::Parse_Status
Parse_Status
Definition: model_utils.h:108
Model_Utils::PS_Illegal_MethodName
@ PS_Illegal_MethodName
Definition: model_utils.h:110
Model_Utils::PS_Unknown_ReturnType
@ PS_Unknown_ReturnType
Definition: model_utils.h:110
Model_Utils::PS_Unspecified_Error
@ PS_Unspecified_Error
Definition: model_utils.h:110
Model_Utils::PS_Empty
@ PS_Empty
Definition: model_utils.h:109
Model_Utils::PS_Unknown_ArgType
@ PS_Unknown_ArgType
Definition: model_utils.h:109
Model_Utils::PS_OK
@ PS_OK
Return type of parseOperation().
Definition: model_utils.h:109
Model_Utils::PS_Malformed_Arg
@ PS_Malformed_Arg
Definition: model_utils.h:109
Model_Utils::convert_LVT_PT
MultiPageDialogBase::PageType convert_LVT_PT(UMLListViewItem::ListViewType type)
Definition: model_utils.cpp:2076
Model_Utils::typeIsAllowedInDiagram
bool typeIsAllowedInDiagram(UMLObject *o, UMLScene *scene)
Definition: model_utils.cpp:2177
Model_Utils::parseTemplate
Parse_Status parseTemplate(QString t, NameAndType &nmTp, UMLClassifier *owningScope)
Definition: model_utils.cpp:946
Model_Utils::typeIsClassifierList
bool typeIsClassifierList(UMLListViewItem::ListViewType type)
Definition: model_utils.cpp:1253
Model_Utils::getXmiId
QString getXmiId(QDomElement element)
Definition: model_utils.cpp:752
Model_Utils::treeViewMoveObjectTo
void treeViewMoveObjectTo(UMLObject *container, UMLObject *object)
Definition: model_utils.cpp:442
Model_Utils::convert_LVT_OT
UMLObject::ObjectType convert_LVT_OT(UMLListViewItem::ListViewType lvt)
Definition: model_utils.cpp:1736
Model_Utils::newText
QString newText(UMLObject::ObjectType type)
Definition: model_utils.cpp:625
Model_Utils::isCommonDataType
bool isCommonDataType(QString type)
Definition: model_utils.cpp:791
Model_Utils::newTitle
QString newTitle(UMLObject::ObjectType type)
Definition: model_utils.cpp:582
Model_Utils::psText
QString psText(Parse_Status value)
Definition: model_utils.cpp:1151
Model_Utils::treeViewGetPackageFromCurrent
UMLPackage * treeViewGetPackageFromCurrent()
Definition: model_utils.cpp:469
Model_Utils::uniqObjectName
QString uniqObjectName(UMLObject::ObjectType type, UMLPackage *parentPkg, QString prefix)
Definition: model_utils.cpp:531
Model_Utils::findUMLObjectRecursive
UMLObject * findUMLObjectRecursive(const UMLObjectList &inList, const QString &name, UMLObject::ObjectType type)
Definition: model_utils.cpp:365
Model_Utils::NameAndType_List
QLinkedList< NameAndType > NameAndType_List
Auxiliary type for OpDescriptor.
Definition: model_utils.h:126
Model_Utils::typeIsDiagram
bool typeIsDiagram(UMLListViewItem::ListViewType type)
Definition: model_utils.cpp:1403
Model_Utils::isCommonXMI1Attribute
bool isCommonXMI1Attribute(const QString &tag)
Definition: model_utils.cpp:766
Model_Utils::typeIsContainer
bool typeIsContainer(UMLListViewItem::ListViewType type)
Definition: model_utils.cpp:1239
Model_Utils::convert_DT_MT
Uml::ModelType::Enum convert_DT_MT(Uml::DiagramType::Enum dt)
Definition: model_utils.cpp:1424
Model_Utils::convert_OT_LVT
UMLListViewItem::ListViewType convert_OT_LVT(UMLObject *o)
Definition: model_utils.cpp:1578
Model_Utils::treeViewAddViews
void treeViewAddViews(const UMLViewList &viewList)
Definition: model_utils.cpp:404
Model_Utils::treeViewGetCurrentObject
UMLObject * treeViewGetCurrentObject()
Definition: model_utils.cpp:455
Model_Utils::findObjectInList
UMLObject * findObjectInList(Uml::ID::Type id, const UMLObjectList &inList)
Definition: model_utils.cpp:85
Model_Utils::treeViewSetCurrentItem
void treeViewSetCurrentItem(UMLObject *object)
Definition: model_utils.cpp:430
Model_Utils::convert_LVT_DT
Uml::DiagramType::Enum convert_LVT_DT(UMLListViewItem::ListViewType lvt)
Definition: model_utils.cpp:2030
Model_Utils::convert_LVT_IT
Icon_Utils::IconType convert_LVT_IT(UMLListViewItem::ListViewType lvt, UMLObject *o)
Definition: model_utils.cpp:1852
Model_Utils::renameTitle
QString renameTitle(UMLObject::ObjectType type)
Definition: model_utils.cpp:668
Model_Utils::treeViewBuildDiagramName
QString treeViewBuildDiagramName(Uml::ID::Type id)
Definition: model_utils.cpp:495
Model_Utils::NameAndType_ListIt
QLinkedList< NameAndType >::iterator NameAndType_ListIt
Auxiliary type for OpDescriptor.
Definition: model_utils.h:127
Model_Utils::parseAttribute
Parse_Status parseAttribute(QString a, NameAndType &nmTp, UMLClassifier *owningScope, Uml::Visibility::Enum *vis)
Definition: model_utils.cpp:986
Model_Utils::typeIsAllowedInType
bool typeIsAllowedInType(UMLListViewItem::ListViewType childType, UMLListViewItem::ListViewType parentType)
Definition: model_utils.cpp:1313
Model_Utils::findUMLObjectRaw
UMLObject * findUMLObjectRaw(const UMLObjectList &inList, const QString &name, UMLObject::ObjectType type, UMLObject *currentObj)
Definition: model_utils.cpp:339
Model_Utils::convert_DT_LVT
UMLListViewItem::ListViewType convert_DT_LVT(Uml::DiagramType::Enum dt)
Definition: model_utils.cpp:1517
Model_Utils::typeIsRootView
bool typeIsRootView(UMLListViewItem::ListViewType type)
Definition: model_utils.cpp:1166
Model_Utils::isClassifierListitem
bool isClassifierListitem(UMLObject::ObjectType type)
Definition: model_utils.cpp:813
Model_Utils::convert_LVT_MT
Uml::ModelType::Enum convert_LVT_MT(UMLListViewItem::ListViewType lvt)
Definition: model_utils.cpp:1489
Model_Utils::findUMLObject
UMLObject * findUMLObject(const UMLObjectList &inList, const QString &inName, UMLObject::ObjectType type, UMLObject *currentObj)
Definition: model_utils.cpp:157
Model_Utils::typeIsFolder
bool typeIsFolder(UMLListViewItem::ListViewType type)
Definition: model_utils.cpp:1220
Model_Utils::guessContainer
Uml::ModelType::Enum guessContainer(UMLObject *o)
Definition: model_utils.cpp:837
Model_Utils::convert_OT_MT
Uml::ModelType::Enum convert_OT_MT(UMLObject::ObjectType ot)
Definition: model_utils.cpp:2116
Model_Utils::rootPackage
UMLPackage * rootPackage(UMLObject *obj)
Definition: model_utils.cpp:385
Model_Utils::updateDeleteActionToString
QString updateDeleteActionToString(UMLForeignKeyConstraint::UpdateDeleteAction uda)
Definition: model_utils.cpp:2152
Model_Utils::renameText
QString renameText(UMLObject::ObjectType type)
Definition: model_utils.cpp:711
Model_Utils::parseConstraint
Parse_Status parseConstraint(QString m, QString &name, UMLEntity *owningScope)
Definition: model_utils.cpp:1131
Model_Utils::isCloneable
bool isCloneable(WidgetBase::WidgetType type)
Definition: model_utils.cpp:54
Model_Utils::stringToDirection
int stringToDirection(QString input, Uml::ParameterDirection::Enum &result)
Definition: model_utils.cpp:917
Model_Utils::typeIsCanvasWidget
bool typeIsCanvasWidget(UMLListViewItem::ListViewType type)
Definition: model_utils.cpp:1186
Model_Utils::parseOperation
Parse_Status parseOperation(QString m, OpDescriptor &desc, UMLClassifier *owningScope)
Definition: model_utils.cpp:1061
Model_Utils::typeIsProperties
bool typeIsProperties(UMLListViewItem::ListViewType type)
Definition: model_utils.cpp:1289
Model_Utils::treeViewChangeIcon
void treeViewChangeIcon(UMLObject *object, Icon_Utils::IconType to)
Definition: model_utils.cpp:420
Model_Utils::hasAssociations
bool hasAssociations(UMLObject::ObjectType type)
Definition: model_utils.cpp:2312
Uml::DiagramType::Enum
Enum
Definition: basictypes.h:77
Uml::ID::Type
std::string Type
Definition: basictypes.h:385
Uml::ModelType::Enum
Enum
Definition: basictypes.h:41
Uml::ParameterDirection::Enum
Enum
Definition: basictypes.h:268
Uml::ParameterDirection::In
@ In
Definition: basictypes.h:269
Uml::Visibility::Enum
Enum
Definition: basictypes.h:59
Uml
Definition: basictypes.cpp:37
a
QString a
Definition: petalnode.cpp:18
Model_Utils::NameAndType
Definition: model_utils.h:113
Model_Utils::NameAndType::m_direction
Uml::ParameterDirection::Enum m_direction
Definition: model_utils.h:116
Model_Utils::NameAndType::NameAndType
NameAndType()
Definition: model_utils.h:118
Model_Utils::NameAndType::m_type
UMLObject * m_type
Definition: model_utils.h:115
Model_Utils::NameAndType::m_initialValue
QString m_initialValue
Definition: model_utils.h:117
Model_Utils::NameAndType::NameAndType
NameAndType(QString name, UMLObject *type, Uml::ParameterDirection::Enum direction=Uml::ParameterDirection::In, QString initialValue=QString())
Definition: model_utils.h:119
Model_Utils::NameAndType::m_name
QString m_name
< Data structure filled by parseAttribute().
Definition: model_utils.h:114
Model_Utils::OpDescriptor
Definition: model_utils.h:129
Model_Utils::OpDescriptor::m_name
QString m_name
< Data structure filled by parseOperation().
Definition: model_utils.h:130
Model_Utils::OpDescriptor::m_pReturnType
UMLObject * m_pReturnType
Definition: model_utils.h:132
Model_Utils::OpDescriptor::m_args
NameAndType_List m_args
Definition: model_utils.h:131
umllistviewitem.h
umlobjectlist.h
umlviewlist.h
UMLViewList
QList< QPointer< UMLView > > UMLViewList
Definition: umlviewlist.h:26
widgetbase.h