umbrello: Widget_Utils Namespace Reference

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

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

Enumerations | Functions
Widget_Utils Namespace Reference

## Enumerations
enum | Axis_Type { X , Y }
enum | Comparison_Type { Smallest , Largest }

## Functions
UMLWidget * | findWidget (Uml::ID::Type id, const UMLWidgetList &widgets, const MessageWidgetList *messages)
QGraphicsRectItem * | decoratePoint (const QPointF &p, QGraphicsItem *parent)
void | drawCrossInEllipse (QPainter *p, const QRectF &r)
void | drawTriangledRect (QPainter *painter, const QRectF &rect, const QSizeF &triSize)
QString | pointToString (const QPointF &point)
QPointF | stringToPoint (const QString &str)
bool | loadPixmapFromXMI (QDomElement &pixEle, QPixmap &pixmap)
void | savePixmapToXMI (QXmlStreamWriter &stream, const QPixmap &pixmap)
bool | loadGradientFromXMI (QDomElement &gradientElement, QGradient *&gradient)
void | saveGradientToXMI (QXmlStreamWriter &stream, const QGradient *gradient)
bool | loadBrushFromXMI (QDomElement &qElement, QBrush &brush)
void | saveBrushToXMI (QXmlStreamWriter &stream, const QBrush &brush)
bool | hasSmallerX (const UMLWidget *widget1, const UMLWidget *widget2)
bool | hasSmallerY (const UMLWidget *widget1, const UMLWidget *widget2)
Uml::Region::Enum | findRegion (const QRectF &self, const QRectF &other)
QPointF | prevPoint (int index, const QPolygonF &poly)
QPointF | nextPoint (int index, const QPolygonF &poly)
qreal | middle (qreal a, qreal b)
QLineF | findLine (const QPolygonF &poly, Axis_Type axis, Comparison_Type seek, const QRectF &boundingRect)
QLineF | closestPoints (const QPolygonF &self, const QPolygonF &other)
QString | defaultWidgetName (WidgetBase::WidgetType type)
QString | newTitle (WidgetBase::WidgetType type)
QString | newText (WidgetBase::WidgetType type)
QString | renameTitle (WidgetBase::WidgetType type)
QString | renameText (WidgetBase::WidgetType type)
void | ensureNestedVisible (UMLWidget *self, UMLWidgetList widgetList)
QString | adornStereo (QString name, bool appendSpace)

## Detailed Description

General purpose widget utilities. Bugs and comments to umbre.nosp@m.llo-.nosp@m.devel.nosp@m.@kde.nosp@m..org or https://bugs.kde.org

## Enumeration Type Documentation

## ◆ Axis_Type

enum Widget_Utils::Axis_Type

Auxiliary type for function findLine()

Enumerator
X |
Y |

## ◆ Comparison_Type

enum Widget_Utils::Comparison_Type

Auxiliary type for function findLine()

Enumerator
Smallest |
Largest |

## Function Documentation

## ◆ adornStereo()

QString Widget_Utils::adornStereo | ( | QString | name,
|  | bool | appendSpace
| ) |  |

Adorn stereotype name with guillemets.

## ◆ closestPoints()

QLineF Widget_Utils::closestPoints | ( | const QPolygonF & | self,
|  | const QPolygonF & | other
| ) |  |

Determine the approximate closest points of two polygons.

Parameters

  self | First QPolygonF.
  other | Second QPolygonF.

Returns
  QLineF::p1() returns point of self; QLineF::p2() returns point of other.

## ◆ decoratePoint()

QGraphicsRectItem * Widget_Utils::decoratePoint | ( | const QPointF & | p,
|  | QGraphicsItem * | parent
| ) |  |

Creates the decoration point.

Parameters

  p | base point to decorate
  parent | parent item

Returns
  decoration point

## ◆ defaultWidgetName()

QString Widget_Utils::defaultWidgetName | ( | WidgetBase::WidgetType | type | ) |

Returns a default name for the new widget

Parameters

  type | the widget type

Returns
  the default name

## ◆ drawCrossInEllipse()

void Widget_Utils::drawCrossInEllipse | ( | QPainter * | p,
|  | const QRectF & | r
| ) |  |

Calculates and draws a cross inside an ellipse

Parameters

  p | Pointer to a QPainter object.
  r | The rectangle describing the ellipse.

## ◆ drawTriangledRect()

void Widget_Utils::drawTriangledRect | ( | QPainter * | painter,
|  | const QRectF & | rect,
|  | const QSizeF & | triSize
| ) |  |

Draws a polygon which is almost rectangular except for the top right corner. A triangle is drawn in top right corner of the rectangle.

Parameters

  painter | The painter with which this shape is to be drawn.
  rect | The rectangle dimensions.
  triSize | The size of the triangle in the top-right corner.

## ◆ ensureNestedVisible()

void Widget_Utils::ensureNestedVisible | ( | UMLWidget * | self,
|  | UMLWidgetList | widgetList
| ) |  |

Prevent nested widget(s) located inside the area of a larger widget from disappearing.

Parameters

  self | The widget against which to test the other widgets of the diagram
  widgetList | The widgets of the diagram

## ◆ findLine()

QLineF Widget_Utils::findLine | ( | const QPolygonF & | poly,
|  | Axis_Type | axis,
|  | Comparison_Type | seek,
|  | const QRectF & | boundingRect
| ) |  |

Find the line of poly with the smallest or largest value (controlled by seek) along the axis controlled by axis. In case axis is X, do not consider lines whose Y values lie outside the Y values defined by boundingRect. In case axis is Y, do not consider lines whose X values lie outside the X values defined by boundingRect.

## ◆ findRegion()

