umbrello API Documentation

FloatingTextWidget Class Reference

This is a multipurpose class. Displays a line of text or an operation. More...

#include <floatingtextwidget.h>

Inheritance diagram for FloatingTextWidget:

UMLWidget WidgetBase List of all members.

Public Slots

void slotMenuSelection (int sel)
 Called when a menu selection has been made.
void setMessageText ()
 Sets the text for this label if it is acting as a sequence diagram message or a collaboration diagram message.

Public Member Functions

 FloatingTextWidget (UMLView *view, Uml::Text_Role role=Uml::tr_Floating, const QString &text="", Uml::IDType id=Uml::id_None)
 Constructs a FloatingTextWidget instance.
virtual ~FloatingTextWidget ()
 destructor
void setText (const QString &t)
 Set the main body of text to display.
void setPreText (const QString &t)
 Set some text to be prepended to the main body of text.
void setPostText (const QString &t)
 Set some text to be appended to the main body of text.
void setSeqNum (const QString &sn)
 Set the sequence number to display.
QString getSeqNum () const
 Return the sequence number.
void setOperation (const QString &op)
 Set the operation to display.
QString getText () const
 Use to get the _main body_ of text (e.g.
QString getPreText () const
 Use to get the pre-text which is prepended to the main body of text to be displayed.
QString getPostText () const
 Use to get the post-text which is appended to the main body of text to be displayed.
QString getDisplayText () const
 Use to get the total text (prepended + main body + appended) currently displayed by the widget.
void changeTextDlg ()
 Displays a dialog box to change the text.
void setLink (LinkWidget *l)
 Set the LinkWidget that this FloatingTextWidget is related to.
LinkWidgetgetLink ()
 Returns the LinkWidget this floating text is related to.
bool isText ()
 Returns whether this is a line of text.
bool activate (IDChangeLog *ChangeLog=0)
 Activate the FloatingTextWidget after the saved data has been loaded.
void setRole (Uml::Text_Role role)
 Sets the role type of this FloatingTextWidget.
Uml::Text_Role getRole () const
 Return the role of the text widget.
void draw (QPainter &p, int offsetX, int offsetY)
 Overrides default method.
void handleRename ()
 Handle the ListPopupMenu::mt_Rename case of the slotMenuSelection.
void showOpDlg ()
 Shows an operation dialog box.
void showProperties ()
 Show the properties for a FloatingTextWidget.
void saveToXMI (QDomDocument &qDoc, QDomElement &qElement)
 Creates the <floatingtext> XMI element.
bool loadFromXMI (QDomElement &qElement)
 Loads the <floatingtext> XMI element.

Static Public Member Functions

static bool isTextValid (const QString &text)
 For a text to be valid it must be non-empty, i.e.

Static Public Attributes

static const int restrictPositionMin = 0
 sometimes the x/y values get numbers of <0 and >10000 - which is probably due to a bug somewhere in calculating the position.
static const int restrictPositionMax = 3000

Protected Member Functions

QSize calculateSize ()
 Overrides method from UMLWidget.

Friends

class FloatingTextWidgetController

Detailed Description

This is a multipurpose class. Displays a line of text or an operation.

In its simplest form it will display a line of text. It can also be setup to be the text for an operation with regard to the MessageWidget on the sequence diagram. It is also used for the text required for an association.

The differences between all these different uses will be the popup menu that is associated with it.

Author:
Paul Hensgen <phensgen@techie.com>
See also:
UMLWidget Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org

Definition at line 38 of file floatingtextwidget.h.


Constructor & Destructor Documentation

FloatingTextWidget::FloatingTextWidget UMLView view,
Uml::Text_Role  role = Uml::tr_Floating,
const QString &  text = "",
Uml::IDType  id = Uml::id_None
[explicit]
 

Constructs a FloatingTextWidget instance.

Parameters:
view The parent of this FloatingTextWidget.
role The role this FloatingTextWidget will take up.
text The main text to display.
id The ID to assign (-1 will prompt a new ID.)

Definition at line 40 of file floatingtextwidget.cpp.

References UMLWidget::init(), UMLWidget::setZ(), and UMLWidget::updateComponentSize().

FloatingTextWidget::~FloatingTextWidget  )  [virtual]
 

destructor

Definition at line 66 of file floatingtextwidget.cpp.


Member Function Documentation

void FloatingTextWidget::setText const QString &  t  ) 
 

Set the main body of text to display.

Parameters:
t The text to display.

Definition at line 228 of file floatingtextwidget.cpp.

References LinkWidget::getSeqNumAndOp(), UMLView::getShowOpSig(), and UMLWidget::updateComponentSize().

Referenced by changeTextDlg(), handleRename(), and AssociationWidget::setName().

void FloatingTextWidget::setPreText const QString &  t  ) 
 

Set some text to be prepended to the main body of text.

Parameters:
t The text to prepend to main body which is displayed.

Definition at line 244 of file floatingtextwidget.cpp.

References UMLWidget::updateComponentSize().

void FloatingTextWidget::setPostText const QString &  t  ) 
 

Set some text to be appended to the main body of text.

Parameters:
t The text to append to main body which is displayed.

Definition at line 251 of file floatingtextwidget.cpp.

References UMLWidget::updateComponentSize().

void FloatingTextWidget::setSeqNum const QString &  sn  ) 
 

Set the sequence number to display.

Parameters:
sn The sequence number to display.

QString FloatingTextWidget::getSeqNum  )  const
 

Return the sequence number.

Returns:
The sequence number.

void FloatingTextWidget::setOperation const QString &  op  ) 
 

Set the operation to display.

Parameters:
op The operation to display.

QString FloatingTextWidget::getText  )  const
 

Use to get the _main body_ of text (e.g.

prepended and appended text is omitted) as currently displayed by the widget.

Returns:
The main text currently being displayed by the widget.

Definition at line 337 of file floatingtextwidget.cpp.

Referenced by MessageWidget::activate(), AssociationWidget::activate(), changeTextDlg(), AssociationWidget::getMulti(), AssociationWidget::getName(), AssociationWidget::getRoleName(), handleRename(), AssociationWidget::loadFromXMI(), MessageWidget::saveToXMI(), setMessageText(), UMLView::slotMenuSelection(), slotMenuSelection(), and AssociationWidget::slotMenuSelection().

QString FloatingTextWidget::getPreText  )  const
 

Use to get the pre-text which is prepended to the main body of text to be displayed.

Returns:
The pre-text currently displayed by the widget.

Definition at line 329 of file floatingtextwidget.cpp.

QString FloatingTextWidget::getPostText  )  const
 

Use to get the post-text which is appended to the main body of text to be displayed.

Returns:
The post-text currently displayed by the widget.

Definition at line 333 of file floatingtextwidget.cpp.

QString FloatingTextWidget::getDisplayText  )  const
 

Use to get the total text (prepended + main body + appended) currently displayed by the widget.

Returns:
The text currently being displayed by the widget.

Definition at line 350 of file floatingtextwidget.cpp.

Referenced by UMLView::addWidget(), calculateSize(), draw(), MessageWidget::setSelected(), and MessageWidget::setTextPosition().

void FloatingTextWidget::changeTextDlg  ) 
 

Displays a dialog box to change the text.

Definition at line 257 of file floatingtextwidget.cpp.

References getText(), isTextValid(), setText(), and UMLWidget::updateComponentSize().

Referenced by UMLView::slotMenuSelection().

void FloatingTextWidget::setLink LinkWidget l  ) 
 

Set the LinkWidget that this FloatingTextWidget is related to.

Parameters:
l The related LinkWidget.

Definition at line 365 of file floatingtextwidget.cpp.

Referenced by AssociationWidget::activate(), AssociationWidget::loadFromXMI(), MessageWidget::setLinkAndTextPos(), and AssociationWidget::setName().

LinkWidget * FloatingTextWidget::getLink  ) 
 

Returns the LinkWidget this floating text is related to.

Returns:
The LinkWidget this floating text is related to.

Definition at line 369 of file floatingtextwidget.cpp.

Referenced by UMLView::selectWidgets().

bool FloatingTextWidget::isText  )  [inline, virtual]
 

Returns whether this is a line of text.

Used for transparency in printing.

Returns:
Returns whether this is a line of text.

Reimplemented from UMLWidget.

Definition at line 174 of file floatingtextwidget.h.

bool FloatingTextWidget::activate IDChangeLog ChangeLog = 0  )  [virtual]
 

Activate the FloatingTextWidget after the saved data has been loaded.

Parameters:
ChangeLog Pointer to the IDChangeLog.
Returns:
true for success

Reimplemented from UMLWidget.

Definition at line 358 of file floatingtextwidget.cpp.

Referenced by AssociationWidget::activate().

void FloatingTextWidget::setRole Uml::Text_Role  role  ) 
 

Sets the role type of this FloatingTextWidget.

Parameters:
role The Text_Role of this FloatingTextWidget.

Definition at line 373 of file floatingtextwidget.cpp.

Referenced by AssociationWidget::activate().

Uml::Text_Role FloatingTextWidget::getRole  )  const
 

Return the role of the text widget.

Returns:
The Text_Role of this FloatingTextWidget.

Definition at line 377 of file floatingtextwidget.cpp.

Referenced by UMLWidget::activate(), UMLView::getSelectCount(), UMLView::getSelectedWidgets(), and MessageWidget::setTextPosition().

bool FloatingTextWidget::isTextValid const QString &  text  )  [static]
 

For a text to be valid it must be non-empty, i.e.

have a length larger that zero, and have at least one non whitespace character.

Parameters:
text The string to analyze.
Returns:
True if the given text is valid.

Definition at line 381 of file floatingtextwidget.cpp.

Referenced by changeTextDlg(), handleRename(), AssociationWidget::loadFromXMI(), and UMLView::slotMenuSelection().

