40 #include <QtCore/QRegExp>
41 #include <QtCore/QString>
42 #include <QtCore/QDate>
44 using namespace KCalCore;
47 const QString &implementationVersion)
51 int korg = productId.indexOf(
"KOrganizer");
52 int outl9 = productId.indexOf(
"Outlook 9.0");
55 int versionStart = productId.indexOf(
" ", korg);
56 if (versionStart >= 0) {
57 int versionStop = productId.indexOf(QRegExp(
"[ /]"), versionStart + 1);
58 if (versionStop >= 0) {
59 QString version = productId.mid(versionStart + 1,
60 versionStop - versionStart - 1);
62 int versionNum = version.section(
'.', 0, 0).toInt() * 10000 +
63 version.section(
'.', 1, 1).toInt() * 100 +
64 version.section(
'.', 2, 2).toInt();
65 int releaseStop = productId.indexOf(
"/", versionStop);
67 if (releaseStop > versionStop) {
68 release = productId.mid(versionStop+1, releaseStop-versionStop-1);
70 if (versionNum < 30100) {
72 }
else if (versionNum < 30200) {
74 }
else if (versionNum == 30200 && release ==
"pre") {
75 kDebug() <<
"Generating compat for KOrganizer 3.2 pre";
77 }
else if (versionNum < 30400) {
79 }
else if (versionNum < 30500) {
84 }
else if (outl9 >= 0) {
85 kDebug() <<
"Generating compat for Outlook < 2000 (Outlook 9.0)";
93 if (implementationVersion.isEmpty() &&
94 (productId.contains(
"libkcal") ||
95 productId.contains(
"KOrganizer") ||
96 productId.contains(
"KAlarm"))) {
117 if (incidence->summary().isEmpty() && !(incidence->description().isEmpty())) {
118 QString oldDescription = incidence->description().trimmed();
119 QString newSummary(oldDescription);
120 newSummary.remove(QRegExp(
"\n.*"));
121 incidence->setSummary(newSummary);
122 if (oldDescription == newSummary) {
123 incidence->setDescription(
"");
161 struct CompatDecorator::Private {
165 CompatDecorator::CompatDecorator(
Compat *compat)
171 CompatDecorator::~CompatDecorator()
179 d->compat->fixEmptySummary(incidence);
184 d->compat->fixAlarms(incidence);
189 d->compat->fixFloatingEnd(date);
194 d->compat->fixRecurrence(incidence);
199 return d->compat->fixPriority(priority);
204 return d->compat->useTimeZoneShift();
208 const KDateTime &dtstamp)
210 d->compat->setCreatedToDtStamp(incidence, dtstamp);
215 Recurrence *recurrence = incidence->recurrence();
217 KDateTime start(incidence->dtStart());
220 if (r && !r->dateMatchesRules(start)) {
221 recurrence->addExDateTime(start);
231 if (0 < priority && priority < 6) {
233 return 2 * priority - 1;
241 Recurrence *recurrence = incidence->recurrence();
243 recurrence->
setDuration(recurrence->
duration() + incidence->recurrence()->exDates().count());
251 endDate = endDate.addDays(1);
261 r = recur->defaultRRule();
271 QDate end(r->
startDt().date());
272 bool doNothing =
false;
274 int tmp = (duration - 1) * r->
frequency();
275 switch (r->recurrenceType()) {
276 case RecurrenceRule::rWeekly:
278 end = end.addDays(tmp * 7 + 7 - end.dayOfWeek());
281 case RecurrenceRule::rMonthly:
283 int month = end.month() - 1 + tmp;
284 end.setYMD(end.year() + month / 12, month % 12 + 1, 31);
287 case RecurrenceRule::rYearly:
289 end.setYMD(end.year() + tmp, 12, 31);
298 KDateTime(end, QTime(0, 0, 0), incidence->dtStart().timeSpec()));
306 QList<int> days = r->byYearDays();
307 if (!days.isEmpty()) {
308 QList<int> months = r->byMonths();
309 for (
int i = 0; i < months.size(); ++i) {
311 QDate(r->
startDt().date().year(), 1, 1).addDays(months.at(i) - 1).month();
312 if (!months.contains(newmonth)) {
313 months.append(newmonth);
317 r->setByMonths(months);
319 r->setByYearDays(days);
330 Alarm::List::Iterator it;
331 for (it = alarms.begin(); it != alarms.end(); ++it) {
333 if (al && al->hasStartOffset()) {
334 Duration offsetDuration = al->startOffset();
339 al->setStartOffset(offsetDuration);
349 CompatPre410::CompatPre410(
Compat *decoratedCompat)
356 if (dtstamp.isValid()) {
357 incidence->setCreated(dtstamp);