-rw-r--r-- | korganizer/calendarview.cpp | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index b3b4cdb..d71ea08 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1379,130 +1379,131 @@ bool CalendarView::importBday() #else //DESKTOP_VERSION ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); // the result should now arrive through method insertBirthdays #endif //DESKTOP_VERSION #endif //KORG_NOKABC return true; } // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, const QStringList& anniversaryList, const QStringList& realNameList, const QStringList& emailList, const QStringList& assembledNameList, const QStringList& uidList) { qDebug("CalendarView::insertBirthdays"); if (uid == this->name()) { int count = birthdayList.count(); int addCount = 0; KCal::Attendee* a = 0; qDebug("CalView 1 %i", count); QProgressBar bar(count,0 ); int w = 300; if ( QApplication::desktop()->width() < 320 ) w = 220; int h = bar.sizeHint().height() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); bar.show(); bar.setCaption (i18n("inserting birthdays - close to abort!") ); qApp->processEvents(); QDate birthday; QDate anniversary; QString realName; QString email; QString assembledName; QString uid; bool ok = true; for ( int i = 0; i < count; i++) - { - if ( ! bar.isVisible() ) - return; - bar.setProgress( i ); - qApp->processEvents(); - - qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); - - birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); - if (!ok) - qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); - - anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); - if (!ok) - qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); - realName = realNameList[i]; - email = emailList[i]; - assembledName = assembledNameList[i]; - uid = uidList[i]; + { + if ( ! bar.isVisible() ) + return; + bar.setProgress( i ); + qApp->processEvents(); - if ( birthday.isValid() ){ - a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, - KCal::Attendee::ReqParticipant,uid) ; - if ( addAnniversary( birthday, assembledName, a, true ) ) - ++addCount; - } + birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); + if (!ok) { + ; //qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); + } - if ( anniversary.isValid() ){ - a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, - KCal::Attendee::ReqParticipant,uid) ; - if ( addAnniversary( anniversary, assembledName, a, false ) ) - ++addCount; + anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); + if (!ok) { + ;// qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); + } + realName = realNameList[i]; + email = emailList[i]; + assembledName = assembledNameList[i]; + uid = uidList[i]; + //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); + + if ( birthday.isValid() ){ + a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, + KCal::Attendee::ReqParticipant,uid) ; + if ( addAnniversary( birthday, assembledName, a, true ) ) + ++addCount; + } + + if ( anniversary.isValid() ){ + a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, + KCal::Attendee::ReqParticipant,uid) ; + if ( addAnniversary( anniversary, assembledName, a, false ) ) + ++addCount; + } } - } updateView(); topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); } } bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) { //qDebug("addAnni "); Event * ev = new Event(); if ( a ) { ev->addAttendee( a ); } QString kind; if ( birthday ) kind = i18n( "Birthday" ); else kind = i18n( "Anniversary" ); ev->setSummary( name + " - " + kind ); ev->setOrganizer( "nobody@nowhere" ); ev->setCategories( kind ); ev->setDtStart( QDateTime(date) ); ev->setDtEnd( QDateTime(date) ); ev->setFloats( true ); Recurrence * rec = ev->recurrence(); rec->setYearly(Recurrence::rYearlyMonth,1,-1); rec->addYearlyNum( date.month() ); if ( !mCalendar->addAnniversaryNoDup( ev ) ) { delete ev; return false; } return true; } bool CalendarView::importQtopia( const QString &categories, const QString &datebook, const QString &todolist ) { QtopiaFormat qtopiaFormat; qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |