summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/alarm.cpp36
-rw-r--r--libkcal/recurrence.cpp56
-rw-r--r--libkcal/sharpformat.cpp7
3 files changed, 83 insertions, 16 deletions
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp
index 29e6205..1fc7169 100644
--- a/libkcal/alarm.cpp
+++ b/libkcal/alarm.cpp
@@ -40,40 +40,74 @@ Alarm::Alarm(Incidence *parent)
40 mHasTime(false), 40 mHasTime(false),
41 mAlarmEnabled(false) 41 mAlarmEnabled(false)
42{ 42{
43 43
44} 44}
45 45
46Alarm::~Alarm() 46Alarm::~Alarm()
47{ 47{
48} 48}
49 49
50bool Alarm::operator==( const Alarm& rhs ) const 50bool Alarm::operator==( const Alarm& rhs ) const
51{ 51{
52
52 if ( mType != rhs.mType || 53 if ( mType != rhs.mType ||
53 mAlarmSnoozeTime != rhs.mAlarmSnoozeTime || 54 mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ||
54 mAlarmRepeatCount != rhs.mAlarmRepeatCount || 55 mAlarmRepeatCount != rhs.mAlarmRepeatCount ||
55 mAlarmEnabled != rhs.mAlarmEnabled || 56 mAlarmEnabled != rhs.mAlarmEnabled ||
56 mHasTime != rhs.mHasTime) 57 mHasTime != rhs.mHasTime)
57 return false; 58 return false;
58 59
60#if 0
61 if ( mType != rhs.mType ) {
62
63 qDebug("aaa1 ");
64 return false;
65 }
66
67 if ( mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ) {
68
69 qDebug("aaa2 ");
70 return false;
71 }
72
73
74 if ( mAlarmRepeatCount != rhs.mAlarmRepeatCount ) {
75
76 qDebug("aaa3 ");
77 return false;
78 }
79
80 if ( mAlarmEnabled != rhs.mAlarmEnabled ) {
81
82 qDebug("aaa4 ");
83 return false;
84 }
85
86 if ( mHasTime != rhs.mHasTime ) {
87
88 qDebug("aaa5 ");
89 return false;
90 }
91#endif
92
93
59 if (mHasTime) { 94 if (mHasTime) {
60 if (mAlarmTime != rhs.mAlarmTime) 95 if (mAlarmTime != rhs.mAlarmTime)
61 return false; 96 return false;
62 } else { 97 } else {
63 if (mOffset != rhs.mOffset || 98 if (mOffset != rhs.mOffset ||
64 mEndOffset != rhs.mEndOffset) 99 mEndOffset != rhs.mEndOffset)
65 return false; 100 return false;
66 } 101 }
67
68 switch (mType) { 102 switch (mType) {
69 case Display: 103 case Display:
70 return mDescription == rhs.mDescription; 104 return mDescription == rhs.mDescription;
71 105
72 case Email: 106 case Email:
73 return mDescription == rhs.mDescription && 107 return mDescription == rhs.mDescription &&
74 mMailAttachFiles == rhs.mMailAttachFiles && 108 mMailAttachFiles == rhs.mMailAttachFiles &&
75 mMailAddresses == rhs.mMailAddresses && 109 mMailAddresses == rhs.mMailAddresses &&
76 mMailSubject == rhs.mMailSubject; 110 mMailSubject == rhs.mMailSubject;
77 111
78 case Procedure: 112 case Procedure:
79 return mFile == rhs.mFile && 113 return mFile == rhs.mFile &&
diff --git a/libkcal/recurrence.cpp b/libkcal/recurrence.cpp
index dd74e10..e84f672 100644
--- a/libkcal/recurrence.cpp
+++ b/libkcal/recurrence.cpp
@@ -97,52 +97,84 @@ Recurrence::~Recurrence()
97} 97}
98 98
99 99
100bool Recurrence::operator==( const Recurrence& r2 ) const 100bool Recurrence::operator==( const Recurrence& r2 ) const
101{ 101{
102 102
103 // the following line is obvious 103 // the following line is obvious
104 if ( recurs == rNone && r2.recurs == rNone ) 104 if ( recurs == rNone && r2.recurs == rNone )
105 return true; 105 return true;
106 // we need the above line, because two non recurring events may 106 // we need the above line, because two non recurring events may
107 // differ in the other settings, because one (or both) 107 // differ in the other settings, because one (or both)
108 // may be not initialized properly 108 // may be not initialized properly
109
109 if ( recurs != r2.recurs 110 if ( recurs != r2.recurs
110 || rFreq != r2.rFreq 111 || rFreq != r2.rFreq
111 || rDuration != r2.rDuration 112 || rDuration != r2.rDuration
112 || !rDuration && rEndDateTime != r2.rEndDateTime 113 || !rDuration && rEndDateTime != r2.rEndDateTime
113 || mRecurStart != r2.mRecurStart 114 || mRecurStart != r2.mRecurStart
114 || mFloats != r2.mFloats 115 || mFloats != r2.mFloats
115 || mRecurReadOnly != r2.mRecurReadOnly 116 || mRecurReadOnly != r2.mRecurReadOnly
116 || mRecurExDatesCount != r2.mRecurExDatesCount ) 117 || mRecurExDatesCount != r2.mRecurExDatesCount )
117 return false; 118 return false;
118 // no need to compare mCompat* and mParent 119 // no need to compare mCompat* and mParent
119 // OK to compare the pointers 120 // OK to compare the pointers
120 switch ( recurs ) 121 switch ( recurs )
121 { 122 {
122 case rWeekly: 123 case rWeekly:
123 return rDays == r2.rDays 124 return rDays == r2.rDays
124 && rWeekStart == r2.rWeekStart; 125 && rWeekStart == r2.rWeekStart;
125 case rMonthlyPos: 126 case rMonthlyPos: {
126 return rMonthPositions.count() == r2.rMonthPositions.count(); 127 QPtrList<rMonthPos> MonthPositions = rMonthPositions;
127 case rMonthlyDay: 128 QPtrList<rMonthPos> MonthPositions2 = r2.rMonthPositions;
128 return rMonthDays.count() == r2.rMonthDays.count(); 129 if ( !MonthPositions.count() )
129 case rYearlyPos: 130 return false;
130 return rYearNums.count() == r2.rYearNums.count() 131 if ( !MonthPositions2.count() )
131 && rMonthPositions.count() == r2.rMonthPositions.count(); 132 return false;
132 case rYearlyMonth: 133 return MonthPositions.first()->rPos == MonthPositions2.first()->rPos;
133 return rYearNums.count() == r2.rYearNums.count() 134 }
134 && mFeb29YearlyType == r2.mFeb29YearlyType; 135 case rMonthlyDay: {
135 case rYearlyDay: 136 QPtrList<int> MonthDays = rMonthDays ;
136 return rYearNums == r2.rYearNums; 137 QPtrList<int> MonthDays2 = r2.rMonthDays ;
138 if ( !MonthDays.count() )
139 return false;
140 if ( !MonthDays2.count() )
141 return false;
142 return *MonthDays.first() == *MonthDays2.first() ;
143 }
144 case rYearlyPos: {
145
146 QPtrList<int> YearNums = rYearNums;
147 QPtrList<int> YearNums2 = r2.rYearNums;
148 if ( *YearNums.first() != *YearNums2.first() )
149 return false;
150 QPtrList<rMonthPos> MonthPositions = rMonthPositions;
151 QPtrList<rMonthPos> MonthPositions2 = r2.rMonthPositions;
152 if ( !MonthPositions.count() )
153 return false;
154 if ( !MonthPositions2.count() )
155 return false;
156 return MonthPositions.first()->rPos == MonthPositions2.first()->rPos;
157
158 }
159 case rYearlyMonth: {
160 QPtrList<int> YearNums = rYearNums;
161 QPtrList<int> YearNums2 = r2.rYearNums;
162 return ( *YearNums.first() == *YearNums2.first() && mFeb29YearlyType == r2.mFeb29YearlyType);
163 }
164 case rYearlyDay: {
165 QPtrList<int> YearNums = rYearNums;
166 QPtrList<int> YearNums2 = r2.rYearNums;
167 return ( *YearNums.first() == *YearNums2.first() );
168 }
137 case rNone: 169 case rNone:
138 case rMinutely: 170 case rMinutely:
139 case rHourly: 171 case rHourly:
140 case rDaily: 172 case rDaily:
141 default: 173 default:
142 return true; 174 return true;
143 } 175 }
144} 176}
145/* 177/*
146bool Recurrence::compareLists( const QPtrList<int> &l1 ,const QPtrList<int> &l2) 178bool Recurrence::compareLists( const QPtrList<int> &l1 ,const QPtrList<int> &l2)
147{ 179{
148 if ( l1.count() != l2.count() ) 180 if ( l1.count() != l2.count() )
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index defdb09..89eb72f 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -171,26 +171,27 @@ class SharpParser : public QObject
171 171
172 QString categoryList = attList[1] ; 172 QString categoryList = attList[1] ;
173 event->setCategories( lookupCategories( categoryList ) ); 173 event->setCategories( lookupCategories( categoryList ) );
174 174
175 // strange 0 semms to mean: alarm enabled 175 // strange 0 semms to mean: alarm enabled
176 if ( attList[8] == "0" ) { 176 if ( attList[8] == "0" ) {
177 Alarm *alarm; 177 Alarm *alarm;
178 if ( event->alarms().count() > 0 ) 178 if ( event->alarms().count() > 0 )
179 alarm = event->alarms().first(); 179 alarm = event->alarms().first();
180 else { 180 else {
181 alarm = new Alarm( event ); 181 alarm = new Alarm( event );
182 event->addAlarm( alarm ); 182 event->addAlarm( alarm );
183 alarm->setType( Alarm::Audio );
183 } 184 }
184 alarm->setType( Alarm::Audio ); 185 //alarm->setType( Alarm::Audio );
185 alarm->setEnabled( true ); 186 alarm->setEnabled( true );
186 int alarmOffset = attList[9].toInt(); 187 int alarmOffset = attList[9].toInt();
187 alarm->setStartOffset( alarmOffset * -60 ); 188 alarm->setStartOffset( alarmOffset * -60 );
188 } else { 189 } else {
189 Alarm *alarm; 190 Alarm *alarm;
190 if ( event->alarms().count() > 0 ) { 191 if ( event->alarms().count() > 0 ) {
191 alarm = event->alarms().first(); 192 alarm = event->alarms().first();
192 alarm->setType( Alarm::Audio ); 193 alarm->setType( Alarm::Audio );
193 alarm->setStartOffset( -60*15 ); 194 alarm->setStartOffset( -60*15 );
194 alarm->setEnabled( false ); 195 alarm->setEnabled( false );
195 } 196 }
196 } 197 }
@@ -359,31 +360,31 @@ ulong SharpFormat::getCsum( const QStringList & attList)
359 add = s[k].unicode (); 360 add = s[k].unicode ();
360 if ( k < 16 ) 361 if ( k < 16 )
361 mul = mul * mul; 362 mul = mul * mul;
362 add = add * mul *i*i*i; 363 add = add * mul *i*i*i;
363 cSum += add; 364 cSum += add;
364 } 365 }
365 } 366 }
366 } 367 }
367 return cSum; 368 return cSum;
368 369
369} 370}
370#include <stdlib.h> 371#include <stdlib.h>
371#define DEBUGMODE false 372//#define DEBUGMODE false
373#define DEBUGMODE true
372bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) 374bool SharpFormat::load( Calendar *calendar, Calendar *existngCal )
373{ 375{
374 376
375 377
376 bool debug = DEBUGMODE; 378 bool debug = DEBUGMODE;
377 //debug = true;
378 QString text; 379 QString text;
379 QString codec = "utf8"; 380 QString codec = "utf8";
380 QLabel status ( i18n("Reading events ..."), 0 ); 381 QLabel status ( i18n("Reading events ..."), 0 );
381 382
382 int w = status.sizeHint().width()+20 ; 383 int w = status.sizeHint().width()+20 ;
383 if ( w < 200 ) w = 200; 384 if ( w < 200 ) w = 200;
384 int h = status.sizeHint().height()+20 ; 385 int h = status.sizeHint().height()+20 ;
385 int dw = QApplication::desktop()->width(); 386 int dw = QApplication::desktop()->width();
386 int dh = QApplication::desktop()->height(); 387 int dh = QApplication::desktop()->height();
387 status.setCaption(i18n("Reading DTM Data") ); 388 status.setCaption(i18n("Reading DTM Data") );
388 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 389 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
389 status.show(); 390 status.show();