void FloatingTextWidget::draw QPainter &  p,
int  offsetX,
int  offsetY
[virtual]
 

Overrides default method.

Implements UMLWidget.

Definition at line 69 of file floatingtextwidget.cpp.

References UMLWidget::drawSelected(), and getDisplayText().

void FloatingTextWidget::handleRename  ) 
 

Handle the ListPopupMenu::mt_Rename case of the slotMenuSelection.

Given an own method because it requires rather lengthy code.

Definition at line 158 of file floatingtextwidget.cpp.

References UMLApp::getDocument(), getText(), isTextValid(), UMLView::removeWidget(), AssociationWidget::setChangeability(), UMLDoc::setModified(), AssociationWidget::setMulti(), UMLWidget::setName(), AssociationWidget::setName(), AssociationWidget::setRoleName(), setText(), LinkWidget::setText(), and UMLWidget::updateComponentSize().

Referenced by showProperties(), UMLWidget::slotMenuSelection(), and slotMenuSelection().

void FloatingTextWidget::showOpDlg  ) 
 

Shows an operation dialog box.

Definition at line 271 of file floatingtextwidget.cpp.

References UMLClassifier::createOperation(), UMLClassifier::findSuperClassConcepts(), LinkWidget::getOperation(), SelectOpDlg::getOpText(), LinkWidget::getSeqNumAndOp(), SelectOpDlg::getSeqNumber(), SelectOpDlg::isClassOp(), Model_Utils::OpDescriptor::m_args, Model_Utils::OpDescriptor::m_name, Model_Utils::OpDescriptor::m_pReturnType, Model_Utils::parseOperation(), SelectOpDlg::setClassOp(), SelectOpDlg::setCustomOp(), setMessageText(), LinkWidget::setOperation(), LinkWidget::setSeqNumAndOp(), SelectOpDlg::setSeqNumber(), and UMLOperation::setType().

Referenced by ToolBarStateMessages::setSecondWidget(), showProperties(), and slotMenuSelection().

void FloatingTextWidget::showProperties  )  [virtual]
 

Show the properties for a FloatingTextWidget.

Depending on the role of the floating text wiget, the options dialog for the floating text widget, the rename dialog for floating text or the options dialog for the link widget are shown.

Reimplemented from UMLWidget.

Definition at line 391 of file floatingtextwidget.cpp.

References handleRename(), LinkWidget::showDialog(), and showOpDlg().

Referenced by slotMenuSelection().

void FloatingTextWidget::saveToXMI QDomDocument &  qDoc,
QDomElement &  qElement
[virtual]
 

Creates the <floatingtext> XMI element.

Reimplemented from UMLWidget.

Definition at line 403 of file floatingtextwidget.cpp.

bool FloatingTextWidget::loadFromXMI QDomElement &  qElement  )  [virtual]
 

Loads the <floatingtext> XMI element.

Reimplemented from UMLWidget.

Definition at line 419 of file floatingtextwidget.cpp.

Referenced by MessageWidget::loadFromXMI(), and AssociationWidget::loadFromXMI().

void FloatingTextWidget::slotMenuSelection int  sel  )  [virtual, slot]
 

Called when a menu selection has been made.

This method is public due to called by MessageWidget when this is text for a MessageWidget.

Parameters:
sel The selection that has been made.

Reimplemented from UMLWidget.

Definition at line 89 of file floatingtextwidget.cpp.

References UMLWidget::getFont(), LinkWidget::getOperationOwner(), getText(), handleRename(), LinkWidget::lwSetFont(), LinkWidget::resetTextPositions(), LinkWidget::setCustomOpText(), UMLWidget::setFont(), LinkWidget::setOperation(), showOpDlg(), showProperties(), and UMLWidget::slotMenuSelection().

Referenced by MessageWidgetController::doMouseDoubleClick(), and AssociationWidget::slotMenuSelection().

void FloatingTextWidget::setMessageText  )  [slot]
 

Sets the text for this label if it is acting as a sequence diagram message or a collaboration diagram message.

Definition at line 439 of file floatingtextwidget.cpp.

References getText(), LinkWidget::setMessageText(), and UMLWidget::updateComponentSize().

Referenced by MessageWidget::setCustomOpText(), and showOpDlg().

QSize FloatingTextWidget::calculateSize  )  [protected, virtual]
 

Overrides method from UMLWidget.

Reimplemented from UMLWidget.

Definition at line 82 of file floatingtextwidget.cpp.

References getDisplayText(), and UMLWidget::getFontMetrics().


Member Data Documentation

const int FloatingTextWidget::restrictPositionMin = 0 [static]
 

sometimes the x/y values get numbers of <0 and >10000 - which is probably due to a bug somewhere in calculating the position.

-> workaround till problem is found: define min and max limits => if x or y is outside of interval, the position is reset ( e.g. by AssociationWidget::resetTextPositions() )

Definition at line 49 of file floatingtextwidget.h.


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:08:05 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003