Review Request 128743: Addressee: Implemented a way to determine if the birthday has been set with a time
Benni Hill
benni at mytum.de
Fri Aug 26 10:15:55 BST 2016
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/128743/
-----------------------------------------------------------
(Updated Aug. 26, 2016, 11:15 a.m.)
Status
------
This change has been marked as submitted.
Review request for KDEPIM-Libraries and Laurent Montel.
Changes
-------
Submitted with commit bd9f439d46ec0ca21fdac7834c7f2d5a6e8e1560 by Benjamin Löwe to branch master.
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
-----
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/20160826/c0f79d5d/attachment.html>
More information about the kde-pim
mailing list