umbrello: umbrello/umlwidgets/classifierwidget.h Source File

umbrello 2.32.0 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-2021 *
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, // DEPRECATED - see umlwidgets/widgetbase.cpp
44 // WidgetBase::slotMenuSelection(QAction*)
45 // case ListPopupMenu::mt_{Show,Hide}_Stereotypes_Selection
46 ShowOperations = 0x2,
47 ShowPublicOnly = 0x4,
48 ShowVisibility = 0x8,
49 ShowPackage = 0x10,
50 ShowAttributes = 0x20,
51 DrawAsCircle = 0x40,
52 ShowOperationSignature = 0x60,
53 ShowAttributeSignature = 0x80,
54 DrawAsPackage = 0x100,
55 ShowDocumentation = 0x200,
56 };
57
58 Q_DECLARE_FLAGS(VisualProperties, VisualProperty)
59
60 ClassifierWidget(UMLScene * scene, UMLClassifier * umlc);
61 ClassifierWidget(UMLScene * scene, UMLInstance * umli);
62 ClassifierWidget(UMLScene * scene, UMLPackage * o);
63 virtual ~ClassifierWidget();
64
65 UMLClassifier *classifier() const;
66
67 void setShowStereotype(Uml::ShowStereoType::Enum flag);
68
69 VisualProperties visualProperties() const;
70 void setVisualProperties(VisualProperties properties);
71
72 bool visualProperty(VisualProperty property) const;
73 void setVisualProperty(VisualProperty property, bool enable = true);
74 void setVisualPropertyCmd(VisualProperty property, bool enable = true);
75 void toggleVisualProperty(VisualProperty property);
76
77 int displayedAttributes() const;
78 int displayedOperations() const;
79
80 Uml::SignatureType::Enum attributeSignature() const;
81 void setAttributeSignature(Uml::SignatureType::Enum sig);
82
83 Uml::SignatureType::Enum operationSignature() const;
84 void setOperationSignature(Uml::SignatureType::Enum sig);
85
86 void setShowAttSigs(bool _show);
87 void toggleShowAttSigs();
88
89 bool getDrawAsCircle() const;
90 void setDrawAsCircle(bool drawAsCircle);
91 void toggleDrawAsCircle();
92
93 void changeToClass();
94 void changeToInterface();
95 void changeToPackage();
96
97 AssociationWidget *classAssociationWidget() const;
98 void setClassAssociationWidget(AssociationWidget *assocwidget);
99
100 UMLWidget* onWidget(const QPointF& p);
101 UMLWidget* widgetWithID(Uml::ID::Type id);
102
103 virtual void setDocumentation(const QString& doc);
104
105 QSizeF calculateSize(bool withExtensions = true) const;
106
107 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
108 virtual QPainterPath shape() const;
109
110 virtual void saveToXMI1(QXmlStreamWriter& writer);
111 virtual bool loadFromXMI1(QDomElement & qElement);
112
113 virtual bool showPropertiesDialog();
114 void setUMLObject(UMLObject *obj);
115
116 public Q_SLOTS:
117 virtual void slotMenuSelection(QAction* action);
118
119 private Q_SLOTS:
120 void slotShowAttributes(bool state);
121 void slotShowOperations(bool state);
122
123 protected:
124 virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
125
126 private:
127 void updateSignatureTypes();
128 QSize calculateTemplatesBoxSize() const;
129
130 QSizeF minimumSize() const;
131
132 void drawAsCircle(QPainter *p, const QStyleOptionGraphicsItem *option);
133 QSize calculateAsCircleSize() const;
134
135 void drawAsPackage(QPainter *painter, const QStyleOptionGraphicsItem *option);
136 QSize calculateAsPackageSize() const;
137
138 int displayedMembers(UMLObject::ObjectType ot) const;
139 void drawMembers(QPainter *painter, UMLObject::ObjectType ot, Uml::SignatureType::Enum sigType,
140 int x, int y, int textWidth, int fontHeight);
141
142 static const int CIRCLE_SIZE;
143 static const int SOCKET_INCREMENT;
144
145 VisualProperties m_visualProperties;
146 Uml::SignatureType::Enum m_attributeSignature;
147 Uml::SignatureType::Enum m_operationSignature;
148 AssociationWidget *m_pAssocWidget;
149 QPointer<FloatingTextWidget> m_pInterfaceName;
150
151 };
152
153 Q_DECLARE_OPERATORS_FOR_FLAGS(ClassifierWidget::VisualProperties)
154
155 #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:717
ClassifierWidget::slotShowOperations
void slotShowOperations(bool state)
Definition: classifierwidget.cpp:1579
ClassifierWidget::setVisualPropertyCmd
void setVisualPropertyCmd(VisualProperty property, bool enable=true)
Definition: classifierwidget.cpp:271
ClassifierWidget::m_pAssocWidget
AssociationWidget * m_pAssocWidget
related AssociationWidget in case this classifier acts as an association class
Definition: classifierwidget.h:148
ClassifierWidget::showPropertiesDialog
virtual bool showPropertiesDialog()
Definition: classifierwidget.cpp:1595
ClassifierWidget::widgetWithID
UMLWidget * widgetWithID(Uml::ID::Type id)
Definition: classifierwidget.cpp:1219
ClassifierWidget::setDrawAsCircle
void setDrawAsCircle(bool drawAsCircle)
Definition: classifierwidget.cpp:1240
ClassifierWidget::attributeSignature
Uml::SignatureType::Enum attributeSignature() const
Definition: classifierwidget.cpp:403
ClassifierWidget::changeToPackage
void changeToPackage()
Definition: classifierwidget.cpp:1333
ClassifierWidget::SOCKET_INCREMENT
static const int SOCKET_INCREMENT
augmentation of circle for socket (required interface)
Definition: classifierwidget.h:143
ClassifierWidget::m_operationSignature
Uml::SignatureType::Enum m_operationSignature
Loaded/saved item.
Definition: classifierwidget.h:147
ClassifierWidget::VisualProperty
VisualProperty
Definition: classifierwidget.h:42
ClassifierWidget::ShowPackage
@ ShowPackage
Definition: classifierwidget.h:49
ClassifierWidget::ShowDocumentation
@ ShowDocumentation
Definition: classifierwidget.h:55
ClassifierWidget::ShowPublicOnly
@ ShowPublicOnly
Definition: classifierwidget.h:47
ClassifierWidget::ShowOperations
@ ShowOperations
Definition: classifierwidget.h:46
ClassifierWidget::ShowOperationSignature
@ ShowOperationSignature
only in setter
Definition: classifierwidget.h:52
ClassifierWidget::ShowStereotype
@ ShowStereotype
Definition: classifierwidget.h:43
ClassifierWidget::DrawAsCircle
@ DrawAsCircle
Definition: classifierwidget.h:51
ClassifierWidget::ShowAttributeSignature
@ ShowAttributeSignature
only in setter
Definition: classifierwidget.h:53
ClassifierWidget::DrawAsPackage
@ DrawAsPackage
Definition: classifierwidget.h:54
ClassifierWidget::ShowAttributes
@ ShowAttributes
Definition: classifierwidget.h:50
ClassifierWidget::ShowVisibility
@ ShowVisibility
Definition: classifierwidget.h:48
ClassifierWidget::setUMLObject
void setUMLObject(UMLObject *obj)
Definition: classifierwidget.cpp:1610
ClassifierWidget::setOperationSignature
void setOperationSignature(Uml::SignatureType::Enum sig)
Definition: classifierwidget.cpp:435
ClassifierWidget::calculateSize
QSizeF calculateSize(bool withExtensions=true) const
Definition: classifierwidget.cpp:521
ClassifierWidget::classAssociationWidget
AssociationWidget * classAssociationWidget() const
Definition: classifierwidget.cpp:751
ClassifierWidget::visualProperty
bool visualProperty(VisualProperty property) const
Definition: classifierwidget.cpp:225
ClassifierWidget::onWidget
UMLWidget * onWidget(const QPointF &p)
Definition: classifierwidget.cpp:1205
ClassifierWidget::toggleVisualProperty
void toggleVisualProperty(VisualProperty property)
Definition: classifierwidget.cpp:342
ClassifierWidget::visualProperties
VisualProperties visualProperties() const
Definition: classifierwidget.cpp:198
ClassifierWidget::operationSignature
Uml::SignatureType::Enum operationSignature() const
Definition: classifierwidget.cpp:425
ClassifierWidget::setVisualProperties
void setVisualProperties(VisualProperties properties)
Definition: classifierwidget.cpp:207
ClassifierWidget::setShowStereotype
void setShowStereotype(Uml::ShowStereoType::Enum flag)
Definition: classifierwidget.cpp:186
ClassifierWidget::drawMembers
void drawMembers(QPainter *painter, UMLObject::ObjectType ot, Uml::SignatureType::Enum sigType, int x, int y, int textWidth, int fontHeight)
Definition: classifierwidget.cpp:1141
ClassifierWidget::getDrawAsCircle
bool getDrawAsCircle() const
Definition: classifierwidget.cpp:1277
ClassifierWidget::m_visualProperties
VisualProperties m_visualProperties
Definition: classifierwidget.h:145
ClassifierWidget::calculateAsCircleSize
QSize calculateAsCircleSize() const
Definition: classifierwidget.cpp:1057
ClassifierWidget::drawAsCircle
void drawAsCircle(QPainter *p, const QStyleOptionGraphicsItem *option)
Definition: classifierwidget.cpp:974
ClassifierWidget::m_pInterfaceName
QPointer< FloatingTextWidget > m_pInterfaceName
Separate widget for name in case of interface drawn as circle.
Definition: classifierwidget.h:149
ClassifierWidget::calculateTemplatesBoxSize
QSize calculateTemplatesBoxSize() const
Definition: classifierwidget.cpp:685
ClassifierWidget::setAttributeSignature
void setAttributeSignature(Uml::SignatureType::Enum sig)
Definition: classifierwidget.cpp:414
ClassifierWidget::paint
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Definition: classifierwidget.cpp:761
ClassifierWidget::changeToInterface
void changeToInterface()
Definition: classifierwidget.cpp:1317
ClassifierWidget::setClassAssociationWidget
void setClassAssociationWidget(AssociationWidget *assocwidget)
Definition: classifierwidget.cpp:738
ClassifierWidget::~ClassifierWidget
virtual ~ClassifierWidget()
Definition: classifierwidget.cpp:164
ClassifierWidget::mouseDoubleClickEvent
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
Definition: classifierwidget.cpp:1584
ClassifierWidget::calculateAsPackageSize
QSize calculateAsPackageSize() const
Definition: classifierwidget.cpp:1104
ClassifierWidget::setDocumentation
virtual void setDocumentation(const QString &doc)
Definition: classifierwidget.cpp:1228
ClassifierWidget::ClassifierWidget
ClassifierWidget(UMLScene *scene, UMLClassifier *umlc)
Definition: classifierwidget.cpp:49
ClassifierWidget::saveToXMI1
virtual void saveToXMI1(QXmlStreamWriter &writer)
Definition: classifierwidget.cpp:1420
ClassifierWidget::classifier
UMLClassifier * classifier() const
Definition: classifierwidget.cpp:178
ClassifierWidget::drawAsPackage
void drawAsPackage(QPainter *painter, const QStyleOptionGraphicsItem *option)
Definition: classifierwidget.cpp:1064
ClassifierWidget::CIRCLE_SIZE
static const int CIRCLE_SIZE
size of circle when interface is rendered as such
Definition: classifierwidget.h:142
ClassifierWidget::loadFromXMI1
virtual bool loadFromXMI1(QDomElement &qElement)
Definition: classifierwidget.cpp:1348
ClassifierWidget::minimumSize
QSizeF minimumSize() const
Definition: classifierwidget.cpp:512
ClassifierWidget::toggleDrawAsCircle
void toggleDrawAsCircle()
Definition: classifierwidget.cpp:1286
ClassifierWidget::displayedMembers
int displayedMembers(UMLObject::ObjectType ot) const
Definition: classifierwidget.cpp:493
ClassifierWidget::toggleShowAttSigs
void toggleShowAttSigs()
Definition: classifierwidget.cpp:471
ClassifierWidget::slotMenuSelection
virtual void slotMenuSelection(QAction *action)
Definition: classifierwidget.cpp:1467
ClassifierWidget::shape
virtual QPainterPath shape() const
Definition: classifierwidget.cpp:951
ClassifierWidget::setShowAttSigs
void setShowAttSigs(bool _show)
Definition: classifierwidget.cpp:449
ClassifierWidget::m_attributeSignature
Uml::SignatureType::Enum m_attributeSignature
Loaded/saved item.
Definition: classifierwidget.h:146
ClassifierWidget::setVisualProperty
void setVisualProperty(VisualProperty property, bool enable=true)
Definition: classifierwidget.cpp:255
ClassifierWidget::displayedOperations
int displayedOperations() const
Definition: classifierwidget.cpp:727
ClassifierWidget::changeToClass
void changeToClass()
Definition: classifierwidget.cpp:1299
ClassifierWidget::updateSignatureTypes
void updateSignatureTypes()
Definition: classifierwidget.cpp:364
ClassifierWidget::slotShowAttributes
void slotShowAttributes(bool state)
Definition: classifierwidget.cpp:1571
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
UMLInstance
Non-graphical Information for an Instance.
Definition: instance.h:48
UMLObject
The base class for UML objects.
Definition: umlobject.h:75
UMLObject::ObjectType
ObjectType
Definition: umlobject.h:81
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
x
int x
Definition: cxx11-lambda-functions-and-expressions.h:4
Uml::ID::Type
std::string Type
Definition: basictypes.h:385
Uml::ShowStereoType::Enum
Enum
Definition: basictypes.h:162
Uml::SignatureType::Enum
Enum
Definition: basictypes.h:174
umlobject.h
umlwidget.h