Uml::Region::Enum Widget_Utils::findRegion | ( | const QRectF & | self,
|  | const QRectF & | other
| ) |  |

Find the region in which the rectangle other lies with respect to the rectangle self. Beware that the Qt coordinate system has its origin point (0,0) in the upper left corner with Y values growing downwards, thus the Y related comparisons might look inverted if your are used to the natural coordinate system with (0,0) in the lower left corner.

## ◆ findWidget()

UMLWidget * Widget_Utils::findWidget | ( | Uml::ID::Type | id,
|  | const UMLWidgetList & | widgets,
|  | const MessageWidgetList * | messages
| ) |  |

Find the widget identified by the given ID in the given widget or message list.

Parameters

  id | The unique ID to find.
  widgets | The UMLWidgetList to search in.
  messages | Optional pointer to a MessageWidgetList to search in.

## ◆ hasSmallerX()

bool Widget_Utils::hasSmallerX | ( | const UMLWidget * | widget1,
|  | const UMLWidget * | widget2
| ) |  |

Returns true if the first widget's X is smaller than second's. Used for sorting the UMLWidgetList.

Parameters

  widget1 | The widget to compare.
  widget2 | The widget to compare with.

## ◆ hasSmallerY()

bool Widget_Utils::hasSmallerY | ( | const UMLWidget * | widget1,
|  | const UMLWidget * | widget2
| ) |  |

Returns true if the first widget's Y is smaller than second's. Used for sorting the UMLWidgetList.

Parameters

  widget1 | The widget to compare.
  widget2 | The widget to compare with.

## ◆ loadBrushFromXMI()

bool Widget_Utils::loadBrushFromXMI | ( | QDomElement & | qElement,
|  | QBrush & | brush
| ) |  |

Extracts the QBrush properties into brush from the XMI xml element qElement.

Parameters

  qElement | The DOM element from which the xmi info should be extracted.
  brush | The QBrush object into which brush details should be read into.

## ◆ loadGradientFromXMI()

bool Widget_Utils::loadGradientFromXMI | ( | QDomElement & | gradientElement,
|  | QGradient *& | gradient
| ) |  |

Loads gradient from xmi. The gradient pointer should be null and the new gradient object will be created inside this method. The gradient should later be deleted externally.

Parameters

  gradientElement | The DOM element from which gradient should be loaded.
  gradient | The pointer to gradient into which the gradient should be loaded. (Allocated inside this method)

Returns
  True or false based on success or failure of this method.

## ◆ loadPixmapFromXMI()

bool Widget_Utils::loadPixmapFromXMI | ( | QDomElement & | pixEle,
|  | QPixmap & | pixmap
| ) |  |

Loads pixmap from xmi.

Parameters

  pixEle | The dom element from which pixmap should be loaded.
  pixmap | The pixmap into which the image should be loaded.

Returns
  True or false based on success or failure of this method.

## ◆ middle()

qreal Widget_Utils::middle | ( | qreal | a,
|  | qreal | b
| ) |  |

Return the middle value between a and b.

## ◆ newText()

QString Widget_Utils::newText | ( | WidgetBase::WidgetType | type | ) |

Returns translated text string used by widget related dialogs

Parameters

  type | widget type

Returns
  translated text string

## ◆ newTitle()

QString Widget_Utils::newTitle | ( | WidgetBase::WidgetType | type | ) |

Returns translated title string used by widget related dialogs

Parameters

  type | widget type

Returns
  translated title string

## ◆ nextPoint()

QPointF Widget_Utils::nextPoint | ( | int | index,
|  | const QPolygonF & | poly
| ) |  |

Return the point in poly which follows the point at index index. If index is the last index then return the first (or, if poly.isClosed() is true, the second) point.

## ◆ pointToString()

QString Widget_Utils::pointToString | ( | const QPointF & | point | ) |

Converts a point to a comma separated string i.e "x,y"

Parameters

  point | The QPointF to convert.

## ◆ prevPoint()

QPointF Widget_Utils::prevPoint | ( | int | index,
|  | const QPolygonF & | poly
| ) |  |

Return the point in poly which precedes the point at index index. If index is 0 then return the last (or, if poly.isClosed() is true, the second to last) point.

## ◆ renameText()

QString Widget_Utils::renameText | ( | WidgetBase::WidgetType | type | ) |

Returns translated text string used by widget related dialogs

Parameters

  type | widget type

Returns
  translated text string

## ◆ renameTitle()

QString Widget_Utils::renameTitle | ( | WidgetBase::WidgetType | type | ) |

Returns translated title string used by widget related dialogs

Parameters

  type | widget type

Returns
  translated title string

## ◆ saveBrushToXMI()

void Widget_Utils::saveBrushToXMI | ( | QXmlStreamWriter & | stream,
|  | const QBrush & | brush
| ) |  |

Saves the brush info as XMI.

Parameters

  stream | The QXmlStreamWriter object to write to.
  brush | The QBrush whose details should be saved.

## ◆ saveGradientToXMI()

void Widget_Utils::saveGradientToXMI | ( | QXmlStreamWriter & | stream,
|  | const QGradient * | gradient
| ) |  |

Saves gradient information to XMI.

Parameters

  stream | The QXmlStreamWriter object to write to.
  gradient | The gradient to be saved.

## ◆ savePixmapToXMI()

void Widget_Utils::savePixmapToXMI | ( | QXmlStreamWriter & | stream,
|  | const QPixmap & | pixmap
| ) |  |

Saves pixmap information to XMI.

Parameters

  stream | The QXmlStreamWriter object to write to.
  pixmap | The pixmap to be saved.

## ◆ stringToPoint()

QPointF Widget_Utils::stringToPoint | ( | const QString & | str | ) |

Converts a comma separated string to point.