[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: Re: Review Request 109773: New runner that translates words and sentences via Google Translate.
From: "Aaron J. Seigo" <aseigo () kde ! org>
Date: 2013-04-08 15:39:43
Message-ID: 20130408153943.4643.37252 () vidsolbach ! de
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/109773/#review30684
-----------------------------------------------------------
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22823>
"<language code>" needs to be translated
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22824>
as above, this needs to be i18n'd .. and languagce -> language (small typo)
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22844>
see comment on line 109 below
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22825>
you should use "!language.second.isEmpty()" instead of comparing with an empty \
string, but in any case this is not necessary as supportedLanguages should never \
contain "", right? :)
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22830>
might be nice to pop a small comment here why this is required
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22829>
should be commented out prior to committing
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22828>
indentation looks like it went a bit off from here?
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22831>
l0 is not a great variable name. please name it something descriptive to its \
purpose.
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22832>
same as with l0 above
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22833>
same as with l0 above
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22836>
a comment here about why there is a new and old "foundWord" might be useful for \
people touching this code in future
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22835>
last2.at(1) implies at least 2 entries in list2.. so this should probably be:
bool foundWordNew = list2.size() > 1 && !list2.at(1).toList().isEmpty();
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22834>
indexOf(l1) could be cached above to avoid having to re-search the list?
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22838>
this should of type Informational rather than ExactMatch since there is no \
further action to be taken (and selecting it should copy it to the clipboard)
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22837>
elsewhere you do "} else {"; would be good to be consistent
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22843>
i would suggest taking advantage of the fact that QMap is sorted. in the while \
loop, the code already does a check for i.key() == key, so one may as well do that \
from the start and do something like:
QMapIterator<int, QPair<QString, double> > it(sentences);
int currentKey = -1;
double currentRel = 1;
QString currentString;
while (it.hasNext()) {
pair = it.next();
// we're on to another key, process previous results, if any
if (currentKey != it.key()) {
if (!combined.isEmpty()) {
Plasma::QueryMatch match(this);
.. setup match ..
combined.clear();
}
currentKey = it.key();
currentRel = 1;
currentString.clear();
}
currentString.append(' ').append(pair.first);
currentRel *= pair.second;
}
this woudl avoid the more expensive calls of uniqueKeys and find and make the \
code a lot easier to read. (assuming it does what i think it does from reading it :)
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22840>
pref to use tmp.isEmpty()
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22839>
type Informational
runners/translator/translator.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22827>
as this is used as a look up table, to make it faster use a QSet<QString> \
instead. here the difference will be tiny as string comparisons aren't THAT slow and \
there are only a few dozen 2 char strings to match against. still .. :)
runners/translator/translatorjob.cpp
<http://git.reviewboard.kde.org/r/109773/#comment22847>
this is leaking. from the QNetworkAccessManager docs:
"Note: After the request has finished, it is the responsibility of the user to \
delete the QNetworkReply object at an appropriate time. Do not directly delete it \
inside the slot connected to finished(). You can use the deleteLater() function."
so in jobCompleted, a reply->deleteLater() is required.
- Aaron J. Seigo
On April 5, 2013, 10:39 p.m., David Baum wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/109773/
> -----------------------------------------------------------
>
> (Updated April 5, 2013, 10:39 p.m.)
>
>
> Review request for Plasma.
>
>
> Description
> -------
>
> The Runner uses the Google Translate Homepage and supports all languages provided \
> by Google. It doesn't use the API, because it's not free of charge.
>
> Diffs
> -----
>
> runners/translator/CMakeLists.txt PRE-CREATION
> runners/CMakeLists.txt bb4b491b10e6fef8183a66f55f5d5832dd7bc41a
> runners/translator/plasma-runner-translator.desktop PRE-CREATION
> runners/translator/translator.h PRE-CREATION
> runners/translator/translator.cpp PRE-CREATION
> runners/translator/translatorjob.h PRE-CREATION
> runners/translator/translatorjob.cpp PRE-CREATION
>
> Diff: http://git.reviewboard.kde.org/r/109773/diff/
>
>
> Testing
> -------
>
>
> Thanks,
>
> David Baum
>
>
[Attachment #5 (text/html)]
<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;"> <tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="http://git.reviewboard.kde.org/r/109773/">http://git.reviewboard.kde.org/r/109773/</a>
</td>
</tr>
</table>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line55" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">55</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span \
class="n">Plasma</span><span class="o">::</span><span class="n">RunnerSyntax</span> \
<span class="n">autoSyntax</span><span class="p">(</span><span \
class="n">QString</span><span class="p">(</span><span \
class="s">"%1:q:"</span><span class="p">).</span><span \
class="n">arg</span><span class="p">(</span><span class="s">"<language \
code>"</span><span class="p">),</span></pre></td> </tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">"<language code>" needs to be translated</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line59" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">59</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span \
class="n">Plasma</span><span class="o">::</span><span class="n">RunnerSyntax</span> \
<span class="n">syntax</span><span class="p">(</span><span \
class="n">QString</span><span class="p">(</span><span \
class="s">"%1:q:"</span><span class="p">).</span><span \
class="n">arg</span><span class="p">(</span><span class="s">"<source \
languagce>-<target languagce>"</span><span \
class="p">),</span></pre></td> </tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">as above, \
this needs to be i18n'd .. and languagce -> language (small typo)</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line105" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">105</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span \
class="k">return</span> <span class="n">language</span><span class="p">.</span><span \
class="n">second</span> <span class="o">!=</span> <span class="s">""</span> \
<span class="o">&&</span> <span class="n">supportedLanguages</span><span \
class="p">.</span><span class="n">contains</span><span class="p">(</span><span \
class="n">language</span><span class="p">.</span><span class="n">first</span><span \
class="p">)</span> <span class="o">&&</span> <span \
class="n">supportedLanguages</span><span class="p">.</span><span \
class="n">contains</span><span class="p">(</span><span class="n">language</span><span \
class="p">.</span><span class="n">second</span><span class="p">);</span></pre></td> \
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">see comment \
on line 109 below</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line109" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">109</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span \
class="k">return</span> <span class="n">language</span><span class="p">.</span><span \
class="n">second</span> <span class="o">!=</span> <span class="s">""</span> \
<span class="o">&&</span> <span class="n">supportedLanguages</span><span \
class="p">.</span><span class="n">contains</span><span class="p">(</span><span \
class="n">language</span><span class="p">.</span><span class="n">second</span><span \
class="p">);</span></pre></td> </tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">you should \
use "!language.second.isEmpty()" instead of comparing with an empty string, \
but in any case this is not necessary as supportedLanguages should never contain \
"", right? :)</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line116" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">116</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span \
class="n">jsonData</span> <span class="o">=</span> <span \
class="n">jsonData</span><span class="p">.</span><span class="n">replace</span><span \
class="p">(</span><span class="n">QRegExp</span><span class="p">(</span><span \
class="s">",{3,3}"</span><span class="p">),</span> <span \
class="s">",</span><span class="se">\"\"</span><span \
class="s">,</span><span class="se">\"\"</span><span \
class="s">,"</span><span class="p">);</span></pre></td> </tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">117</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span \
class="n">jsonData</span> <span class="o">=</span> <span \
class="n">jsonData</span><span class="p">.</span><span class="n">replace</span><span \
class="p">(</span><span class="n">QRegExp</span><span class="p">(</span><span \
class="s">",{2,2}"</span><span class="p">),</span> <span \
class="s">",</span><span class="se">\"\"</span><span \
class="s">,"</span><span class="p">);</span></pre></td> </tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">might be \
nice to pop a small comment here why this is required</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line118" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">118</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="n">kDebug</span><span class="p">()</span> <span \
class="o"><<</span> <span class="n">jsonData</span><span \
class="p">;</span></pre></td> </tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">should be \
commented out prior to committing</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line126" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">126</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="p">}</span></pre></td> </tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">indentation \
looks like it went a bit off from here?</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line131" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">131</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="n">foreach</span> <span class="p">(</span><span \
class="k">const</span> <span class="n">QVariant</span> <span \
class="o">&</span><span class="n">l0</span><span class="p">,</span> <span \
class="n">json</span><span class="p">)</span> <span class="p">{</span></pre></td> \
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">l0 is not a \
great variable name. please name it something descriptive to its purpose.</pre> \
</div> <br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line132" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">132</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="n">QVariantList</span> <span \
class="n">list0</span> <span class="o">=</span> <span class="n">l0</span><span \
class="p">.</span><span class="n">toList</span><span class="p">();</span></pre></td> \
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">same as \
with l0 above</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line136" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">136</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="n">foreach</span> <span \
class="p">(</span><span class="k">const</span> <span class="n">QVariant</span> <span \
class="o">&</span><span class="n">l1</span><span class="p">,</span> <span \
class="n">list0</span><span class="p">)</span> <span class="p">{</span></pre></td> \
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">same as \
with l0 above</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line143" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">143</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> \
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">a comment \
here about why there is a new and old "foundWord" might be useful for \
people touching this code in future</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line144" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">144</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="tb"> </span><span \
class="tb"> </span><span class="kt">bool</span> <span class="n">foundWordNew</span> \
<span class="o">=</span> <span class="p">(</span><span class="n">list2</span><span \
class="p">.</span><span class="n">size</span><span class="p">()</span> <span \
class="o">>=</span> <span class="mi">1</span><span class="p">)</span> <span \
class="o">&&</span> <span class="p">(</span><span class="n">list2</span><span \
class="p">.</span><span class="n">at</span><span class="p">(</span><span \
class="mi">1</span><span class="p">).</span><span class="n">toList</span><span \
class="p">().</span><span class="n">size</span><span class="p">()</span> <span \
class="o">>=</span> <span class="mi">1</span><span class="p">);</span></pre></td> \
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">last2.at(1) \
implies at least 2 entries in list2.. so this should probably be:
bool foundWordNew = list2.size() > 1 && \
!list2.at(1).toList().isEmpty();</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line149" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">149</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="tb"> </span><span \
class="tb"> </span><span class="tb"> </span><span class="tb"> </span><span \
class="n">sentences</span><span class="p">.</span><span class="n">insert</span><span \
class="p">(</span><span class="n">list0</span><span class="p">.</span><span \
class="n">indexOf</span><span class="p">(</span><span class="n">l1</span><span \
class="p">),</span> <span class="n">qMakePair</span><span class="p">(</span><span \
class="n">list2</span><span class="p">.</span><span class="n">at</span><span \
class="p">(</span><span class="mi">0</span><span class="p">).</span><span \
class="n">toString</span><span class="p">(),</span> <span class="n">list2</span><span \
class="p">.</span><span class="n">at</span><span class="p">(</span><span \
class="mi">1</span><span class="p">).</span><span class="n">toDouble</span><span \
class="p">()</span> <sp an class="o">/</span> <span class="mi">1000</span><span \
class="p">));</span></pre></td> </tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">indexOf(l1) \
could be cached above to avoid having to re-search the list?</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line152" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">152</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="tb"> </span><span \
class="tb"> </span><span class="tb"> </span><span class="tb"> </span><span \
class="n">match</span><span class="p">.</span><span class="n">setType</span><span \
class="p">(</span><span class="n">Plasma</span><span class="o">::</span><span \
class="n">QueryMatch</span><span class="o">::</span><span \
class="n">ExactMatch</span><span class="p">);</span></pre></td> </tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">this should \
of type Informational rather than ExactMatch since there is no further action to be \
taken (and selecting it should copy it to the clipboard)</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line166" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">166</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="tb"> </span><span \
class="tb"> </span><span class="tb"> </span><span class="tb"> </span><span \
class="tb"> </span><span class="p">}</span></pre></td> </tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">167</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="tb"> </span><span \
class="tb"> </span><span class="tb"> </span><span class="tb"> </span><span \
class="tb"> </span><span class="k">else</span> <span class="p">{</span></pre></td> \
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">elsewhere \
you do "} else {"; would be good to be consistent</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line184" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">184</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="n">QList</span><span \
class="o"><</span><span class="kt">int</span><span class="o">></span> <span \
class="n">keys</span> <span class="o">=</span> <span class="n">sentences</span><span \
class="p">.</span><span class="n">uniqueKeys</span><span \
class="p">();</span></pre></td> </tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">185</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="n">QList</span><span \
class="o"><</span><span class="n">QPair</span><span class="o"><</span><span \
class="n">QString</span><span class="p">,</span> <span class="kt">double</span><span \
class="o">></span> <span class="o">></span> <span \
class="n">combined</span><span class="p">;</span></pre></td> </tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">186</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="n">QPair</span><span \
class="o"><</span><span class="n">QString</span><span class="p">,</span> <span \
class="kt">double</span><span class="o">></span> <span class="n">pair</span><span \
class="p">;</span></pre></td> </tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">187</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> \
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">188</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="n">foreach</span> <span \
class="p">(</span><span class="k">const</span> <span class="kt">int</span> <span \
class="n">k</span><span class="p">,</span> <span class="n">keys</span><span \
class="p">)</span> <span class="p">{</span></pre></td> </tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">189</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="tb"> </span><span \
class="n">QList</span><span class="o"><</span><span class="n">QPair</span><span \
class="o"><</span><span class="n">QString</span><span class="p">,</span> <span \
class="kt">double</span><span class="o">></span> <span class="o">></span> <span \
class="n">tmp</span> <span class="o">=</span> <span class="n">combined</span><span \
class="p">;</span></pre></td> </tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">190</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="tb"> </span><span \
class="n">combined</span><span class="p">.</span><span class="n">clear</span><span \
class="p">();</span></pre></td> </tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">191</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="tb"> </span><span \
class="n">QMultiMap</span><span class="o"><</span><span class="kt">int</span><span \
class="p">,</span> <span class="n">QPair</span><span class="o"><</span><span \
class="n">QString</span><span class="p">,</span> <span class="kt">double</span><span \
class="o">></span> <span class="o">>::</span><span \
class="n">const_iterator</span> <span class="n">i</span> <span class="o">=</span> \
<span class="n">sentences</span><span class="p">.</span><span \
class="n">find</span><span class="p">(</span><span class="n">k</span><span \
class="p">);</span></pre></td> </tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">192</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="tb"> </span><span \
class="k">while</span> <span class="p">(</span><span class="n">i</span> <span \
class="o">!=</span> <span class="n">sentences</span><span class="p">.</span><span \
class="n">end</span><span class="p">()</span> <span class="o">&&</span> <span \
class="n">i</span><span class="p">.</span><span class="n">key</span><span \
class="p">()</span> <span class="o">==</span> <span class="n">k</span><span \
class="p">)</span> <span class="p">{</span></pre></td> </tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">i would \
suggest taking advantage of the fact that QMap is sorted. in the while loop, the code \
already does a check for i.key() == key, so one may as well do that from the start \
and do something like:
QMapIterator<int, QPair<QString, double> > it(sentences);
int currentKey = -1;
double currentRel = 1;
QString currentString;
while (it.hasNext()) {
pair = it.next();
// we're on to another key, process previous results, if any
if (currentKey != it.key()) {
if (!combined.isEmpty()) {
Plasma::QueryMatch match(this);
.. setup match ..
combined.clear();
}
currentKey = it.key();
currentRel = 1;
currentString.clear();
}
currentString.append(' ').append(pair.first);
currentRel *= pair.second;
}
this woudl avoid the more expensive calls of uniqueKeys and find and make the code a \
lot easier to read. (assuming it does what i think it does from reading it :)</pre> \
</div> <br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line193" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">193</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="tb"> </span><span \
class="tb"> </span><span class="k">if</span> <span class="p">(</span><span \
class="n">tmp</span><span class="p">.</span><span class="n">size</span><span \
class="p">()</span> <span class="o">==</span> <span class="mi">0</span><span \
class="p">)</span> <span class="p">{</span></pre></td> </tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">pref to use \
tmp.isEmpty()</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line210" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">210</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="tb"> </span><span \
class="tb"> </span><span class="n">match</span><span class="p">.</span><span \
class="n">setType</span><span class="p">(</span><span class="n">Plasma</span><span \
class="o">::</span><span class="n">QueryMatch</span><span class="o">::</span><span \
class="n">ExactMatch</span><span class="p">);</span></pre></td> </tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">type \
Informational</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131524#file131524line223" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translator.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">223</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="k">const</span> <span class="n">QStringList</span> <span \
class="n">Translator</span><span class="o">::</span><span \
class="n">supportedLanguages</span> <span class="o">=</span> <span \
class="n">QStringList</span><span class="p">()</span> <span class="o"><<</span> \
<span class="s">"af"</span> <span class="o"><<</span> <span \
class="s">"sq"</span> <span class="o"><<</span> <span \
class="s">"ar"</span> <span class="o"><<</span> <span \
class="s">"az"</span></pre></td> </tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">as this is \
used as a look up table, to make it faster use a QSet<QString> instead. here \
the difference will be tiny as string comparisons aren't THAT slow and there are \
only a few dozen 2 char strings to match against. still .. :)</pre> </div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/109773/diff/5/?file=131526#file131526line35" \
style="color: black; font-weight: bold; text-decoration: \
underline;">runners/translator/translatorjob.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">35</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="n">m_manager</span> <span class="o">-></span> \
<span class="n">post</span><span class="p">(</span><span \
class="n">request</span><span class="p">,</span> <span class="n">postData</span><span \
class="p">.</span><span class="n">encodedQuery</span><span \
class="p">());</span></pre></td> </tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">this is \
leaking. from the QNetworkAccessManager docs:
"Note: After the request has finished, it is the responsibility of the user to \
delete the QNetworkReply object at an appropriate time. Do not directly delete it \
inside the slot connected to finished(). You can use the deleteLater() \
function."
so in jobCompleted, a reply->deleteLater() is required.</pre>
</div>
<br />
<p>- Aaron J.</p>
<br />
<p>On April 5th, 2013, 10:39 p.m. UTC, David Baum wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('http://git.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;"> <tr>
<td>
<div>Review request for Plasma.</div>
<div>By David Baum.</div>
<p style="color: grey;"><i>Updated April 5, 2013, 10:39 p.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" \
style="border: 1px solid #b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">The Runner uses the Google Translate Homepage and supports all languages \
provided by Google. It doesn't use the API, because it's not free of charge. \
</pre> </td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>runners/translator/CMakeLists.txt <span style="color: \
grey">(PRE-CREATION)</span></li>
<li>runners/CMakeLists.txt <span style="color: \
grey">(bb4b491b10e6fef8183a66f55f5d5832dd7bc41a)</span></li>
<li>runners/translator/plasma-runner-translator.desktop <span style="color: \
grey">(PRE-CREATION)</span></li>
<li>runners/translator/translator.h <span style="color: \
grey">(PRE-CREATION)</span></li>
<li>runners/translator/translator.cpp <span style="color: \
grey">(PRE-CREATION)</span></li>
<li>runners/translator/translatorjob.h <span style="color: \
grey">(PRE-CREATION)</span></li>
<li>runners/translator/translatorjob.cpp <span style="color: \
grey">(PRE-CREATION)</span></li>
</ul>
<p><a href="http://git.reviewboard.kde.org/r/109773/diff/" style="margin-left: \
3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic