Bug 321882 - Filenames can get truncated too early
Summary: Filenames can get truncated too early
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: view-engine: icons mode (show other bugs)
Version: 4.10.90
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords: reproducible
Depends on:
Blocks:
 
Reported: 2013-07-03 01:58 UTC by Christoph Feck
Modified: 2013-08-25 14:28 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.11.1


Attachments
Screen shot showing the issue (114.46 KB, image/png)
2013-07-03 01:58 UTC, Christoph Feck
Details
Screen shot showing the issue (91.82 KB, image/png)
2013-07-03 02:07 UTC, Christoph Feck
Details
Proposed patch (1.17 KB, patch)
2013-07-03 09:33 UTC, Frank Reininghaus
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Feck 2013-07-03 01:58:50 UTC
Created attachment 80907 [details]
Screen shot showing the issue

Some filenames get truncated too early, leaving either only a single letter with three dots, no letter but three dots, or no name at all (marked "ln-funktionen.txt" at bottom-left).

From looking at the truncated names, the truncation algorithm has problems with names of the form "xx-xxxxxxxxxxxxxxxx.txt". If the part before the hyphen is longer, such as "xxxxxxxx-xxxxxxxx.txt", it displays more of the filename.

(attached screen shot is from today's master, but the bug is not a recent regression)
Comment 1 Christoph Feck 2013-07-03 02:07:15 UTC
Created attachment 80908 [details]
Screen shot showing the issue

This issue is also visible with larger icons and much more room for the text, as shown here. The marked icon has the filename "GK-Blutalkoholkonzentration.pdf", but not a single letter is visible under the icon.
Comment 2 Frank Reininghaus 2013-07-03 09:32:35 UTC
Thanks for reporting, I can confirm this issue (when limiting the number of lines and setting the width to "Small"). I looked for the right place in the code and found some things which seem strange. I'll attach a patch in a minute.
Comment 3 Frank Reininghaus 2013-07-03 09:33:48 UTC
Created attachment 80916 [details]
Proposed patch

I'd appreciate it if you could test this patch. I'm not 100% sure, but it might also fix bug 304558.
Comment 4 Christoph Feck 2013-07-03 11:41:33 UTC
Thanks, the patch works so far, it looks like it can display as many characters as possible.
The hover/selection rectangle needs the same fix, though.
Comment 5 Emmanuel Pescosta 2013-07-24 17:39:24 UTC
The patch works for me too and it also fixes bug 304558.
Comment 6 Frank Reininghaus 2013-08-25 14:28:31 UTC
Git commit 82d42b8dcc9fea455d1e1cd6c060c4a2c178358e by Frank Reininghaus.
Committed on 25/08/2013 at 14:24.
Pushed by freininghaus into branch 'KDE/4.11'.

Fix filename trucation issues in Icons View with maximum number of lines

When the name of a file is too long to be shown inside the maximum
number of lines, the last line is elided. However, there were several
problems before this commit:

(a) "lastTextLine", which contains the text to be elided, was not
    assigned the complete remaining text, but only the part that would
    be put into the last line if there were more lines following. This
    may be less than what would fit into the line because we try to not
    break the text at random points.

(b) QFontMetrics::elidedText() was not given the width that is available
    for the last line (that would be maxWidth), but only the width that
    would be occupied by the text if there were more lines following
    (line.naturalTextWidth()).

(c) The variable "nameWidth", which is required to calculate the QRectF
    that is reserved for the name, was not updated correctly.

The result is that the text was sometimes trucated too early (especially
if there would be a line break early in the text if we had more lines
available), that there may be insufficient space to show the "...", and
that the hover/selection rectangle might be too narrow.
Related: bug 304558
FIXED-IN: 4.11.1
REVIEW: 112265

M  +5    -2    dolphin/src/kitemviews/kstandarditemlistwidget.cpp

http://commits.kde.org/kde-baseapps/82d42b8dcc9fea455d1e1cd6c060c4a2c178358e