Add utility text function KShell::tildeCollapse
ClosedPublic

Authored by meven on Dec 20 2019, 3:31 PM.

Details

Summary

KShell::tildeCollapse return a string with homedir (usually /home/$USER) replaced by ~.

Test Plan

ctest

Diff Detail

Repository
R244 KCoreAddons
Branch
arcpatch-D26122
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 21034
Build 21052: arc lint + arc unit
meven created this revision.Dec 20 2019, 3:31 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptDec 20 2019, 3:31 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
meven requested review of this revision.Dec 20 2019, 3:31 PM
ngraham accepted this revision.Dec 20 2019, 7:33 PM
This revision is now accepted and ready to land.Dec 20 2019, 7:33 PM
apol added a subscriber: apol.Dec 23 2019, 1:57 AM

I might be missing something, explaining why it's necessary would be useful for the commit log as well as for lost reviewers like me.

ervin accepted this revision.Dec 23 2019, 1:04 PM
meven added a comment.Dec 23 2019, 1:39 PM
In D26122#581717, @apol wrote:

I might be missing something, explaining why it's necessary would be useful for the commit log as well as for lost reviewers like me.

I replaced my first use case by KFilePlacesModel::closestItem.

The use case is to avoid redundant code doing this over and over just like KShell::tildeExpand does :

plasma-desktop/kcms/kfontinst/lib/Misc.cpp:391
plasma-desktop/kcms/baloo/filteredfoldermodel.cpp:50
plasma-workspace/runners/baloo/baloosearchrunner.cpp:176
plasma-workspace/libnotificationmanager/job_p.cpp:120
solid/src/solid/devices/backends/fstab/fstabdevice.cpp:61

meven updated this revision to Diff 73386.Jan 13 2020, 10:35 AM

Update KF5 version in @since

In D26122#581717, @apol wrote:

I might be missing something, explaining why it's necessary would be useful for the commit log as well as for lost reviewers like me.

To reiterate.
The use case is to avoid redundant code doing this over and over just like KShell::tildeExpand does :

plasma-desktop/kcms/kfontinst/lib/Misc.cpp:391
plasma-desktop/kcms/baloo/filteredfoldermodel.cpp:50
plasma-workspace/runners/baloo/baloosearchrunner.cpp:176
plasma-workspace/libnotificationmanager/job_p.cpp:120
solid/src/solid/devices/backends/fstab/fstabdevice.cpp:61

I thought the header documentation and commit comment would be sufficient to explain the intent and the usefullness.
After all it is just the opposite of tildeExpand.

meven added a comment.Jan 14 2020, 9:47 AM

@apol is it ok with you ?

apol accepted this revision.Jan 14 2020, 12:37 PM

Looks good to me, just explain what it does on the commit message.

meven edited the summary of this revision. (Show Details)Jan 14 2020, 1:00 PM
This revision was automatically updated to reflect the committed changes.
meven added a comment.Jan 14 2020, 2:43 PM

Now we have a small list of potential users of this :

plasma-desktop/kcms/kfontinst/lib/Misc.cpp:391
plasma-desktop/kcms/baloo/filteredfoldermodel.cpp:50
plasma-workspace/runners/baloo/baloosearchrunner.cpp:176
plasma-workspace/libnotificationmanager/job_p.cpp:120
solid/src/solid/devices/backends/fstab/fstabdevice.cpp:61