Bug 506817

Summary: Smart Flat TreeView for the Project View
Product: [Applications] kate Reporter: Malte Grave <malte.grave>
Component: applicationAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: task CC: christoph, waqar.17a
Priority: NOR    
Version First Reported In: 25.04.3   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: The new Smart Flat TreeView

Description Malte Grave 2025-07-09 17:48:43 UTC
Created attachment 183096 [details]
The new Smart Flat TreeView

SUMMARY

This is not a classic issue, but rather a question of whether the intended implementation is something usefull.
I also considered opening a discussion topic for Kate but couldn't find anything appropriate.

A brief background: I use Kate for all kinds of programming, including Java (and as we all know, Java projects tend to have a deep folder structurt, that's how the idea came about). 
I developed a prototype of a "Smart Flat TreeView" that mimics the behavior seen in Eclipse, IntelliJ, and VSCode. If a folder only contains another single folder, it doesn't need to be shown as a separate leaf in the tree. It can be "flattened" and represented accordingly.

Attached is my prototype of the new TreeView.

Now the question is: Is this desired or unnecessary?

I would add it as an option in the settings, allowing users to choose which TreeView to use.

Happy to hear your feedback
Comment 1 Waqar Ahmed 2025-07-09 18:55:57 UTC
Valid request. I would like something like this myself.

Relevant code to look at in case someone wants to work on this https://invent.kde.org/utilities/kate/-/blob/master/addons/project/kateprojectworker.cpp?ref_type=heads#L362
Comment 2 Malte Grave 2025-07-09 19:15:36 UTC
(In reply to Waqar Ahmed from comment #1)
> Valid request. I would like something like this myself.
> 
> Relevant code to look at in case someone wants to work on this
> https://invent.kde.org/utilities/kate/-/blob/master/addons/project/
> kateprojectworker.cpp?ref_type=heads#L362

Thanks for your reply. I started digging into the code base a bit today. My original approach was to replace the QTreeView with my new SmartFileTreeView component, which inherits from QTreeView. But I will take a look at the line of code you suggested.

Thanks.
Comment 3 Christoph Cullmann 2025-07-09 19:28:45 UTC
I would love that feature, too! Would be a great option to have and could even be the default if it works well.
Comment 4 Malte Grave 2025-07-10 14:21:08 UTC
I pushed the first version of the flattened algorithm.

https://invent.kde.org/mgrave/kate/-/commit/88e82d537e0ebcb12e940096549b5fa6131f0014

The only thing that's missing is the appending of the extracted flattened folder into the correct hierarchy (and I think some case handling). 
I'm unsure how it works. Maybe someone can help me.
Comment 5 Waqar Ahmed 2025-07-14 19:37:14 UTC
> The only thing that's missing is the appending of the extracted flattened folder into the correct hierarchy (and I think some case handling). 
I'm unsure how it works

What do you mean? Sorry, I don't understand. Can you explain a bit?

Appending an item to a folder is done using the appendRow() function. We can discuss/help better if you open an MR.
Comment 6 Malte Grave 2025-07-15 19:47:48 UTC
(In reply to Waqar Ahmed from comment #5)
> > The only thing that's missing is the appending of the extracted flattened folder into the correct hierarchy (and I think some case handling). 
> I'm unsure how it works
> 
> What do you mean? Sorry, I don't understand. Can you explain a bit?
> 
> Appending an item to a folder is done using the appendRow() function. We can
> discuss/help better if you open an MR.

I open an MR and explained everything there:

https://invent.kde.org/utilities/kate/-/merge_requests/1821
Comment 7 Waqar Ahmed 2025-08-03 13:22:16 UTC
This is done now