umbrello 2.39.0
Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology
Public Slots | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
ToolBarStateAssociation Class Reference

#include <toolbarstateassociation.h>

Inheritance diagram for ToolBarStateAssociation:
Collaboration diagram for ToolBarStateAssociation:

Public Slots

virtual void slotWidgetRemoved (UMLWidget *widget)
 
- Public Slots inherited from ToolBarState
virtual void slotAssociationRemoved (AssociationWidget *association)
 
virtual void slotWidgetRemoved (UMLWidget *widget)
 

Public Member Functions

 ToolBarStateAssociation (UMLScene *umlScene)
 
virtual ~ToolBarStateAssociation ()
 
virtual void init ()
 
virtual void cleanBeforeChange ()
 
virtual void mouseMove (QGraphicsSceneMouseEvent *ome)
 
- Public Member Functions inherited from ToolBarStatePool
virtual ~ToolBarStatePool ()
 
void setButton (const WorkToolBar::ToolBar_Buttons &button)
 
WorkToolBar::ToolBar_Buttons getButton () const
 
- Public Member Functions inherited from ToolBarState
virtual ~ToolBarState ()
 
virtual void mousePress (QGraphicsSceneMouseEvent *ome)
 
virtual void mouseRelease (QGraphicsSceneMouseEvent *ome)
 
virtual void mouseDoubleClick (QGraphicsSceneMouseEvent *ome)
 

Protected Member Functions

virtual void mouseReleaseAssociation ()
 
virtual void mouseReleaseWidget ()
 
virtual void mouseReleaseEmpty ()
 
- Protected Member Functions inherited from ToolBarStatePool
 ToolBarStatePool (UMLScene *umlScene)
 
- Protected Member Functions inherited from ToolBarState
 ToolBarState (UMLScene *umlScene)
 
virtual void setCurrentElement ()
 
virtual void mousePressAssociation ()
 
virtual void mousePressWidget ()
 
virtual void mousePressEmpty ()
 
virtual void mouseDoubleClickAssociation ()
 
virtual void mouseDoubleClickWidget ()
 
virtual void mouseDoubleClickEmpty ()
 
virtual void mouseMoveAssociation ()
 
virtual void mouseMoveWidget ()
 
virtual void mouseMoveEmpty ()
 
virtual void changeTool ()
 
virtual UMLWidgetcurrentWidget () const
 
virtual void setCurrentWidget (UMLWidget *widget)
 
virtual AssociationWidgetcurrentAssociation () const
 
virtual void setCurrentAssociation (AssociationWidget *association)
 
void setMouseEvent (QGraphicsSceneMouseEvent *ome, const QEvent::Type &type)
 
AssociationWidgetassociationAt (const QPointF &pos)
 
MessageWidgetmessageAt (const QPointF &pos)
 
FloatingDashLineWidgetfloatingLineAt (const QPointF &pos)
 

Private Member Functions

void setFirstWidget ()
 
void setSecondWidget ()
 
Uml::AssociationType::Enum getAssociationType ()
 
bool addAssociationInViewAndDoc (AssociationWidget *assoc)
 
void cleanAssociation ()
 

Private Attributes

UMLWidgetm_firstWidget
 
QGraphicsLineItem * m_associationLine
 

Additional Inherited Members

- Signals inherited from ToolBarState
void finished ()
 
- Protected Attributes inherited from ToolBarState
UMLScenem_pUMLScene
 The UMLScene.
 
QGraphicsSceneMouseEvent * m_pMouseEvent
 The mouse event currently in use.
 

Detailed Description

Association tool to create associations between widgets. With association tool, two widgets are selected clicking with left button on them and an association of the needed type (depending on the association button selected) is created between the widgets. When the first widget is selected, a temporary visual association that follows the cursor movement is created until the second widget is selected or the association cancelled.

Also, association tool can create association class: a classifier widget which is linked to an association. To do this, the classifier must be selected first and then the association must be selected. The association can't be selected first.

An association can be cancelled using right button, which also returns to default tool, or with middle button, which only cancels the association without changing the tool being used.

Todo
refactor with common code in ToolBarStateMessages?

Constructor & Destructor Documentation

◆ ToolBarStateAssociation()

ToolBarStateAssociation::ToolBarStateAssociation ( UMLScene * umlScene)
explicit

Creates a new ToolBarStateAssociation.

