author | zautrix <zautrix> | 2004-10-15 14:26:07 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-15 14:26:07 (UTC) |
commit | 4f276d80bd977401d656851515474cc00c661e5b (patch) (side-by-side diff) | |
tree | 0d3a747bef0431ef791b69876f5bda554f9ca83f /libkcal/vcalformat.cpp | |
parent | c2fb960297c4b08980921c818a4d347057732390 (diff) | |
download | kdepimpi-4f276d80bd977401d656851515474cc00c661e5b.zip kdepimpi-4f276d80bd977401d656851515474cc00c661e5b.tar.gz kdepimpi-4f276d80bd977401d656851515474cc00c661e5b.tar.bz2 |
many phone and sync fixes
-rw-r--r-- | libkcal/vcalformat.cpp | 141 |
1 files changed, 74 insertions, 67 deletions
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index a6ae1bc..df93209 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp @@ -64,3 +64,4 @@ bool VCalFormat::load(Calendar *calendar, const QString &fileName) clearException(); - useLocalTime = mCalendar->isLocalTime(); + if ( ! useLocalTime ) + useLocalTime = mCalendar->isLocalTime(); VObject *vcal = 0; @@ -92,3 +93,4 @@ bool VCalFormat::save(Calendar *calendar, const QString &fileName) mCalendar = calendar; - useLocalTime = mCalendar->isLocalTime(); + if ( ! useLocalTime ) + useLocalTime = mCalendar->isLocalTime(); @@ -1174,32 +1176,34 @@ Event* VCalFormat::VEventToEvent(VObject *vevent) else if (tmpStr.left(2) == "YM") { - int index = tmpStr.find(' '); - int last = tmpStr.findRev(' ') + 1; - int rFreq = tmpStr.mid(2, (index-1)).toInt(); - index += 1; - short tmpMonth; - if( index == last ) { - // e.g. YM1 #0 - tmpMonth = anEvent->dtStart().date().month(); - anEvent->recurrence()->addYearlyNum(tmpMonth); - } - else { - // e.g. YM1 3 #0 - while (index < last) { - int index2 = tmpStr.find(' ', index); - tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); - index = index2+1; - anEvent->recurrence()->addYearlyNum(tmpMonth); - } // while != # - } - index = last; if (tmpStr.mid(index,1) == "#") index++; - if (tmpStr.find('T', index) != -1) { - QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); - anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); - } else { - int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); - if (rDuration == 0) - anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); - else - anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); - } + // we have to set this such that recurrence accepts addYearlyNum(tmpDay); + anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, 1, -1); + int index = tmpStr.find(' '); + int last = tmpStr.findRev(' ') + 1; + int rFreq = tmpStr.mid(2, (index-1)).toInt(); + index += 1; + short tmpMonth; + if( index == last ) { + // e.g. YM1 #0 + tmpMonth = anEvent->dtStart().date().month(); + anEvent->recurrence()->addYearlyNum(tmpMonth); + } + else { + // e.g. YM1 3 #0 + while (index < last) { + int index2 = tmpStr.find(' ', index); + tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); + index = index2+1; + anEvent->recurrence()->addYearlyNum(tmpMonth); + } // while != # + } + index = last; if (tmpStr.mid(index,1) == "#") index++; + if (tmpStr.find('T', index) != -1) { + QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); + anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); + } else { + int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); + if (rDuration == 0) + anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); + else + anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); + } } @@ -1208,34 +1212,36 @@ Event* VCalFormat::VEventToEvent(VObject *vevent) else if (tmpStr.left(2) == "YD") { - int index = tmpStr.find(' '); - int last = tmpStr.findRev(' ') + 1; - int rFreq = tmpStr.mid(2, (index-1)).toInt(); - index += 1; - short tmpDay; - if( index == last ) { - // e.g. YD1 #0 - tmpDay = anEvent->dtStart().date().dayOfYear(); - anEvent->recurrence()->addYearlyNum(tmpDay); - } - else { - // e.g. YD1 123 #0 - while (index < last) { - int index2 = tmpStr.find(' ', index); - tmpDay = tmpStr.mid(index, (index2-index)).toShort(); - index = index2+1; - anEvent->recurrence()->addYearlyNum(tmpDay); - } // while != # - } - index = last; if (tmpStr.mid(index,1) == "#") index++; - if (tmpStr.find('T', index) != -1) { - QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); - anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); - } else { - int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); - if (rDuration == 0) - anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); - else - anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); - } + // we have to set this such that recurrence accepts addYearlyNum(tmpDay); + anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, 1, -1); + int index = tmpStr.find(' '); + int last = tmpStr.findRev(' ') + 1; + int rFreq = tmpStr.mid(2, (index-1)).toInt(); + index += 1; + short tmpDay; + if( index == last ) { + // e.g. YD1 #0 + tmpDay = anEvent->dtStart().date().dayOfYear(); + anEvent->recurrence()->addYearlyNum(tmpDay); + } + else { + // e.g. YD1 123 #0 + while (index < last) { + int index2 = tmpStr.find(' ', index); + tmpDay = tmpStr.mid(index, (index2-index)).toShort(); + index = index2+1; + anEvent->recurrence()->addYearlyNum(tmpDay); + } // while != # + } + index = last; if (tmpStr.mid(index,1) == "#") index++; + if (tmpStr.find('T', index) != -1) { + QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); + anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); + } else { + int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); + if (rDuration == 0) + anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); + else + anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); + } } else { - kdDebug(5800) << "we don't understand this type of recurrence!" << endl; + kdDebug(5800) << "we don't understand this type of recurrence!" << endl; } // if @@ -1538,8 +1544,9 @@ void VCalFormat::populate(VObject *vcal) if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { - char *s = fakeCString(vObjectUStringZValue(curVO)); - mCalendar->setTimeZone(s); - deleteStr(s); + if ( vObjectUStringZValue(curVO) != 0 ) { + char *s = fakeCString(vObjectUStringZValue(curVO)); + mCalendar->setTimeZone(s); + deleteStr(s); + } } - // Store all events with a relatedTo property in a list for post-processing |