Bug 337104 - Dolphin show 4 lines of a file even if the maximum length is 3 lines
Summary: Dolphin show 4 lines of a file even if the maximum length is 3 lines
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: view-engine: icons mode (show other bugs)
Version: 4.13.2
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
: 337732 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-07-05 08:42 UTC by Eugenio
Modified: 2014-09-01 09:49 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.14.0
Sentry Crash Report:


Attachments
screenshot (69.99 KB, image/png)
2014-07-05 08:43 UTC, Eugenio
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eugenio 2014-07-05 08:42:55 UTC
The maximum lines settings is not respected for all files.
Some with dot in their names are shown with one more line (3 lines in setting -> 4 lines shown).
Dolphin however considers that this file has a 3 lines long filename (look at the selection in the screenshot).

Reproducible: Always

Steps to Reproduce:
1. In setting put 3 for maximum lines
2. Create a file with this name "Calendario.Accademico.Unbla.2013.1.pdf"
Actual Results:  
Filename is 4 lines long.

Expected Results:  
Filename should be 3 lines long.
Comment 1 Eugenio 2014-07-05 08:43:59 UTC
Created attachment 87570 [details]
screenshot
Comment 2 Emmanuel Pescosta 2014-07-05 12:54:20 UTC
Thanks for the bug report, I can reproduce it!
Comment 3 Emmanuel Pescosta 2014-07-06 13:52:09 UTC
The problem is in KStandardItemListWidget::updateIconsLayoutTextCache().

m_customizedFontMetrics.elidedText(lastTextLine, Qt::ElideRight, maxWidth) returns a non-elided text (which is wrong in thi case) and the resulting nameWidth is bigger than maxWidth. When I replace maxWidth by "maxWidth - 1" the eliding is correct and it works fine. 

My first thought was, that the problems comes from qreal to int conversion (which should be fixed by qFloor) but this isn't the case. Maybe the customized font metric is wrong?!
Comment 4 Frank Reininghaus 2014-07-06 21:58:17 UTC
Thanks for the report and for the investigation! This issue looks strange indeed. I could not reproduce it so far - maybe it depends on the font settings.
Comment 5 Emmanuel Pescosta 2014-07-07 18:31:01 UTC
(In reply to comment #4)
> I could not reproduce it so far - maybe it depends on the font settings.

My settings:
Font: System Font (Sans Serif with size 9.0 and 96 DPI)
Width: Medium
Max. Lines: 3
Icon Size: 80px
Comment 6 Eugenio 2014-07-07 22:10:15 UTC
My settings:
Font: Dejavu Sans size 9.0 and 96 DPI
Hinting: Medium with RGB subpixel
Width: Medium
Max. Lines: 3
Icon Size: 32px (but I can reproduce with any size)
I played some time with font settings this evening..
This particular file is shown correctly with Hinting Full but some other files are not however shown correctly "LongName.LongLongName.2009.irp.001.mkv" for example is not shown properly and does not depend on hinting here.
Comment 7 Christoph Feck 2014-07-17 18:27:53 UTC
Qt has different code places where it measures the length of a rendered text string, and if I remember correctly, they do not always lead to the same result, because of differences in handling hinted vs. real metrics, sub-pixel precision, wrapping, or kerning. This can lead to bugs such as 328497, where one function is used to determine the space needed, while the rendering function suddenly believes otherwise.
Comment 8 Emmanuel Pescosta 2014-07-19 10:26:56 UTC
(In reply to Christoph Feck from comment #7)
> Qt has different code places where it measures the length of a rendered text
> string, and if I remember correctly, they do not always lead to the same
> result, because of differences in handling hinted vs. real metrics,
> sub-pixel precision, wrapping, or kerning. This can lead to bugs such as
> 328497, where one function is used to determine the space needed, while the
> rendering function suddenly believes otherwise.

Thanks for the info! 

@Frank
Should we decrease the width passed on to elideText (in a loop) as long as nameWidth is bigger than the allowed maxWidth? I see no better solution/workaround for this bug :(
Comment 9 Frank Reininghaus 2014-07-21 14:51:07 UTC
(In reply to Emmanuel Pescosta from comment #8)
> @Frank
> Should we decrease the width passed on to elideText (in a loop) as long as
> nameWidth is bigger than the allowed maxWidth? I see no better
> solution/workaround for this bug :(

I cannot see any other solution either :-(

If elidedText is the problem (I still cannot reproduce, it seems that the "Sans Serif" font on this system might be different from yours, and I don't have the Dejavu Snas one), then this might be the only solution indeed.
Comment 10 Emmanuel Pescosta 2014-07-23 19:13:12 UTC
*** Bug 337732 has been marked as a duplicate of this bug. ***
Comment 11 Emmanuel Pescosta 2014-08-04 17:44:22 UTC
Git commit a203c271161ce953354b9e0722492605a4d17415 by Emmanuel Pescosta.
Committed on 04/08/2014 at 17:43.
Pushed by emmanuelp into branch 'KDE/4.14'.

Fix wrong text eliding in some corner cases.
FIXED-IN: 4.14.0
REVIEW: 119546

M  +18   -8    dolphin/src/kitemviews/kstandarditemlistwidget.cpp

http://commits.kde.org/kde-baseapps/a203c271161ce953354b9e0722492605a4d17415
Comment 12 Eugenio 2014-09-01 09:37:31 UTC
This is not fixed for me with dolphin 4.14.0 :(
I have a series of videos that are shown with 4 lines.
To test:
file name "LongName.LongLongName.2009.irp.001.mkv"
Font Dejavu Sans, size 9.0
Hinting RGB medium
With name "Calendario.Accademico.Unbla.2013.1.pdf" the bug seems fixed here.
Comment 13 Emmanuel Pescosta 2014-09-01 09:49:48 UTC
(In reply to Eugenio from comment #12)
> This is not fixed for me with dolphin 4.14.0 :(
> I have a series of videos that are shown with 4 lines.
> To test:
> file name "LongName.LongLongName.2009.irp.001.mkv"
> Font Dejavu Sans, size 9.0
> Hinting RGB medium
> With name "Calendario.Accademico.Unbla.2013.1.pdf" the bug seems fixed here.

I can't reproduce it here :(
Tested with file name "LongName.LongLongName.2009.irp.001.mkv",  Dejavu Sans font, size 9.0, all different font styles and medium/full RGB hinting.