<table><tr><td style="">markg requested changes to this revision.<br />markg added a comment.<br />This revision now requires changes to proceed.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D18380">View Revision</a></tr></table><br /><div><div><p>I too would quite like the to have resizeable columns back.<br />
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.</p>
<p>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.</p>
<p>Now let's take a step back. What do we really want? We want:</p>
<ul class="remarkup-list">
<li class="remarkup-list-item">Have the first column resizable and calculate the optimal size when the user had not resized the column yet.</li>
<li class="remarkup-list-item">Restore that setting if the user had manually resized it.</li>
</ul>
<p>In QHeaderView code, what we want is "QHeaderView::Interactive" [1] followed by QHeaderView::resizeSection [2]. Exactly as [1] described! QHeaderView merely lacks a convenience function for this, that is what we have to implement!<br />
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 [5]. 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 :)</p>
<p>[1] <a href="http://doc.qt.io/qt-5/qheaderview.html#ResizeMode-enum" class="remarkup-link" target="_blank" rel="noreferrer">http://doc.qt.io/qt-5/qheaderview.html#ResizeMode-enum</a><br />
[2] <a href="http://doc.qt.io/qt-5/qheaderview.html#resizeSection" class="remarkup-link" target="_blank" rel="noreferrer">http://doc.qt.io/qt-5/qheaderview.html#resizeSection</a><br />
[3] <a href="https://p.sc2.nl/r1RJBLsQ4" class="remarkup-link" target="_blank" rel="noreferrer">https://p.sc2.nl/r1RJBLsQ4</a><br />
[4] <a href="https://p.sc2.nl/BJlMSLimN" class="remarkup-link" target="_blank" rel="noreferrer">https://p.sc2.nl/BJlMSLimN</a><br />
[5] <a href="https://p.sc2.nl/SJIYI8jQV" class="remarkup-link" target="_blank" rel="noreferrer">https://p.sc2.nl/SJIYI8jQV</a></p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R241 KIO</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D18380">https://phabricator.kde.org/D18380</a></div></div><br /><div><strong>To: </strong>rjvbb, ngraham, Frameworks, Dolphin, apol, dfaure, ahartmetz, markg<br /><strong>Cc: </strong>markg, cfeck, dhaumann, kwrite-devel, kde-frameworks-devel, michaelh, ngraham, bruns<br /></div>