Bug 424863 - Enable wrapping of long lines in use cases and parameter lists of operations
Summary: Enable wrapping of long lines in use cases and parameter lists of operations
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: Git
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-31 14:05 UTC by Robert Hairgrove
Modified: 2021-02-11 23:25 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.32.0 (KDE releases 20.08.0)


Attachments
Parameter list too long (130.39 KB, image/png)
2020-08-02 12:40 UTC, Robert Hairgrove
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Hairgrove 2020-07-31 14:05:27 UTC
SUMMARY
Long lines in objects do not (always?) wrap.

STEPS TO REPRODUCE
1. Create a use case diagram;
2. Add a use case with a very long name;
3. Observe that it stays formatted in one single line instead of wrapping in multiple lines depending on the width of the use case.

OBSERVED RESULT
See above.

EXPECTED (DESIRED) RESULT
Multiple lines.

SOFTWARE/OS VERSIONS
Linux Ubuntu 18.04.4
Qt Version: 5.x

ADDITIONAL INFORMATION
Comment 1 Robert Hairgrove 2020-08-01 06:58:11 UTC
It would also be nice to be able to insert hard line breaks directly into the text of a use case, e.g. to enable writing lists or other things needing structure.
Comment 2 Robert Hairgrove 2020-08-02 12:40:32 UTC
Created attachment 130576 [details]
Parameter list too long
Comment 3 Robert Hairgrove 2020-08-02 12:41:15 UTC
After looking at the source code some more, I think it might be fairly easy to support wrapping, at least in use case widgets. The call to the overloaded drawText() function can take a rectangle and a set of flags, one of which can be Qt::TextWordWrap.

However, getting the rectangle might be the tricky part because it appears that the widget is resized by some code before paint() is called. Ideally, the rectangle used by the paint() function should be whatever the user has done with the mouse, possibly after fetching a new bounding rectangle.

Sadly, newline characters (hard breaks) are not supported natively by QPainter, and I have no idea if this can be done.

Would it be enough to uncheck the "Auto-Resize" option and trust the height() and width() values returned by the base UMLWidget class? Then one could fetch a bounding rectangle which would be used to draw the text (see example in the Qt help docs for QPainter).

It is also very necessary for function parameter lists (see attachment).
Comment 4 Robert Hairgrove 2020-08-03 08:50:28 UTC
OK, I have now implemented wrapping for use cases. But I want to work on wrapping parameter lists in classes before I make a patch, which I consider to be a much more serious defect.

It was very easy, involving changes to two functions:
void UseCaseWidget::paint() and UseCaseWidget::minimumSize().

In minimumSize, I had to change just one line:
int width = (textWidth / 3) > UC_WIDTH ? textWidth / 3 : UC_WIDTH;

This sets the minimum width to 1/3 of the text width which is a bit arbitrary, but allows for wrapping at least three lines.

In the paint() function, the painter->drawText will also take hard breaks into consideration if the Qt::TextWordWrap flag is set. So I merely added any stereotype to the beginning of the other text and let drawText() take care of it.

Also, I used QFontMetricsF instead of the version with int. It seems to give better results at times due to less rounding errors.
Comment 5 Robert Hairgrove 2020-08-03 19:38:15 UTC
I think I would like to submit the changes to the use case widget already; getting it right for wrapping parameter lists will take a little more time.

Can I simply post the file usecasewidget.cpp here as an attachment for your perusal? I never submitted any patches to KDE projects before, so I am not familiar with the right procedures.
Comment 6 Christoph Feck 2020-08-03 19:45:07 UTC
KDE uses GitLab for submit/merge requests, see https://community.kde.org/Infrastructure/GitLab#Submitting_a_merge_request

This allows developers to give feedback on specific code sections, and merge the patch when it is finalized.
Comment 7 Bug Janitor Service 2020-08-03 20:59:26 UTC
A possibly relevant merge request was started @ https://invent.kde.org/sdk/umbrello/-/merge_requests/8
Comment 8 Robert Hairgrove 2020-08-03 21:02:58 UTC
(In reply to Christoph Feck from comment #6)
> KDE uses GitLab for submit/merge requests, see
> https://community.kde.org/Infrastructure/GitLab#Submitting_a_merge_request
> 
> This allows developers to give feedback on specific code sections, and merge
> the patch when it is finalized.

Done!

Thanks for the link to the instructions.
Comment 9 Ralf Habacker 2020-08-05 11:45:27 UTC
Git commit 6cb3d49749c4e460cf34d777472cf00f5946ce43 by Ralf Habacker, on behalf of Robert Hairgrove.
Committed on 05/08/2020 at 11:45.
Pushed by habacker into branch 'release/20.08'.

New feature allowing word wrapping in use case texts when resizing and entering line breaks
FIXED-IN:2.32.01 (KDE releases 20.08.1)

M  +24   -12   umbrello/umlwidgets/usecasewidget.cpp

https://invent.kde.org/sdk/umbrello/commit/6cb3d49749c4e460cf34d777472cf00f5946ce43
Comment 10 Robert Hairgrove 2020-08-05 12:28:28 UTC
(In reply to Ralf Habacker from comment #9)
> Git commit 6cb3d49749c4e460cf34d777472cf00f5946ce43 by Ralf Habacker, on
> behalf of Robert Hairgrove.
> Committed on 05/08/2020 at 11:45.
> Pushed by habacker into branch 'release/20.08'.
> 
> New feature allowing word wrapping in use case texts when resizing and
> entering line breaks
> FIXED-IN:2.32.01 (KDE releases 20.08.1)
> 
> M  +24   -12   umbrello/umlwidgets/usecasewidget.cpp
> 
> https://invent.kde.org/sdk/umbrello/commit/
> 6cb3d49749c4e460cf34d777472cf00f5946ce43

Thank you very much for all your help, Ralf! I will now learn more about using git before attempting another merge request.
Comment 11 Christoph Feck 2020-08-05 13:24:20 UTC
Strictly speaking, new features would need to be committed to master branch, but I see this as a bug fix, because it doesn't require a new string to translate.

This will be part of the 20.08.0 release to be tagged tomorrow. For details on our schedule, please see https://community.kde.org/Schedules
Comment 12 Ralf Habacker 2020-08-06 05:07:32 UTC
(In reply to Christoph Feck from comment #11)

> This will be part of the 20.08.0 release to be tagged tomorrow. 

Then this has been added just in time - Thanks for you work