umbrello: umbrello/umlwidgets/statewidget.h Source File

umbrello 2.32.1 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(QXmlStreamWriter& writer);
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
StateWidget
A graphical version of a UML State.
Definition: statewidget.h:39
StateWidget::minimumSize
QSizeF minimumSize() const
Definition: statewidget.cpp:228
StateWidget::renameActivity
bool renameActivity(const QString &activity, const QString &newName)
Definition: statewidget.cpp:445
StateWidget::mouseDoubleClickEvent
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
Definition: statewidget.cpp:350
StateWidget::~StateWidget
virtual ~StateWidget()
Definition: statewidget.cpp:57
StateWidget::stateType
StateType stateType() const
Definition: statewidget.cpp:394
StateWidget::removeActivity
bool removeActivity(const QString &activity)
Definition: statewidget.cpp:434
StateWidget::stateTypeStr
QString stateTypeStr() const
Definition: statewidget.cpp:402
StateWidget::activities
QStringList activities() const
Definition: statewidget.cpp:466
StateWidget::contextMenuEvent
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
Definition: statewidget.cpp:340
StateWidget::mousePressEvent
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
Definition: statewidget.cpp:360
StateWidget::setActivities
void setActivities(const QStringList &list)
Definition: statewidget.cpp:457
StateWidget::maximumSize
QSizeF maximumSize()
Definition: statewidget.cpp:292
StateWidget::mouseReleaseEvent
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Definition: statewidget.cpp:380
StateWidget::mouseMoveEvent
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Definition: statewidget.cpp:370
StateWidget::drawVertical
bool drawVertical() const
Definition: statewidget.cpp:474
StateWidget::m_size
QSizeF m_size
widget size used by combined state
Definition: statewidget.h:102
StateWidget::StateType
StateType
Enumeration that codes the different types of state.
Definition: statewidget.h:45
StateWidget::Junction
@ Junction
Definition: statewidget.h:51
StateWidget::Fork
@ Fork
Definition: statewidget.h:49
StateWidget::ShallowHistory
@ ShallowHistory
Definition: statewidget.h:53
StateWidget::Join
@ Join
Definition: statewidget.h:50
StateWidget::DeepHistory
@ DeepHistory
Definition: statewidget.h:52
StateWidget::Combined
@ Combined
Definition: statewidget.h:58
StateWidget::Choice
@ Choice
Definition: statewidget.h:54
StateWidget::Initial
@ Initial
Definition: statewidget.h:46
StateWidget::End
@ End
Definition: statewidget.h:48
StateWidget::Normal
@ Normal
Definition: statewidget.h:47
StateWidget::slotMenuSelection
virtual void slotMenuSelection(QAction *action)
Definition: statewidget.cpp:569
StateWidget::saveToXMI1
virtual void saveToXMI1(QXmlStreamWriter &writer)
Definition: statewidget.cpp:511
StateWidget::setStateType
void setStateType(StateType stateType)
Definition: statewidget.cpp:410
StateWidget::m_drawVertical
bool m_drawVertical
whether to draw the fork/join horizontally or vertically
Definition: statewidget.h:100
StateWidget::loadFromXMI1
virtual bool loadFromXMI1(QDomElement &qElement)
Definition: statewidget.cpp:536
StateWidget::showPropertiesDialog
virtual bool showPropertiesDialog()
Definition: statewidget.cpp:493
StateWidget::addActivity
bool addActivity(const QString &activity)
Definition: statewidget.cpp:424
StateWidget::setAspectRatioMode
void setAspectRatioMode()
Definition: statewidget.cpp:321
StateWidget::paint
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Definition: statewidget.cpp:64
StateWidget::m_stateType
StateType m_stateType
Type of state.
Definition: statewidget.h:99
StateWidget::StateWidget
StateWidget(UMLScene *scene, StateType stateType=Normal, Uml::ID::Type id=Uml::ID::None)
Definition: statewidget.cpp:44
StateWidget::setDrawVertical
void setDrawVertical(bool to=true)
Definition: statewidget.cpp:482
StateWidget::m_Activities
QStringList m_Activities
List of activities for the state.
Definition: statewidget.h:101
UMLScene
Definition: umlscene.h:70
UMLWidget
The base class for graphical UML objects.
Definition: umlwidget.h:41
Uml::ID::None
const Type None
special value for uninitialized ID
Definition: basictypes.h:387
Uml::ID::Type
std::string Type
Definition: basictypes.h:385
umlwidget.h