umbrello API Documentation

ToolBarState Class Reference

Base class for toolbar states. More...

#include <toolbarstate.h>

Inheritance diagram for ToolBarState:

ToolBarStateArrow ToolBarStatePool ToolBarStateAssociation ToolBarStateMessages ToolBarStateOther List of all members.

Public Slots

virtual void slotAssociationRemoved (AssociationWidget *association)
 An association was removed from the UMLView.
virtual void slotWidgetRemoved (UMLWidget *widget)
 A widget was removed from the UMLView.

Public Member Functions

virtual ~ToolBarState ()
 Destroys this ToolBarState.
virtual void init ()
 Goes back to the initial state.
virtual void cleanBeforeChange ()
 Called when the current tool is changed to use another tool.
virtual void mousePress (QMouseEvent *ome)
 Handler for mouse press events.
virtual void mouseRelease (QMouseEvent *ome)
 Handler for mouse release events.
virtual void mouseDoubleClick (QMouseEvent *ome)
 Handler for mouse double click events.
virtual void mouseMove (QMouseEvent *ome)
 Handler for mouse double click events.

Protected Member Functions

 ToolBarState (UMLView *umlView)
 Creates a new ToolBarState.
virtual void setCurrentElement ()
 Sets the current association or widget.
virtual void mousePressAssociation ()
 Called when the press event happened on an association.
virtual void mousePressWidget ()
 Called when the press event happened on a widget.
virtual void mousePressEmpty ()
 Called when the press event happened on an empty space.
virtual void mouseReleaseAssociation ()
 Called when the release event happened on an association.
virtual void mouseReleaseWidget ()
 Called when the release event happened on a widget.
virtual void mouseReleaseEmpty ()
 Called when the release event happened on an empty space.
virtual void mouseDoubleClickAssociation ()
 Called when the double click event happened on an association.
virtual void mouseDoubleClickWidget ()
 Called when the double click event happened on a widget.
virtual void mouseDoubleClickEmpty ()
 Called when the double click event happened on an empty space.
virtual void mouseMoveAssociation ()
 Called when the move event happened when an association is currently available.
virtual void mouseMoveWidget ()
 Called when the move event happened when a widget is currently available.
virtual void mouseMoveEmpty ()
 Called when the move event happened when no association nor widget are currently available.
virtual void changeTool ()
 Changes the current tool to the default one if the right button was released.
virtual UMLWidgetgetCurrentWidget ()
 Returns the widget currently in use.
virtual void setCurrentWidget (UMLWidget *currentWidget)
 Sets the widget currently in use.
virtual AssociationWidgetgetCurrentAssociation ()
 Returns the association currently in use.
virtual void setCurrentAssociation (AssociationWidget *currentAssociation)
 Sets the association currently in use.
void setMouseEvent (QMouseEvent *ome, const QEvent::Type &type)
 Sets m_pMouseEvent as the equivalent of the received event after transforming it using the inverse world matrix in the UMLView.
AssociationWidgetgetAssociationAt (QPoint pos)
 Returns the AssociationWidget at the specified position, or null if there is none.
MessageWidgetgetMessageAt (QPoint pos)
 Returns the MessageWidget at the specified position, or null if there is none.

Protected Attributes

UMLViewm_pUMLView
 The UMLView.
QMouseEvent * m_pMouseEvent
 The mouse event currently in use.

Detailed Description

Base class for toolbar states.

All toolbar states inherit directly or indirectly from this class. Toolbar states represent tools that work with the diagram (for example, to create widgets, make associations...). All the mouse events received in the diagram are delivered to the toolbar state currently active. The events are handled in the tool and it executes the needed actions.

All the mouse event handlers can be overridden in subclasses. However, the behaviour of the main handlers shouldn't be modified (apart from extend it, that is, call the base implementation before any other actions in the derived method).

In order to handle the events, each main handler has three protected "sub-handlers" named like the main handler with the suffixes "Association", "Wdiget" and "Empty". The events received in the main handlers are delivered to the suitable handler, depending on if the event happened on an association, on a widget or on an empty space of the diagram. Those methods are the ones to override or extend to specify the behaviour of the toolbar state.

The mouse events received in main handlers are tweaked to use the inverse position. The modified event is saved in m_pMouseEvent. This is the event that must be used everywhere.

The association or widget that will receive the events is set in press event. How they are set can be tweaked in subclasses overriding setCurrentElement(). Once a press event happens, all the mouse events and the release event are sent to the same widget or association. Mouse events are delivered only when mouse tracking is enabled. It is enabled in press event, and disabled in release event. Also, it is disabled in the toolbar state initialization. Additionally, it can be enabled or disabled in other situations by subclasses if needed.

After handling a release event, the tool is changed if needed. Default implementation sets the default tool if the button released was the right button. Subclasses can override this behaviour if needed.

When a toolbar state is selected, method init is called to revert its state to the initial. Subclasses should extend that method as needed. Also, method cleanBeforeChange() is called before changing it to the new tool. Subclasses should extend that method as needed.

Definition at line 71 of file toolbarstate.h.


Constructor & Destructor Documentation

ToolBarState::~ToolBarState  )  [virtual]
 

Destroys this ToolBarState.

Frees m_pMouseEvent.

Definition at line 25 of file toolbarstate.cpp.

References m_pMouseEvent.

ToolBarState::ToolBarState UMLView umlView  )  [protected]
 

Creates a new ToolBarState.

UMLView is set as parent of this QObject, and name is left empty. Protected to avoid classes other than derived to create objects of this class.

Parameters:
umlView The UMLView to use.

Definition at line 156 of file toolbarstate.cpp.


Member Function Documentation

void ToolBarState::init  )  [virtual]
 

Goes back to the initial state.

Subclasses can extend, but not override, this method as needed.

Reimplemented in ToolBarStateArrow, ToolBarStateAssociation, and ToolBarStateMessages.

Definition at line 29 of file toolbarstate.cpp.

References m_pMouseEvent, m_pUMLView, slotAssociationRemoved(), and slotWidgetRemoved().

Referenced by ToolBarStateMessages::init(), ToolBarStateAssociation::init(), ToolBarStateArrow::init(), ToolBarStatePool::setButton(), and UMLView::slotToolBarChanged().

void ToolBarState::cleanBeforeChange  )  [virtual]
 

Called when the current tool is changed to use another tool.

Subclasses can extend, but not override, this method as needed. Default implementation does nothing.

Reimplemented in ToolBarStateAssociation, and ToolBarStateMessages.

Definition at line 41 of file toolbarstate.cpp.

References m_pUMLView, slotAssociationRemoved(), and slotWidgetRemoved().

Referenced by ToolBarStateMessages::cleanBeforeChange(), ToolBarStateAssociation::cleanBeforeChange(), and UMLView::slotToolBarChanged().

void ToolBarState::mousePress QMouseEvent *  ome  )  [virtual]
 

Handler for mouse press events.

Mouse tracking is enabled, any pop up menu removed, the position of the cursor set and paste state disabled. Then, the current association or widget are set (if any), and events are delivered to the specific methods, depending on where the cursor was pressed.

Parameters:
ome The received event.
See also:
setCurrentElement()

Definition at line 48 of file toolbarstate.cpp.

References UMLView::emitRemovePopupMenu(), getCurrentAssociation(), getCurrentWidget(), m_pMouseEvent, m_pUMLView, mousePressAssociation(), mousePressEmpty(), mousePressWidget(), setCurrentElement(), setMouseEvent(), UMLView::setPaste(), and UMLView::setPos().

Referenced by UMLView::contentsMousePressEvent().

void ToolBarState::mouseRelease QMouseEvent *  ome  )  [virtual]
 

Handler for mouse release events.

Mouse tracking is disabled and the position of the cursor set. The events are delivered to the specific methods, depending on where the cursor was released, and the current association or widget cleaned. Finally, the current tool is changed if needed.

Parameters:
ome The received event.

Definition at line 74 of file toolbarstate.cpp.

