summaryrefslogtreecommitdiffabout
path: root/libkcal/vcalformat.cpp
authorzautrix <zautrix>2004-10-15 14:26:07 (UTC)
committer zautrix <zautrix>2004-10-15 14:26:07 (UTC)
commit4f276d80bd977401d656851515474cc00c661e5b (patch) (side-by-side diff)
tree0d3a747bef0431ef791b69876f5bda554f9ca83f /libkcal/vcalformat.cpp
parentc2fb960297c4b08980921c818a4d347057732390 (diff)
downloadkdepimpi-4f276d80bd977401d656851515474cc00c661e5b.zip
kdepimpi-4f276d80bd977401d656851515474cc00c661e5b.tar.gz
kdepimpi-4f276d80bd977401d656851515474cc00c661e5b.tar.bz2
many phone and sync fixes
Diffstat (limited to 'libkcal/vcalformat.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/vcalformat.cpp141
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
@@ -62,7 +62,8 @@ bool VCalFormat::load(Calendar *calendar, const QString &fileName)
{
mCalendar = calendar;
clearException();
- useLocalTime = mCalendar->isLocalTime();
+ if ( ! useLocalTime )
+ useLocalTime = mCalendar->isLocalTime();
VObject *vcal = 0;
// this is not necessarily only 1 vcal. Could be many vcals, or include
@@ -90,7 +91,8 @@ bool VCalFormat::load(Calendar *calendar, const QString &fileName)
bool VCalFormat::save(Calendar *calendar, const QString &fileName)
{
mCalendar = calendar;
- useLocalTime = mCalendar->isLocalTime();
+ if ( ! useLocalTime )
+ useLocalTime = mCalendar->isLocalTime();
QString tmpStr;
VObject *vcal, *vo;
@@ -1172,72 +1174,76 @@ Event* VCalFormat::VEventToEvent(VObject *vevent)
/*********************** YEARLY-BY-MONTH *******************************/
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);
+ }
}
/*********************** YEARLY-BY-DAY *********************************/
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
} // repeats
@@ -1536,12 +1542,13 @@ void VCalFormat::populate(VObject *vcal)
// set the time zone
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
mEventsRelate.clear();
mTodosRelate.clear();