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
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.
Created attachment 130576 [details] Parameter list too long
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).
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.
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.
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.
A possibly relevant merge request was started @ https://invent.kde.org/sdk/umbrello/-/merge_requests/8
(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.
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
(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.
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
(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