[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-telepathy
Subject: Re: Review Request: Add syntax for changing global presence
From: "David Edmundson" <kde () davidedmundson ! co ! uk>
Date: 2012-07-04 15:07:20
Message-ID: 20120704150720.31571.71067 () 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/105407/#review15378
-----------------------------------------------------------
src/contactrunner.cpp
<http://git.reviewboard.kde.org/r/105407/#comment11983>
The reason we have setAccountManager is so that you can create the globalPresence \
object at initialisation.
Move the "m_globalPresence = new KTp::GlobalPresence()" to the ctor.
Same for AccountsModel.
Then you can remove your destructor, and remove your checks everywhere.
src/contactrunner.cpp
<http://git.reviewboard.kde.org/r/105407/#comment11986>
We can't keep filling the code with "mid(3)" everywhere.
Magic numbers are always bad and it's impossible to read and harder to debug.
Consider .split("whatever");
or QString("whatever").length();
or .startsWith("whatever");
What is the string we're splitting?
I don't care if it's slower if it's easier to read.
src/contactrunner.cpp
<http://git.reviewboard.kde.org/r/105407/#comment11987>
Use KTp::Presence() to get the icon. (you create one anyway).
Also KIcon("blah") is generally used instead of QIcon::fromTheme("blah").
src/contactrunner.cpp
<http://git.reviewboard.kde.org/r/105407/#comment11989>
- David Edmundson
On July 2, 2012, 8:22 a.m., Dan Vratil wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/105407/
> -----------------------------------------------------------
>
> (Updated July 2, 2012, 8:22 a.m.)
>
>
> Review request for Telepathy.
>
>
> Description
> -------
>
> This patch adds syntax for changing global presence:
>
> go online|away|busy|hidden|offline [status message]
>
> The status message is optional. The "go" keyword and presence names are \
> translatable.
>
> Diffs
> -----
>
> src/contactrunner.h c316aa4
> src/contactrunner.cpp 0d48c79
>
> Diff: http://git.reviewboard.kde.org/r/105407/diff/
>
>
> Testing
> -------
>
>
> Thanks,
>
> Dan Vratil
>
>
[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/105407/">http://git.reviewboard.kde.org/r/105407/</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/105407/diff/1/?file=70950#file70950line124" \
style="color: black; font-weight: bold; text-decoration: \
underline;">src/contactrunner.cpp</a> <span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; \
">ContactRunner::ContactRunner(QObject *parent, const QVariantList \
&args):</pre></td>
</tr>
</tbody>
<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">124</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span \
class="n">m_globalPresence</span><span class="o">-></span><span \
class="n">setAccountManager</span><span class="p">(</span><span \
class="n">m_accountManager</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;">The reason \
we have setAccountManager is so that you can create the globalPresence object at \
initialisation.
Move the "m_globalPresence = new KTp::GlobalPresence()" to the ctor.
Same for AccountsModel.
Then you can remove your destructor, and remove your checks everywhere. </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/105407/diff/1/?file=70950#file70950line461" \
style="color: black; font-weight: bold; text-decoration: \
underline;">src/contactrunner.cpp</a> <span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">void \
ContactRunner::match(Plasma::RunnerContext &context)</pre></td> <td \
colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">void \
ContactRunner::matchContacts(Plasma::RunnerContext &context)</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2">327</font></th> <td bgcolor="#fdfebc" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">429</font></th> <td bgcolor="#fdfebc" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span \
class="n">QString</span> <span class="n">cmd</span> <span class="o">=</span> <span \
class="n">term</span><span class="p">.</span><span class="n">mid</span><span \
class="p">(</span><span class="mi">3</span><span class="p">).</span><span \
class="n">trimmed</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;">We \
can't keep filling the code with "mid(3)" everywhere.
Magic numbers are always bad and it's impossible to read and harder to debug.
Consider .split("whatever");
or QString("whatever").length();
or .startsWith("whatever");
What is the string we're splitting?
I don't care if it's slower if it's easier to read.</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/105407/diff/1/?file=70950#file70950line515" \
style="color: black; font-weight: bold; text-decoration: \
underline;">src/contactrunner.cpp</a> <span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">void \
ContactRunner::match(Plasma::RunnerContext &context)</pre></td> <td \
colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">void \
ContactRunner::matchContacts(Plasma::RunnerContext &context)</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2">370</font></th> <td bgcolor="#fdfebc" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "> <span \
class="k">return</span> <span class="kc">true</span><span \
class="p">;</span></pre></td> <th bgcolor="#e9eaa8" style="border-left: 1px solid \
#C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font \
size="2">472</font></th> <td bgcolor="#fdfebc" width="50%"><pre style="font-size: \
8pt; line-height: 140%; margin: 0; "> <span class="n">match</span><span \
class="p">.</span><span class="n">setIcon</span><span class="p">(</span><span \
class="n">QIcon</span><span class="o">::</span><span class="n">fromTheme</span><span \
class="p">(</span><span class="s">"user-online"</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;">Use \
KTp::Presence() to get the icon. (you create one anyway).
Also KIcon("blah") is generally used instead of \
QIcon::fromTheme("blah"). </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/105407/diff/1/?file=70950#file70950line515" \
style="color: black; font-weight: bold; text-decoration: \
underline;">src/contactrunner.cpp</a> <span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">void \
ContactRunner::match(Plasma::RunnerContext &context)</pre></td> <td \
colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">void \
ContactRunner::matchContacts(Plasma::RunnerContext &context)</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2">370</font></th> <td bgcolor="#fdfebc" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "> <span \
class="k">return</span> <span class="kc">true</span><span \
class="p">;</span></pre></td> <th bgcolor="#e9eaa8" style="border-left: 1px solid \
#C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font \
size="2">472</font></th> <td bgcolor="#fdfebc" width="50%"><pre style="font-size: \
8pt; line-height: 140%; margin: 0; "> <span class="n">match</span><span \
class="p">.</span><span class="n">setIcon</span><span class="p">(</span><span \
class="n">QIcon</span><span class="o">::</span><span class="n">fromTheme</span><span \
class="p">(</span><span class="s">"user-online"</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;"></pre> \
</div> <br />
<p>- David</p>
<br />
<p>On July 2nd, 2012, 8:22 a.m., Dan Vratil wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('http://git.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;"> <tr>
<td>
<div>Review request for Telepathy.</div>
<div>By Dan Vratil.</div>
<p style="color: grey;"><i>Updated July 2, 2012, 8:22 a.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;">This patch adds syntax for changing global presence:
go online|away|busy|hidden|offline [status message]
The status message is optional. The "go" keyword and presence names are \
translatable.</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>src/contactrunner.h <span style="color: grey">(c316aa4)</span></li>
<li>src/contactrunner.cpp <span style="color: grey">(0d48c79)</span></li>
</ul>
<p><a href="http://git.reviewboard.kde.org/r/105407/diff/" style="margin-left: \
3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>
_______________________________________________
KDE-Telepathy mailing list
KDE-Telepathy@kde.org
https://mail.kde.org/mailman/listinfo/kde-telepathy
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic