umbrello: UMLListView Class Reference

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

Public Slots | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
UMLListView Class Reference

Displays the list view for the program. More...

`#include <umllistview.h>`

Inheritance diagram for UMLListView:

## Public Slots
void | slotDiagramCreated (Uml::ID::Type id)
void | slotDiagramRenamed (Uml::ID::Type id)
void | slotDiagramRemoved (Uml::ID::Type id)
void | slotObjectCreated (UMLObject *object)
void | slotObjectRemoved (UMLObject *object)
void | connectNewObjectsSlots (UMLObject *object)
void | childObjectAdded (UMLClassifierListItem *obj)
void | childObjectRemoved (UMLClassifierListItem *obj)
void | slotObjectChanged ()
void | slotMenuSelection (QAction *action, const QPoint &position=QPoint())
void | slotDropped (QDropEvent *de, UMLListViewItem *target)
void | expandAll (UMLListViewItem *item)
void | collapseAll (UMLListViewItem *item)
void | slotCutSuccessful ()
void | slotDeleteSelectedItems ()

## Public Member Functions
| UMLListView (QWidget *parent=0)
| ~UMLListView ()
void | setDocument (UMLDoc *doc)
UMLDoc * | document () const
void | init ()
void | clean ()
void | setView (UMLView *view)
void | setTitle (int column, const QString &text)
UMLListViewItemList | selectedItems () const
UMLListViewItemList | selectedItemsRoot () const
int | selectedItemsCount () const
UMLListViewItem * | createDiagramItem (UMLView *view)
bool | createItem (UMLListViewItem *item)
UMLListViewItem * | findFolderForDiagram (Uml::DiagramType::Enum dt) const
UMLListViewItem * | determineParentItem (UMLObject *object) const
UMLListViewItem * | determineParentItem (UMLListViewItem::ListViewType lvt) const
void | addNewItem (UMLListViewItem *parent, UMLListViewItem::ListViewType type)
UMLListViewItem * | findUMLObject (const UMLObject *p) const
UMLListViewItem * | findView (UMLView *v)
UMLListViewItem * | findItem (Uml::ID::Type id)
UMLListViewItem * | rootView (UMLListViewItem::ListViewType type)
void | changeIconOf (UMLObject *o, Icon_Utils::IconType to)
bool | isUnique (UMLListViewItem *item, const QString &name) const
void | setStartedCut (bool startedCut)
void | setStartedCopy (bool startedCopy)
bool | startedCopy () const
UMLListViewItem * | moveObject (Uml::ID::Type srcId, UMLListViewItem::ListViewType srcType, UMLListViewItem *newParent)
void | closeDatatypesFolder ()
UMLListViewItem * | theRootView ()
UMLListViewItem * | theLogicalView ()
UMLListViewItem * | theUseCaseView ()
UMLListViewItem * | theComponentView ()
UMLListViewItem * | theDeploymentView ()
UMLListViewItem * | theDatatypeFolder ()
UMLListViewItem::ListViewType | rootViewType (UMLListViewItem *item)
void | saveToXMI (QXmlStreamWriter &writer)
bool | loadFromXMI (QDomElement &element)
bool | loadChildrenFromXMI (UMLListViewItem *parent, QDomElement &element)

## Static Public Member Functions
static bool | mayHaveChildItems (UMLObject::ObjectType type)

## Protected Slots
void | slotItemSelectionChanged ()
void | slotExpanded (QTreeWidgetItem *item)
void | slotCollapsed (QTreeWidgetItem *item)

## Protected Member Functions
bool | event (QEvent *e)
void | mouseReleaseEvent (QMouseEvent *me)
void | mousePressEvent (QMouseEvent *me)
void | mouseMoveEvent (QMouseEvent *me)
void | mouseDoubleClickEvent (QMouseEvent *me)
void | focusOutEvent (QFocusEvent *fe)
void | contextMenuEvent (QContextMenuEvent *event)
UMLDragData * | getDragData ()
bool | acceptDrag (QDropEvent *event) const
void | keyPressEvent (QKeyEvent *ke)
void | dragEnterEvent (QDragEnterEvent *event)
void | dragMoveEvent (QDragMoveEvent *event)
void | dropEvent (QDropEvent *event)
void | commitData (QWidget *editor)
UMLListViewItem * | findUMLObjectInFolder (UMLListViewItem *folder, UMLObject *obj)
void | deleteChildrenOf (UMLListViewItem *parent)
bool | deleteItem (UMLListViewItem *temp)
void | childObjectAdded (UMLClassifierListItem *child, UMLClassifier *parent)
void | addAtContainer (UMLListViewItem *item, UMLListViewItem *parent)

## Static Protected Member Functions
static bool | isExpandable (UMLListViewItem::ListViewType lvt)

## Private Member Functions
UMLListViewItem * | recursiveSearchForView (UMLListViewItem *folder, UMLListViewItem::ListViewType type, Uml::ID::Type id)
void | setBackgroundColor (const QColor &color)

## Private Attributes
UMLListViewItem * | m_rv
| root view (home) More...
UMLListViewItem * | m_lv [Uml::ModelType::N_MODELTYPES]
| predefined list view roots More...
UMLListViewItem * | m_datatypeFolder
UMLListViewItem * | m_settingsFolder
| settings root More...
UMLDoc * | m_doc
bool | m_bStartedCut
bool | m_bStartedCopy
bool | m_bCreatingChildObject
| when creating an attribute or an operation to stop it adding a second listViewItem More...
QPoint | m_dragStartPosition
QMimeData * | m_dragCopyData
QList< QTreeWidgetItem * > | m_findItems

## Friends
QDebug | operator<< (QDebug out, const UMLListView &view)

## Detailed Description

Displays the list view for the program.

This is one of the main classes used in this program. Information is displayed here in a tree view. No objects are created here. A call to UMLDoc make any additions/deletion or updates to objects. This class will then wait for a signal before updating the tree view.

Author
  Paul Hensgen phens.nosp@m.gen@.nosp@m.techi.nosp@m.e.co.nosp@m.m Bugs and comments to umbre.nosp@m.llo-.nosp@m.devel.nosp@m.@kde.nosp@m..org or https://bugs.kde.org

## Constructor & Destructor Documentation

## ◆ UMLListView()

UMLListView::UMLListView | ( | QWidget * | parent = `0` | ) |
| explicit

Constructs the tree view.

Parameters

  parent | The parent to this.

## ◆ ~UMLListView()

UMLListView::~UMLListView | ( |  | ) |

Standard destructor.

## Member Function Documentation

## ◆ acceptDrag()

bool UMLListView::acceptDrag | ( | QDropEvent * | event | ) | const
| protected

Event handler for accepting drag request.

Parameters

  event | the drop event

Returns
  success state

## ◆ addAtContainer()

void UMLListView::addAtContainer | ( | UMLListViewItem * | item,
|  | UMLListViewItem * | parent
| ) |  |
| protected

Auxiliary method for moveObject(): Adds the model object at the proper new container (package if nested, UMLDoc if at global level), and updates the containment relationships in the model.

## ◆ addNewItem()

void UMLListView::addNewItem | ( | UMLListViewItem * | parentItem,
|  | UMLListViewItem::ListViewType | type
| ) |  |

Adds a new item to the tree of the given type under the given parent. Method will take care of signalling anyone needed on creation of new item. e.g. UMLDoc if a UMLObject is created.

## ◆ changeIconOf()

void UMLListView::changeIconOf | ( | UMLObject * | o,
|  | Icon_Utils::IconType | to
| ) |  |

Changes the icon for the given UMLObject to the given icon.

## ◆ childObjectAdded() [1/2]

void UMLListView::childObjectAdded | ( | UMLClassifierListItem * | child,
|  | UMLClassifier * | parent
| ) |  |
| protected

Adds a new operation, attribute or template item to a classifier, identical to childObjectAdded(obj) but with an explicit parent.

Parameters

  child | the child object
  parent | the parent object

## ◆ childObjectAdded [2/2]

void UMLListView::childObjectAdded | ( | UMLClassifierListItem * | obj | ) |
| slot

Adds a new operation, attribute or template item to a classifier.

Parameters

  obj | the child object

## ◆ childObjectRemoved

void UMLListView::childObjectRemoved | ( | UMLClassifierListItem * | obj | ) |
| slot

Deletes the list view item.

Parameters

  obj | the object to remove

## ◆ clean()

void UMLListView::clean | ( |  | ) |

Remove all items and subfolders of the main folders.

## ◆ closeDatatypesFolder()

void UMLListView::closeDatatypesFolder | ( |  | ) |

## ◆ collapseAll

void UMLListView::collapseAll | ( | UMLListViewItem * | item | ) |
| slot

Close all items in the list view.

## ◆ commitData()

void UMLListView::commitData | ( | QWidget * | editor | ) |
| protected

## ◆ connectNewObjectsSlots

void UMLListView::connectNewObjectsSlots | ( | UMLObject * | object | ) |
| slot

Connect some signals into slots in the list view for newly created UMLObjects.

## ◆ contextMenuEvent()

void UMLListView::contextMenuEvent | ( | QContextMenuEvent * | event | ) |
| protected

## ◆ createDiagramItem()

UMLListViewItem * UMLListView::createDiagramItem | ( | UMLView * | view | ) |

Create a listview item for an existing diagram.

Parameters

  view | The existing diagram.

## ◆ createItem()

bool UMLListView::createItem | ( | UMLListViewItem * | item | ) |

## ◆ deleteChildrenOf()

void UMLListView::deleteChildrenOf | ( | UMLListViewItem * | parent | ) |
| protected

Deletes all child-items of `parent`. Do it in reverse order, because of the index.

## ◆ deleteItem()

bool UMLListView::deleteItem | ( | UMLListViewItem * | temp | ) |
| protected

Delete a listview item.

Parameters

  temp | a non-null UMLListViewItem, for example: (UMLListViewItem*)currentItem()

Returns
  true if correctly deleted

## ◆ determineParentItem() [1/2]

UMLListViewItem * UMLListView::determineParentItem | ( | UMLListViewItem::ListViewType | lvt | ) | const

Determine the parent ListViewItem given a ListViewType. This parent is used for creating new UMLListViewItems.

Parameters

  lvt | The ListViewType for which to lookup the parent.

Returns
  Pointer to the parent UMLListViewItem chosen.

## ◆ determineParentItem() [2/2]

UMLListViewItem * UMLListView::determineParentItem | ( | UMLObject * | object | ) | const

Determine the parent ListViewItem given a UMLObject.

Parameters

  object | Pointer to the UMLObject for which to look up the parent.

Returns
  Pointer to the parent UMLListViewItem chosen. Returns NULL on error (no parent could be determined.)

## ◆ document()

UMLDoc * UMLListView::document | ( |  | ) | const

Returns the document pointer. Called by the UMLListViewItem class.

## ◆ dragEnterEvent()

void UMLListView::dragEnterEvent | ( | QDragEnterEvent * | event | ) |
| protected

Always allow starting a drag

## ◆ dragMoveEvent()

void UMLListView::dragMoveEvent | ( | QDragMoveEvent * | event | ) |
| protected

Check drag destination and update move/copy action

## ◆ dropEvent()

void UMLListView::dropEvent | ( | QDropEvent * | event | ) |
| protected

## ◆ event()

bool UMLListView::event | ( | QEvent * | e | ) |
| protected

Event handler for the tool tip event. Works only for operations to show the signature.

## ◆ expandAll

void UMLListView::expandAll | ( | UMLListViewItem * | item | ) |
| slot

Open all items in the list view.

## ◆ findFolderForDiagram()

UMLListViewItem * UMLListView::findFolderForDiagram | ( | Uml::DiagramType::Enum | dt | ) | const

Find the parent folder for a diagram. If the currently selected item in the list view is a folder then that folder is returned as the parent.

Parameters

  dt | The Diagram_Type of the diagram. The type will only be used if there is no currently selected item, or if the current item is not a folder. In that case the root folder which is suitable for the Diagram_Type is returned.

Returns
  Pointer to the parent UMLListViewItem for the diagram.

## ◆ findItem()

UMLListViewItem * UMLListView::findItem | ( | Uml::ID::Type | id | ) |

Searches through the tree for the item with the given ID.

Parameters

  id | The ID to search for.

Returns
  The item with the given ID or 0 if not found.

## ◆ findUMLObject()

UMLListViewItem * UMLListView::findUMLObject | ( | const UMLObject * | p | ) | const

Find a UMLObject in the listview.

Parameters

  p | Pointer to the object to find in the list view.

Returns
  Pointer to the UMLObject found or NULL if not found.

## ◆ findUMLObjectInFolder()

UMLListViewItem * UMLListView::findUMLObjectInFolder | ( | UMLListViewItem * | folder,
|  | UMLObject * | obj
| ) |  |
| protected

This method looks for an object in a folder an its subfolders recursively.

Parameters

  folder | The folder entry of the list view.
  obj | The object to be found in the folder.

Returns
  The object if found else a NULL pointer.

## ◆ findView()

UMLListViewItem * UMLListView::findView | ( | UMLView * | v | ) |

Searches through the tree for the item which represents the diagram given.

Parameters

  v | the diagram to search for

Returns
  the item which represents the diagram

## ◆ focusOutEvent()

void UMLListView::focusOutEvent | ( | QFocusEvent * | fe | ) |
| protected

Event handler for lost focus.

Parameters

  fe | the focus event

## ◆ getDragData()

UMLDragData * UMLListView::getDragData | ( |  | ) |
| protected

## ◆ init()

void UMLListView::init | ( |  | ) |

Carries out initalisation of attributes in class. This method is called more than once during an instance's lifetime (by UMLDoc)! So we must not allocate any memory before freeing the previously allocated one or do connect()s.

## ◆ isExpandable()

bool UMLListView::isExpandable | ( | UMLListViewItem::ListViewType | lvt | ) |
| staticprotected

Return true if the given list view type can be expanded/collapsed.

## ◆ isUnique()

bool UMLListView::isUnique | ( | UMLListViewItem * | item,
|  | const QString & | name
| ) |  | const

Returns if the given name is unique for the given items type.

## ◆ keyPressEvent()

void UMLListView::keyPressEvent | ( | QKeyEvent * | ke | ) |
| protected

Handler for key press events.

Parameters

  ke | the key event

## ◆ loadChildrenFromXMI()

bool UMLListView::loadChildrenFromXMI | ( | UMLListViewItem * | parent,
|  | QDomElement & | element
| ) |  |

## ◆ loadFromXMI()

bool UMLListView::loadFromXMI | ( | QDomElement & | element | ) |

## ◆ mayHaveChildItems()

bool UMLListView::mayHaveChildItems | ( | UMLObject::ObjectType | type | ) |
| static

Return true if the given ObjectType permits child items. A "child item" is anything that qualifies as a UMLClassifierListItem, e.g. operations and attributes of classifiers.

## ◆ mouseDoubleClickEvent()

void UMLListView::mouseDoubleClickEvent | ( | QMouseEvent * | me | ) |
| protected

Event handler for mouse double click.

## ◆ mouseMoveEvent()

void UMLListView::mouseMoveEvent | ( | QMouseEvent * | me | ) |
| protected

Handler for mouse move events.

Parameters

  me | the mouse event

## ◆ mousePressEvent()

void UMLListView::mousePressEvent | ( | QMouseEvent * | me | ) |
| protected

Handler for mouse press events.

Parameters

  me | the mouse event

## ◆ mouseReleaseEvent()

void UMLListView::mouseReleaseEvent | ( | QMouseEvent * | me | ) |
| protected

Handler for mouse release event.

Parameters

  me | the mouse event

## ◆ moveObject()

UMLListViewItem * UMLListView::moveObject | ( | Uml::ID::Type | srcId,
|  | UMLListViewItem::ListViewType | srcType,
|  | UMLListViewItem * | newParent
| ) |  |

Moves an object given its unique ID and listview type to an other listview parent item. Also takes care of the corresponding move in the model.

## ◆ recursiveSearchForView()

UMLListViewItem * UMLListView::recursiveSearchForView | ( | UMLListViewItem * | listViewItem,
|  | UMLListViewItem::ListViewType | type,
|  | Uml::ID::Type | id
| ) |  |
| private

Searches the tree for a diagram (view). Warning: these method may return in some cases the wrong diagram Used by findView().

## ◆ rootView()

UMLListViewItem * UMLListView::rootView | ( | UMLListViewItem::ListViewType | type | ) |

Returns the corresponding view if the listview type is one of the root views, Root/Logical/UseCase/Component/Deployment/EntityRelation View.

## ◆ rootViewType()

UMLListViewItem::ListViewType UMLListView::rootViewType | ( | UMLListViewItem * | item | ) |

Determines the root listview type of the given UMLListViewItem. Starts at the given item, compares it against each of the predefined root views (Root, Logical, UseCase, Component, Deployment, EntityRelationship.) Returns the ListViewType of the matching root view; if no match then continues the search using the item's parent, then grandparent, and so forth. Returns UMLListViewItem::lvt_Unknown if no match at all is found.

## ◆ saveToXMI()

void UMLListView::saveToXMI | ( | QXmlStreamWriter & | writer | ) |

## ◆ selectedItems()

UMLListViewItemList UMLListView::selectedItems | ( |  | ) | const

Get selected items.

Returns
  the list of selected items

## ◆ selectedItemsCount()

int UMLListView::selectedItemsCount | ( |  | ) | const

Return the amount of items selected.

## ◆ selectedItemsRoot()

UMLListViewItemList UMLListView::selectedItemsRoot | ( |  | ) | const

Get selected items, but only root elements selected (without children).

Returns
  the list of selected root items

## ◆ setBackgroundColor()

void UMLListView::setBackgroundColor | ( | const QColor & | color | ) |
| private

Set the background color.

Parameters

  color | the new background color

## ◆ setDocument()

void UMLListView::setDocument | ( | UMLDoc * | doc | ) |

Sets the document this is associated with. This is important as this is required as to set up the callbacks.

Parameters

  doc | The document to associate with this class.

## ◆ setStartedCopy()

void UMLListView::setStartedCopy | ( | bool | startedCopy | ) |

Set the variable m_bStartedCopy. NB: While m_bStartedCut is reset as soon as the Cut operation is done, the variable m_bStartedCopy is reset much later - upon pasting.

## ◆ setStartedCut()

void UMLListView::setStartedCut | ( | bool | startedCut | ) |

Set the variable m_bStartedCut to indicate that selection should be deleted in slotCutSuccessful().

## ◆ setTitle()

void UMLListView::setTitle | ( | int | column,
|  | const QString & | text
| ) |  |

Sets the title.

Parameters

  column | column in which to write
  text | the text to write

## ◆ setView()

void UMLListView::setView | ( | UMLView * | view | ) |

Set the current view to the given view.

Parameters

  view | The current view.

## ◆ slotCollapsed

void UMLListView::slotCollapsed | ( | QTreeWidgetItem * | item | ) |
| protectedslot

Calls updateFolder() on the item to update the icon to closed.

## ◆ slotCutSuccessful

void UMLListView::slotCutSuccessful | ( |  | ) |
| slot

Connects to the signal that UMLApp emits when a cut operation is successful.

## ◆ slotDeleteSelectedItems

void UMLListView::slotDeleteSelectedItems | ( |  | ) |
| slot

Delete every selected item

## ◆ slotDiagramCreated

void UMLListView::slotDiagramCreated | ( | Uml::ID::Type | id | ) |
| slot

Creates a new item to represent a new diagram.

Parameters

  id | the id of the new diagram

## ◆ slotDiagramRemoved

void UMLListView::slotDiagramRemoved | ( | Uml::ID::Type | id | ) |
| slot

Removes the item representing a diagram.

Parameters

  id | the id of the diagram

## ◆ slotDiagramRenamed

void UMLListView::slotDiagramRenamed | ( | Uml::ID::Type | id | ) |
| slot

Renames a diagram in the list view

Parameters

  id | the id of the renamed diagram

## ◆ slotDropped

void UMLListView::slotDropped | ( | QDropEvent * | de,
|  | UMLListViewItem * | target
| ) |  |
| slot

Something has been dragged and dropped onto the list view.

## ◆ slotExpanded

void UMLListView::slotExpanded | ( | QTreeWidgetItem * | item | ) |
| protectedslot

Calls updateFolder() on the item to update the icon to open.

## ◆ slotItemSelectionChanged

void UMLListView::slotItemSelectionChanged | ( |  | ) |
| protectedslot

Handler for item selection changed signals.

## ◆ slotMenuSelection

void UMLListView::slotMenuSelection | ( | QAction * | action,
|  | const QPoint & | position = `QPoint()`
| ) |  |
| slot

Called when a right mouse button menu has an item selected.

Parameters

  action | the selected action
  position | the position of the menu on the diagram (only used for multi selection "Show")

## ◆ slotObjectChanged

void UMLListView::slotObjectChanged | ( |  | ) |
| slot

Calls updateObject() on the item representing the sending object no parameters, uses sender() to work out which object called the slot.

## ◆ slotObjectCreated

void UMLListView::slotObjectCreated | ( | UMLObject * | object | ) |
| slot

Creates a new list view item and connects the appropriate signals/slots.

Parameters

  object | the newly created object

## ◆ slotObjectRemoved

void UMLListView::slotObjectRemoved | ( | UMLObject * | object | ) |
| slot

Disconnects signals and removes the list view item.

Parameters

  object | the object about to be removed

## ◆ startedCopy()

bool UMLListView::startedCopy | ( |  | ) | const

Return the variable m_bStartedCopy.

## ◆ theComponentView()

UMLListViewItem * UMLListView::theComponentView | ( |  | ) |
| inline

## ◆ theDatatypeFolder()

UMLListViewItem * UMLListView::theDatatypeFolder | ( |  | ) |
| inline

## ◆ theDeploymentView()

UMLListViewItem * UMLListView::theDeploymentView | ( |  | ) |
| inline

## ◆ theLogicalView()

UMLListViewItem * UMLListView::theLogicalView | ( |  | ) |
| inline

## ◆ theRootView()

UMLListViewItem * UMLListView::theRootView | ( |  | ) |
| inline

## ◆ theUseCaseView()

UMLListViewItem * UMLListView::theUseCaseView | ( |  | ) |
| inline

## Friends And Related Function Documentation

## ◆ operator<<

QDebug operator<< | ( | QDebug | out,
|  | const UMLListView & | view
| ) |  |
| friend

Overloading operator for debugging output.

## Member Data Documentation

## ◆ m_bCreatingChildObject

bool UMLListView::m_bCreatingChildObject
| private

when creating an attribute or an operation to stop it adding a second listViewItem

## ◆ m_bStartedCopy

bool UMLListView::m_bStartedCopy
| private

## ◆ m_bStartedCut

bool UMLListView::m_bStartedCut
| private

## ◆ m_datatypeFolder

UMLListViewItem* UMLListView::m_datatypeFolder
| private

## ◆ m_doc

UMLDoc* UMLListView::m_doc
| private

## ◆ m_dragCopyData

QMimeData* UMLListView::m_dragCopyData
| private

## ◆ m_dragStartPosition

QPoint UMLListView::m_dragStartPosition
| private

## ◆ m_findItems

QList<QTreeWidgetItem*> UMLListView::m_findItems
| private

## ◆ m_lv

UMLListViewItem* UMLListView::m_lv[Uml::ModelType::N_MODELTYPES]
| private

predefined list view roots

## ◆ m_rv

UMLListViewItem* UMLListView::m_rv
| private

root view (home)

## ◆ m_settingsFolder

UMLListViewItem* UMLListView::m_settingsFolder
| private

settings root

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

- umbrello/umllistview.h
- umbrello/umllistview.cpp