<table><tr><td style="">mwolff requested changes to this revision.<br />mwolff added inline comments.<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/D8367" rel="noreferrer">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/D8367#inline-39026" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kfileplacesmodel.cpp:70</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span class="p">{</span> <span class="n">KFilePlacesModel</span><span style="color: #aa2211">::</span><span class="n">PlacesType</span><span class="p">,</span> <span class="n">QStringLiteral</span><span class="p">(</span><span style="color: #766510">"GroupState-Places-IsHidden"</span><span class="p">)</span> <span class="p">},</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span class="p">{</span> <span class="n">KFilePlacesModel</span><span style="color: #aa2211">::</span><span class="n">RecentlySavedType</span><span class="p">,</span> <span class="n">QStringLiteral</span><span class="p">(</span><span style="color: #766510">"GroupState-RecentlySaved-IsHidden"</span><span class="p">)</span> <span class="p">},</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">instead of a global static and hash, why not simply do the mapping in a function with a simple switch statement?</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);">namespace {
QString stateNameForGroupType(KFilePlacesModel::GroupType type)
{
    switch (type) {
    case KFilePlacesModel::PlacesType:
        return QStringLiteral("GroupState-Places-IsHidden");
    ...
    }
    Q_UNREACHABLE();
}
}</pre></div></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/D8367#inline-39025" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kfileplacesmodel.cpp:127</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span style="color: #aa4000">const</span> <span style="color: #aa4000">bool</span> <span class="n">areGroupsHiddenByDefault</span> <span style="color: #aa2211">=</span> <span style="color: #304a96">false</span><span class="p">;</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">why not hardcode this below? we will never hide them by default, will we?</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/D8367#inline-39031" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kfileplacesmodel.cpp:164</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span class="n">root</span><span class="p">.</span><span class="n">setMetaDataItem</span><span class="p">(</span><span class="n">s_groupTypeToStateName</span><span style="color: #aa2211">-></span><span class="n">value</span><span class="p">(</span><span class="n">PlacesType</span><span class="p">),</span> <span class="p">(</span><span class="n">areGroupsHiddenByDefault</span> <span style="color: #aa2211">?</span> <span class="n">QStringLiteral</span><span class="p">(</span><span style="color: #766510">"true"</span><span class="p">)</span> <span style="color: #aa2211">:</span> <span class="n">QStringLiteral</span><span class="p">(</span><span style="color: #766510">"false"</span><span class="p">)));</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span class="n">root</span><span class="p">.</span><span class="n">setMetaDataItem</span><span class="p">(</span><span class="n">s_groupTypeToStateName</span><span style="color: #aa2211">-></span><span class="n">value</span><span class="p">(</span><span class="n">DevicesType</span><span class="p">),</span> <span class="p">(</span><span class="n">areGroupsHiddenByDefault</span> <span style="color: #aa2211">?</span> <span class="n">QStringLiteral</span><span class="p">(</span><span style="color: #766510">"true"</span><span class="p">)</span> <span style="color: #aa2211">:</span> <span class="n">QStringLiteral</span><span class="p">(</span><span style="color: #766510">"false"</span><span class="p">)));</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">introduce a helper lambda for this to share duplicate code</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/D8367#inline-39028" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kfileplacesmodel.cpp:532</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span style="color: #aa4000">static</span> <span style="color: #aa4000">const</span> <span class="n">QHash</span><span style="color: #aa2211"><</span><span class="n">KFilePlacesModel</span><span style="color: #aa2211">::</span><span class="n">GroupType</span><span class="p">,</span> <span style="color: #aa4000">bool</span><span style="color: #aa2211">></span> <span class="n">groupStateHidden</span><span class="p">(</span><span style="color: #aa4000">const</span> <span class="n">KBookmark</span> <span class="n">rootBookmark</span><span class="p">)</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span class="p">{</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">misnomer? I'd rename this function to <tt style="background: #ebebeb; font-size: 13px;">hiddenGroups</tt></p>

<p style="padding: 0; margin: 8px;">also, take the rootBookmark by <tt style="background: #ebebeb; font-size: 13px;">const &</tt>?</p>

<p style="padding: 0; margin: 8px;">actually, remove this whole function and instead introduce a <tt style="background: #ebebeb; font-size: 13px;">bool isGroupHidden(KFilePlacesModel::GroupType)</tt> helper function, see also below</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/D8367#inline-39024" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kfileplacesmodel.cpp:596</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; ">    <span class="p">}</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span style="color: #74777d">// we make sure an item within a hidden group remains hidden too</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span style="color: #aa4000">const</span> <span class="n">QHash</span><span style="color: #aa2211"><</span><span class="n">GroupType</span><span class="p">,</span> <span style="color: #aa4000">bool</span><span style="color: #aa2211">></span> <span class="n">groupStates</span> <span style="color: #aa2211">=</span> <span class="n">groupStateHidden</span><span class="p">(</span><span class="n">root</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">why is this needed? i.e. doesn't this mean that once I unhide the group, all child items are still hidden?  or what happens when I hide an item, then its group, and then unhide its group - will the item remain hidden or not?</p>

<p style="padding: 0; margin: 8px;">is this b/c the file items don't build a tree with their groups, but rather just a list? a comment would be useful</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/D8367#inline-39029" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kfileplacesmodel.cpp:878</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">    <span class="bright"></span><span class="n"><span class="bright">bookmark</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span class="n"><span class="bright">setMetaDataItem</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">QStringLiteral</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #766510"><span class="bright">"IsHidden"</span></span><span class="bright"></span><span class="p"><span class="bright">),</span></span><span class="bright"> </span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">hidden</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">?</span></span><span class="bright"> </span><span class="n"><span class="bright">QStringLiteral</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #766510"><span class="bright">"true"</span></span><span class="bright"></span><span class="p"><span class="bright">)</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">:</span></span><span class="bright"> </span><span class="n"><span class="bright">QStringLiteral</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #766510"><span class="bright">"false"</span></span><span class="bright"></span><span class="p"><span class="bright">)</span>));</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span class="bright"></span><span style="color: #aa4000"><span class="bright">const</span></span><span class="bright"> </span><span class="n"><span class="bright">QHash</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright"><</span></span><span class="bright"></span><span class="n"><span class="bright">GroupType</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span style="color: #aa4000"><span class="bright">bool</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">></span></span><span class="bright"> </span><span class="n"><span class="bright">gpStateHidden</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=</span></span><span class="bright"> </span><span class="n"><span class="bright">groupStateHidden</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">d</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">-></span></span><span class="bright"></span><span class="n"><span class="bright">bookmarkManager</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">-></span></span><span class="bright"></span><span class="n"><span class="bright">root</span></span><span class="bright"></span><span class="p"><span class="bright">(</span>));</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span style="color: #aa4000">const</span> <span style="color: #aa4000">bool</span> <span class="n">hidingChildOnShownParent</span> <span style="color: #aa2211">=</span> <span class="n">hidden</span> <span style="color: #aa2211">&&</span> <span style="color: #aa2211">!</span><span class="n">gpStateHidden</span><span class="p">.</span><span class="n">value</span><span class="p">(</span><span class="n">item</span><span style="color: #aa2211">-></span><span class="n">groupType</span><span class="p">());</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">this is overkill, what you want is only a</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);">const bool isGroupHidden = ::isGrouphidden(item->groupType());
const bool hidingChildOnShownParent = hidden && !isGroupHidden;
const bool showingChildOnShownParent = !hidden && !isGroupHidden;</pre></div></div></div></div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D8367" rel="noreferrer">https://phabricator.kde.org/D8367</a></div></div><br /><div><strong>To: </strong>mlaurent, renatoo, ngraham, franckarrecot, ervin, mwolff<br /><strong>Cc: </strong>mwolff, ngraham, mlaurent, Frameworks<br /></div>