umbrello: umbrello/umlwidgets/messagewidget.h Source File

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

messagewidget.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) 2002-2020 *
8 * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
9 ***************************************************************************/
10
11 #ifndef MESSAGEWIDGET_H
12 #define MESSAGEWIDGET_H
13
14 #include "umlwidget.h"
15 #include "linkwidget.h"
16
17 // forward declarations
18 class FloatingTextWidget;
19 class ObjectWidget;
20 class QResizeEvent;
21 class UMLOperation;
22
40 class MessageWidget : public UMLWidget, public LinkWidget
41 {
42 Q_OBJECT
43 public:
44 MessageWidget(UMLScene * scene, ObjectWidget* a, ObjectWidget* b,
45 int y, Uml::SequenceMessage::Enum sequenceMessageType,
46 Uml::ID::Type id = Uml::ID::None);
47 MessageWidget(UMLScene * scene, Uml::SequenceMessage::Enum sequenceMessageType,
48 Uml::ID::Type id = Uml::ID::None);
49 MessageWidget(UMLScene * scene, ObjectWidget* a, int xclick, int yclick,
50 Uml::SequenceMessage::Enum sequenceMessageType,
51 Uml::ID::Type id = Uml::ID::None);
52 virtual ~MessageWidget();
53
54 virtual void setY(qreal y);
55
56 //---------- LinkWidget Interface methods implemementation from now on.
57
58 virtual void lwSetFont (QFont font);
59 virtual UMLClassifier *operationOwner();
60
61 virtual UMLOperation *operation();
62 virtual void setOperation(UMLOperation *op);
63
64 virtual QString customOpText();
65 virtual void setCustomOpText(const QString &opText);
66
67 virtual void setMessageText(FloatingTextWidget *ft);
68 virtual void setText(FloatingTextWidget *ft, const QString &newText);
69
70 virtual QString lwOperationText();
71 virtual UMLClassifier *lwClassifier();
72 virtual void setOperationText(const QString &op);
73
74 virtual void constrainTextPos(qreal &textX, qreal &textY, qreal textWidth, qreal textHeight,
75 Uml::TextRole::Enum tr);
76
77 //---------- End LinkWidget Interface methods implemementation.
78
80 Uml::SequenceMessage::Enum sequenceMessageType() const {
81 return m_sequenceMessageType;
82 }
83
84 bool hasObjectWidget(ObjectWidget * w);
85
86 ObjectWidget* objectWidget(Uml::RoleType::Enum role);
87 void setObjectWidget(ObjectWidget * ow, Uml::RoleType::Enum role) ;
88
89 bool isSelf() const;
90
96 FloatingTextWidget * floatingTextWidget() {
97 return m_pFText;
98 }
99
105 void setFloatingTextWidget(FloatingTextWidget * f) {
106 m_pFText = f;
107 }
108
109 void calculateWidget();
110
111 virtual bool activate(IDChangeLog * Log = 0);
112 void resolveObjectWidget(IDChangeLog* log);
113
114 void calculateDimensions();
115 void calculateDimensionsSynchronous();
116 void calculateDimensionsAsynchronous();
117 void calculateDimensionsCreation();
118 void calculateDimensionsDestroy();
119 void calculateDimensionsLost();
120 void calculateDimensionsFound();
121
122 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
123
124 void setTextPosition();
125
126 void cleanup();
127
128 void setSelected(bool _select);
129
130 int getMinY();
131 int getMaxY();
132
133 virtual QSizeF minimumSize() const;
134
135 UMLWidget* onWidget(const QPointF& p);
136
137 virtual void resizeWidget(qreal newW, qreal newH);
138
139 virtual void saveToXMI1(QDomDocument & qDoc, QDomElement & qElement);
140 virtual bool loadFromXMI1(QDomElement & qElement);
141
142 void setxclicked(int xclick);
143 void setyclicked(int yclick);
144
148 int getxclicked() const {
149 return m_xclicked;
150 }
151
152 virtual bool showPropertiesDialog();
153
154 protected:
155 virtual void moveWidgetBy(qreal diffX, qreal diffY);
156 virtual void constrainMovementForAllWidgets(qreal &diffX, qreal &diffY);
157
158 virtual QCursor resizeCursor() const;
159
160 void setLinkAndTextPos();
161
162 int constrainX(int textX, int textWidth, Uml::TextRole::Enum tr);
163
164 static void paintArrow(QPainter *p, int x, int y, int w,
165 Qt::ArrowType direction, bool useDottedLine = false);
166 static void paintSolidArrowhead(QPainter *p, int x, int y, Qt::ArrowType direction);
167
168 void updateResizability();
169
170 void paintSynchronous(QPainter *painter, const QStyleOptionGraphicsItem *option);
171 void paintAsynchronous(QPainter *painter, const QStyleOptionGraphicsItem *option);
172 void paintCreation(QPainter *painter, const QStyleOptionGraphicsItem *option);
173 void paintDestroy(QPainter *painter, const QStyleOptionGraphicsItem *option);
174 void paintLost(QPainter *painter, const QStyleOptionGraphicsItem *option);
175 void paintFound(QPainter *painter, const QStyleOptionGraphicsItem *option);
176
177 // Data loaded/saved
178 QString m_CustomOp;
182 Uml::SequenceMessage::Enum m_sequenceMessageType;
183
184 private:
185 void resizeEvent(QResizeEvent *re);
186
187 qreal constrainPositionY(qreal diffY);
188
189 void init();
190
191 QPointer<ObjectWidget> m_pOw[2];
192 FloatingTextWidget * m_pFText;
193
194 int m_xclicked;
195 int m_yclicked;
196
202 Uml::ID::Type m_widgetAId, m_widgetBId, m_textId;
203
204 public slots:
205 void slotWidgetMoved(Uml::ID::Type id);
206 void slotMenuSelection(QAction* action);
207
208 signals:
213 void sigMessageMoved();
214 };
215
216 #endif
FloatingTextWidget
Displays a line of text or an operation.
Definition: floatingtextwidget.h:37
IDChangeLog
Definition: idchangelog.h:27
LinkWidget
Interface to FloatingTextWidget for AssociationWidget and MessageWidget.
Definition: linkwidget.h:36
MessageWidget
Displays a message.
Definition: messagewidget.h:41
MessageWidget::lwClassifier
virtual UMLClassifier * lwClassifier()
Definition: messagewidget.cpp:1013
MessageWidget::m_sequenceMessageType
Uml::SequenceMessage::Enum m_sequenceMessageType
Definition: messagewidget.h:182
MessageWidget::calculateDimensionsCreation
void calculateDimensionsCreation()
Definition: messagewidget.cpp:1121
MessageWidget::slotWidgetMoved
void slotWidgetMoved(Uml::ID::Type id)
Definition: messagewidget.cpp:734
MessageWidget::setSelected
void setSelected(bool _select)
Definition: messagewidget.cpp:1233
MessageWidget::resizeCursor
virtual QCursor resizeCursor() const
Definition: messagewidget.cpp:195
MessageWidget::calculateWidget
void calculateWidget()
Definition: messagewidget.cpp:727
MessageWidget::MessageWidget
MessageWidget(UMLScene *scene, ObjectWidget *a, ObjectWidget *b, int y, Uml::SequenceMessage::Enum sequenceMessageType, Uml::ID::Type id=Uml::ID::None)
Definition: messagewidget.cpp:56
MessageWidget::resolveObjectWidget
void resolveObjectWidget(IDChangeLog *log)
Definition: messagewidget.cpp:885
MessageWidget::getMinY
int getMinY()
Definition: messagewidget.cpp:1251
MessageWidget::saveToXMI1
virtual void saveToXMI1(QDomDocument &qDoc, QDomElement &qElement)
Definition: messagewidget.cpp:1372
MessageWidget::constrainPositionY
qreal constrainPositionY(qreal diffY)
Definition: messagewidget.cpp:241
MessageWidget::calculateDimensionsLost
void calculateDimensionsLost()
Definition: messagewidget.cpp:1160
MessageWidget::m_pFText
FloatingTextWidget * m_pFText
Definition: messagewidget.h:192
MessageWidget::m_xclicked
int m_xclicked
Definition: messagewidget.h:194
MessageWidget::paintFound
void paintFound(QPainter *painter, const QStyleOptionGraphicsItem *option)
Definition: messagewidget.cpp:571
MessageWidget::isSelf
bool isSelf() const
Definition: messagewidget.cpp:778
MessageWidget::loadFromXMI1
virtual bool loadFromXMI1(QDomElement &qElement)
Definition: messagewidget.cpp:1404
MessageWidget::calculateDimensionsAsynchronous
void calculateDimensionsAsynchronous()
Definition: messagewidget.cpp:1085
MessageWidget::cleanup
void cleanup()
Definition: messagewidget.cpp:1210
MessageWidget::paintAsynchronous
void paintAsynchronous(QPainter *painter, const QStyleOptionGraphicsItem *option)
Definition: messagewidget.cpp:443
MessageWidget::hasObjectWidget
bool hasObjectWidget(ObjectWidget *w)
Definition: messagewidget.cpp:763
MessageWidget::setFloatingTextWidget
void setFloatingTextWidget(FloatingTextWidget *f)
Definition: messagewidget.h:105
MessageWidget::constrainX
int constrainX(int textX, int textWidth, Uml::TextRole::Enum tr)
Definition: messagewidget.cpp:662
MessageWidget::paintSynchronous
void paintSynchronous(QPainter *painter, const QStyleOptionGraphicsItem *option)
Definition: messagewidget.cpp:375
MessageWidget::customOpText
virtual QString customOpText()
Definition: messagewidget.cpp:980
MessageWidget::getMaxY
int getMaxY()
Definition: messagewidget.cpp:1273
MessageWidget::sequenceMessageType
Uml::SequenceMessage::Enum sequenceMessageType() const
Definition: messagewidget.h:80
MessageWidget::lwOperationText
virtual QString lwOperationText()
Definition: messagewidget.cpp:999
MessageWidget::paint
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Definition: messagewidget.cpp:298
MessageWidget::setObjectWidget
void setObjectWidget(ObjectWidget *ow, Uml::RoleType::Enum role)
Definition: messagewidget.cpp:1315
MessageWidget::setxclicked
void setxclicked(int xclick)
Definition: messagewidget.cpp:1334
MessageWidget::paintLost
void paintLost(QPainter *painter, const QStyleOptionGraphicsItem *option)
Definition: messagewidget.cpp:533
MessageWidget::getxclicked
int getxclicked() const
Definition: messagewidget.h:148
MessageWidget::calculateDimensionsDestroy
void calculateDimensionsDestroy()
Definition: messagewidget.cpp:1152
MessageWidget::m_widgetAId
Uml::ID::Type m_widgetAId
Definition: messagewidget.h:202
MessageWidget::m_textId
Uml::ID::Type m_textId
Definition: messagewidget.h:202
MessageWidget::objectWidget
ObjectWidget * objectWidget(Uml::RoleType::Enum role)
Definition: messagewidget.cpp:1326
MessageWidget::setOperationText
virtual void setOperationText(const QString &op)
Definition: messagewidget.cpp:924
MessageWidget::activate
virtual bool activate(IDChangeLog *Log=0)
Definition: messagewidget.cpp:802
MessageWidget::setyclicked
void setyclicked(int yclick)
Definition: messagewidget.cpp:1342
MessageWidget::resizeEvent
void resizeEvent(QResizeEvent *re)
Definition: messagewidget.cpp:720
MessageWidget::m_CustomOp
QString m_CustomOp
Definition: messagewidget.h:178
MessageWidget::calculateDimensionsFound
void calculateDimensionsFound()
Definition: messagewidget.cpp:1185
MessageWidget::moveWidgetBy
virtual void moveWidgetBy(qreal diffX, qreal diffY)
Definition: messagewidget.cpp:272
MessageWidget::updateResizability
void updateResizability()
Definition: messagewidget.cpp:180
MessageWidget::m_widgetBId
Uml::ID::Type m_widgetBId
Definition: messagewidget.h:202
MessageWidget::m_yclicked
int m_yclicked
Definition: messagewidget.h:195
MessageWidget::setOperation
virtual void setOperation(UMLOperation *op)
Definition: messagewidget.cpp:965
MessageWidget::calculateDimensions
void calculateDimensions()
Definition: messagewidget.cpp:1026
MessageWidget::constrainTextPos
virtual void constrainTextPos(qreal &textX, qreal &textY, qreal textWidth, qreal textHeight, Uml::TextRole::Enum tr)
Definition: messagewidget.cpp:694
MessageWidget::setCustomOpText
virtual void setCustomOpText(const QString &opText)
Definition: messagewidget.cpp:989
MessageWidget::m_pOw
QPointer< ObjectWidget > m_pOw[2]
Definition: messagewidget.h:191
MessageWidget::sigMessageMoved
void sigMessageMoved()
MessageWidget::minimumSize
virtual QSizeF minimumSize() const
Definition: messagewidget.cpp:1289
MessageWidget::paintCreation
void paintCreation(QPainter *painter, const QStyleOptionGraphicsItem *option)
Definition: messagewidget.cpp:493
MessageWidget::setMessageText
virtual void setMessageText(FloatingTextWidget *ft)
Definition: messagewidget.cpp:896
MessageWidget::setTextPosition
void setTextPosition()
Definition: messagewidget.cpp:642
MessageWidget::onWidget
UMLWidget * onWidget(const QPointF &p)
Definition: messagewidget.cpp:617
MessageWidget::calculateDimensionsSynchronous
void calculateDimensionsSynchronous()
Definition: messagewidget.cpp:1051
MessageWidget::setLinkAndTextPos
void setLinkAndTextPos()
Definition: messagewidget.cpp:712
MessageWidget::constrainMovementForAllWidgets
virtual void constrainMovementForAllWidgets(qreal &diffX, qreal &diffY)
Definition: messagewidget.cpp:288
MessageWidget::operationOwner
virtual UMLClassifier * operationOwner()
Definition: messagewidget.cpp:943
MessageWidget::init
void init()
Definition: messagewidget.cpp:132
MessageWidget::paintDestroy
void paintDestroy(QPainter *painter, const QStyleOptionGraphicsItem *option)
Definition: messagewidget.cpp:524
MessageWidget::lwSetFont
virtual void lwSetFont(QFont font)
Definition: messagewidget.cpp:933
MessageWidget::paintSolidArrowhead
static void paintSolidArrowhead(QPainter *p, int x, int y, Qt::ArrowType direction)
Definition: messagewidget.cpp:328
MessageWidget::setY
virtual void setY(qreal y)
Definition: messagewidget.cpp:157
MessageWidget::~MessageWidget
virtual ~MessageWidget()
Definition: messagewidget.cpp:145
MessageWidget::slotMenuSelection
void slotMenuSelection(QAction *action)
Definition: messagewidget.cpp:784
MessageWidget::showPropertiesDialog
virtual bool showPropertiesDialog()
Definition: messagewidget.cpp:1350
MessageWidget::setText
virtual void setText(FloatingTextWidget *ft, const QString &newText)
Definition: messagewidget.cpp:912
MessageWidget::resizeWidget
virtual void resizeWidget(qreal newW, qreal newH)
Definition: messagewidget.cpp:208
MessageWidget::paintArrow
static void paintArrow(QPainter *p, int x, int y, int w, Qt::ArrowType direction, bool useDottedLine=false)
Definition: messagewidget.cpp:346
MessageWidget::operation
virtual UMLOperation * operation()
Definition: messagewidget.cpp:956
MessageWidget::floatingTextWidget
FloatingTextWidget * floatingTextWidget()
Definition: messagewidget.h:96
ObjectWidget
Displays an instance of a Concept.
Definition: objectwidget.h:33
UMLClassifier
Information for a non-graphical Concept/Class.
Definition: classifier.h:40
UMLOperation
Definition: operation.h:25
UMLScene
Definition: umlscene.h:69
UMLWidget
The base class for graphical UML objects.
Definition: umlwidget.h:41
WidgetBase::font
virtual QFont font() const
Definition: widgetbase.cpp:543
x
int x
Definition: cxx11-lambda-functions-and-expressions.h:4
b
bool b
Definition: cxx11-null-pointer-constant.h:6
linkwidget.h
Model_Utils::newText
QString newText(UMLObject::ObjectType type)
Definition: model_utils.cpp:620
Uml::ID::None
const Type None
special value for uninitialized ID
Definition: basictypes.h:353
Uml::ID::Type
std::string Type
Definition: basictypes.h:351
Uml::RoleType::Enum
Enum
Definition: basictypes.h:238
Uml::SequenceMessage::Enum
Enum
Definition: basictypes.h:219
Uml::TextRole::Enum
Enum
Definition: basictypes.h:178
a
QString a
Definition: petalnode.cpp:18
umlwidget.h