References changeTool(), getCurrentAssociation(), getCurrentWidget(), m_pMouseEvent, m_pUMLView, mouseReleaseAssociation(), mouseReleaseEmpty(), mouseReleaseWidget(), setCurrentAssociation(), setCurrentWidget(), setMouseEvent(), and UMLView::setPos().

Referenced by UMLView::contentsMouseReleaseEvent().

void ToolBarState::mouseDoubleClick QMouseEvent *  ome  )  [virtual]
 

Handler for mouse double click events.

The current association or widget is set (if any), and events are delivered to the specific methods, depending on where the cursor was pressed. After delivering the events, the current association or widget is cleaned.

Parameters:
ome The received event.

Definition at line 98 of file toolbarstate.cpp.

References getAssociationAt(), UMLView::getWidgetAt(), m_pMouseEvent, m_pUMLView, mouseDoubleClickAssociation(), mouseDoubleClickEmpty(), mouseDoubleClickWidget(), setCurrentAssociation(), setCurrentWidget(), and setMouseEvent().

Referenced by UMLView::contentsMouseDoubleClickEvent().

void ToolBarState::mouseMove QMouseEvent *  ome  )  [virtual]
 

Handler for mouse double click events.

Events are delivered to the specific methods, depending on where the cursor was pressed. It uses the current widget or association set in press event, if any. Then, the view is scrolled if needed (if the cursor is moved in any of the 30 pixels width area from left, top, right or bottom sides, and there is more diagram currently not being shown in that direction). This method is only called when mouse tracking is enabled and the mouse is moved.

Parameters:
ome The received event.

Reimplemented in ToolBarStateAssociation, and ToolBarStateMessages.

Definition at line 116 of file toolbarstate.cpp.

References getCurrentAssociation(), getCurrentWidget(), m_pUMLView, mouseMoveAssociation(), mouseMoveEmpty(), mouseMoveWidget(), and setMouseEvent().

Referenced by UMLView::contentsMouseMoveEvent(), ToolBarStateMessages::mouseMove(), and ToolBarStateAssociation::mouseMove().

void ToolBarState::slotAssociationRemoved AssociationWidget association  )  [virtual, slot]
 

An association was removed from the UMLView.

If the association removed was the current association, the current association is set to 0. It can be extended in subclasses if needed.

Definition at line 144 of file toolbarstate.cpp.

Referenced by cleanBeforeChange(), and init().

void ToolBarState::slotWidgetRemoved UMLWidget widget  )  [virtual, slot]
 

A widget was removed from the UMLView.

If the widget removed was the current widget, the current widget is set to 0. It can be extended in subclasses if needed.

Reimplemented in ToolBarStateAssociation, and ToolBarStateMessages.

Definition at line 150 of file toolbarstate.cpp.

Referenced by cleanBeforeChange(), init(), ToolBarStateMessages::slotWidgetRemoved(), and ToolBarStateAssociation::slotWidgetRemoved().

void ToolBarState::setCurrentElement  )  [protected, virtual]
 

Sets the current association or widget.

It sets the current element when a press event happened. The element will be used until the next release event. Default implementation first checks for associations, then message widgets and then any other widgets. It can be overridden in subclasses if needed.

Reimplemented in ToolBarStateMessages.

Definition at line 161 of file toolbarstate.cpp.

References m_pMouseEvent, and setCurrentAssociation().

Referenced by mousePress().

void ToolBarState::mousePressAssociation  )  [protected, virtual]
 

Called when the press event happened on an association.

Default implementation does nothing.

Reimplemented in ToolBarStateArrow.

Definition at line 185 of file toolbarstate.cpp.

Referenced by mousePress().

void ToolBarState::mousePressWidget  )  [protected, virtual]
 

Called when the press event happened on a widget.

Default implementation does nothing.

Reimplemented in ToolBarStateArrow.

Definition at line 188 of file toolbarstate.cpp.

Referenced by mousePress().

void ToolBarState::mousePressEmpty  )  [protected, virtual]
 

Called when the press event happened on an empty space.

Default implementation cleans the selection.

