<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="12" style="border: 1px #c9c399 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://git.reviewboard.kde.org/r/128743/">https://git.reviewboard.kde.org/r/128743/</a>
     </td>
    </tr>
   </table>
   <br />





 <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">If you change API (new method) please increase PIM_VERSION.</p></pre>
 <br />









<p>- Laurent Montel</p>


<br />
<p>On August 24th, 2016, 3:51 p.m. UTC, Benni Hill wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="12" style="border: 1px #888a85 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
 <tr>
  <td>

<div>Review request for KDEPIM-Libraries and Laurent Montel.</div>
<div>By Benni Hill.</div>


<p style="color: grey;"><i>Updated Aug. 24, 2016, 3:51 p.m.</i></p>









<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
kcontacts
</div>


<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;"><ul style="padding: 0;text-rendering: inherit;margin: 0 0 0 1em;line-height: inherit;white-space: normal;">
<li style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">My aim was to implement a way to determine if there has been set a explicit time with the date of birth and that the time is only exported to a vcard if it has been explicitly specified. Some vcard implementations (e.g. on Android) ignore the birthday field if it comes with a time.
The problem here is that <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">QDateTime</code> (when set with a valid date) always has a valid time (midnight by default). I therefore added the boolean <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">withTime</code> to <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">setBirthday()</code> which is stored inside <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">Addressee</code> and can be queried with <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">birthdayHasTime()</code>. I also added <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">setBirthday
 (QDate)</code>.
I changed <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">VCardTool</code> to make use of this new methods when importing/exporting vcards.
Probably <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">KContacts::Field</code> and <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">KContacts::LDIFConverter</code> also should be adjusted.
To make use of this change in KAddressbook, (at least?) akonadi-contatcs has to be adjusted as well (in <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">PersonalEditorWidget::storeContact()</code>):</li>
</ul>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #A00000">--- a/src/editor/personaleditor/personaleditorwidget.cpp</span>
<span style="color: #00A000">+++ b/src/editor/personaleditor/personaleditorwidget.cpp</span>
<span style="color: #800080; font-weight: bold">@@ -83,12 +83,7 @@ void PersonalEditorWidget::loadContact(const KContacts::Addressee &contact)</span>
 void PersonalEditorWidget::storeContact(KContacts::Addressee &contact)
 {
     // dates group
<span style="color: #A00000">-    QDateTime birthday = QDateTime(mBirthdateWidget->date(), QTime(), contact.birthday().timeSpec());</span>
<span style="color: #A00000">-    // This is needed because the constructor above sets the time component</span>
<span style="color: #A00000">-    // of the QDateTime to midnight.  We want it to stay invalid.</span>
<span style="color: #A00000">-    birthday.setTime(QTime());</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-    contact.setBirthday(birthday);</span>
<span style="color: #00A000">+    contact.setBirthday(mBirthdateWidget->date());</span>
     Akonadi::Utils::storeCustom(contact, QStringLiteral("X-Anniversary"), mAnniversaryWidget->date().toString(Qt::ISODate));

     // family group
</pre></div>
</p>
<ul style="padding: 0;text-rendering: inherit;margin: 0 0 0 1em;line-height: inherit;white-space: normal;">
<li style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">Unrelated to this changes I implemented a way in VCardTool to import/export dates without a year. Dates without a year ('--MMdd') are imported as year=-1 and during export, years <= 0 are written as '--'. (This also has to be implemented in the user inteface some where to make any use.)</li>
</ul></pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Added autotests:</p>
<ul style="padding: 0;text-rendering: inherit;margin: 0 0 0 1em;line-height: inherit;white-space: normal;">
<li style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">Exporting birthdays without a time.</li>
<li style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">Importing/Exporting dates without a year.</li>
</ul></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>autotests/birthdaytest.h <span style="color: grey">(6535c42)</span></li>

 <li>autotests/birthdaytest.cpp <span style="color: grey">(4c5313b)</span></li>

 <li>autotests/datetimetest.h <span style="color: grey">(329810e)</span></li>

 <li>autotests/datetimetest.cpp <span style="color: grey">(8517f00)</span></li>

 <li>src/addressee.h <span style="color: grey">(4dc0dfd)</span></li>

 <li>src/addressee.cpp <span style="color: grey">(9f4dd2e)</span></li>

 <li>src/vcardtool.h <span style="color: grey">(48890ed)</span></li>

 <li>src/vcardtool.cpp <span style="color: grey">(aa5654d)</span></li>

</ul>

<p><a href="https://git.reviewboard.kde.org/r/128743/diff/" style="margin-left: 3em;">View Diff</a></p>






  </td>
 </tr>
</table>







  </div>
 </body>
</html>