<table><tr><td style="">ahiemstra requested changes to this revision.<br />ahiemstra 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/D6513">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/D6513#inline-75451">View Inline</a><span style="color: #4b4d51; font-weight: bold;">atticaprovider.cpp:283</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 style="color: #aa4000">if</span><span class="p">(</span><span class="n">filterAcceptsDownloads</span> <span style="color: #aa2211">&&</span> <span class="n">checker</span><span class="p">.</span><span class="n">filterAccepts</span><span class="p">(</span><span class="n">content</span><span class="p">.</span><span class="n">tags</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="n">mCachedContent</span><span class="p">.</span><span class="n">insert</span><span class="p">(</span><span class="n">content</span><span class="p">.</span><span class="n">id</span><span class="p">(),</span> <span class="n">content</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Wouldn't it be simpler to first check if the content should be considered at all, and then check if one of the downloads is valid? So something like:</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);">if(!checker.filterAccepts(content.tags()) {
continue
}
foreach download {
if(downloadsChecker.filterAccepts(download.tags) {
add download
break
}
}</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/D6513#inline-75453">View Inline</a><span style="color: #4b4d51; font-weight: bold;">engine.cpp:131</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">d</span><span style="color: #aa2211">-></span><span class="n">tagFilter</span> <span style="color: #aa2211">=</span> <span class="n">group</span><span class="p">.</span><span class="n">readEntry</span><span class="p">(</span><span style="color: #766510">"TagFilter"</span><span class="p">).</span><span class="n">split</span><span class="p">(</span><span class="n">QStringLiteral</span><span class="p">(</span><span style="color: #766510">","</span><span class="p">));</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #aa4000">if</span><span class="p">(</span><span class="n">d</span><span style="color: #aa2211">-></span><span class="n">tagFilter</span><span class="p">.</span><span class="n">length</span><span class="p">()</span> <span style="color: #aa2211">==</span> <span style="color: #601200">1</span> <span style="color: #aa2211">&&</span> <span class="n">d</span><span style="color: #aa2211">-></span><span class="n">tagFilter</span><span class="p">.</span><span class="n">at</span><span class="p">(</span><span style="color: #601200">0</span><span class="p">).</span><span class="n">isEmpty</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;">Considering KConfig has methods to read and write lists, wouldn't it be better to use those?</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/D6513#inline-75457">View Inline</a><span style="color: #4b4d51; font-weight: bold;">engine.h:190</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: #74777d"> * out entries marked as ghns_exclude=1. To retain this when setting a custom</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span style="color: #74777d"> * filter, add "ghns_exclude!=1" as one of the filters.</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span style="color: #74777d"> *</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Would it make sense to add an <tt style="background: #ebebeb; font-size: 13px;">addTagFilter</tt> method or similar for convenience that appends instead of replaces? Or maybe make the setter a bit more intelligent so it is harder to forget adding the <tt style="background: #ebebeb; font-size: 13px;">ghns_exclude!=1</tt> filter? Right now, if I need to do anything with the tag filters, I will constantly need to remember to add the ghns_exclude filter.</p>
<p style="padding: 0; margin: 8px;">Maybe even completely separate the ghns_exclude filter from this setter and make a separate "also show excluded content" switch that removes the filter?</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/D6513#inline-75454">View Inline</a><span style="color: #4b4d51; font-weight: bold;">engine.h:227</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: #74777d"> */</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #aa4000">void</span> <span style="color: #004012">setTagFilter</span><span class="p">(</span><span class="n">QStringList</span> <span class="n">filter</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #74777d">/**</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;"><tt style="background: #ebebeb; font-size: 13px;">const QStringList&</tt></p>
<p style="padding: 0; margin: 8px;">(Also applies to setDownloadTagFilter 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/D6513#inline-75455">View Inline</a><span style="color: #4b4d51; font-weight: bold;">entryinternal.cpp:165</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">void</span> <span class="n">KNSCore</span><span style="color: #aa2211">::</span><span class="n">EntryInternal</span><span style="color: #aa2211">::</span><span class="n">setTags</span><span class="p">(</span><span style="color: #aa4000">const</span> <span class="n">QStringList</span><span style="color: #aa2211">&</span> <span class="n">tags</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;">Nitpick, but this doesn't match with the coding style of the declaration (<tt style="background: #ebebeb; font-size: 13px;">const QStringList& tags</tt> vs <tt style="background: #ebebeb; font-size: 13px;">const QStringList &tags</tt>)</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/D6513#inline-75464">View Inline</a><span style="color: #4b4d51; font-weight: bold;">tagsfilterchecker.cpp:43</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">public</span><span style="color: #aa2211">:</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">Validator</span><span class="p">(</span><span style="color: #aa4000">const</span> <span class="n">QString</span><span style="color: #aa2211">&</span> <span class="n">tag</span><span class="p">,</span> <span style="color: #aa4000">const</span> <span class="n">QString</span> <span class="n">value</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="n">m_tag</span> <span style="color: #aa2211">=</span> <span class="n">tag</span><span class="p">;</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">I think you mean <tt style="background: #ebebeb; font-size: 13px;">const QString& value</tt> ?</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/D6513#inline-75466">View Inline</a><span style="color: #4b4d51; font-weight: bold;">tagsfilterchecker.cpp:98</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">QString</span> <span class="n">value</span> <span style="color: #aa2211">=</span> <span class="n">filter</span><span class="p">.</span><span class="n">mid</span><span class="p">(</span><span class="n">tag</span><span class="p">.</span><span class="n">length</span><span class="p">()</span> <span style="color: #aa2211">+</span> <span style="color: #601200">2</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">Validator</span><span style="color: #aa2211">*</span> <span class="n">val</span> <span style="color: #aa2211">=</span> <span class="n">validators</span><span class="p">.</span><span class="n">value</span><span class="p">(</span><span class="n">tag</span><span class="p">,</span> <span style="color: #aa4000">nullptr</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #aa4000">if</span><span class="p">(</span><span class="n">val</span><span class="p">)</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Wouldn't this be simpler?</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);">if(!validators.contains(tag)) {
validators[tag] = new EqualityValidator(tag, "");
}
validators.value(tag)->m_acceptedValues << value;</pre></div></div></div></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R304 KNewStuff</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D6513">https://phabricator.kde.org/D6513</a></div></div><br /><div><strong>To: </strong>leinir, KNewStuff, apol, KDE Store, whiting, ahiemstra<br /><strong>Cc: </strong>ahiemstra, kde-frameworks-devel, KNewStuff, michaelh, ZrenBot, ngraham, bruns<br /></div>