Bug 315569

Summary: Dolphin not group folders when names not in English
Product: dolphin Reporter: ademaro
Component: generalAssignee: Dolphin Bug Assignee <dolphin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: emmanuelpescosta099, oldium.pro
Priority: NOR Keywords: reproducible
Version: 16.12.2   
Target Milestone: ---   
Platform: Other   
OS: Linux   
URL: http://i.imgur.com/03N6gG3.png
Latest Commit: Version Fixed In: 4.10.2
Attachments: archive with non-English file names
Suggested fix

Description ademaro 2013-02-21 11:12:53 UTC
Dolphin not group folders when names not in English
http://i.imgur.com/03N6gG3.png

Reproducible: Always

Steps to Reproduce:
1. open dolphin
2. sort by name
3. apply grouping for filenames
Actual Results:  
All non eng filenames in one group "all others"

Expected Results:  
Group files by first letter

Dolphin 2.1
KDE 4.9.4
LinuxMint 14 (Nadia)

Linux adwork 3.5.0-23-generic #35-Ubuntu SMP Thu Jan 24 13:15:40 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Comment 1 Frank Reininghaus 2013-02-28 09:50:05 UTC
Thanks for the bug report! I do have some ideas how this issue could be fixed, but it would be helpful to have some test data. Could you attach an archive that contains some non-English file names? Thanks for your help.
Comment 2 ademaro 2013-03-01 12:00:05 UTC
Created attachment 77662 [details]
archive with non-English file names

filenames for testing
Comment 3 Frank Reininghaus 2013-03-07 10:19:30 UTC
Thanks for the file names, I can reproduce the problem and will have a look.
Comment 4 Emmanuel Pescosta 2013-03-07 14:17:27 UTC
(In reply to comment #3)
> Thanks for the file names, I can reproduce the problem and will have a look.

Hello Frank,
the problem is located in KFileItemModel::nameRoleGroups():

if (newFirstChar >= QLatin1Char('A') && newFirstChar <= QLatin1Char('Z')) { // Apply group 'A' - 'Z'

Is there a better way to test the first char? Maybe somewhere in kdelibs? 
That would be awesome :)
Comment 5 Frank Reininghaus 2013-03-07 14:35:34 UTC
Created attachment 77836 [details]
Suggested fix

@Emmanuel: I had been thinking about this issue during the last days, and I think I found a solution.

Feel free to test and report any problems with the patch here. I think I'll try to ask more international users to test and see if this works and does not break anything.
Comment 6 Emmanuel Pescosta 2013-03-07 15:40:09 UTC
(In reply to comment #5)
Works great with the provided test folders.

One problem I have found is, that it doesn't use german umlaute (Ä, Ö and Ü) for the grouping header title, instead Dolphin uses A, O and U.
Comment 7 Frank Reininghaus 2013-03-08 14:59:28 UTC
(In reply to comment #6)
> One problem I have found is, that it doesn't use german umlaute (Ä, Ö and Ü)
> for the grouping header title, instead Dolphin uses A, O and U.

This is actually intentional, and it even works like that in the current code. That is, with one small exception: If there are two files "A" and "Ä", they will be put into a common group "A", but if there is only "Ä", the group is called "Others". There is a TODO comment in the current code about this issue.
Comment 8 ademaro 2013-03-15 13:17:49 UTC
How to make a patch test? Does it make sense to connect the repo ppa: kubuntu-ppa/batskports or need to compile?
Comment 9 Frank Reininghaus 2013-03-15 13:29:57 UTC
(In reply to comment #8)
> How to make a patch test? Does it make sense to connect the repo ppa:
> kubuntu-ppa/batskports

No, you have to build Dolphin from source to test it, sorry.
Comment 10 Oldřich Jedlička 2013-03-15 13:57:24 UTC
Regarding the TODO: You should be able to "decompose" the character, which should split it into a character and diacritical marks. Unicode standard defines the decomposition and the Qt library implements it in the QChar.decomposition() method. You first want to make the letter upper case and then decomposed.

The decomposition is not always a single character plus diacritical marks. The German small letter sharp "S" (U+00DF) when made upper case is "SS" (two letters S), so you would need to extract all letters from the "decomposed" string in order to make a group without diacritical marks.
Comment 11 Oldřich Jedlička 2013-03-15 14:12:04 UTC
For more details there is a text in Unicode Standard: http://unicode.org/reports/tr15/
Comment 12 Frank Reininghaus 2013-03-15 14:20:00 UTC
(In reply to comment #10)
Thanks for the detailed explanations. Note that the proposed patch only aims to fix some of the existing problems, it's certainly not perfect.

I don't have much detailed Unicode knowledge, which is one of the reasons why I'm afraid that the approach you propose would require quite a lot of work. Considering that "Group by Name" for non-ASCII file names has been broken for quite some time before that has been reported, further work on this does currently not have a high priority for me, to be honest. However, if anyone else is willing to make further improvements, that would definitely be welcome.

At the moment, I'm mostly trying to find out if the proposed patch causes any regressions.
Comment 13 ademaro 2013-03-18 16:31:22 UTC
Sorry for the dumb question, I never compiled KDE components... It will help me to apply the patch? 
```
a="$HOME/kde-git";  mkdir "$a" ; cd "$a" ;sudo apt-get install git-core  build-essential libkactivities-dev  ;  sudo apt-get build-dep dolphin ; git clone git://anongit.kde.org/kde-baseapps ; cd kde-baseapps ; mkdir build ; cd build; cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` .. ; make -j3 ; cd dolphin/src/ ; ./dolphin
```
Comment 14 Frank Reininghaus 2013-03-21 13:54:20 UTC
(In reply to comment #13)
> Sorry for the dumb question, I never compiled KDE components... It will help
> me to apply the patch? 
> ```
> a="$HOME/kde-git";  mkdir "$a" ; cd "$a" ;sudo apt-get install git-core 
> build-essential libkactivities-dev  ;  sudo apt-get build-dep dolphin ; git
> clone git://anongit.kde.org/kde-baseapps ; cd kde-baseapps ; mkdir build ;
> cd build; cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` .. ; make -j3
> ; cd dolphin/src/ ; ./dolphin

Sorry for the late response. These steps look reasonable for building the latest Dolphin from master. I see that you don't run 'make install', but you can just run Dolphin from the build folder.

If you want to apply a patch, cd to the source folder kde-baseapps/, then enter

patch -p1 < /path/to/patch_file.diff

and repeat the "cd build; make -j3" steps. Note that the patch is for the KDE/4.10 branch, but it should also apply to master. If that is not the case, do "git reset --hard HEAD && git checkout KDE/4.10" before applying the patch. Thanks for your help!
Comment 15 Frank Reininghaus 2013-03-26 00:33:15 UTC
Git commit 02f4a69f58fef89ec6df4c6775be1e8d4b9d40b2 by Frank Reininghaus.
Committed on 26/03/2013 at 01:21.
Pushed by freininghaus into branch 'KDE/4.10'.

Improve grouping by name for non-ASCII file names

This commit prevents that all non-ASCII letters which are not umlauts
are grouped in a single group "Others", and that the joint group of
an ASCII letter and the associated umlaut in some locales is called
"Others" if there is only the umlaut in the group.
REVIEW: 109457
FIXED-IN: 4.10.2

M  +28   -21   dolphin/src/kitemviews/kfileitemmodel.cpp

http://commits.kde.org/kde-baseapps/02f4a69f58fef89ec6df4c6775be1e8d4b9d40b2