Reimplemented in ToolBarStateArrow.

Definition at line 191 of file toolbarstate.cpp.

References UMLView::clearSelected(), and m_pUMLView.

Referenced by mousePress(), and ToolBarStateArrow::mousePressEmpty().

void ToolBarState::mouseReleaseAssociation  )  [protected, virtual]
 

Called when the release event happened on an association.

Default implementation does nothing.

Reimplemented in ToolBarStateArrow, and ToolBarStateAssociation.

Definition at line 195 of file toolbarstate.cpp.

Referenced by mouseRelease().

void ToolBarState::mouseReleaseWidget  )  [protected, virtual]
 

Called when the release event happened on a widget.

Default implementation does nothing.

Reimplemented in ToolBarStateArrow, ToolBarStateAssociation, and ToolBarStateMessages.

Definition at line 198 of file toolbarstate.cpp.

Referenced by mouseRelease().

void ToolBarState::mouseReleaseEmpty  )  [protected, virtual]
 

Called when the release event happened on an empty space.

Default implementation does nothing.

Reimplemented in ToolBarStateArrow, ToolBarStateAssociation, and ToolBarStateMessages.

Definition at line 201 of file toolbarstate.cpp.

Referenced by mouseRelease().

void ToolBarState::mouseDoubleClickAssociation  )  [protected, virtual]
 

Called when the double click event happened on an association.

Default implementation does nothing.

Reimplemented in ToolBarStateArrow.

Definition at line 204 of file toolbarstate.cpp.

Referenced by mouseDoubleClick().

void ToolBarState::mouseDoubleClickWidget  )  [protected, virtual]
 

Called when the double click event happened on a widget.

Default implementation does nothing.

Reimplemented in ToolBarStateArrow.

Definition at line 207 of file toolbarstate.cpp.

Referenced by mouseDoubleClick().

void ToolBarState::mouseDoubleClickEmpty  )  [protected, virtual]
 

Called when the double click event happened on an empty space.

Default implementation cleans the selection.

Definition at line 210 of file toolbarstate.cpp.

References UMLView::clearSelected(), and m_pUMLView.

Referenced by mouseDoubleClick().

void ToolBarState::mouseMoveAssociation  )  [protected, virtual]
 

Called when the move event happened when an association is currently available.

Default implementation does nothing.

Reimplemented in ToolBarStateArrow.

Definition at line 214 of file toolbarstate.cpp.

Referenced by mouseMove().

void ToolBarState::mouseMoveWidget  )  [protected, virtual]
 

Called when the move event happened when a widget is currently available.

Default implementation does nothing.

Reimplemented in ToolBarStateArrow.

Definition at line 217 of file toolbarstate.cpp.

Referenced by mouseMove().

void ToolBarState::mouseMoveEmpty  )  [protected, virtual]
 

Called when the move event happened when no association nor widget are currently available.

Default implementation does nothing.

Reimplemented in ToolBarStateArrow.

Definition at line 220 of file toolbarstate.cpp.

Referenced by mouseMove().

void ToolBarState::changeTool  )  [protected, virtual]
 

Changes the current tool to the default one if the right button was released.

It can be overridden in subclasses if needed.

Reimplemented in ToolBarStateArrow.

Definition at line 223 of file toolbarstate.cpp.

References UMLApp::getWorkToolBar(), m_pMouseEvent, and WorkToolBar::setDefaultTool().

Referenced by mouseRelease().

virtual UMLWidget* ToolBarState::getCurrentWidget  )  [inline, protected, virtual]
 

Returns the widget currently in use.

Returns:
The widget currently in use.

Definition at line 269 of file toolbarstate.h.

Referenced by ToolBarStateArrow::mouseDoubleClickWidget(), mouseMove(), ToolBarStateArrow::mouseMoveWidget(), mousePress(), ToolBarStateArrow::mousePressWidget(), mouseRelease(), ToolBarStateMessages::mouseReleaseWidget(), ToolBarStateArrow::mouseReleaseWidget(), and ToolBarStateArrow::setCurrentWidget().

virtual void ToolBarState::setCurrentWidget UMLWidget currentWidget  )  [inline, protected, virtual]
 

Sets the widget currently in use.

This method is called in main press events handler just before calling the press event for widgets handler. Default implementation is set the specified widget, although this behaviour can be overridden in subclasses if needed.

Parameters:
currentWidget The widget to be set.

Reimplemented in ToolBarStateArrow.

Definition at line 282 of file toolbarstate.h.

Referenced by mouseDoubleClick(), mouseRelease(), ToolBarStateMessages::setCurrentElement(), and ToolBarStateArrow::setCurrentWidget().

virtual AssociationWidget* ToolBarState::getCurrentAssociation  )  [inline, protected, virtual]
 

Returns the association currently in use.

Returns:
The association currently in use.

Definition at line 291 of file toolbarstate.h.

Referenced by ToolBarStateArrow::mouseDoubleClickAssociation(), mouseMove(), ToolBarStateArrow::mouseMoveAssociation(), mousePress(), ToolBarStateArrow::mousePressAssociation(), mouseRelease(), ToolBarStateAssociation::mouseReleaseAssociation(), and ToolBarStateArrow::mouseReleaseAssociation().

virtual void ToolBarState::setCurrentAssociation AssociationWidget currentAssociation  )  [inline, protected, virtual]
 

Sets the association currently in use.

This method is called in main press events handler just before calling the press event for associations handler. Default implementation is set the specified association, although this behaviour can be overridden in subclasses if needed.

Parameters:
currentAssociation The association to be set.

Definition at line 304 of file toolbarstate.h.

Referenced by mouseDoubleClick(), mouseRelease(), and setCurrentElement().

void ToolBarState::setMouseEvent QMouseEvent *  ome,
const QEvent::Type &  type
[protected]
 

Sets m_pMouseEvent as the equivalent of the received event after transforming it using the inverse world matrix in the UMLView.

This method is called at the beginning of the main event handler methods.

Parameters:
ome The mouse event to transform.
type The type of the event.

Definition at line 229 of file toolbarstate.cpp.

References m_pMouseEvent, and m_pUMLView.

Referenced by mouseDoubleClick(), mouseMove(), mousePress(), and mouseRelease().

AssociationWidget * ToolBarState::getAssociationAt QPoint  pos  )  [protected]
 

Returns the AssociationWidget at the specified position, or null if there is none.

If there are more than one association at this point, it returns the first found.

Parameters:
pos The position to get the association.
Returns:
The AssociationWidget at the specified position, or null if there is none.

Definition at line 248 of file toolbarstate.cpp.

References UMLView::getAssociationList(), m_pUMLView, and AssociationWidget::onAssociation().

Referenced by mouseDoubleClick().

MessageWidget * ToolBarState::getMessageAt QPoint  pos  )  [protected]
 

Returns the MessageWidget at the specified position, or null if there is none.

The message is only returned if it is visible. If there are more than one message at this point, it returns the first found.

Parameters:
pos The position to get the message.
Returns:
The MessageWidget at the specified position, or null if there is none.

Definition at line 236 of file toolbarstate.cpp.

References UMLView::getMessageList(), m_pUMLView, and MessageWidget::onWidget().


Member Data Documentation

UMLView* ToolBarState::m_pUMLView [protected]
 

The UMLView.

Definition at line 342 of file toolbarstate.h.

Referenced by cleanBeforeChange(), getAssociationAt(), getMessageAt(), init(), mouseDoubleClick(), mouseDoubleClickEmpty(), mouseMove(), mousePress(), mousePressEmpty(), mouseRelease(), and setMouseEvent().

QMouseEvent* ToolBarState::m_pMouseEvent [protected]
 

The mouse event currently in use.

This event is the equivalent of the received event after transforming it using the inverse world matrix in the UMLView.

Definition at line 349 of file toolbarstate.h.

Referenced by changeTool(), init(), mouseDoubleClick(), mousePress(), mouseRelease(), setCurrentElement(), setMouseEvent(), and ~ToolBarState().


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:06 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003