[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-pim
Subject: Re: [Kde-pim] Korganizer Anniversary import?
From: Tobias Koenig <tokoe () kde ! org>
Date: 2004-02-11 1:59:45
Message-ID: 20040211015945.GA4335 () ghostdog
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
On Tue, Feb 10, 2004 at 07:00:37PM +0000, Eugene Nine wrote:
Hi Eugene,
> I opened Kontact for the first time in a while and noticed that on the summary
> page lists birthdays and anniversaries but the import for korganizer only
> does birthdays.
The attached patch does also import anniversaries.
Cornelius, can I commit? Maybe we should rename the resource then?
> For example the addresseditor has a simple
> mBirthdayPicker->setDate( mAddressee.birthday().date() ); for birthdays and
> mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom(
> "KADDRESSBOOK", "X-Anniversary" ),
> Qt::ISODate) ); for anniversaries. Why wasn't the anniversary simply stored
> as mAddresss.anniversary()?
Because KABC::Addressee mainly reflects the fields of a vCard and a
vCard has no field for anniversary, just for birthday. But that isn't a
problem, because vCards supports custom fields and we use them to store
the anniversary.
Like you can see in the patch it's not really hard to use.
Ciao,
Tobias
--
Separate politics from religion and economy!
["anniversary.patch" (text/plain)]
Index: resourcekabc.cpp
===================================================================
RCS file: /home/kde/kdepim/libkcal/resourcekabc.cpp,v
retrieving revision 1.11
diff -p -u -b -r1.11 resourcekabc.cpp
--- resourcekabc.cpp 30 Oct 2003 09:44:04 -0000 1.11
+++ resourcekabc.cpp 11 Feb 2004 01:52:51 -0000
@@ -133,18 +133,18 @@ bool ResourceKABC::load()
mCalendar.close();
// import from kabc
- QDateTime birthdate;
QString summary;
KABC::AddressBook::Iterator it;
for ( it = mAddressbook->begin(); it != mAddressbook->end(); ++it ) {
- if ( (*it).birthday().date().isValid() ) {
- kdDebug() << "found a birthday " << (*it).birthday().toString() << endl;
+
+ QDateTime birthdate = (*it).birthday().date();
+ if ( birthdate.isValid() ) {
+ kdDebug() << "found a birthday " << birthdate.toString() << endl;
QString name = (*it).nickName();
if (name.isEmpty()) name = (*it).realName();
summary = i18n("%1's birthday").arg( name );
- birthdate = (*it).birthday();
Event *ev = new Event();
@@ -180,6 +180,49 @@ bool ResourceKABC::load()
mCalendar.addEvent(ev);
kdDebug() << "imported " << birthdate.toString() << endl;
}
+
+ QDateTime anniversary = QDate::fromString( (*it).custom( "KADDRESSBOOK", \
"X-Anniversary" ), Qt::ISODate ); + if ( anniversary.isValid() ) {
+ kdDebug() << "found a anniversary " << anniversary.toString() << endl;
+
+ QString name = (*it).nickName();
+ if (name.isEmpty()) name = (*it).realName();
+ summary = i18n("%1's anniversary").arg( name );
+
+ Event *ev = new Event();
+
+ ev->setDtStart(anniversary);
+ ev->setDtEnd(anniversary);
+ ev->setHasEndDate(true);
+ ev->setFloats(true);
+
+ ev->setSummary(summary);
+
+ // Set the recurrence
+ Recurrence *vRecurrence = ev->recurrence();
+ vRecurrence->setRecurStart(anniversary);
+ vRecurrence->setYearly(Recurrence::rYearlyMonth,1,-1);
+ vRecurrence->addYearlyNum(anniversary.date().month());
+
+ ev->clearAlarms();
+
+ if ( mAlarm ) {
+ // Set the alarm
+ Alarm* vAlarm = ev->newAlarm();
+ vAlarm->setText(summary);
+ vAlarm->setTime(anniversary);
+ // 24 hours before
+ vAlarm->setStartOffset( -1440 * mAlarmDays );
+ vAlarm->setEnabled(true);
+ }
+
+ // insert category
+ ev->setCategories(i18n("Anniversary"));
+
+ ev->setReadOnly( true );
+ mCalendar.addEvent(ev);
+ kdDebug() << "imported " << anniversary.toString() << endl;
+ }
}
emit resourceChanged( this );
["signature.asc" (application/pgp-signature)]
_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic