<table><tr><td style="">ahiemstra added inline comments.
</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/D25326">View Revision</a></tr></table><br /><div><strong>INLINE COMMENTS</strong><div><div style="margin: 6px 0 12px 0;"><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25326#inline-151407">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kmaterka</span> wrote in <span style="color: #4b4d51; font-weight: bold;">ksortfilterproxymodel_qml.cpp:111</span></div>
<div style="margin: 8px 0; padding: 0 12px; color: #74777D;"><p style="padding: 0; margin: 8px;">Can you add a test for sortColumn? It might be useful for newcomers (like me) to understand how it works. I had real trouble understanding when it is needed and when not (<a href="https://phabricator.kde.org/source/plasma-workspace/browse/master/applets/systemtray/package/contents/ui/ConfigEntries.qml;v5.17.90$83" class="remarkup-link" target="_blank" rel="noreferrer">ConfigEntries.qml</a>)</p></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">I don't think a unit test is the right place for example code. It's probably better to either improve the documentation of the property or add an example somewhere where it makes sense.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25326#inline-151412">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kmaterka</span> wrote in <span style="color: #4b4d51; font-weight: bold;">ksortfilterproxymodel.cpp:165</span></div>
<div style="margin: 8px 0; padding: 0 12px; color: #74777D;"><p style="padding: 0; margin: 8px;">When using PlasmaCore.SortFilterModel sortColumn is sometimes set to -1 and sorting is not working when <tt style="background: #ebebeb; font-size: 13px;">sortColumn</tt> is not set. If I remember correctly, -1 is the default in QSortFilterProxyModel. Is <tt style="background: #ebebeb; font-size: 13px;">std::max(sortColumn(), 0)</tt> added to fix that? What will happen in this situation:</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">KSortFilterProxyModel {
sourceModel: testModel
sortColumn: -1
sortRole: "user"
}</pre></div>
<p style="padding: 0; margin: 8px;">Maybe is should be documented in <tt style="background: #ebebeb; font-size: 13px;">sortRole</tt> and <tt style="background: #ebebeb; font-size: 13px;">sortOrder</tt> properties that these two set sortColumn to 0 (or -1 in case of empty role)?</p></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">In that example, you'd be sorting on the "user" role of column 0, which seems like a reasonable default to me. I would actually suggest to make sortColumn always at least 0, I don't think there really is much of a use case for -1 as default.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25326#inline-151389">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kmaterka</span> wrote in <span style="color: #4b4d51; font-weight: bold;">ksortfilterproxymodel.h:67</span></div>
<div style="margin: 8px 0; padding: 0 12px; color: #74777D;"><p style="padding: 0; margin: 8px;">can we have something similar for sorting? <tt style="background: #ebebeb; font-size: 13px;">sortColumnCallback</tt> and use it in overridden <tt style="background: #ebebeb; font-size: 13px;">lessThan</tt>?</p></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Let's keep this a bit constrained, if we add a stub implementation of <tt style="background: #ebebeb; font-size: 13px;">lessThan()</tt>, we can later on add a property to expose a JS callback for it somehow.</p></div></div></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R275 KItemModels</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D25326">https://phabricator.kde.org/D25326</a></div></div><br /><div><strong>To: </strong>davidedmundson<br /><strong>Cc: </strong>kmaterka, iasensio, ahmadsamir, broulik, ahiemstra, mart, kde-frameworks-devel, LeGast00n, GB_2, michaelh, ngraham, bruns<br /></div>