Parameters
umlSceneThe UMLScene to use.

◆ ~ToolBarStateAssociation()

ToolBarStateAssociation::~ToolBarStateAssociation ( )
virtual

Destroys this ToolBarStateAssociation. Deletes the association line.

Here is the call graph for this function:

Member Function Documentation

◆ addAssociationInViewAndDoc()

bool ToolBarStateAssociation::addAssociationInViewAndDoc ( AssociationWidget * assoc)
private

Adds an AssociationWidget to the association list and creates the corresponding UMLAssociation in the current UMLDoc. If the association can't be added, is deleted.

Parameters
assocThe AssociationWidget to add.
Returns
True on success
Here is the call graph for this function:

◆ cleanAssociation()

void ToolBarStateAssociation::cleanAssociation ( )
private

Cleans the first widget and the temporary association line, if any. Both are set to null, and the association line is also deleted.

◆ cleanBeforeChange()

void ToolBarStateAssociation::cleanBeforeChange ( )
virtual

Called when the current tool is changed to use another tool. Executes base method and cleans the association.

Reimplemented from ToolBarState.

Here is the call graph for this function:

◆ getAssociationType()

Uml::AssociationType::Enum ToolBarStateAssociation::getAssociationType ( )
private

Returns the association type of this tool.

Returns
The association type of this tool.
Here is the call graph for this function:

◆ init()

void ToolBarStateAssociation::init ( )
virtual

Goes back to the initial state.

Reimplemented from ToolBarState.

Here is the call graph for this function:

◆ mouseMove()

void ToolBarStateAssociation::mouseMove ( QGraphicsSceneMouseEvent * ome)
virtual

Called when a mouse event happened. It executes the base method and then updates the position of the association line, if any.

Reimplemented from ToolBarState.

Here is the call graph for this function:

◆ mouseReleaseAssociation()

void ToolBarStateAssociation::mouseReleaseAssociation ( )
protectedvirtual

Called when the release event happened on an association. If the button pressed isn't left button, the association being created is cleaned. If it is left button, and the first widget is set and is a classifier widget, it creates an association class. Otherwise, the association being created is cleaned.

Reimplemented from ToolBarState.

Here is the call graph for this function:

◆ mouseReleaseEmpty()

void ToolBarStateAssociation::mouseReleaseEmpty ( )
protectedvirtual

Called when the release event happened on an empty space. Cleans the association.

Reimplemented from ToolBarState.

Here is the call graph for this function:

◆ mouseReleaseWidget()

void ToolBarStateAssociation::mouseReleaseWidget ( )
protectedvirtual

Called when the release event happened on a widget. If the button pressed isn't left button, the association is cleaned. If it is left button, sets the first widget or the second, depending on whether the first widget is already set or not.

Reimplemented from ToolBarState.

Here is the call graph for this function:

◆ setFirstWidget()

void ToolBarStateAssociation::setFirstWidget ( )
private

Sets the first widget in the association using the current widget. If the widget can't be associated using the current type of association, an error is shown and the widget isn't set. Otherwise, the temporary visual association is created and the mouse tracking is enabled, so move events will be delivered.

Here is the call graph for this function:

◆ setSecondWidget()

void ToolBarStateAssociation::setSecondWidget ( )
private

Sets the second widget in the association using the current widget and creates the association. If the association between the two widgets using the current type of association is illegitimate, an error is shown and the association cancelled. Otherwise, the association is created and added to the scene, and the tool is changed to the default tool.

Todo
Why change to the default tool? Shouldn't it better to stay on association and let the user change with a right click? The tool to create widgets doesn't change to default after creating a widget
Here is the call graph for this function:

◆ slotWidgetRemoved

void ToolBarStateAssociation::slotWidgetRemoved ( UMLWidget * widget)
virtualslot

A widget was removed from the UMLScene. If the widget removed was the current widget, the current widget is set to 0. Also, if it was the first widget, the association is cleaned.

Here is the call graph for this function:

Member Data Documentation

◆ m_associationLine

QGraphicsLineItem* ToolBarStateAssociation::m_associationLine
private

The association line shown while the first widget is selected and the second one wasn't selected yet.

◆ m_firstWidget

UMLWidget* ToolBarStateAssociation::m_firstWidget
private

The first widget in the association.


The documentation for this class was generated from the following files: