Review Request 128743: Addressee: Implemented a way to determine if the birthday has been set with a time

Benni Hill benni at mytum.de
Thu Aug 25 15:29:19 BST 2016


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/128743/
-----------------------------------------------------------

(Updated Aug. 25, 2016, 4:29 nachm.)


Review request for KDEPIM-Libraries and Laurent Montel.


Changes
-------

`LDIFConverter`: added support for import/export of birthdays without a year


Repository: kcontacts


Description
-------

- 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 `QDateTime` (when set with a valid date) always has a valid time (midnight by default). I therefore added the boolean `withTime` to `setBirthday()` which is stored inside `Addressee` and can be queried with `birthdayHasTime()`. I also added `setBirthday(QDate)`.
I changed `VCardTool` to make use of this new methods when importing/exporting vcards.
Probably `KContacts::Field` and `KContacts::LDIFConverter` also should be adjusted.
To make use of this change in KAddressbook, (at least?) akonadi-contatcs has to be adjusted as well (in `PersonalEditorWidget::storeContact()`):
```
--- a/src/editor/personaleditor/personaleditorwidget.cpp
+++ b/src/editor/personaleditor/personaleditorwidget.cpp
@@ -83,12 +83,7 @@ void PersonalEditorWidget::loadContact(const KContacts::Addressee &contact)
 void PersonalEditorWidget::storeContact(KContacts::Addressee &contact)
 {
     // dates group
-    QDateTime birthday = QDateTime(mBirthdateWidget->date(), QTime(), contact.birthday().timeSpec());
-    // This is needed because the constructor above sets the time component
-    // of the QDateTime to midnight.  We want it to stay invalid.
-    birthday.setTime(QTime());
-
-    contact.setBirthday(birthday);
+    contact.setBirthday(mBirthdateWidget->date());
     Akonadi::Utils::storeCustom(contact, QStringLiteral("X-Anniversary"), mAnniversaryWidget->date().toString(Qt::ISODate));
 
     // family group
```

- 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.)


Diffs (updated)
-----

  CMakeLists.txt 0b4786f 
  autotests/addresseetest.cpp 156d642 
  autotests/birthdaytest.h 6535c42 
  autotests/birthdaytest.cpp 4c5313b 
  autotests/datetimetest.h 329810e 
  autotests/datetimetest.cpp 8517f00 
  autotests/ldifconvertertest.h da9220f 
  autotests/ldifconvertertest.cpp 9d3971e 
  src/addressee.h 4dc0dfd 
  src/addressee.cpp 9f4dd2e 
  src/converter/ldifconverter.cpp d1fee94 
  src/field.cpp 3406c9d 
  src/vcardtool.h 48890ed 
  src/vcardtool.cpp aa5654d 

Diff: https://git.reviewboard.kde.org/r/128743/diff/


Testing
-------

Added autotests:

- Exporting birthdays without a time.
- Importing/Exporting dates without a year.


Thanks,

Benni Hill

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20160825/f31e8548/attachment.html>


More information about the kde-pim mailing list