• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

umbrello/umbrello

  • sources
  • kde-4.14
  • kdesdk
  • umbrello
  • umbrello
  • widgets
widgetbase.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-2014 *
8  * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
9  ***************************************************************************/
10 
11 #ifndef WIDGETBASE_H
12 #define WIDGETBASE_H
13 
14 #include "basictypes.h"
15 
16 #include <QColor>
17 #include <QDomDocument>
18 #include <QFont>
19 #include <QGraphicsObject>
20 #include <QObject>
21 #include <QPainter>
22 
23 // forward declarations
24 class QAction;
25 class UMLDoc;
26 class UMLObject;
27 class UMLScene;
28 class UMLWidget; // required by function onWidget()
29 
35 class WidgetBase : public QGraphicsObject
36 {
37  Q_OBJECT
38  Q_ENUMS(WidgetType)
39 
40 public:
41  enum WidgetType
42  {
43  wt_UMLWidget = 300, // does not have UMLObject representation
44  wt_Actor, // has UMLObject representation
45  wt_UseCase, // has UMLObject representation
46  wt_Class, // has UMLObject representation
47  wt_Interface, // has UMLObject representation
48  wt_Datatype, // has UMLObject representation
49  wt_Enum, // has UMLObject representation
50  wt_Entity, // has UMLObject representation
51  wt_Package, // has UMLObject representation
52  wt_Object, // has UMLObject representation
53  wt_Note, // does not have UMLObject representation
54  wt_Box, // does not have UMLObject representation
55  wt_Message, // does not have UMLObject representation
56  wt_Text, // does not have UMLObject representation
57  wt_State, // does not have UMLObject representation
58  wt_Activity, // does not have UMLObject representation
59  wt_Component, // has UMLObject representation
60  wt_Artifact, // has UMLObject representation
61  wt_Node, // has UMLObject representation
62  wt_Association, // has UMLObject representation
63  wt_ForkJoin, // does not have UMLObject representation
64  wt_Precondition, // does not have UMLObject representation
65  wt_CombinedFragment, // does not have UMLObject representation
66  wt_FloatingDashLine, // does not have UMLObject representation
67  wt_Signal, // does not have UMLObject representation
68  wt_Pin,
69  wt_ObjectNode,
70  wt_Region,
71  wt_Category, // has UMLObject representation
72  wt_Port // has UMLObject representation
73  };
74 
75  static QString toString(WidgetType wt);
76 
77  explicit WidgetBase(UMLScene * scene, WidgetType type= wt_UMLWidget);
78  virtual ~WidgetBase();
79 
80  UMLObject* umlObject() const;
81  virtual void setUMLObject(UMLObject *obj);
82 
83  Uml::ID::Type id() const;
84  void setID(Uml::ID::Type id);
85 
86  WidgetType baseType() const;
87  QLatin1String baseTypeStr() const;
88 
89  virtual void setSelected(bool select);
90 
91  UMLScene* umlScene() const;
92  UMLDoc* umlDoc() const;
93 
94  QString documentation() const;
95  bool hasDocumentation();
96  void setDocumentation(const QString& doc);
97 
98  QString name() const;
99  virtual void setName(const QString &strName);
100 
101  QColor lineColor() const;
102  virtual void setLineColor(const QColor& color);
103 
104  uint lineWidth() const;
105  virtual void setLineWidth(uint width);
106 
107  QColor textColor() const;
108  virtual void setTextColor(const QColor& color);
109 
110  QColor fillColor() const;
111  virtual void setFillColor(const QColor& color);
112 
113  bool usesDiagramLineColor() const;
114  void setUsesDiagramLineColor(bool state);
115 
116  bool usesDiagramLineWidth() const;
117  void setUsesDiagramLineWidth(bool state);
118 
119  bool useFillColor();
120  virtual void setUseFillColor(bool state);
121 
122  bool usesDiagramTextColor() const;
123  void setUsesDiagramTextColor(bool state);
124 
125  bool usesDiagramFillColor() const;
126  void setUsesDiagramFillColor(bool state);
127 
128  bool usesDiagramUseFillColor() const;
129  void setUsesDiagramUseFillColor(bool state);
130 
131  virtual QFont font() const;
132  virtual void setFont(const QFont& font);
133 
134  virtual void showPropertiesDialog();
135 
136  virtual bool loadFromXMI(QDomElement &qElement);
137  virtual void saveToXMI(QDomDocument &qDoc, QDomElement &qElement);
138 
139  WidgetBase& operator=(const WidgetBase& other);
140 
141  QRectF rect() const;
142  void setRect(const QRectF& rect);
143  void setRect(qreal x, qreal y, qreal width, qreal height);
144 
145  virtual QRectF boundingRect() const;
146 
147  virtual UMLWidget* onWidget(const QPointF &p);
148 
149  virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
150 
151 public Q_SLOTS:
152  virtual void slotMenuSelection(QAction *trigger);
153 
154 protected:
155  virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
156 
157  WidgetType m_baseType;
158  UMLScene *m_scene;
159  UMLObject *m_umlObject;
160  QString m_Doc;
161  QString m_Text;
162  QRectF m_rect;
163 
169  Uml::ID::Type m_nId;
170 
171  QColor m_textColor;
172  QColor m_lineColor;
173  QColor m_fillColor;
174  QBrush m_brush;
175  QFont m_font;
176  uint m_lineWidth;
177  bool m_useFillColor;
178 
184  bool m_usesDiagramTextColor;
185  bool m_usesDiagramLineColor;
186  bool m_usesDiagramFillColor;
187  bool m_usesDiagramUseFillColor;
188  bool m_usesDiagramLineWidth;
189 };
190 
191 #endif
WidgetBase::setUsesDiagramFillColor
void setUsesDiagramFillColor(bool state)
Set state if diagram fill color is used.
Definition: widgetbase.cpp:396
WidgetBase::m_usesDiagramTextColor
bool m_usesDiagramTextColor
true by default, false if the colors have been explicitly set for this widget.
Definition: widgetbase.h:184
QGraphicsItem::x
qreal x() const
QGraphicsItem::y
qreal y() const
QWidget
WidgetBase::m_usesDiagramLineWidth
bool m_usesDiagramLineWidth
Definition: widgetbase.h:188
WidgetBase::wt_Precondition
Definition: widgetbase.h:64
WidgetBase::wt_Package
Definition: widgetbase.h:51
WidgetBase::m_textColor
QColor m_textColor
Color of the text of the widget. Is saved to XMI.
Definition: widgetbase.h:171
WidgetBase::umlObject
UMLObject * umlObject() const
Returns the UMLObject set to represent.
Definition: widgetbase.cpp:127
WidgetBase::wt_Association
Definition: widgetbase.h:62
WidgetBase::fillColor
QColor fillColor() const
Returns fill color.
Definition: widgetbase.cpp:279
WidgetBase::wt_Datatype
Definition: widgetbase.h:48
WidgetBase::wt_Actor
Definition: widgetbase.h:44
WidgetBase::umlDoc
UMLDoc * umlDoc() const
This is shortcut method for UMLApp::app()->document().
Definition: widgetbase.cpp:117
WidgetBase::setUsesDiagramTextColor
void setUsesDiagramTextColor(bool state)
Set state if diagram text color is used.
Definition: widgetbase.cpp:352
WidgetBase::showPropertiesDialog
virtual void showPropertiesDialog()
A virtual method for the widget to display a property dialog box.
Definition: widgetbase.cpp:462
WidgetBase::~WidgetBase
virtual ~WidgetBase()
Destructor.
Definition: widgetbase.cpp:73
WidgetBase
Common base class for UMLWidget and AssociationWidget.
Definition: widgetbase.h:35
WidgetBase::paint
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Draws the UMLWidget on the given paint device.
Definition: widgetbase.cpp:686
QFont
WidgetBase::usesDiagramUseFillColor
bool usesDiagramUseFillColor() const
Returns state of diagram use fill color is used.
Definition: widgetbase.cpp:406
WidgetBase::m_usesDiagramUseFillColor
bool m_usesDiagramUseFillColor
Definition: widgetbase.h:187
WidgetBase::m_lineWidth
uint m_lineWidth
Width of the lines of the widget. Is saved to XMI.
Definition: widgetbase.h:176
WidgetBase::umlScene
UMLScene * umlScene() const
Deliver a pointer to the connected UMLView (needed esp.
Definition: widgetbase.cpp:107
WidgetBase::setUMLObject
virtual void setUMLObject(UMLObject *obj)
Sets the UMLObject to represent.
Definition: widgetbase.cpp:137
WidgetBase::m_font
QFont m_font
Definition: widgetbase.h:175
WidgetBase::wt_Category
Definition: widgetbase.h:71
WidgetBase::contextMenuEvent
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
Reimplemented to show appropriate context menu.
Definition: widgetbase.cpp:694
WidgetBase::textColor
QColor textColor() const
Returns text color.
Definition: widgetbase.cpp:237
WidgetBase::saveToXMI
virtual void saveToXMI(QDomDocument &qDoc, QDomElement &qElement)
A virtual method to save the properties of this widget into a QDomElement i.e xml.
Definition: widgetbase.cpp:477
WidgetBase::wt_State
Definition: widgetbase.h:57
QBrush
WidgetBase::loadFromXMI
virtual bool loadFromXMI(QDomElement &qElement)
A virtual method to load the properties of this widget from a QDomElement into this widget...
Definition: widgetbase.cpp:517
WidgetBase::WidgetType
WidgetType
Definition: widgetbase.h:41
WidgetBase::m_Doc
QString m_Doc
Only used if m_umlObject is not set.
Definition: widgetbase.h:160
WidgetBase::wt_Interface
Definition: widgetbase.h:47
WidgetBase::boundingRect
virtual QRectF boundingRect() const
Definition: widgetbase.cpp:640
WidgetBase::id
Uml::ID::Type id() const
Read property of m_nId.
Definition: widgetbase.cpp:159
QGraphicsItem::scene
QGraphicsScene * scene() const
WidgetBase::m_baseType
WidgetType m_baseType
Type of widget.
Definition: widgetbase.h:157
WidgetBase::name
QString name() const
Gets the name from the corresponding UMLObject if this widget has an underlying UMLObject; if it does...
Definition: widgetbase.cpp:211
WidgetBase::wt_Component
Definition: widgetbase.h:59
WidgetBase::useFillColor
bool useFillColor()
Return state of fill color usage.
Definition: widgetbase.cpp:321
WidgetBase::wt_CombinedFragment
Definition: widgetbase.h:65
WidgetBase::documentation
QString documentation() const
Used by some child classes to get documentation.
Definition: widgetbase.cpp:171
WidgetBase::setFillColor
virtual void setFillColor(const QColor &color)
Sets the fill color.
Definition: widgetbase.cpp:289
WidgetBase::wt_ForkJoin
Definition: widgetbase.h:63
QGraphicsItem::type
virtual int type() const
UMLObject
This class is the non-graphical version of UMLWidget.
Definition: umlobject.h:41
QPointF
QObject::event
virtual bool event(QEvent *e)
WidgetBase::m_umlObject
UMLObject * m_umlObject
Definition: widgetbase.h:159
WidgetBase::setName
virtual void setName(const QString &strName)
Sets the name in the corresponding UMLObject.
Definition: widgetbase.cpp:224
WidgetBase::setLineColor
virtual void setLineColor(const QColor &color)
Sets the line color.
Definition: widgetbase.cpp:268
WidgetBase::toString
static QString toString(WidgetType wt)
Helper function for debug output.
Definition: widgetbase.cpp:987
WidgetBase::m_usesDiagramFillColor
bool m_usesDiagramFillColor
Definition: widgetbase.h:186
WidgetBase::m_Text
QString m_Text
Definition: widgetbase.h:161
WidgetBase::m_fillColor
QColor m_fillColor
color of the background of the widget
Definition: widgetbase.h:173
WidgetBase::wt_Enum
Definition: widgetbase.h:49
WidgetBase::wt_Class
Definition: widgetbase.h:46
WidgetBase::usesDiagramTextColor
bool usesDiagramTextColor() const
Returns state if diagram text color is used.
Definition: widgetbase.cpp:342
WidgetBase::setLineWidth
virtual void setLineWidth(uint width)
Sets the line width.
Definition: widgetbase.cpp:310
QPainter
WidgetBase::slotMenuSelection
virtual void slotMenuSelection(QAction *trigger)
This is usually called synchronously after menu.exec() and trigger's parent is always the ListPopupMe...
Definition: widgetbase.cpp:757
WidgetBase::setUseFillColor
virtual void setUseFillColor(bool state)
Set state if fill color is used.
Definition: widgetbase.cpp:331
WidgetBase::setDocumentation
void setDocumentation(const QString &doc)
Used by some child classes to set documentation.
Definition: widgetbase.cpp:196
WidgetBase::m_usesDiagramLineColor
bool m_usesDiagramLineColor
Definition: widgetbase.h:185
WidgetBase::wt_Text
Definition: widgetbase.h:56
WidgetBase::wt_FloatingDashLine
Definition: widgetbase.h:66
WidgetBase::lineWidth
uint lineWidth() const
Returns line width.
Definition: widgetbase.cpp:300
WidgetBase::m_brush
QBrush m_brush
Definition: widgetbase.h:174
QGraphicsSceneContextMenuEvent
WidgetBase::wt_Artifact
Definition: widgetbase.h:60
QString
QColor
WidgetBase::rect
QRectF rect() const
return drawing rectangle of widget in local coordinates
Definition: widgetbase.cpp:611
QGraphicsObject
WidgetBase::onWidget
virtual UMLWidget * onWidget(const QPointF &p)
Test if point is inside the bounding rectangle of the widget.
Definition: widgetbase.cpp:655
WidgetBase::wt_UMLWidget
Definition: widgetbase.h:43
Uml::ID::Type
std::string Type
Definition: basictypes.h:325
QDomDocument
WidgetBase::setUsesDiagramLineWidth
void setUsesDiagramLineWidth(bool state)
Set state of diagram line width is used.
Definition: widgetbase.cpp:436
WidgetBase::usesDiagramLineWidth
bool usesDiagramLineWidth() const
Returns state of diagram line width is used.
Definition: widgetbase.cpp:426
WidgetBase::m_lineColor
QColor m_lineColor
Color of the lines of the widget. Is saved to XMI.
Definition: widgetbase.h:172
WidgetBase::wt_Activity
Definition: widgetbase.h:58
WidgetBase::WidgetBase
WidgetBase(UMLScene *scene, WidgetType type=wt_UMLWidget)
Creates a WidgetBase object.
Definition: widgetbase.cpp:35
WidgetBase::m_nId
Uml::ID::Type m_nId
This ID is only used when the widget does not have a corresponding UMLObject (i.e.
Definition: widgetbase.h:169
WidgetBase::setFont
virtual void setFont(const QFont &font)
Set the font used to display text inside this widget.
Definition: widgetbase.cpp:453
WidgetBase::setUsesDiagramUseFillColor
void setUsesDiagramUseFillColor(bool state)
Set state of diagram use fill color is used.
Definition: widgetbase.cpp:416
WidgetBase::m_rect
QRectF m_rect
widget size
Definition: widgetbase.h:162
WidgetBase::wt_Signal
Definition: widgetbase.h:67
WidgetBase::wt_Note
Definition: widgetbase.h:53
WidgetBase::wt_Entity
Definition: widgetbase.h:50
QLatin1String
QRectF
WidgetBase::usesDiagramLineColor
bool usesDiagramLineColor() const
Returns state of diagram line color is used.
Definition: widgetbase.cpp:366
WidgetBase::baseTypeStr
QLatin1String baseTypeStr() const
Definition: widgetbase.cpp:88
QAction
WidgetBase::baseType
WidgetType baseType() const
Read property of m_baseType.
Definition: widgetbase.cpp:80
WidgetBase::setSelected
virtual void setSelected(bool select)
Definition: widgetbase.cpp:98
WidgetBase::wt_Pin
Definition: widgetbase.h:68
WidgetBase::wt_Message
Definition: widgetbase.h:55
WidgetBase::setUsesDiagramLineColor
void setUsesDiagramLineColor(bool state)
Set state of diagram line color is used.
Definition: widgetbase.cpp:376
WidgetBase::wt_UseCase
Definition: widgetbase.h:45
QStyleOptionGraphicsItem
WidgetBase::wt_Box
Definition: widgetbase.h:54
WidgetBase::setID
void setID(Uml::ID::Type id)
Write property of m_nId.
Definition: widgetbase.cpp:145
WidgetBase::setRect
void setRect(const QRectF &rect)
set widget rectangle in item coordinates
Definition: widgetbase.cpp:619
WidgetBase::wt_Object
Definition: widgetbase.h:52
WidgetBase::m_useFillColor
bool m_useFillColor
flag indicates if the UMLWidget uses the Diagram FillColour
Definition: widgetbase.h:177
WidgetBase::wt_Node
Definition: widgetbase.h:61
QDomElement
WidgetBase::operator=
WidgetBase & operator=(const WidgetBase &other)
Assignment operator.
Definition: widgetbase.cpp:584
WidgetBase::wt_ObjectNode
Definition: widgetbase.h:69
basictypes.h
WidgetBase::font
virtual QFont font() const
Returns the font used for diaplaying any text.
Definition: widgetbase.cpp:445
WidgetBase::setTextColor
virtual void setTextColor(const QColor &color)
Sets the text color.
Definition: widgetbase.cpp:247
WidgetBase::wt_Region
Definition: widgetbase.h:70
UMLScene
UMLScene instances represent diagrams.
Definition: umlscene.h:68
WidgetBase::lineColor
QColor lineColor() const
Returns line color.
Definition: widgetbase.cpp:258
WidgetBase::wt_Port
Definition: widgetbase.h:72
WidgetBase::m_scene
UMLScene * m_scene
Definition: widgetbase.h:158
WidgetBase::usesDiagramFillColor
bool usesDiagramFillColor() const
Returns state of diagram fill color is used.
Definition: widgetbase.cpp:386
UMLDoc
UMLDoc provides a document object for a document-view model.
Definition: umldoc.h:64
WidgetBase::hasDocumentation
bool hasDocumentation()
Returns state of documentation for the widget.
Definition: widgetbase.cpp:183
UMLWidget
This is the base class for nearly all graphical widgets.
Definition: umlwidget.h:38
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:40:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

umbrello/umbrello

Skip menu "umbrello/umbrello"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal