Bug 447661 - Diagram objects moved to inside enclosing package become invisible
Summary: Diagram objects moved to inside enclosing package become invisible
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: Git
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
: 209757 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-12-29 20:28 UTC by Oliver Kellogg
Modified: 2022-02-15 16:06 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 2.33.80 (KDE releases 22.03.80)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Kellogg 2021-12-29 20:28:17 UTC
SUMMARY
Nested classifiers/nested packages which are moved to inside their enclosing package become invisible

STEPS TO REPRODUCE
1. In the tree view, right click on Logical View, select "Package..." and create a new_package
2. In the tree view, right click on new_package, select "Package..." and create a nested new_package.
   Rename it to "nested_pkg" for clarity.
3. Drag new_package to class diagram and resize it to be large enough to contain nested items.
4. Drag nested_pkg to inside the new_package display area in the class diagram.
5. Click on new_package in the diagram.

OBSERVED RESULT
The nested_pkg vanishes, i.e. it is obscured by its containing package.

EXPECTED RESULT
Objects nested in the diagram display area of their containing package shall be visible at all times.

SOFTWARE/OS VERSIONS
Umbrello git master of 2021-12-27
Comment 1 Oliver Kellogg 2021-12-29 21:51:37 UTC
Git commit 8f410485cfcc75a4fe452708d8b1aa009ae35f50 by Oliver Kellogg.
Committed on 29/12/2021 at 21:51.
Pushed by okellogg into branch 'master'.

Fix "Diagram objects moved to inside enclosing package become invisible"

umbrello/umlwidgets/widget_utils.{h,cpp}
- New function ensureNestedVisible prevents nested widget(s) located
  inside the area of a larger widget from disappearing.
  This is achieved by increasing the Z value on the contained widgets.

umbrello/toolbarstate.cpp
- In function mouseRelease add debug messages in the branches of the
  if-chain to ease tracing of events.
- In function mouseReleaseEmpty, if m_currentWidget is non null then
  call Widget_Utils::ensureNestedVisible with arguments m_currentWidget
  and m_pUMLScene->widgetList().

umbrello/umlwidgets/toolbarstateonewidget.cpp
- Split if-statement testing m_pMouseEvent->button() and currentWidget()
  into two separate if-statements.
  Return immediately if m_pMouseEvent->button() is not Qt::LeftButton.
- Add local UMLWidget *currWgt as shorthand for currentWidget().
- Call Widget_Utils::ensureNestedVisible with arguments currWgt and
  m_pUMLScene->widgetList() before executing the second part of the
  split if-statement (see above).

umbrello/umlwidgets/umlwidget.{h,cpp}
- New function isLocatedIn(const UMLWidget *other) returns true if
  `this' is located in the bounding rectangle of `other'.

umbrello/umlwidgets/umlwidget.cpp
- In function mouseReleaseEvent :
  - In if-statement testing (!m_moved && !m_resized), if neither
      (!m_shiftPressed && (m_scene->selectedCount() > 1))
    nor
      !isSelected()
    evaluates to true then call
    Widget_Utils::ensureNestedVisible(this, umlScene()->widgetList()).
  - In else-part of the if-statement, if m_moved is true then
    - local UMLWidgetList selectedWidgets acts as shorthand for
      umlScene()->selectedWidgets();
    - in foreach-loop over selectedWidgets additionally call
      Widget_Utils::ensureNestedVisible with arguments `widget' and
      umlScene()->widgetList().
- In function setSelected add call to
  Widget_Utils::ensureNestedVisible(this, umlScene()->widgetList()).

M  +9    -1    umbrello/toolbarstate.cpp
M  +17   -8    umbrello/umlwidgets/toolbarstateonewidget.cpp
M  +50   -2    umbrello/umlwidgets/umlwidget.cpp
M  +2    -0    umbrello/umlwidgets/umlwidget.h
M  +21   -0    umbrello/umlwidgets/widget_utils.cpp
M  +3    -1    umbrello/umlwidgets/widget_utils.h

https://invent.kde.org/sdk/umbrello/commit/8f410485cfcc75a4fe452708d8b1aa009ae35f50
Comment 2 Oliver Kellogg 2021-12-30 13:07:48 UTC
Git commit a038b342b30a43faae177cd140bddccbd1daf674 by Oliver Kellogg.
Committed on 30/12/2021 at 13:07.
Pushed by okellogg into branch 'master'.

Completion of fix for "Diagram objects moved to inside enclosing package become invisible"

umbrello/umlscene.cpp
- In function createAutoAssociations code handling "object is capable of
  containing nested objects" use new function UMLWidget::isLocatedIn().
  Reason: WidgetBase function rect() always returns x() and y() with
  value 0, which is not right for this context.

M  +2    -2    umbrello/umlscene.cpp

https://invent.kde.org/sdk/umbrello/commit/a038b342b30a43faae177cd140bddccbd1daf674
Comment 3 Oliver Kellogg 2022-02-15 16:06:58 UTC
*** Bug 209757 has been marked as a duplicate of this bug. ***