D18380: KIO: make file dialog columns resizable again (and movable)
noreply at phabricator.kde.org
Sun Jan 27 16:15:23 GMT 2019
markg requested changes to this revision.
markg added a comment.
This revision now requires changes to proceed.
I too would quite like the to have resizeable columns back.
But the approach you've chosen looks a little too complicated. Also, the fact that KDirOperatorDetailView::event needs to know about your custom QHeaderView is a code smell. Sometimes you do indeed need logic like that to make things work. But still, isn't there another way? Now the header and view are locked together. One doesn't work without the other.
The thing that triggered me to comment wasn't any of that though. It's the "narrow mode". I cannot see how that wouldn't be seen as a bug by a user. With that little trick you're also overruling any font spacing settings the user might have had (in fontconfig) which is quite likely going to cause unexpected behavior and therefore bug reports.
Now let's take a step back. What do we really want? We want:
- Have the first column resizable and calculate the optimal size when the user had not resized the column yet.
- Restore that setting if the user had manually resized it.
In QHeaderView code, what we want is "QHeaderView::Interactive"  followed by QHeaderView::resizeSection . Exactly as  described! QHeaderView merely lacks a convenience function for this, that is what we have to implement!
I quickly threw this in a test project (minus the state saving) and i ended up with this fairly minimal QHeaderView subclass [3: header], [4: source] and this sample to see how you use it . Note that there is one quirk in there in the source. The size calculation is not perfect and will fail on longer strings! That likely needs to be extended to take the style and margins into account. Anyhow, the goal of this example is to show a different approach with a far smaller code footprint and be far easier to debug. Use it as you please :)
To: rjvbb, ngraham, #frameworks, #dolphin, apol, dfaure, ahartmetz, markg
Cc: markg, cfeck, dhaumann, kwrite-devel, kde-frameworks-devel, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the KWrite-Devel