Bug 246260 - KDirLister - kdelibs/kio - should respect .hidden files, an at-least-de-facto standard that gnome respects
Summary: KDirLister - kdelibs/kio - should respect .hidden files, an at-least-de-facto...
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: general (show other bugs)
Version: 19.04.3
Platform: Neon Linux
: NOR wishlist
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
: 64740 245994 320925 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-07-30 13:13 UTC by Mark
Modified: 2021-01-10 18:03 UTC (History)
14 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
patch to add private methods to KDirLister (3.83 KB, patch)
2010-07-30 16:55 UTC, Mark
Details
improvement to patch to time the retrieval / consideration of .hidden file contents more correctly (4.25 KB, patch)
2010-07-30 17:19 UTC, Mark
Details
Updated patch (3.41 KB, patch)
2014-07-17 20:04 UTC, brunombn
Details
Updated patch 2 (2.05 KB, patch)
2014-07-18 21:26 UTC, brunombn
Details
Updated patch 3 (3.20 KB, patch)
2014-08-01 18:47 UTC, brunombn
Details
.hidden support for KDE4 (3.84 KB, patch)
2014-08-04 16:19 UTC, brunombn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark 2010-07-30 13:13:23 UTC
Version:           CVS (using Devel) 
OS:                Linux

files named in a .hidden file in the current directory should be hidden when dot files are hidden

Reproducible: Always

Steps to Reproduce:
view a directory from a component that connects KdirLister - such as dolphin - containing a .hidden file that contains the name of a specific file in that directory to hide

Actual Results:  
named file is visible

Expected Results:  
named file should be invisible unless hidden files - dot files - are generally visible

see bug #245994 in dolphin
comments #64740 - originally kde3
Comment 1 Mark 2010-07-30 16:55:42 UTC
Created attachment 49684 [details]
patch to add private methods to KDirLister

I'm ready to hear comments whether the methods should really be private;

My feeling is that it would be irregular for an app to need to override the inclusion of files listed in .hidden as 'in the group of' dot files, so that standard handling of dot files should include files listed in .hidden

it may need some more tuning to guarantee that the timing of it all is right

Best regards

Mark
Comment 2 Mark 2010-07-30 17:19:30 UTC
Created attachment 49685 [details]
improvement to patch to time the retrieval / consideration of .hidden file contents more correctly

now waits until the signals have been sent, to update the list then emit the signal that the filters have changed; works properly - could need advanced testing
Comment 3 Peter Penz 2010-07-30 17:47:18 UTC
*** Bug 245994 has been marked as a duplicate of this bug. ***
Comment 4 Frank Reininghaus 2010-08-08 10:50:48 UTC
Maybe David can comment on the patch.
Comment 5 David Faure 2010-08-11 17:36:10 UTC
It would be easier to comment on it on reviewboard, but here it goes:

The approach seems generally OK.
In details:
- the QStringList of hidden files should probably be a QSet for faster lookup, since this is called for every file... or maybe better: instead of a lookup, maybe this could actually modify the kfileitem directly (while parsing the .hidden file) and set it to hidden?
Another reason for changing it to do things that way, is that the current code
(iterating over dirData.listersCurrentlyListing and calling setHiddenList) breaks in the case of dirlisters that hold multiple directories (e.g. when enabling expandable folders in dolphin and viewing things as a tree).

Basically, add a KFileItem::setHidden() method, which does
  d->m_hidden = KFileItemPrivate::Hidden;

- QRegExp is horribly slow, please rewrite this without using a regexp (which doesn't really seem necessary anyway).

- QStringList thelist = QStringList::QStringList();
is two mentions too many, just write   QStringList thelist;

Please email me directly or use reviewboard.kde.org if I don't see your answer, I'm failing at monitoring all incoming bugzilla emails.
Comment 6 Martin Flöser 2010-11-10 19:11:59 UTC
SVN commit 1195269 by graesslin:

Fix Prevent Screen Locking electric border action.

Thanks to Ralf Hemmenstaedt for providing the patch.
BUG: 246260
FIXED-IN: 4.5.4



 M  +1 -1      options.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1195269
Comment 7 Martin Flöser 2010-11-10 19:15:00 UTC
sorry, typo in commit message
Comment 8 Philipp A. 2011-02-01 11:22:49 UTC
1. when do we get this?
2. how is this different from bug 64740?
3. why not support a per-user .hidden-file directly in the home directory, too?
4. does this support wildcards? (e.g. i have a directory only for LaTeX-documents, so i want to hide every *.aux, *.log, *~ and *.backup file in there)
Comment 9 Frank Reininghaus 2011-02-01 16:16:30 UTC
(In reply to comment #8)
> 1. when do we get this?

Mark, have you updated your patch and submitted it via reviewboard/email, as David suggested?

> 2. how is this different from bug 64740?

It's not. I'm just not sure which one should be marked as a duplicate - the present one contains a patch+discussion about it, the other one has lots of votes, so maybe one could wait until the issue is resolved and then close both together.
Comment 10 Philipp A. 2011-02-01 19:43:40 UTC
why aren’t the votes of dupes added to the remaining bug (and the comments merged)?
Comment 11 Frank Reininghaus 2011-02-01 20:23:15 UTC
(In reply to comment #10)
> why aren’t the votes of dupes added to the remaining bug (and the comments
> merged)?

I think that Bugzilla does not have that feature, but I agree that at least a transfer of the votes would be nice to have.
Comment 12 Frank Reininghaus 2013-06-11 06:31:35 UTC
*** Bug 320925 has been marked as a duplicate of this bug. ***
Comment 13 brunombn 2014-07-15 19:48:19 UTC
Is this feature ever going to be added to KDE? It's 2014 already!

The standard way of hiding a file (prepending a dot) requires renaming it, so it's not always possible. That's why this feature would be a very nice addition!
And, to please everyone, you could add a configuration option to enable/disable this feature.
Comment 14 Frank Reininghaus 2014-07-15 21:21:11 UTC
(In reply to Bruno Nova from comment #13)
> Is this feature ever going to be added to KDE? It's 2014 already!

Well, David said in comment 5 that the approach of Mark's patch in comment 2 is generally OK. Since Mark did not respond to any of David's suggestions in 4 years or submitted a patch to Review Board AFAIK, I think that anyone who has some time and motivation to look into the issue should feel free to take the patch and finish the work.

> And, to please everyone, you could add a configuration option to
> enable/disable this feature.

I think we should either add this feature or leave it as it is, but please do not add an option. 

Config options do definitely not please everyone ;-) Adding options for every little detail will slowly turn the settings dialog into a big mess, makes testing all code paths extremely hard, and will introduce new bugs.
Comment 15 brunombn 2014-07-15 23:06:58 UTC
(In reply to Frank Reininghaus from comment #14)
That was a fast response!

> > And, to please everyone, you could add a configuration option to
> > enable/disable this feature.
> 
> I think we should either add this feature or leave it as it is, but please
> do not add an option. 
> 
> Config options do definitely not please everyone ;-) Adding options for
> every little detail will slowly turn the settings dialog into a big mess,
> makes testing all code paths extremely hard, and will introduce new bugs.

You have a point. :)

I never developed for KDE, and I'm also not using KDE right now (but I occasionally thing about switching to it).
As there already is a patch, I could try looking into it. If only small changes are required I may update the patch, but no promises.
But if someone else with more experience wants to do it, go ahead! :)
Comment 16 brunombn 2014-07-17 20:04:45 UTC
Created attachment 87784 [details]
Updated patch

I'm using Ubuntu 14.04.
I got the code with "apt-get source kde4libs" (package version4:4.13.2a-0ubuntu0.2), then applied the changes in the old patch, adapting it when necessary.
Then I compiled it, installed Dolphin, replaced the installed libkio.so and tested.

It works, but not perfectly.
It seems Dolphin displays all files as before, then hides those listed in ".hidden".
I also sometimes needed to press F5 for those files to be hidden, especially when changing folders.

I've attached the updated patch.
I'll look at the suggestions and try to improve it.
Comment 17 Thomas Braxton 2014-07-18 02:15:40 UTC
If you're going to work on this, you should use reviewboard. It works a lot better for reviewing patches.
Comment 18 brunombn 2014-07-18 21:26:18 UTC
Created attachment 87801 [details]
Updated patch 2

I've updated the patch.
I followed David's suggestions, and the patch is now simpler (almost completely different). The approach is a bit different now.

I've tested this in Ubuntu 14.04 (Unity) with Dolphin.
It seems to be working, but this will need a lot more testing (in full KDE).

I've attached the patch.
Tomorrow or next week I will try to base the patch on KDE's current version (after I find it) and add this to the review board.
Comment 19 brunombn 2014-07-24 13:27:33 UTC
I've now tested this in actual KDE (Kubuntu 14.04 in VirtualBox), and it's not working correctly in the home folder for some reason.
Initially it works fine and hides the files listed in ".hidden", but then it makes them visible. Pressing F5 hides them again.
When testing in another folder (tried ~/Documents), the patch worked perfectly.
I've seen this in Dolphin, the folder widget and the open/save dialog.

Maybe d->m_hidden is reset to KFileItemPrivate::Auto in some place.
I'll try to find out why this happens, and put the patch in the review board, eventually.
Comment 20 Yannik Sembritzki 2014-07-30 11:52:13 UTC
*** This bug has been confirmed by popular vote. ***
Comment 21 Yannik Sembritzki 2014-07-30 12:08:19 UTC
Hi Bruno,

thank you very much for your work, it is highly appreciated. :-)

Have you fixed the problem of files coming visible again yet?

Best regards
Yannik Sembritzki
Comment 22 brunombn 2014-07-30 12:36:09 UTC
Not yet. I haven't had much time lately.
But I will try to fix that issue sooner or later, or ask for help if I can't figure it out :).
Comment 23 brunombn 2014-07-31 15:31:06 UTC
The files listed in ".hidden" also reappear if I choose to show hidden files, then choose to hide them again.
I see, in the debug output, KDirListerCache::updateDirectory being called when this happens. That's probably where d->m_hidden is set to KFileItemPrivate::Auto.

I wouldn't mind some help from someone who knows how these classes work. :)
Comment 24 brunombn 2014-08-01 18:47:40 UTC
Created attachment 88079 [details]
Updated patch 3

OK, it seems we're going somewhere!
I copied the code I added in slotEntries() to slotUpdateResult() (these methods resemble each other), and now the files in ".hidden" stay hidden, both in Dolphin and the folder widget (very brief test).
The patch isn't finished yet (duplicating code isn't a good practice), but I've attached it, just in case.

Note that the patch is (still) based on the source code package in Ubuntu 14.04 (it makes it easier for me to test it).

KDE developers, is this the official repository for this library (KIO): https://projects.kde.org/projects/frameworks/kio/repository ? It's organized very differently from what's in the Ubuntu repository.
Next week I would like to base the patch on the official repository and send it to the review board.
Comment 25 Yannik Sembritzki 2014-08-01 22:15:40 UTC
Sounds great. Thank you for the status update and your work so far.

Looking forward to the final patch.

Yannik

Am 01.08.2014 20:47, schrieb Bruno Nova:
> https://bugs.kde.org/show_bug.cgi?id=246260
>
> Bruno Nova <brunomb.nova@gmail.com> changed:
>
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>   Attachment #87801 [details]|0                           |1
>         is obsolete|                            |
>
> --- Comment #24 from Bruno Nova <brunomb.nova@gmail.com> ---
> Created attachment 88079 [details]
>   --> https://bugs.kde.org/attachment.cgi?id=88079&action=edit
> Updated patch 3
>
> OK, it seems we're going somewhere!
> I copied the code I added in slotEntries() to slotUpdateResult() (these methods
> resemble each other), and now the files in ".hidden" stay hidden, both in
> Dolphin and the folder widget (very brief test).
> The patch isn't finished yet (duplicating code isn't a good practice), but I've
> attached it, just in case.
>
> Note that the patch is (still) based on the source code package in Ubuntu 14.04
> (it makes it easier for me to test it).
>
> KDE developers, is this the official repository for this library (KIO):
> https://projects.kde.org/projects/frameworks/kio/repository ? It's organized
> very differently from what's in the Ubuntu repository.
> Next week I would like to base the patch on the official repository and send it
> to the review board.
>
Comment 26 Frank Reininghaus 2014-08-03 09:08:50 UTC
Thanks for working on this, Bruno.

(In reply to Bruno Nova from comment #24)
> Created attachment 88079 [details]
> Updated patch 3

I cannot say very much about the KDirLister internals, but you should try to follow the kdelibs coding style:

https://techbase.kde.org/Policies/Kdelibs_Coding_Style

In particular, also use braces ({...}) after if-statements even if only a single line follows.

> KDE developers, is this the official repository for this library (KIO):
> https://projects.kde.org/projects/frameworks/kio/repository ?

Yes. This is the Qt5-based version of KIO. The source code package in Ubuntu is most likely based on the Qt4-version of kdelibs, which is shipped as a single package.

The Qt4/kdelibs 4.x version is in bug-fix-only mode. New features should go to the Qt5-based kio repository (David Faure, who maintains KIO, has the final say in that).
Comment 27 brunombn 2014-08-04 14:43:03 UTC
(In reply to Frank Reininghaus from comment #26)
> I cannot say very much about the KDirLister internals, but you should try to
> follow the kdelibs coding style:
> 
> https://techbase.kde.org/Policies/Kdelibs_Coding_Style

Thank you for the link!

> Yes. This is the Qt5-based version of KIO. The source code package in Ubuntu
> is most likely based on the Qt4-version of kdelibs, which is shipped as a
> single package.

This also crossed my mind. It makes sense!
I'll keep working on the Qt4-version for now, and then I'll work on the Qt5-version (I hope the code hasn't changed much).
Comment 28 brunombn 2014-08-04 16:19:14 UTC
Created attachment 88105 [details]
.hidden support for KDE4

Here is the final (I hope) patch for KDE4/Qt4, which is probably the version being used is most distributions right now.
I refactored the code according to the coding style.
KDE developers might want to check if they agree with the implementation and placement of the declarations.

I've tested this a bit.
It seems to be working everywhere I tested: Dolphin, folder view widget, Kate open/save dialogs and even in Dolphin's detailed/tree view.
More thorough tests should be done, though.

I'll start working on the KDE5 version now.
Comment 29 brunombn 2014-08-04 19:37:30 UTC
I submitted the patch for KDE5 to the review board here: https://git.reviewboard.kde.org/r/119607/

I haven't tested that patch yet.
Comment 30 brunombn 2014-08-05 14:19:48 UTC
It would probably be better if a developer running KDE5 built and tested the patch in the review board. I had no success building KIO yet.
Comment 31 Christoph Feck 2014-08-16 11:49:45 UTC
*** Bug 64740 has been marked as a duplicate of this bug. ***
Comment 32 brunombn 2014-09-14 15:04:02 UTC
The patch I submitted to the review board (https://git.reviewboard.kde.org/r/119607/) has had no response yet.
Could any KDE developer, who knows more about this than me, check if the patch information is correct? Particularly the "Reviewers" part.

Also, I did manage to build and run KIO with the patch in KDE5 Project Neon some time ago, but it seems both KDE4 and KDE5 libraries are used in different places, so it's a bit of a mess to test it.
More info is in the review board.
Comment 33 Frank Reininghaus 2014-09-14 15:28:30 UTC
(In reply to Bruno Nova from comment #32)
> Could any KDE developer, who knows more about this than me, check if the
> patch information is correct? Particularly the "Reviewers" part.

You should add the "kdeframeworks" group to all review requests that affect one of the KDE Frameworks.
Comment 34 brunombn 2014-09-14 15:34:13 UTC
(In reply to Frank Reininghaus from comment #33)
> (In reply to Bruno Nova from comment #32)
> > Could any KDE developer, who knows more about this than me, check if the
> > patch information is correct? Particularly the "Reviewers" part.
> 
> You should add the "kdeframeworks" group to all review requests that affect
> one of the KDE Frameworks.

Thank you for the very quick response! I did what you said.
Comment 35 David Faure 2015-01-01 21:54:40 UTC
Git commit a67a1534726edfea63dec7841f90f68898c2e26b by David Faure, on behalf of Bruno Nova.
Committed on 01/01/2015 at 20:30.
Pushed by dfaure into branch 'master'.

Support for ".hidden" files

This adds support for *.hidden* files to KDE.

When listing a directory, the files/folders listed in the *.hidden* file
will be hidden, unless the user has chosen to show hidden files.

This patch was initially based on the patch provided by Mark in Bug #246260.

Unittest by David Faure in next commit.
Change-Id: I5e28de50e1fb9f3517ac22c9f2160f50bf11f798

M  +71   -1    src/core/kcoredirlister.cpp
M  +21   -0    src/core/kcoredirlister_p.h
M  +7    -0    src/core/kfileitem.cpp
M  +6    -0    src/core/kfileitem.h

http://commits.kde.org/kio/a67a1534726edfea63dec7841f90f68898c2e26b
Comment 36 David Faure 2015-01-01 21:54:40 UTC
Git commit 30e9d1c82206435c43acc9b2bef67c194560e0bb by David Faure.
Committed on 01/01/2015 at 21:54.
Pushed by dfaure into branch 'master'.

Unittest for the .hidden file feature

Change-Id: I845aeca0e0b6f6ce0bc62059d2d36e9f6fd111da

M  +49   -5    autotests/kdirmodeltest.cpp
M  +2    -0    autotests/kdirmodeltest.h

http://commits.kde.org/kio/30e9d1c82206435c43acc9b2bef67c194560e0bb
Comment 37 smihael 2019-08-12 12:23:06 UTC
Please reimplement this for Dolphin 19.04
Comment 38 boredpengu 2021-01-10 17:37:11 UTC
With the beginning of 2021, is there any chance that Dolphin 19.12 will see this feature again? Or any of the Upcoming releases of Dolphin? Would be highly appreciating it. 

Anyway thanks for all the great work!!
Comment 39 boredpengu 2021-01-10 18:03:48 UTC
EDIT: .hidden behaviour seems to be working!  It didnt at first, when I created a new ".hidden" file. But then I copied the ".hidden" file from another computer where it has been working for a while. Out of some strange reason it works now.