umbrello: umbrello/umlwidgets/classifierwidget.h Source File

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

classifierwidget.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 CLASSIFIERWIDGET_H
12 #define CLASSIFIERWIDGET_H
13
14 #include "basictypes.h"
15 #include "umlobject.h"
16 #include "umlwidget.h"
17
18 class AssociationWidget;
19 class FloatingTextWidget;
20 class QPainter;
21 class UMLClassifier;
22
32 class ClassifierWidget : public UMLWidget
33 {
34 Q_OBJECT
35 Q_ENUMS(VisualProperty)
36 public:
42 enum VisualProperty {
43 ShowStereotype = 0x1,
44 ShowOperations = 0x2,
45 ShowPublicOnly = 0x4,
46 ShowVisibility = 0x8,
47 ShowPackage = 0x10,
48 ShowAttributes = 0x20,
49 DrawAsCircle = 0x40,
50 ShowOperationSignature = 0x60,
51 ShowAttributeSignature = 0x80,
52 DrawAsPackage = 0x100,
53 ShowDocumentation = 0x200,
54 };
55
56 Q_DECLARE_FLAGS(VisualProperties, VisualProperty)
57
58 ClassifierWidget(UMLScene * scene, UMLClassifier * o);
59 ClassifierWidget(UMLScene * scene, UMLPackage * o);
60 virtual ~ClassifierWidget();
61
62 UMLClassifier *classifier() const;
63
64 VisualProperties visualProperties() const;
65 void setVisualProperties(VisualProperties properties);
66
67 bool visualProperty(VisualProperty property) const;
68 void setVisualProperty(VisualProperty property, bool enable = true);
69 void setVisualPropertyCmd(VisualProperty property, bool enable = true);
70 void toggleVisualProperty(VisualProperty property);
71
72 int displayedAttributes() const;
73 int displayedOperations() const;
74
75 Uml::SignatureType::Enum attributeSignature() const;
76 void setAttributeSignature(Uml::SignatureType::Enum sig);
77
78 Uml::SignatureType::Enum operationSignature() const;
79 void setOperationSignature(Uml::SignatureType::Enum sig);
80
81 void setShowAttSigs(bool _show);
82 void toggleShowAttSigs();
83
84 bool getDrawAsCircle() const;
85 void setDrawAsCircle(bool drawAsCircle);
86 void toggleDrawAsCircle();
87
88 void changeToClass();
89 void changeToInterface();
90 void changeToPackage();
91
92 AssociationWidget *classAssociationWidget() const;
93 void setClassAssociationWidget(AssociationWidget *assocwidget);
94
95 UMLWidget* onWidget(const QPointF& p);
96 UMLWidget* widgetWithID(Uml::ID::Type id);
97
98 virtual void setDocumentation(const QString& doc);
99
100 QSizeF calculateSize(bool withExtensions = true) const;
101
102 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
103 virtual QPainterPath shape() const;
104
105 virtual void saveToXMI1(QDomDocument & qDoc, QDomElement & qElement);
106 virtual bool loadFromXMI1(QDomElement & qElement);
107
108 virtual bool showPropertiesDialog();
109 void setUMLObject(UMLObject *obj);
110
111 public Q_SLOTS:
112 virtual void slotMenuSelection(QAction* action);
113
114 private Q_SLOTS:
115 void slotShowAttributes(bool state);
116 void slotShowOperations(bool state);
117
118 protected:
119 virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
120
121 private:
122 void updateSignatureTypes();
123 QSize calculateTemplatesBoxSize() const;
124
125 QSizeF minimumSize() const;
126
127 void drawAsCircle(QPainter *p, const QStyleOptionGraphicsItem *option);
128 QSize calculateAsCircleSize() const;
129
130 void drawAsPackage(QPainter *painter, const QStyleOptionGraphicsItem *option);
131 QSize calculateAsPackageSize() const;
132
133 int displayedMembers(UMLObject::ObjectType ot) const;
134 void drawMembers(QPainter *painter, UMLObject::ObjectType ot, Uml::SignatureType::Enum sigType,
135 int x, int y, int textWidth, int fontHeight);
136
137 static const int CIRCLE_SIZE;
138 static const int SOCKET_INCREMENT;
139
140 VisualProperties m_visualProperties;
141 Uml::SignatureType::Enum m_attributeSignature;
142 Uml::SignatureType::Enum m_operationSignature;
143 AssociationWidget *m_pAssocWidget;
144 QPointer<FloatingTextWidget> m_pInterfaceName;
145
146 };
147
148 Q_DECLARE_OPERATORS_FOR_FLAGS(ClassifierWidget::VisualProperties)
149
150 #endif
basictypes.h
AssociationWidget
This class represents an association inside a diagram. Bugs and comments to umbrello-devel@kde....
Definition: associationwidget.h:52
ClassifierWidget
Common implementation for class widget and interface widget.
Definition: classifierwidget.h:33
ClassifierWidget::displayedAttributes
int displayedAttributes() const
Definition: classifierwidget.cpp:664
ClassifierWidget::slotShowOperations
void slotShowOperations(bool state)
Definition: classifierwidget.cpp:1490
ClassifierWidget::setVisualPropertyCmd
void setVisualPropertyCmd(VisualProperty property, bool enable=true)
Definition: classifierwidget.cpp:224
ClassifierWidget::m_pAssocWidget
AssociationWidget * m_pAssocWidget
related AssociationWidget in case this classifier acts as an association class
Definition: classifierwidget.h:143
ClassifierWidget::showPropertiesDialog
virtual bool showPropertiesDialog()
Definition: classifierwidget.cpp:1506
ClassifierWidget::widgetWithID
UMLWidget * widgetWithID(Uml::ID::Type id)
Definition: classifierwidget.cpp:1132
ClassifierWidget::setDrawAsCircle
void setDrawAsCircle(bool drawAsCircle)
Definition: classifierwidget.cpp:1153
ClassifierWidget::attributeSignature
Uml::SignatureType::Enum attributeSignature() const
Definition: classifierwidget.cpp:361
ClassifierWidget::changeToPackage
void changeToPackage()
Definition: classifierwidget.cpp:1246
ClassifierWidget::SOCKET_INCREMENT
static const int SOCKET_INCREMENT
augmentation of circle for socket (required interface)
Definition: classifierwidget.h:138
ClassifierWidget::m_operationSignature
Uml::SignatureType::Enum m_operationSignature
Loaded/saved item.
Definition: classifierwidget.h:142
ClassifierWidget::VisualProperty
VisualProperty
Definition: classifierwidget.h:42
ClassifierWidget::ShowPackage
@ ShowPackage
Definition: classifierwidget.h:47
ClassifierWidget::ShowDocumentation
@ ShowDocumentation
Definition: classifierwidget.h:53
ClassifierWidget::ShowPublicOnly
@ ShowPublicOnly
Definition: classifierwidget.h:45
ClassifierWidget::ShowOperations
@ ShowOperations
Definition: classifierwidget.h:44
ClassifierWidget::ShowOperationSignature
@ ShowOperationSignature
only in setter
Definition: classifierwidget.h:50
ClassifierWidget::ShowStereotype
@ ShowStereotype
Definition: classifierwidget.h:43
ClassifierWidget::DrawAsCircle
@ DrawAsCircle
Definition: classifierwidget.h:49
ClassifierWidget::ShowAttributeSignature
@ ShowAttributeSignature
only in setter
Definition: classifierwidget.h:51
ClassifierWidget::DrawAsPackage
@ DrawAsPackage
Definition: classifierwidget.h:52
ClassifierWidget::ShowAttributes
@ ShowAttributes
Definition: classifierwidget.h:48
ClassifierWidget::ShowVisibility
@ ShowVisibility
Definition: classifierwidget.h:46
ClassifierWidget::setUMLObject
void setUMLObject(UMLObject *obj)
Definition: classifierwidget.cpp:1521
ClassifierWidget::setOperationSignature
void setOperationSignature(Uml::SignatureType::Enum sig)
Definition: classifierwidget.cpp:393
ClassifierWidget::calculateSize
QSizeF calculateSize(bool withExtensions=true) const
Definition: classifierwidget.cpp:477
ClassifierWidget::classAssociationWidget
AssociationWidget * classAssociationWidget() const
Definition: classifierwidget.cpp:701
ClassifierWidget::visualProperty
bool visualProperty(VisualProperty property) const
Definition: classifierwidget.cpp:182
ClassifierWidget::onWidget
UMLWidget * onWidget(const QPointF &p)
Definition: classifierwidget.cpp:1118
ClassifierWidget::saveToXMI1
virtual void saveToXMI1(QDomDocument &qDoc, QDomElement &qElement)
Definition: classifierwidget.cpp:1333
ClassifierWidget::toggleVisualProperty
void toggleVisualProperty(VisualProperty property)
Definition: classifierwidget.cpp:300
ClassifierWidget::visualProperties
VisualProperties visualProperties() const
Definition: classifierwidget.cpp:155
ClassifierWidget::operationSignature
Uml::SignatureType::Enum operationSignature() const
Definition: classifierwidget.cpp:383
ClassifierWidget::setVisualProperties
void setVisualProperties(VisualProperties properties)
Definition: classifierwidget.cpp:164
ClassifierWidget::drawMembers
void drawMembers(QPainter *painter, UMLObject::ObjectType ot, Uml::SignatureType::Enum sigType, int x, int y, int textWidth, int fontHeight)
Definition: classifierwidget.cpp:1081
ClassifierWidget::getDrawAsCircle
bool getDrawAsCircle() const
Definition: classifierwidget.cpp:1190
ClassifierWidget::m_visualProperties
VisualProperties m_visualProperties
Definition: classifierwidget.h:140
ClassifierWidget::ClassifierWidget
ClassifierWidget(UMLScene *scene, UMLClassifier *o)
Definition: classifierwidget.cpp:47
ClassifierWidget::calculateAsCircleSize
QSize calculateAsCircleSize() const
Definition: classifierwidget.cpp:997
ClassifierWidget::drawAsCircle
void drawAsCircle(QPainter *p, const QStyleOptionGraphicsItem *option)
Definition: classifierwidget.cpp:914
ClassifierWidget::m_pInterfaceName
QPointer< FloatingTextWidget > m_pInterfaceName
Separate widget for name in case of interface drawn as circle.
Definition: classifierwidget.h:144
ClassifierWidget::calculateTemplatesBoxSize
QSize calculateTemplatesBoxSize() const
Definition: classifierwidget.cpp:632
ClassifierWidget::setAttributeSignature
void setAttributeSignature(Uml::SignatureType::Enum sig)
Definition: classifierwidget.cpp:372
ClassifierWidget::paint
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Definition: classifierwidget.cpp:711
ClassifierWidget::changeToInterface
void changeToInterface()
Definition: classifierwidget.cpp:1230
ClassifierWidget::setClassAssociationWidget
void setClassAssociationWidget(AssociationWidget *assocwidget)
Definition: classifierwidget.cpp:688
ClassifierWidget::~ClassifierWidget
virtual ~ClassifierWidget()
Definition: classifierwidget.cpp:133
ClassifierWidget::mouseDoubleClickEvent
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
Definition: classifierwidget.cpp:1495
ClassifierWidget::calculateAsPackageSize
QSize calculateAsPackageSize() const
Definition: classifierwidget.cpp:1044
ClassifierWidget::setDocumentation
virtual void setDocumentation(const QString &doc)
Definition: classifierwidget.cpp:1141
ClassifierWidget::classifier
UMLClassifier * classifier() const
Definition: classifierwidget.cpp:147
ClassifierWidget::drawAsPackage
void drawAsPackage(QPainter *painter, const QStyleOptionGraphicsItem *option)
Definition: classifierwidget.cpp:1004
ClassifierWidget::CIRCLE_SIZE
static const int CIRCLE_SIZE
size of circle when interface is rendered as such
Definition: classifierwidget.h:137
ClassifierWidget::loadFromXMI1
virtual bool loadFromXMI1(QDomElement &qElement)
Definition: classifierwidget.cpp:1261
ClassifierWidget::minimumSize
QSizeF minimumSize() const
Definition: classifierwidget.cpp:468
ClassifierWidget::toggleDrawAsCircle
void toggleDrawAsCircle()
Definition: classifierwidget.cpp:1199
ClassifierWidget::displayedMembers
int displayedMembers(UMLObject::ObjectType ot) const
Definition: classifierwidget.cpp:451
ClassifierWidget::toggleShowAttSigs
void toggleShowAttSigs()
Definition: classifierwidget.cpp:429
ClassifierWidget::slotMenuSelection
virtual void slotMenuSelection(QAction *action)
Definition: classifierwidget.cpp:1378
ClassifierWidget::shape
virtual QPainterPath shape() const
Definition: classifierwidget.cpp:891
ClassifierWidget::setShowAttSigs
void setShowAttSigs(bool _show)
Definition: classifierwidget.cpp:407
ClassifierWidget::m_attributeSignature
Uml::SignatureType::Enum m_attributeSignature
Loaded/saved item.
Definition: classifierwidget.h:141
ClassifierWidget::setVisualProperty
void setVisualProperty(VisualProperty property, bool enable=true)
Definition: classifierwidget.cpp:208
ClassifierWidget::displayedOperations
int displayedOperations() const
Definition: classifierwidget.cpp:677
ClassifierWidget::changeToClass
void changeToClass()
Definition: classifierwidget.cpp:1212
ClassifierWidget::updateSignatureTypes
void updateSignatureTypes()
Definition: classifierwidget.cpp:322
ClassifierWidget::slotShowAttributes
void slotShowAttributes(bool state)
Definition: classifierwidget.cpp:1482
FloatingTextWidget
Displays a line of text or an operation.
Definition: floatingtextwidget.h:37
UMLClassifier
Information for a non-graphical Concept/Class.
Definition: classifier.h:40
UMLObject
The base class for UML objects.
Definition: umlobject.h:74
UMLObject::ObjectType
ObjectType
Definition: umlobject.h:80
UMLPackage
Non-graphical information for a Package.
Definition: package.h:33
UMLScene
Definition: umlscene.h:69
UMLWidget
The base class for graphical UML objects.
Definition: umlwidget.h:41
x
int x
Definition: cxx11-lambda-functions-and-expressions.h:4
Uml::ID::Type
std::string Type
Definition: basictypes.h:351
Uml::SignatureType::Enum
Enum
Definition: basictypes.h:162
umlobject.h
umlwidget.h