umbrello: umbrello/umlwidgets/statewidget.h Source File

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

statewidget.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 STATEWIDGET_H
12 #define STATEWIDGET_H
13
14 #include "umlwidget.h"
15
16 #include <QPainter>
17 #include <QStringList>
18
19 #define STATE_MARGIN 5
20 #define STATE_WIDTH 30
21 #define STATE_HEIGHT 10
22
38 class StateWidget : public UMLWidget
39 {
40 Q_OBJECT
41 Q_ENUMS(StateType)
42 public:
44 enum StateType
45 {
46 Initial = 0, // Pseudostate
47 Normal,
48 End,
49 Fork, // Pseudostate
50 Join, // Pseudostate
51 Junction, // Pseudostate
52 DeepHistory, // Pseudostate
53 ShallowHistory, // Pseudostate
54 Choice, // Pseudostate
55 //Terminate // Pseudostate
56 //EntryPoint // Pseudostate
57 //ExitPoint // Pseudostate
58 Combined // Pseudostate
59 };
60
61 explicit StateWidget(UMLScene * scene, StateType stateType = Normal, Uml::ID::Type id = Uml::ID::None);
62 virtual ~StateWidget();
63
64 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
65
66 StateType stateType() const;
67 QString stateTypeStr() const;
68 void setStateType(StateType stateType);
69
70 bool addActivity(const QString &activity);
71 bool removeActivity(const QString &activity);
72 bool renameActivity(const QString &activity, const QString &newName);
73
74 QStringList activities() const;
75 void setActivities(const QStringList &list);
76
77 bool drawVertical() const;
78 void setDrawVertical(bool to = true);
79
80 virtual bool showPropertiesDialog();
81
82 virtual bool loadFromXMI1(QDomElement & qElement);
83 virtual void saveToXMI1(QDomDocument & qDoc, QDomElement & qElement);
84
85 protected:
86 QSizeF minimumSize() const;
87 QSizeF maximumSize();
88 void setAspectRatioMode();
89 virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
90 virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
91 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
92 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
93 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
94
95 public Q_SLOTS:
96 virtual void slotMenuSelection(QAction* action);
97
98 private:
99 StateType m_stateType;
100 bool m_drawVertical;
101 QStringList m_Activities;
102 QSizeF m_size;
103 };
104
105 #endif
DiagramProxyWidget::setClientRect
void setClientRect(const QRectF &rect)
Definition: diagramproxywidget.cpp:90
StateWidget::removeActivity
bool removeActivity(const QString &activity)
Definition: statewidget.cpp:433
UMLWidget::height
qreal height() const
Definition: umlwidget.h:114
cmdcreatediagram.h
DiagramProxyWidget::mouseMoveEvent
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Definition: diagramproxywidget.cpp:260
STATE_WIDTH
#define STATE_WIDTH
Definition: statewidget.h:20
x
int x
Definition: cxx11-lambda-functions-and-expressions.h:4
StateWidget::saveToXMI1
virtual void saveToXMI1(QDomDocument &qDoc, QDomElement &qElement)
Definition: statewidget.cpp:510
WidgetBase::textColor
QColor textColor() const
Definition: widgetbase.cpp:335
ListPopupMenu::mt_Properties
@ mt_Properties
Definition: listpopupmenu.h:182
statewidget.h
StateWidget::renameActivity
bool renameActivity(const QString &activity, const QString &newName)
Definition: statewidget.cpp:444
StateWidget::~StateWidget
virtual ~StateWidget()
Definition: statewidget.cpp:56
statedialog.h
docwindow.h
umlview.h
StateWidget::showPropertiesDialog
virtual bool showPropertiesDialog()
Definition: statewidget.cpp:492
StateWidget::paint
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Definition: statewidget.cpp:63
UMLWidget
The base class for graphical UML objects.
Definition: umlwidget.h:40
StateWidget::ShallowHistory
@ ShallowHistory
Definition: statewidget.h:53
WidgetBase::name
QString name() const
Definition: widgetbase.cpp:309
StateWidget::setActivities
void setActivities(const QStringList &list)
Definition: statewidget.cpp:456
UMLWidget::setPenFromSettings
void setPenFromSettings(QPainter &p)
Definition: umlwidget.cpp:1392
UMLWidget::FT_NORMAL
@ FT_NORMAL
Definition: umlwidget.h:217
UMLScene::activeView
UMLView * activeView() const
Definition: umlscene.cpp:348
UMLWidget::FT_BOLD
@ FT_BOLD
Definition: umlwidget.h:218
DiagramProxyWidget::contextMenuEvent
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
Definition: diagramproxywidget.cpp:215
UMLWidget::mouseDoubleClickEvent
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
Definition: umlwidget.cpp:585
StateWidget
A graphical version of a UML State.
Definition: statewidget.h:38
DEBUG_REGISTER_DISABLED
#define DEBUG_REGISTER_DISABLED(src)
Definition: debug_utils.h:132
Uml::ID::None
const Type None
special value for uninitialized ID
Definition: basictypes.h:370
UMLWidget::maximumSize
virtual QSizeF maximumSize()
Definition: umlwidget.cpp:240
Dialog_Utils::askNewName
bool askNewName(WidgetBase::WidgetType type, QString &name)
Definition: dialog_utils.cpp:150
StateWidget::m_Activities
QStringList m_Activities
List of activities for the state.
Definition: statewidget.h:101
DocWindow::updateDocumentation
void updateDocumentation(bool clear=false, bool startup=false)
Definition: docwindow.cpp:273
StateWidget::stateTypeStr
QString stateTypeStr() const
Definition: statewidget.cpp:401
StateWidget::maximumSize
QSizeF maximumSize()
Definition: statewidget.cpp:291
Dialog_Utils::askName
bool askName(const QString &title, const QString &prompt, QString &name)
Definition: dialog_utils.cpp:96
WidgetBase::rect
QRectF rect() const
Definition: widgetbase.cpp:831
Uml::ID::Type
std::string Type
Definition: basictypes.h:368
StateWidget::StateType
StateType
Enumeration that codes the different types of state.
Definition: statewidget.h:44
ENUM_NAME
#define ENUM_NAME(o, e, v)
Definition: debug_utils.h:143
DiagramProxyWidget::mousePressEvent
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
Definition: diagramproxywidget.cpp:248
StateDialog
Definition: statedialog.h:32
StateWidget::Junction
@ Junction
Definition: statewidget.h:51
DiagramProxyWidget::sceneRect
const QRectF & sceneRect()
Definition: diagramproxywidget.cpp:80
StateWidget::setStateType
void setStateType(StateType stateType)
Definition: statewidget.cpp:409
StateWidget::Fork
@ Fork
Definition: statewidget.h:49
StateWidget::m_stateType
StateType m_stateType
Type of state.
Definition: statewidget.h:99
StateWidget::mousePressEvent
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
Definition: statewidget.cpp:359
StateWidget::End
@ End
Definition: statewidget.h:48
UMLWidget::mouseReleaseEvent
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Definition: umlwidget.cpp:534
StateWidget::m_drawVertical
bool m_drawVertical
whether to draw the fork/join horizontally or vertically
Definition: statewidget.h:100
UMLWidget::getFontMetrics
QFontMetrics & getFontMetrics(UMLWidget::FontType fontType) const
Definition: umlwidget.cpp:1936
WidgetBase::font
virtual QFont font() const
Definition: widgetbase.cpp:543
StateWidget::slotMenuSelection
virtual void slotMenuSelection(QAction *action)
Definition: statewidget.cpp:568
WidgetBase::fillColor
QColor fillColor() const
Definition: widgetbase.cpp:377
StateWidget::contextMenuEvent
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
Definition: statewidget.cpp:339
StateWidget::mouseReleaseEvent
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Definition: statewidget.cpp:379
UMLApp::docWindow
DocWindow * docWindow() const
Definition: uml.cpp:1886
UMLWidget::contextMenuEvent
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
Definition: umlwidget.cpp:259
StateWidget::loadFromXMI1
virtual bool loadFromXMI1(QDomElement &qElement)
Definition: statewidget.cpp:535
umlwidget.h
uWarning
#define uWarning()
Definition: debug_utils.h:124
ListPopupMenu::MenuType
MenuType
< This type hosts all possible menu entry types
Definition: listpopupmenu.h:43
i18n
#define i18n
Definition: main.cpp:39
UMLWidget::setFixedAspectRatio
void setFixedAspectRatio(bool state)
Definition: umlwidget.h:204
StateWidget::Combined
@ Combined
Definition: statewidget.h:58
WidgetBase::m_scene
UMLScene * m_scene
Definition: widgetbase.h:316
DiagramProxyWidget::mouseDoubleClickEvent
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
Definition: diagramproxywidget.cpp:227
WidgetBase::setAutoResize
void setAutoResize(bool state)
Definition: widgetbase.cpp:569
StateWidget::minimumSize
QSizeF minimumSize() const
Definition: statewidget.cpp:227
StateWidget::mouseDoubleClickEvent
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
Definition: statewidget.cpp:349
UMLApp::app
static UMLApp * app()
Definition: uml.cpp:269
WidgetBase::useFillColor
bool useFillColor()
Definition: widgetbase.cpp:419
StateWidget::setAspectRatioMode
void setAspectRatioMode()
Definition: statewidget.cpp:320
StateWidget::Join
@ Join
Definition: statewidget.h:50
UMLDoc::setModified
void setModified(bool modified=true)
Definition: umldoc.cpp:3125
WidgetBase
Common base class for UMLWidget and AssociationWidget.
Definition: widgetbase.h:104
UMLWidget::mousePressEvent
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
Definition: umlwidget.cpp:364
DiagramProxyWidget::mouseReleaseEvent
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Definition: diagramproxywidget.cpp:272
Uml
Definition: basictypes.cpp:36
UMLWidget::adjustAssocs
virtual void adjustAssocs(qreal dx, qreal dy)
Definition: umlwidget.cpp:1310
StateWidget::Initial
@ Initial
Definition: statewidget.h:46
ListPopupMenu::mt_FlipHorizontal
@ mt_FlipHorizontal
Definition: listpopupmenu.h:219
DocWindow::showDocumentation
void showDocumentation(UMLObject *object, bool overwrite=false)
Definition: docwindow.cpp:130
DiagramProxyWidget::paint
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Definition: diagramproxywidget.cpp:327
StateWidget::mouseMoveEvent
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Definition: statewidget.cpp:369
WidgetBase::lineColor
QColor lineColor() const
Definition: widgetbase.cpp:356
StateWidget::StateWidget
StateWidget(UMLScene *scene, StateType stateType=Normal, Uml::ID::Type id=Uml::ID::None)
Definition: statewidget.cpp:43
umlscene.h
uml.h
UMLWidget::setSize
void setSize(qreal width, qreal height)
Definition: umlwidget.cpp:1745
StateWidget::stateType
StateType stateType() const
Definition: statewidget.cpp:393
STATE_MARGIN
#define STATE_MARGIN
Definition: statewidget.h:19
debug_utils.h
StateWidget::drawVertical
bool drawVertical() const
Definition: statewidget.cpp:473
StateWidget::m_size
QSizeF m_size
widget size used by combined state
Definition: statewidget.h:102
UMLScene
Definition: umlscene.h:68
ListPopupMenu::typeFromAction
static MenuType typeFromAction(QAction *action)
Definition: listpopupmenu.cpp:407
UMLWidget::updateGeometry
void updateGeometry(bool withAssocs=true)
Definition: umlwidget.cpp:1781
WidgetBase::m_Doc
QString m_Doc
Only used if m_umlObject is not set.
Definition: widgetbase.h:318
ListPopupMenu::mt_Rename
@ mt_Rename
Definition: listpopupmenu.h:183
ListPopupMenu::mt_FlipVertical
@ mt_FlipVertical
Definition: listpopupmenu.h:220
UMLWidget::saveToXMI1
virtual void saveToXMI1(QDomDocument &qDoc, QDomElement &qElement)
Definition: umlwidget.cpp:2045
listpopupmenu.h
DiagramProxyWidget::linkedDiagram
UMLScene * linkedDiagram() const
Definition: diagramproxywidget.cpp:43
WidgetBase::setName
virtual void setName(const QString &strName)
Definition: widgetbase.cpp:322
dialog_utils.h
StateWidget::addActivity
bool addActivity(const QString &activity)
Definition: statewidget.cpp:423
STATE_HEIGHT
#define STATE_HEIGHT
Definition: statewidget.h:21
UMLWidget::mouseMoveEvent
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Definition: umlwidget.cpp:454
StateWidget::Choice
@ Choice
Definition: statewidget.h:54
UMLWidget::width
qreal width() const
Definition: umlwidget.h:121
StateWidget::setDrawVertical
void setDrawVertical(bool to=true)
Definition: statewidget.cpp:481
ListPopupMenu::mt_New_Activity
@ mt_New_Activity
Definition: listpopupmenu.h:134
UMLWidget::loadFromXMI1
virtual bool loadFromXMI1(QDomElement &qElement)
Definition: umlwidget.cpp:2067
WidgetBase::m_Text
QString m_Text
Definition: widgetbase.h:319
UMLApp::document
UMLDoc * document() const
Definition: uml.cpp:1055
umldoc.h
StateWidget::Normal
@ Normal
Definition: statewidget.h:47
UMLWidget::setResizable
void setResizable(bool state)
Definition: umlwidget.h:212
DiagramProxyWidget::slotMenuSelection
void slotMenuSelection(QAction *action)
Definition: diagramproxywidget.cpp:354
StateWidget::DeepHistory
@ DeepHistory
Definition: statewidget.h:52
UMLWidget::paint
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Definition: umlwidget.cpp:1869
StateWidget::activities
QStringList activities() const
Definition: statewidget.cpp:465